2005-12-11 23:44:46 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='Merge-recursive merging renames'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2010-09-20 12:28:37 +04:00
|
|
|
modify () {
|
|
|
|
sed -e "$1" <"$2" >"$2.x" &&
|
|
|
|
mv "$2.x" "$2"
|
|
|
|
}
|
|
|
|
|
2005-12-11 23:44:46 +03:00
|
|
|
test_expect_success setup \
|
|
|
|
'
|
|
|
|
cat >A <<\EOF &&
|
|
|
|
a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
|
|
c cccccccccccccccccccccccccccccccccccccccccccccccc
|
|
|
|
d dddddddddddddddddddddddddddddddddddddddddddddddd
|
|
|
|
e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
|
|
|
f ffffffffffffffffffffffffffffffffffffffffffffffff
|
|
|
|
g gggggggggggggggggggggggggggggggggggggggggggggggg
|
|
|
|
h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
|
|
i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
|
|
|
|
j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
|
|
|
|
k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
|
|
|
|
l llllllllllllllllllllllllllllllllllllllllllllllll
|
|
|
|
m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
|
|
|
|
n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
|
|
|
|
o oooooooooooooooooooooooooooooooooooooooooooooooo
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >M <<\EOF &&
|
|
|
|
A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
|
B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
|
|
|
|
C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
|
|
|
|
D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
|
|
|
|
E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
|
|
|
F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
|
|
|
G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
|
|
|
|
H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
|
|
|
|
I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
|
|
|
|
J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
|
|
|
|
K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
|
|
|
L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
|
|
|
M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
|
|
|
N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
|
|
|
|
O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
|
|
|
|
EOF
|
|
|
|
|
|
|
|
git add A M &&
|
2006-10-28 03:07:02 +04:00
|
|
|
git commit -m "initial has A and M" &&
|
2005-12-11 23:44:46 +03:00
|
|
|
git branch white &&
|
|
|
|
git branch red &&
|
|
|
|
git branch blue &&
|
2006-10-28 03:07:02 +04:00
|
|
|
git branch yellow &&
|
2007-04-26 00:07:45 +04:00
|
|
|
git branch change &&
|
|
|
|
git branch change+rename &&
|
2005-12-11 23:44:46 +03:00
|
|
|
|
|
|
|
sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
|
|
|
|
mv A+ A &&
|
|
|
|
git commit -a -m "master updates A" &&
|
|
|
|
|
2006-10-28 03:07:02 +04:00
|
|
|
git checkout yellow &&
|
|
|
|
rm -f M &&
|
|
|
|
git commit -a -m "yellow removes M" &&
|
|
|
|
|
2005-12-11 23:44:46 +03:00
|
|
|
git checkout white &&
|
|
|
|
sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
|
|
|
|
sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
|
|
|
|
rm -f A M &&
|
|
|
|
git update-index --add --remove A B M N &&
|
|
|
|
git commit -m "white renames A->B, M->N" &&
|
|
|
|
|
|
|
|
git checkout red &&
|
|
|
|
sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
|
|
|
|
sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
|
|
|
|
rm -f A M &&
|
|
|
|
git update-index --add --remove A B M N &&
|
|
|
|
git commit -m "red renames A->B, M->N" &&
|
|
|
|
|
|
|
|
git checkout blue &&
|
|
|
|
sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
|
|
|
|
sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
|
|
|
|
rm -f A M &&
|
|
|
|
git update-index --add --remove A C M N &&
|
|
|
|
git commit -m "blue renames A->C, M->N" &&
|
|
|
|
|
2007-04-26 00:07:45 +04:00
|
|
|
git checkout change &&
|
|
|
|
sed -e "/^g /s/.*/g : changed line/" <A >A+ &&
|
|
|
|
mv A+ A &&
|
|
|
|
git commit -q -a -m "changed" &&
|
|
|
|
|
|
|
|
git checkout change+rename &&
|
|
|
|
sed -e "/^g /s/.*/g : changed line/" <A >B &&
|
|
|
|
rm A &&
|
|
|
|
git update-index --add B &&
|
|
|
|
git commit -q -a -m "changed and renamed" &&
|
|
|
|
|
2005-12-11 23:44:46 +03:00
|
|
|
git checkout master'
|
|
|
|
|
|
|
|
test_expect_success 'pull renaming branch into unrenaming one' \
|
|
|
|
'
|
2010-10-31 10:34:44 +03:00
|
|
|
git show-branch &&
|
|
|
|
test_expect_code 1 git pull . white &&
|
|
|
|
git ls-files -s &&
|
|
|
|
git ls-files -u B >b.stages &&
|
|
|
|
test_line_count = 3 b.stages &&
|
|
|
|
git ls-files -s N >n.stages &&
|
|
|
|
test_line_count = 1 n.stages &&
|
2005-12-11 23:44:46 +03:00
|
|
|
sed -ne "/^g/{
|
|
|
|
p
|
|
|
|
q
|
2010-10-31 10:34:44 +03:00
|
|
|
}" B | grep master &&
|
|
|
|
git diff --exit-code white N
|
2005-12-11 23:44:46 +03:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'pull renaming branch into another renaming one' \
|
|
|
|
'
|
2010-10-31 10:34:44 +03:00
|
|
|
rm -f B &&
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout red &&
|
|
|
|
test_expect_code 1 git pull . white &&
|
|
|
|
git ls-files -u B >b.stages &&
|
|
|
|
test_line_count = 3 b.stages &&
|
|
|
|
git ls-files -s N >n.stages &&
|
|
|
|
test_line_count = 1 n.stages &&
|
2005-12-11 23:44:46 +03:00
|
|
|
sed -ne "/^g/{
|
|
|
|
p
|
|
|
|
q
|
2010-10-31 10:34:44 +03:00
|
|
|
}" B | grep red &&
|
|
|
|
git diff --exit-code white N
|
2005-12-11 23:44:46 +03:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'pull unrenaming branch into renaming one' \
|
|
|
|
'
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
git show-branch &&
|
|
|
|
test_expect_code 1 git pull . master &&
|
|
|
|
git ls-files -u B >b.stages &&
|
|
|
|
test_line_count = 3 b.stages &&
|
|
|
|
git ls-files -s N >n.stages &&
|
|
|
|
test_line_count = 1 n.stages &&
|
2005-12-11 23:44:46 +03:00
|
|
|
sed -ne "/^g/{
|
|
|
|
p
|
|
|
|
q
|
2010-10-31 10:34:44 +03:00
|
|
|
}" B | grep red &&
|
|
|
|
git diff --exit-code white N
|
2005-12-11 23:44:46 +03:00
|
|
|
'
|
|
|
|
|
2005-12-12 03:44:05 +03:00
|
|
|
test_expect_success 'pull conflicting renames' \
|
|
|
|
'
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
git show-branch &&
|
|
|
|
test_expect_code 1 git pull . blue &&
|
|
|
|
git ls-files -u A >a.stages &&
|
|
|
|
test_line_count = 1 a.stages &&
|
|
|
|
git ls-files -u B >b.stages &&
|
|
|
|
test_line_count = 1 b.stages &&
|
|
|
|
git ls-files -u C >c.stages &&
|
|
|
|
test_line_count = 1 c.stages &&
|
|
|
|
git ls-files -s N >n.stages &&
|
|
|
|
test_line_count = 1 n.stages &&
|
2005-12-12 03:44:05 +03:00
|
|
|
sed -ne "/^g/{
|
|
|
|
p
|
|
|
|
q
|
2010-10-31 10:34:44 +03:00
|
|
|
}" B | grep red &&
|
|
|
|
git diff --exit-code white N
|
2006-10-28 03:07:02 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'interference with untracked working tree file' '
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
git show-branch &&
|
|
|
|
echo >A this file should not matter &&
|
|
|
|
test_expect_code 1 git pull . white &&
|
|
|
|
test_path_is_file A
|
2006-10-28 03:07:02 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'interference with untracked working tree file' '
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout white &&
|
|
|
|
git show-branch &&
|
|
|
|
rm -f A &&
|
|
|
|
echo >A this file should not matter &&
|
|
|
|
test_expect_code 1 git pull . red &&
|
|
|
|
test_path_is_file A
|
2006-10-28 03:07:02 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'interference with untracked working tree file' '
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
rm -f A M &&
|
|
|
|
git checkout -f master &&
|
|
|
|
git tag -f anchor &&
|
|
|
|
git show-branch &&
|
|
|
|
git pull . yellow &&
|
|
|
|
test_path_is_missing M &&
|
2006-10-28 03:07:02 +04:00
|
|
|
git reset --hard anchor
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'updated working tree file should prevent the merge' '
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
rm -f A M &&
|
|
|
|
git checkout -f master &&
|
|
|
|
git tag -f anchor &&
|
|
|
|
git show-branch &&
|
|
|
|
echo >>M one line addition &&
|
|
|
|
cat M >M.saved &&
|
|
|
|
test_expect_code 128 git pull . yellow &&
|
|
|
|
test_cmp M M.saved &&
|
2006-10-28 03:07:02 +04:00
|
|
|
rm -f M.saved
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'updated working tree file should prevent the merge' '
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
rm -f A M &&
|
|
|
|
git checkout -f master &&
|
|
|
|
git tag -f anchor &&
|
|
|
|
git show-branch &&
|
|
|
|
echo >>M one line addition &&
|
|
|
|
cat M >M.saved &&
|
|
|
|
git update-index M &&
|
|
|
|
test_expect_code 128 git pull . yellow &&
|
|
|
|
test_cmp M M.saved &&
|
2006-10-28 03:07:02 +04:00
|
|
|
rm -f M.saved
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'interference with untracked working tree file' '
|
2010-10-31 10:34:44 +03:00
|
|
|
git reset --hard &&
|
|
|
|
rm -f A M &&
|
|
|
|
git checkout -f yellow &&
|
|
|
|
git tag -f anchor &&
|
|
|
|
git show-branch &&
|
|
|
|
echo >M this file should not matter &&
|
|
|
|
git pull . master &&
|
|
|
|
test_path_is_file M &&
|
|
|
|
! {
|
|
|
|
git ls-files -s |
|
|
|
|
grep M
|
|
|
|
} &&
|
2006-10-28 03:07:02 +04:00
|
|
|
git reset --hard anchor
|
2005-12-12 03:44:05 +03:00
|
|
|
'
|
|
|
|
|
2007-04-26 00:07:45 +04:00
|
|
|
test_expect_success 'merge of identical changes in a renamed file' '
|
2010-10-31 10:34:44 +03:00
|
|
|
rm -f A M N &&
|
2007-04-26 00:07:45 +04:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout change+rename &&
|
2018-02-08 18:56:50 +03:00
|
|
|
GIT_MERGE_VERBOSITY=3 git merge change >out &&
|
|
|
|
test_i18ngrep "^Skipped B" out &&
|
2007-04-26 00:07:45 +04:00
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
git checkout change &&
|
2018-02-08 18:56:50 +03:00
|
|
|
GIT_MERGE_VERBOSITY=3 git merge change+rename >out &&
|
merge-recursive: fix check for skipability of working tree updates
The can-working-tree-updates-be-skipped check has had a long and blemished
history. The update can be skipped iff:
a) The merge is clean
b) The merge matches what was in HEAD (content, mode, pathname)
c) The target path is usable (i.e. not involved in D/F conflict)
Traditionally, we split b into parts:
b1) The merged result matches the content and mode found in HEAD
b2) The merged target path existed in HEAD
Steps a & b1 are easy to check; we have always gotten those right. While
it is easy to overlook step c, this was fixed seven years ago with commit
4ab9a157d069 ("merge_content(): Check whether D/F conflicts are still
present", 2010-09-20). merge-recursive didn't have a readily available
way to directly check step b2, so various approximations were used:
* In commit b2c8c0a76274 ("merge-recursive: When we detect we can skip
an update, actually skip it", 2011-02-28), it was noted that although
the code claimed it was skipping the update, it did not actually skip
the update. The code was made to skip it, but used lstat(path, ...)
as an approximation to path-was-tracked-in-index-before-merge.
* In commit 5b448b853030 ("merge-recursive: When we detect we can skip
an update, actually skip it", 2011-08-11), the problem with using
lstat was noted. It was changed to the approximation
path2 && strcmp(path, path2)
which is also wrong. !path2 || strcmp(path, path2) would have been
better, but would have fallen short with directory renames.
* In c5b761fb2711 ("merge-recursive: ensure we write updates for
directory-renamed file", 2018-02-14), the problem with the previous
approximation was noted and changed to
was_tracked(path)
That looks close to what we were trying to answer, but was_tracked()
as implemented at the time should have been named is_tracked(); it
returned something different than what we were looking for.
* To make matters more complex, fixing was_tracked() isn't sufficient
because the splitting of b into b1 and b2 is wrong. Consider the
following merge with a rename/add conflict:
side A: modify foo, add unrelated bar
side B: rename foo->bar (but don't modify the mode or contents)
In this case, the three-way merge of original foo, A's foo, and B's
bar will result in a desired pathname of bar with the same
mode/contents that A had for foo. Thus, A had the right mode and
contents for the file, and it had the right pathname present (namely,
bar), but the bar that was present was unrelated to the contents, so
the working tree update was not skippable.
Fix this by introducing a new function:
was_tracked_and_matches(o, path, &mfi.oid, mfi.mode)
and use it to directly check for condition b.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-19 20:58:23 +03:00
|
|
|
test_i18ngrep ! "^Skipped B" out
|
2007-04-26 00:07:45 +04:00
|
|
|
'
|
|
|
|
|
2010-09-20 12:28:37 +04:00
|
|
|
test_expect_success 'setup for rename + d/f conflicts' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan dir-in-way &&
|
|
|
|
git rm -rf . &&
|
2011-08-12 09:19:46 +04:00
|
|
|
git clean -fdqx &&
|
2010-09-20 12:28:37 +04:00
|
|
|
|
|
|
|
mkdir sub &&
|
|
|
|
mkdir dir &&
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >sub/file &&
|
|
|
|
echo foo >dir/file-in-the-way &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2010-09-20 12:28:37 +04:00
|
|
|
|
|
|
|
echo 11 >>sub/file &&
|
|
|
|
echo more >>dir/file-in-the-way &&
|
|
|
|
git add -u &&
|
|
|
|
git commit -m "Commit to merge, with dir in the way" &&
|
|
|
|
|
|
|
|
git checkout -b dir-not-in-way &&
|
|
|
|
git reset --soft HEAD^ &&
|
|
|
|
git rm -rf dir &&
|
|
|
|
git commit -m "Commit to merge, with dir removed" -- dir sub/file &&
|
|
|
|
|
|
|
|
git checkout -b renamed-file-has-no-conflicts dir-in-way~1 &&
|
|
|
|
git rm -rf dir &&
|
|
|
|
git rm sub/file &&
|
|
|
|
printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n" >dir &&
|
|
|
|
git add dir &&
|
|
|
|
git commit -m "Independent change" &&
|
|
|
|
|
|
|
|
git checkout -b renamed-file-has-conflicts dir-in-way~1 &&
|
|
|
|
git rm -rf dir &&
|
|
|
|
git mv sub/file dir &&
|
|
|
|
echo 12 >>dir &&
|
|
|
|
git add dir &&
|
|
|
|
git commit -m "Conflicting change"
|
|
|
|
'
|
|
|
|
|
|
|
|
printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n11\n" >expected
|
|
|
|
|
|
|
|
test_expect_success 'Rename+D/F conflict; renamed file merges + dir not in way' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -q renamed-file-has-no-conflicts^0 &&
|
|
|
|
git merge --strategy=recursive dir-not-in-way &&
|
|
|
|
git diff --quiet &&
|
|
|
|
test -f dir &&
|
|
|
|
test_cmp expected dir
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:07 +04:00
|
|
|
test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
|
2010-09-20 12:28:37 +04:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf dir~* &&
|
|
|
|
git checkout -q renamed-file-has-no-conflicts^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive dir-in-way >output &&
|
|
|
|
|
2012-07-25 18:53:13 +04:00
|
|
|
test_i18ngrep "CONFLICT (modify/delete): dir/file-in-the-way" output &&
|
|
|
|
test_i18ngrep "Auto-merging dir" output &&
|
|
|
|
test_i18ngrep "Adding as dir~HEAD instead" output &&
|
2010-09-20 12:28:37 +04:00
|
|
|
|
2011-08-12 09:20:06 +04:00
|
|
|
test 3 -eq "$(git ls-files -u | wc -l)" &&
|
2010-11-09 00:29:26 +03:00
|
|
|
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
|
2010-09-20 12:28:37 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
test_must_fail git diff --cached --quiet &&
|
|
|
|
|
|
|
|
test -f dir/file-in-the-way &&
|
|
|
|
test -f dir~HEAD &&
|
|
|
|
test_cmp expected dir~HEAD
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:07 +04:00
|
|
|
test_expect_success 'Same as previous, but merged other way' '
|
2010-09-20 12:28:38 +04:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf dir~* &&
|
|
|
|
git checkout -q dir-in-way^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive renamed-file-has-no-conflicts >output 2>errors &&
|
|
|
|
|
|
|
|
! grep "error: refusing to lose untracked file at" errors &&
|
2012-07-25 18:53:13 +04:00
|
|
|
test_i18ngrep "CONFLICT (modify/delete): dir/file-in-the-way" output &&
|
|
|
|
test_i18ngrep "Auto-merging dir" output &&
|
|
|
|
test_i18ngrep "Adding as dir~renamed-file-has-no-conflicts instead" output &&
|
2010-09-20 12:28:38 +04:00
|
|
|
|
2011-08-12 09:20:06 +04:00
|
|
|
test 3 -eq "$(git ls-files -u | wc -l)" &&
|
2010-11-09 00:29:26 +03:00
|
|
|
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
|
2010-09-20 12:28:38 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
test_must_fail git diff --cached --quiet &&
|
|
|
|
|
|
|
|
test -f dir/file-in-the-way &&
|
|
|
|
test -f dir~renamed-file-has-no-conflicts &&
|
|
|
|
test_cmp expected dir~renamed-file-has-no-conflicts
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:28:37 +04:00
|
|
|
cat >expected <<\EOF &&
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
2011-08-12 09:20:09 +04:00
|
|
|
<<<<<<< HEAD:dir
|
2010-09-20 12:28:37 +04:00
|
|
|
12
|
|
|
|
=======
|
|
|
|
11
|
2011-08-12 09:20:09 +04:00
|
|
|
>>>>>>> dir-not-in-way:sub/file
|
2010-09-20 12:28:37 +04:00
|
|
|
EOF
|
|
|
|
|
2010-09-20 12:29:03 +04:00
|
|
|
test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in way' '
|
2010-09-20 12:28:37 +04:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf dir~* &&
|
|
|
|
git checkout -q renamed-file-has-conflicts^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive dir-not-in-way &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 3 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 3 -eq "$(git ls-files -u dir | wc -l)" &&
|
2010-09-20 12:28:37 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
test_must_fail git diff --cached --quiet &&
|
|
|
|
|
|
|
|
test -f dir &&
|
|
|
|
test_cmp expected dir
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:07 +04:00
|
|
|
test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in the way' '
|
2010-09-20 12:28:37 +04:00
|
|
|
modify s/dir-not-in-way/dir-in-way/ expected &&
|
|
|
|
|
|
|
|
git reset --hard &&
|
|
|
|
rm -rf dir~* &&
|
|
|
|
git checkout -q renamed-file-has-conflicts^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive dir-in-way &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 5 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
|
|
|
|
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
|
2010-09-20 12:28:37 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
test_must_fail git diff --cached --quiet &&
|
|
|
|
|
|
|
|
test -f dir/file-in-the-way &&
|
|
|
|
test -f dir~HEAD &&
|
|
|
|
test_cmp expected dir~HEAD
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:28:38 +04:00
|
|
|
cat >expected <<\EOF &&
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
2011-08-12 09:20:09 +04:00
|
|
|
<<<<<<< HEAD:sub/file
|
2010-09-20 12:28:38 +04:00
|
|
|
11
|
|
|
|
=======
|
|
|
|
12
|
2011-08-12 09:20:09 +04:00
|
|
|
>>>>>>> renamed-file-has-conflicts:dir
|
2010-09-20 12:28:38 +04:00
|
|
|
EOF
|
|
|
|
|
2010-09-20 12:29:07 +04:00
|
|
|
test_expect_success 'Same as previous, but merged other way' '
|
2010-09-20 12:28:38 +04:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf dir~* &&
|
|
|
|
git checkout -q dir-in-way^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 5 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
|
|
|
|
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
|
2010-09-20 12:28:38 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
test_must_fail git diff --cached --quiet &&
|
|
|
|
|
|
|
|
test -f dir/file-in-the-way &&
|
|
|
|
test -f dir~renamed-file-has-conflicts &&
|
|
|
|
test_cmp expected dir~renamed-file-has-conflicts
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:28:39 +04:00
|
|
|
test_expect_success 'setup both rename source and destination involved in D/F conflict' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan rename-dest &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
mkdir one &&
|
|
|
|
echo stuff >one/file &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2010-09-20 12:28:39 +04:00
|
|
|
|
|
|
|
git mv one/file destdir &&
|
|
|
|
git commit -m "Renamed to destdir" &&
|
|
|
|
|
|
|
|
git checkout -b source-conflict HEAD~1 &&
|
|
|
|
git rm -rf one &&
|
|
|
|
mkdir destdir &&
|
|
|
|
touch one destdir/foo &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "Conflicts in the way"
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:05 +04:00
|
|
|
test_expect_success 'both rename source and destination involved in D/F conflict' '
|
2010-09-20 12:28:39 +04:00
|
|
|
git reset --hard &&
|
|
|
|
rm -rf dir~* &&
|
|
|
|
git checkout -q rename-dest^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive source-conflict &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 1 -eq "$(git ls-files -u | wc -l)" &&
|
2010-09-20 12:28:39 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
|
|
|
|
test -f destdir/foo &&
|
|
|
|
test -f one &&
|
|
|
|
test -f destdir~HEAD &&
|
|
|
|
test "stuff" = "$(cat destdir~HEAD)"
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:28:40 +04:00
|
|
|
test_expect_success 'setup pair rename to parent of other (D/F conflicts)' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan rename-two &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
mkdir one &&
|
|
|
|
mkdir two &&
|
|
|
|
echo stuff >one/file &&
|
|
|
|
echo other >two/file &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2010-09-20 12:28:40 +04:00
|
|
|
|
|
|
|
git rm -rf one &&
|
|
|
|
git mv two/file one &&
|
|
|
|
git commit -m "Rename two/file -> one" &&
|
|
|
|
|
|
|
|
git checkout -b rename-one HEAD~1 &&
|
|
|
|
git rm -rf two &&
|
|
|
|
git mv one/file two &&
|
|
|
|
rm -r one &&
|
|
|
|
git commit -m "Rename one/file -> two"
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:05 +04:00
|
|
|
test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
|
2010-09-20 12:28:40 +04:00
|
|
|
git checkout -q rename-one^0 &&
|
|
|
|
mkdir one &&
|
|
|
|
test_must_fail git merge --strategy=recursive rename-two &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 2 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u one | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u two | wc -l)" &&
|
2010-09-20 12:28:40 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 4 -eq $(find . | grep -v .git | wc -l) &&
|
2010-09-20 12:28:40 +04:00
|
|
|
|
|
|
|
test -d one &&
|
|
|
|
test -f one~rename-two &&
|
|
|
|
test -f two &&
|
|
|
|
test "other" = $(cat one~rename-two) &&
|
|
|
|
test "stuff" = $(cat two)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean start' '
|
|
|
|
git reset --hard &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
test_must_fail git merge --strategy=recursive rename-two &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 2 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u one | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u two | wc -l)" &&
|
2010-09-20 12:28:40 +04:00
|
|
|
|
|
|
|
test_must_fail git diff --quiet &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 3 -eq $(find . | grep -v .git | wc -l) &&
|
2010-09-20 12:28:40 +04:00
|
|
|
|
|
|
|
test -f one &&
|
|
|
|
test -f two &&
|
|
|
|
test "other" = $(cat one) &&
|
|
|
|
test "stuff" = $(cat two)
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:28:41 +04:00
|
|
|
test_expect_success 'setup rename of one file to two, with directories in the way' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan first-rename &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
echo stuff >original &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2010-09-20 12:28:41 +04:00
|
|
|
|
|
|
|
mkdir two &&
|
|
|
|
>two/file &&
|
|
|
|
git add two/file &&
|
|
|
|
git mv original one &&
|
|
|
|
git commit -m "Put two/file in the way, rename to one" &&
|
|
|
|
|
|
|
|
git checkout -b second-rename HEAD~1 &&
|
|
|
|
mkdir one &&
|
|
|
|
>one/file &&
|
|
|
|
git add one/file &&
|
|
|
|
git mv original two &&
|
|
|
|
git commit -m "Put one/file in the way, rename to two"
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:00 +04:00
|
|
|
test_expect_success 'check handling of differently renamed file with D/F conflicts' '
|
2010-09-20 12:28:41 +04:00
|
|
|
git checkout -q first-rename^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive second-rename &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 5 -eq "$(git ls-files -s | wc -l)" &&
|
|
|
|
test 3 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u one | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u two | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u original | wc -l)" &&
|
|
|
|
test 2 -eq "$(git ls-files -o | wc -l)" &&
|
2010-09-20 12:28:41 +04:00
|
|
|
|
|
|
|
test -f one/file &&
|
|
|
|
test -f two/file &&
|
|
|
|
test -f one~HEAD &&
|
|
|
|
test -f two~second-rename &&
|
|
|
|
! test -f original
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup rename one file to two; directories moving out of the way' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan first-rename-redo &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
echo stuff >original &&
|
|
|
|
mkdir one two &&
|
|
|
|
touch one/file two/file &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2010-09-20 12:28:41 +04:00
|
|
|
|
|
|
|
git rm -rf one &&
|
|
|
|
git mv original one &&
|
|
|
|
git commit -m "Rename to one" &&
|
|
|
|
|
|
|
|
git checkout -b second-rename-redo HEAD~1 &&
|
|
|
|
git rm -rf two &&
|
|
|
|
git mv original two &&
|
|
|
|
git commit -m "Rename to two"
|
|
|
|
'
|
|
|
|
|
2010-09-20 12:29:06 +04:00
|
|
|
test_expect_success 'check handling of differently renamed file with D/F conflicts' '
|
2010-09-20 12:28:41 +04:00
|
|
|
git checkout -q first-rename-redo^0 &&
|
|
|
|
test_must_fail git merge --strategy=recursive second-rename-redo &&
|
|
|
|
|
2010-11-09 00:29:26 +03:00
|
|
|
test 3 -eq "$(git ls-files -u | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u one | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u two | wc -l)" &&
|
|
|
|
test 1 -eq "$(git ls-files -u original | wc -l)" &&
|
|
|
|
test 0 -eq "$(git ls-files -o | wc -l)" &&
|
2010-09-20 12:28:41 +04:00
|
|
|
|
|
|
|
test -f one &&
|
|
|
|
test -f two &&
|
|
|
|
! test -f original
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:19:47 +04:00
|
|
|
test_expect_success 'setup avoid unnecessary update, normal rename' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan avoid-unnecessary-update-1 &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >original &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2011-08-12 09:19:47 +04:00
|
|
|
|
|
|
|
git mv original rename &&
|
|
|
|
echo 11 >>rename &&
|
|
|
|
git add -u &&
|
|
|
|
git commit -m "Renamed and modified" &&
|
|
|
|
|
|
|
|
git checkout -b merge-branch-1 HEAD~1 &&
|
|
|
|
echo "random content" >random-file &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "Random, unrelated changes"
|
|
|
|
'
|
|
|
|
|
merge-recursive: When we detect we can skip an update, actually skip it
In 882fd11 (merge-recursive: Delay content merging for renames 2010-09-20),
there was code that checked for whether we could skip updating a file in
the working directory, based on whether the merged version matched the
current working copy. Due to the desire to handle directory/file conflicts
that were resolvable, that commit deferred content merging by first
updating the index with the unmerged entries and then moving the actual
merging (along with the skip-the-content-update check) to another function
that ran later in the merge process. As part moving the content merging
code, a bug was introduced such that although the message about skipping
the update would be printed (whenever GIT_MERGE_VERBOSITY was sufficiently
high), the file would be unconditionally updated in the working copy
anyway.
When we detect that the file does not need to be updated in the working
copy, update the index appropriately and then return early before updating
the working copy.
Note that there was a similar change in b2c8c0a (merge-recursive: When we
detect we can skip an update, actually skip it 2011-02-28), but it was
reverted by 6db4105 (Revert "Merge branch 'en/merge-recursive'"
2011-05-19) since it did not fix both of the relevant types of unnecessary
update breakages and, worse, it made use of some band-aids that caused
other problems. The reason this change works is due to the changes earlier
in this series to (a) record_df_conflict_files instead of just unlinking
them early, (b) allowing make_room_for_path() to remove D/F entries,
(c) the splitting of update_stages_and_entry() to have its functionality
called at different points, and (d) making the pathnames of the files
involved in the merge available to merge_content().
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-12 09:20:10 +04:00
|
|
|
test_expect_success 'avoid unnecessary update, normal rename' '
|
2011-08-12 09:19:47 +04:00
|
|
|
git checkout -q avoid-unnecessary-update-1^0 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get =1000000000 rename >expect &&
|
2011-08-12 09:19:47 +04:00
|
|
|
git merge merge-branch-1 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get rename >actual &&
|
2011-08-12 09:19:47 +04:00
|
|
|
test_cmp expect actual # "rename" should have stayed intact
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup to test avoiding unnecessary update, with D/F conflict' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan avoid-unnecessary-update-2 &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
mkdir df &&
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >df/file &&
|
|
|
|
git add -A &&
|
2013-09-05 02:28:45 +04:00
|
|
|
git commit -m "Common commit" &&
|
2011-08-12 09:19:47 +04:00
|
|
|
|
|
|
|
git mv df/file temp &&
|
|
|
|
rm -rf df &&
|
|
|
|
git mv temp df &&
|
|
|
|
echo 11 >>df &&
|
|
|
|
git add -u &&
|
|
|
|
git commit -m "Renamed and modified" &&
|
|
|
|
|
|
|
|
git checkout -b merge-branch-2 HEAD~1 &&
|
|
|
|
>unrelated-change &&
|
|
|
|
git add unrelated-change &&
|
|
|
|
git commit -m "Only unrelated changes"
|
|
|
|
'
|
|
|
|
|
merge-recursive: When we detect we can skip an update, actually skip it
In 882fd11 (merge-recursive: Delay content merging for renames 2010-09-20),
there was code that checked for whether we could skip updating a file in
the working directory, based on whether the merged version matched the
current working copy. Due to the desire to handle directory/file conflicts
that were resolvable, that commit deferred content merging by first
updating the index with the unmerged entries and then moving the actual
merging (along with the skip-the-content-update check) to another function
that ran later in the merge process. As part moving the content merging
code, a bug was introduced such that although the message about skipping
the update would be printed (whenever GIT_MERGE_VERBOSITY was sufficiently
high), the file would be unconditionally updated in the working copy
anyway.
When we detect that the file does not need to be updated in the working
copy, update the index appropriately and then return early before updating
the working copy.
Note that there was a similar change in b2c8c0a (merge-recursive: When we
detect we can skip an update, actually skip it 2011-02-28), but it was
reverted by 6db4105 (Revert "Merge branch 'en/merge-recursive'"
2011-05-19) since it did not fix both of the relevant types of unnecessary
update breakages and, worse, it made use of some band-aids that caused
other problems. The reason this change works is due to the changes earlier
in this series to (a) record_df_conflict_files instead of just unlinking
them early, (b) allowing make_room_for_path() to remove D/F entries,
(c) the splitting of update_stages_and_entry() to have its functionality
called at different points, and (d) making the pathnames of the files
involved in the merge available to merge_content().
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-12 09:20:10 +04:00
|
|
|
test_expect_success 'avoid unnecessary update, with D/F conflict' '
|
2011-08-12 09:19:47 +04:00
|
|
|
git checkout -q avoid-unnecessary-update-2^0 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get =1000000000 df >expect &&
|
2011-08-12 09:19:47 +04:00
|
|
|
git merge merge-branch-2 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get df >actual &&
|
2011-08-12 09:19:47 +04:00
|
|
|
test_cmp expect actual # "df" should have stayed intact
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:26 +04:00
|
|
|
test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' '
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
rm -rf .git &&
|
|
|
|
git init &&
|
|
|
|
|
|
|
|
>irrelevant &&
|
|
|
|
mkdir df &&
|
|
|
|
>df/file &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -mA &&
|
|
|
|
|
2015-03-20 13:07:15 +03:00
|
|
|
git checkout -b side &&
|
2011-08-12 09:20:26 +04:00
|
|
|
git rm -rf df &&
|
|
|
|
git commit -mB &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
git rm -rf df &&
|
|
|
|
echo bla >df &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "Add a newfile"
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:27 +04:00
|
|
|
test_expect_success 'avoid unnecessary update, dir->(file,nothing)' '
|
2011-08-12 09:20:26 +04:00
|
|
|
git checkout -q master^0 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get =1000000000 df >expect &&
|
2011-08-12 09:20:26 +04:00
|
|
|
git merge side &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get df >actual &&
|
2011-08-12 09:20:26 +04:00
|
|
|
test_cmp expect actual # "df" should have stayed intact
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup avoid unnecessary update, modify/delete' '
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
rm -rf .git &&
|
|
|
|
git init &&
|
|
|
|
|
|
|
|
>irrelevant &&
|
|
|
|
>file &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -mA &&
|
|
|
|
|
2015-03-20 13:07:15 +03:00
|
|
|
git checkout -b side &&
|
2011-08-12 09:20:26 +04:00
|
|
|
git rm -f file &&
|
|
|
|
git commit -m "Delete file" &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
echo bla >file &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "Modify file"
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:27 +04:00
|
|
|
test_expect_success 'avoid unnecessary update, modify/delete' '
|
2011-08-12 09:20:26 +04:00
|
|
|
git checkout -q master^0 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get =1000000000 file >expect &&
|
2011-08-12 09:20:26 +04:00
|
|
|
test_must_fail git merge side &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get file >actual &&
|
2011-08-12 09:20:26 +04:00
|
|
|
test_cmp expect actual # "file" should have stayed intact
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup avoid unnecessary update, rename/add-dest' '
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
rm -rf .git &&
|
|
|
|
git init &&
|
|
|
|
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n" >file &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -mA &&
|
|
|
|
|
2015-03-20 13:07:15 +03:00
|
|
|
git checkout -b side &&
|
2011-08-12 09:20:26 +04:00
|
|
|
cp file newfile &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "Add file copy" &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
git mv file newfile &&
|
|
|
|
git commit -m "Rename file"
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:27 +04:00
|
|
|
test_expect_success 'avoid unnecessary update, rename/add-dest' '
|
2011-08-12 09:20:26 +04:00
|
|
|
git checkout -q master^0 &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get =1000000000 newfile >expect &&
|
2011-08-12 09:20:26 +04:00
|
|
|
git merge side &&
|
2018-04-25 07:29:00 +03:00
|
|
|
test-tool chmtime --get newfile >actual &&
|
2011-08-12 09:20:26 +04:00
|
|
|
test_cmp expect actual # "file" should have stayed intact
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:19:48 +04:00
|
|
|
test_expect_success 'setup merge of rename + small change' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout --orphan rename-plus-small-change &&
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
|
|
|
|
echo ORIGINAL >file &&
|
|
|
|
git add file &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m Initial &&
|
|
|
|
git checkout -b rename_branch &&
|
|
|
|
git mv file renamed_file &&
|
|
|
|
git commit -m Rename &&
|
|
|
|
git checkout rename-plus-small-change &&
|
|
|
|
echo NEW-VERSION >file &&
|
|
|
|
git commit -a -m Reformat
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge rename + small change' '
|
|
|
|
git merge rename_branch &&
|
|
|
|
|
|
|
|
test 1 -eq $(git ls-files -s | wc -l) &&
|
|
|
|
test 0 -eq $(git ls-files -o | wc -l) &&
|
|
|
|
test $(git rev-parse HEAD:renamed_file) = $(git rev-parse HEAD~1:file)
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:09 +04:00
|
|
|
test_expect_success 'setup for use of extended merge markers' '
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
rm -rf .git &&
|
|
|
|
git init &&
|
|
|
|
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n" >original_file &&
|
|
|
|
git add original_file &&
|
|
|
|
git commit -mA &&
|
|
|
|
|
|
|
|
git checkout -b rename &&
|
|
|
|
echo 9 >>original_file &&
|
|
|
|
git add original_file &&
|
|
|
|
git mv original_file renamed_file &&
|
|
|
|
git commit -mB &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
echo 8.5 >>original_file &&
|
|
|
|
git add original_file &&
|
|
|
|
git commit -mC
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expected <<\EOF &&
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
<<<<<<< HEAD:renamed_file
|
|
|
|
9
|
|
|
|
=======
|
|
|
|
8.5
|
|
|
|
>>>>>>> master^0:original_file
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'merge master into rename has correct extended markers' '
|
|
|
|
git checkout rename^0 &&
|
|
|
|
test_must_fail git merge -s recursive master^0 &&
|
|
|
|
test_cmp expected renamed_file
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expected <<\EOF &&
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
<<<<<<< HEAD:original_file
|
|
|
|
8.5
|
|
|
|
=======
|
|
|
|
9
|
|
|
|
>>>>>>> rename^0:renamed_file
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'merge rename into master has correct extended markers' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout master^0 &&
|
|
|
|
test_must_fail git merge -s recursive rename^0 &&
|
|
|
|
test_cmp expected renamed_file
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:24 +04:00
|
|
|
test_expect_success 'setup spurious "refusing to lose untracked" message' '
|
|
|
|
git rm -rf . &&
|
|
|
|
git clean -fdqx &&
|
|
|
|
rm -rf .git &&
|
|
|
|
git init &&
|
|
|
|
|
|
|
|
> irrelevant_file &&
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n" >original_file &&
|
|
|
|
git add irrelevant_file original_file &&
|
|
|
|
git commit -mA &&
|
|
|
|
|
|
|
|
git checkout -b rename &&
|
|
|
|
git mv original_file renamed_file &&
|
|
|
|
git commit -mB &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
git rm original_file &&
|
|
|
|
git commit -mC
|
|
|
|
'
|
|
|
|
|
2011-08-12 09:20:25 +04:00
|
|
|
test_expect_success 'no spurious "refusing to lose untracked" message' '
|
2011-08-12 09:20:24 +04:00
|
|
|
git checkout master^0 &&
|
|
|
|
test_must_fail git merge rename^0 2>errors.txt &&
|
|
|
|
! grep "refusing to lose untracked file" errors.txt
|
|
|
|
'
|
|
|
|
|
2012-03-23 02:52:24 +04:00
|
|
|
test_expect_success 'do not follow renames for empty files' '
|
|
|
|
git checkout -f -b empty-base &&
|
|
|
|
>empty1 &&
|
|
|
|
git add empty1 &&
|
|
|
|
git commit -m base &&
|
|
|
|
echo content >empty1 &&
|
|
|
|
git add empty1 &&
|
|
|
|
git commit -m fill &&
|
|
|
|
git checkout -b empty-topic HEAD^ &&
|
|
|
|
git mv empty1 empty2 &&
|
|
|
|
git commit -m rename &&
|
|
|
|
test_must_fail git merge empty-base &&
|
2018-07-27 20:48:11 +03:00
|
|
|
test_must_be_empty empty2
|
2012-03-23 02:52:24 +04:00
|
|
|
'
|
|
|
|
|
2005-12-11 23:44:46 +03:00
|
|
|
test_done
|