mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
6936b5859c
Starting from a single file, A, if you create B as a copy of A (and possibly make some edit) and then make extensive change to A, you will see: $ git diff -C --name-status C89 A B M A which is expected. However, if you ask the same question in a different way, you see this: $ git diff -B -M --name-status R89 A B M100 A telling us that A was rename-edited into B (as if "A will no longer exist as the result") and at the same time A itself was extensively edited. In this case, because the resulting tree still does have file A (even if it has contents vastly different from the original), we should use "C"opy, not "R"ename, to avoid hinting that A somehow goes away. Two existing tests were depending on the wrong behaviour, and fixed. Signed-off-by: Junio C Hamano <gitster@pobox.com>
88 lines
1.7 KiB
Bash
Executable File
88 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='typechange rename detection'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
|
|
rm -f foo bar &&
|
|
cat "$TEST_DIRECTORY"/../COPYING >foo &&
|
|
test_ln_s_add linklink bar &&
|
|
git add foo &&
|
|
git commit -a -m Initial &&
|
|
git tag one &&
|
|
|
|
git rm -f foo bar &&
|
|
cat "$TEST_DIRECTORY"/../COPYING >bar &&
|
|
test_ln_s_add linklink foo &&
|
|
git add bar &&
|
|
git commit -a -m Second &&
|
|
git tag two &&
|
|
|
|
git rm -f foo bar &&
|
|
cat "$TEST_DIRECTORY"/../COPYING >foo &&
|
|
git add foo &&
|
|
git commit -a -m Third &&
|
|
git tag three &&
|
|
|
|
mv foo bar &&
|
|
test_ln_s_add linklink foo &&
|
|
git add bar &&
|
|
git commit -a -m Fourth &&
|
|
git tag four &&
|
|
|
|
# This is purely for sanity check
|
|
|
|
git rm -f foo bar &&
|
|
cat "$TEST_DIRECTORY"/../COPYING >foo &&
|
|
cat "$TEST_DIRECTORY"/../Makefile >bar &&
|
|
git add foo bar &&
|
|
git commit -a -m Fifth &&
|
|
git tag five &&
|
|
|
|
git rm -f foo bar &&
|
|
cat "$TEST_DIRECTORY"/../Makefile >foo &&
|
|
cat "$TEST_DIRECTORY"/../COPYING >bar &&
|
|
git add foo bar &&
|
|
git commit -a -m Sixth &&
|
|
git tag six
|
|
|
|
'
|
|
|
|
test_expect_success 'cross renames to be detected for regular files' '
|
|
|
|
git diff-tree five six -r --name-status -B -M | sort >actual &&
|
|
{
|
|
echo "R100 foo bar"
|
|
echo "R100 bar foo"
|
|
} | sort >expect &&
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
test_expect_success 'cross renames to be detected for typechange' '
|
|
|
|
git diff-tree one two -r --name-status -B -M | sort >actual &&
|
|
{
|
|
echo "R100 foo bar"
|
|
echo "R100 bar foo"
|
|
} | sort >expect &&
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
test_expect_success 'moves and renames' '
|
|
|
|
git diff-tree three four -r --name-status -B -M | sort >actual &&
|
|
{
|
|
# see -B -M (#6) in t4008
|
|
echo "C100 foo bar"
|
|
echo "T100 foo"
|
|
} | sort >expect &&
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
test_done
|