diff options
-rw-r--r-- | fetch-pack.c | 5 | ||||
-rwxr-xr-x | t/t5516-fetch-push.sh | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index 058c25837d..84d5a66967 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -555,9 +555,8 @@ static void filter_refs(struct fetch_pack_args *args, continue; ref->matched = 1; - *newtail = ref; - ref->next = NULL; - newtail = &ref->next; + *newtail = copy_ref(ref); + newtail = &(*newtail)->next; } } *refs = newlist; diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index f4da20aa9b..f7947315ba 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1107,9 +1107,16 @@ test_expect_success 'fetch exact SHA1' ' git config uploadpack.allowtipsha1inwant true ) && - git fetch -v ../testrepo $the_commit:refs/heads/copy && - result=$(git rev-parse --verify refs/heads/copy) && - test "$the_commit" = "$result" + git fetch -v ../testrepo $the_commit:refs/heads/copy master:refs/heads/extra && + cat >expect <<-EOF && + $the_commit + $the_first_commit + EOF + { + git rev-parse --verify refs/heads/copy && + git rev-parse --verify refs/heads/extra + } >actual && + test_cmp expect actual ) ' |