summaryrefslogtreecommitdiff
path: root/t/t9350-fast-export.sh
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-09-20 23:55:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-21 04:12:52 (GMT)
commitb3e8ca89cfe34712a093c37fdbac7df7eaae91e7 (patch)
treeef77300c2853291f1825327c7546748563f694d1 /t/t9350-fast-export.sh
parent3b827444811d7eddeddd44850f5dbbb4d59747f5 (diff)
downloadgit-b3e8ca89cfe34712a093c37fdbac7df7eaae91e7.zip
git-b3e8ca89cfe34712a093c37fdbac7df7eaae91e7.tar.gz
git-b3e8ca89cfe34712a093c37fdbac7df7eaae91e7.tar.bz2
fast-export: do not copy from modified file
When run with the "-C" option, fast-export writes 'C' commands in its output whenever the internal diff mechanism detects a file copy, indicating that fast-import should copy the given existing file to the given new filename. However, the diff mechanism works against the prior version of the file, whereas fast-import uses whatever is current. This causes issues when a commit both modifies a file and uses it as the source for a copy. Therefore, teach fast-export to refrain from writing 'C' when it has already written a modification command for a file. An existing test in t9350-fast-export is also fixed in this patch. The existing line "C file6 file7" copies the wrong version of file6, but it has coincidentally worked because file7 was subsequently overridden. Reported-by: Juraj Oršulić <juraj.orsulic@fer.hr> Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9350-fast-export.sh')
-rwxr-xr-xt/t9350-fast-export.sh20
1 files changed, 19 insertions, 1 deletions
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index b5149fd..419d540 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -234,7 +234,7 @@ test_expect_success 'fast-export -C -C | fast-import' '
mkdir new &&
git --git-dir=new/.git init &&
git fast-export -C -C --signed-tags=strip --all > output &&
- grep "^C file6 file7\$" output &&
+ grep "^C file2 file4\$" output &&
cat output |
(cd new &&
git fast-import &&
@@ -522,4 +522,22 @@ test_expect_success 'delete refspec' '
test_cmp expected actual
'
+test_expect_success 'when using -C, do not declare copy when source of copy is also modified' '
+ test_create_repo src &&
+ echo a_line >src/file.txt &&
+ git -C src add file.txt &&
+ git -C src commit -m 1st_commit &&
+
+ cp src/file.txt src/file2.txt &&
+ echo another_line >>src/file.txt &&
+ git -C src add file.txt file2.txt &&
+ git -C src commit -m 2nd_commit &&
+
+ test_create_repo dst &&
+ git -C src fast-export --all -C | git -C dst fast-import &&
+ git -C src show >expected &&
+ git -C dst show >actual &&
+ test_cmp expected actual
+'
+
test_done