fast-export: make sure updated refs get updated

When an object has already been exported (and thus is in the marks) it's flagged as SHOWN, so it will not be exported again, even if in a later time it's exported through a different ref. We don't need the object to be exported again, but we want the ref updated, which doesn't happen. Since we can't know if a ref was exported or not, let's just assume that if the commit was marked (flags & SHOWN), the user still wants the ref updated. IOW: If it's specified in the command line, it will get updated, regardless of whether or not the object was marked. So: % git branch test master % git fast-export $mark_flags master % git fast-export $mark_flags test Would export 'test' properly. Additionally, this fixes issues with remote helpers; now they can push refs whose objects have already been exported, and a few other issues as well. Update the tests accordingly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Nov 28, 2012 at 23:24 UTC f28e7c904ac82b0c5e43805529e7d5296fa4d13b
3 files changed +30 -15
builtin/fast-export.c
+7 -3
@@ -526,10 +526,14 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info,
526 typename(e->item->type));
527 continue;
528 }
529 - if (commit->util)
530 - /* more than one name for the same object */
529 +
530 + /*
531 + * This ref will not be updated through a commit, lets make
532 + * sure it gets properly updated eventually.
533 + */
534 + if (commit->util || commit->object.flags & SHOWN)
535 string_list_append(extra_refs, full_name)->util = commit;
532 - else
536 + if (!commit->util)
537 commit->util = full_name;
538 }
539 }
t/t5801-remote-helpers.sh
+8 -12
@@ -63,18 +63,6 @@ test_expect_success 'fetch new branch' '
63 compare_refs server HEAD local FETCH_HEAD
64 '
65
66 -#
67 -# This is only needed because of a bug not detected by this script. It will be
68 -# fixed shortly, but for now lets not cause regressions.
69 -#
70 -test_expect_success 'bump commit in server' '
71 - (cd server &&
72 - git checkout master &&
73 - echo content >>file &&
74 - git commit -a -m four) &&
75 - compare_refs server HEAD server HEAD
76 -'
77 -
66 test_expect_success 'fetch multiple branches' '
67 (cd local &&
68 git fetch
@@ -170,4 +158,12 @@ test_expect_success 'push all with existing object' '
158 compare_refs local dup2 server dup2
159 '
160
161 +test_expect_success 'push ref with existing object' '
162 + (cd local &&
163 + git branch dup master &&
164 + git push origin dup
165 + ) &&
166 + compare_refs local dup server dup
167 +'
168 +
169 test_done
t/t9350-fast-export.sh
+15
@@ -484,4 +484,19 @@ test_expect_success 'avoid uninteresting refs' '
484 test_cmp expected actual
485 '
486
487 +cat > expected << EOF
488 +reset refs/heads/master
489 +from :14
490 +
491 +EOF
492 +
493 +test_expect_success 'refs are updated even if no commits need to be exported' '
494 + > tmp-marks &&
495 + git fast-export --import-marks=tmp-marks \
496 + --export-marks=tmp-marks master > /dev/null &&
497 + git fast-export --import-marks=tmp-marks \
498 + --export-marks=tmp-marks master > actual &&
499 + test_cmp expected actual
500 +'
501 +
502 test_done