From 5d3698ffb4ccf8b842814559007e011fc409650b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 24 Nov 2012 04:17:01 +0100 Subject: fast-export: avoid importing blob marks We want to be able to import, and then export, using the same marks, so that we don't push things that the other side already received. Unfortunately, fast-export doesn't store blobs in the marks, but fast-import does. This creates a mismatch when fast export is reusing a mark that was previously stored by fast-import. There is no point in one tool saving blobs, and the other not, but for now let's just check in fast-export that the objects are indeed commits. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- t/t9350-fast-export.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/t9350-fast-export.sh') diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 3e821f958b..5948b65f21 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -440,4 +440,18 @@ test_expect_success 'fast-export quotes pathnames' ' ) ' +test_expect_success 'test bidirectionality' ' + >marks-cur && + >marks-new && + git init marks-test && + git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \ + git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new && + (cd marks-test && + git reset --hard && + echo Wohlauf > file && + git commit -a -m "back in time") && + git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \ + git fast-import --export-marks=marks-cur --import-marks=marks-cur +' + test_done -- cgit v1.2.3 From 9ff10fc86989940eb2c016511c293bc0ac50e6f6 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:11:09 +0100 Subject: fast-export: fix comparison in tests First the expected, then the actual, otherwise the diff would be the opposite of what we want. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- t/t9350-fast-export.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t9350-fast-export.sh') diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 5948b65f21..1f598622a6 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -303,7 +303,7 @@ test_expect_success 'dropping tag of filtered out object' ' ( cd limit-by-paths && git fast-export --tag-of-filtered-object=drop mytag -- there > output && - test_cmp output expected + test_cmp expected output ) ' @@ -320,7 +320,7 @@ test_expect_success 'rewriting tag of filtered out object' ' ( cd limit-by-paths && git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && - test_cmp output expected + test_cmp expected output ) ' @@ -351,7 +351,7 @@ test_expect_failure 'no exact-ref revisions included' ' ( cd limit-by-paths && git fast-export master~2..master~1 > output && - test_cmp output expected + test_cmp expected output ) ' -- cgit v1.2.3 From 49266e8a11cffa1bb41217021470e33d26109bb2 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:23:59 +0100 Subject: fast-export: don't handle uninteresting refs They have been marked as UNINTERESTING for a reason, lets respect that. Currently the first ref is handled properly, but not the rest. Assuming that all the refs point at the same commit in the following example: % git fast-export master ^uninteresting ^foo ^bar reset refs/heads/bar from :0 reset refs/heads/foo from :0 reset refs/heads/uninteresting from :0 % git fast-export ^uninteresting ^foo ^bar master reset refs/heads/master from :0 reset refs/heads/bar from :0 reset refs/heads/foo from :0 Clearly this is wrong; the negative refs should be ignored. After this patch: % git fast-export ^uninteresting ^foo ^bar master # nothing % git fast-export master ^uninteresting ^foo ^bar # nothing And even more, it would only happen if the ref is pointing to exactly the same commit, but not otherwise: % git fast-export ^next next reset refs/heads/next from :0 % git fast-export ^next next^{commit} # nothing % git fast-export ^next next~0 # nothing % git fast-export ^next next~1 # nothing % git fast-export ^next next~2 # nothing The reason this happens is that before traversing the commits, fast-export checks if any of the refs point to the same object, and any duplicated ref gets added to a list in order to issue 'reset' commands after the traversing. Unfortunately, it's not even checking if the commit is flagged as UNINTERESTING. The fix of course, is to check it. However, in order to do it properly we need to get the UNINTERESTING flag from the command line, not from the commit object, because "^foo bar" will mark the commit 'bar' uninteresting if foo and bar points at the same commit. rev_cmdline_info, which was introduced exactly to handle this situation, contains all the information we need for get_tags_and_duplicates(), plus the ref flag. This way the rest of the positive refs will remain untouched; it's only the negative ones that change in behavior. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- t/t9350-fast-export.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 't/t9350-fast-export.sh') diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 1f598622a6..c8e41c1d42 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -454,4 +454,34 @@ test_expect_success 'test bidirectionality' ' git fast-import --export-marks=marks-cur --import-marks=marks-cur ' +cat > expected << EOF +blob +mark :13 +data 5 +bump + +commit refs/heads/master +mark :14 +author A U Thor 1112912773 -0700 +committer C O Mitter 1112912773 -0700 +data 5 +bump +from :12 +M 100644 :13 file + +EOF + +test_expect_success 'avoid uninteresting refs' ' + > tmp-marks && + git fast-export --import-marks=tmp-marks \ + --export-marks=tmp-marks master > /dev/null && + git tag v1.0 && + git branch uninteresting && + echo bump > file && + git commit -a -m bump && + git fast-export --import-marks=tmp-marks \ + --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual && + test_cmp expected actual +' + test_done -- cgit v1.2.3 From f28e7c904ac82b0c5e43805529e7d5296fa4d13b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 28 Nov 2012 23:24:00 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- t/t9350-fast-export.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t9350-fast-export.sh') diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index c8e41c1d42..9320b4f94c 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -484,4 +484,19 @@ test_expect_success 'avoid uninteresting refs' ' test_cmp expected actual ' +cat > expected << EOF +reset refs/heads/master +from :14 + +EOF + +test_expect_success 'refs are updated even if no commits need to be exported' ' + > tmp-marks && + git fast-export --import-marks=tmp-marks \ + --export-marks=tmp-marks master > /dev/null && + git fast-export --import-marks=tmp-marks \ + --export-marks=tmp-marks master > actual && + test_cmp expected actual +' + test_done -- cgit v1.2.3