@@ -503,6 +503,21 @@ static int local_counting(int stage, unsigned int current, unsigned int total, v
503503 return error ;
504504}
505505
506+ static int foreach_reference_cb (git_reference * reference , void * payload )
507+ {
508+ git_revwalk * walk = (git_revwalk * )payload ;
509+
510+ int error = git_revwalk_hide (walk , git_reference_target (reference ));
511+ /* The reference is in the local repository, so the target may not
512+ * exist on the remote. It also may not be a commit. */
513+ if (error == GIT_ENOTFOUND || error == GITERR_INVALID ) {
514+ giterr_clear ();
515+ error = 0 ;
516+ }
517+
518+ return error ;
519+ }
520+
506521static int local_download_pack (
507522 git_transport * transport ,
508523 git_repository * repo ,
@@ -542,11 +557,6 @@ static int local_download_pack(
542557 if (git_object_type (obj ) == GIT_OBJ_COMMIT ) {
543558 /* Revwalker includes only wanted commits */
544559 error = git_revwalk_push (walk , & rhead -> oid );
545- if (!error && !git_oid_iszero (& rhead -> loid )) {
546- error = git_revwalk_hide (walk , & rhead -> loid );
547- if (error == GIT_ENOTFOUND )
548- error = 0 ;
549- }
550560 } else {
551561 /* Tag or some other wanted object. Add it on its own */
552562 error = git_packbuilder_insert_recur (pack , & rhead -> oid , rhead -> name );
@@ -556,6 +566,9 @@ static int local_download_pack(
556566 goto cleanup ;
557567 }
558568
569+ if ((error = git_reference_foreach (repo , foreach_reference_cb , walk )))
570+ goto cleanup ;
571+
559572 if ((error = git_packbuilder_insert_walk (pack , walk )))
560573 goto cleanup ;
561574
0 commit comments