2007-12-01 06:22:38 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='typechange rename detection'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
2021-10-15 09:30:17 +00:00
|
|
|
. "$TEST_DIRECTORY"/lib-diff.sh
|
2007-12-01 06:22:38 +00:00
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
test_expect_success setup '
|
2007-12-01 06:22:38 +00:00
|
|
|
|
|
|
|
rm -f foo bar &&
|
2021-10-15 09:30:17 +00:00
|
|
|
COPYING_test_data >foo &&
|
2013-06-07 20:53:32 +00:00
|
|
|
test_ln_s_add linklink bar &&
|
|
|
|
git add foo &&
|
2007-12-01 06:22:38 +00:00
|
|
|
git commit -a -m Initial &&
|
|
|
|
git tag one &&
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
git rm -f foo bar &&
|
2021-10-15 09:30:17 +00:00
|
|
|
COPYING_test_data >bar &&
|
2013-06-07 20:53:32 +00:00
|
|
|
test_ln_s_add linklink foo &&
|
|
|
|
git add bar &&
|
2007-12-01 06:22:38 +00:00
|
|
|
git commit -a -m Second &&
|
|
|
|
git tag two &&
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
git rm -f foo bar &&
|
2021-10-15 09:30:17 +00:00
|
|
|
COPYING_test_data >foo &&
|
2007-12-01 06:22:38 +00:00
|
|
|
git add foo &&
|
|
|
|
git commit -a -m Third &&
|
|
|
|
git tag three &&
|
|
|
|
|
|
|
|
mv foo bar &&
|
2013-06-07 20:53:32 +00:00
|
|
|
test_ln_s_add linklink foo &&
|
|
|
|
git add bar &&
|
2007-12-01 06:22:38 +00:00
|
|
|
git commit -a -m Fourth &&
|
|
|
|
git tag four &&
|
|
|
|
|
|
|
|
# This is purely for sanity check
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
git rm -f foo bar &&
|
2021-10-15 09:30:17 +00:00
|
|
|
COPYING_test_data >foo &&
|
2008-08-08 09:26:28 +00:00
|
|
|
cat "$TEST_DIRECTORY"/../Makefile >bar &&
|
2007-12-01 06:22:38 +00:00
|
|
|
git add foo bar &&
|
|
|
|
git commit -a -m Fifth &&
|
|
|
|
git tag five &&
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
git rm -f foo bar &&
|
2008-08-08 09:26:28 +00:00
|
|
|
cat "$TEST_DIRECTORY"/../Makefile >foo &&
|
2021-10-15 09:30:17 +00:00
|
|
|
COPYING_test_data >bar &&
|
2007-12-01 06:22:38 +00:00
|
|
|
git add foo bar &&
|
|
|
|
git commit -a -m Sixth &&
|
|
|
|
git tag six
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
test_expect_success 'cross renames to be detected for regular files' '
|
2022-12-02 00:06:29 +00:00
|
|
|
git diff-tree five six -r --name-status -B -M >out &&
|
|
|
|
sort out >actual &&
|
2007-12-01 06:22:38 +00:00
|
|
|
{
|
tests: fix broken &&-chains in `{...}` groups
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in `{...}` groups in order to reduce the number of
possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:08 +00:00
|
|
|
echo "R100 foo bar" &&
|
2007-12-01 06:22:38 +00:00
|
|
|
echo "R100 bar foo"
|
|
|
|
} | sort >expect &&
|
2008-03-12 21:36:36 +00:00
|
|
|
test_cmp expect actual
|
2007-12-01 06:22:38 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
test_expect_success 'cross renames to be detected for typechange' '
|
2022-12-02 00:06:29 +00:00
|
|
|
git diff-tree one two -r --name-status -B -M >out &&
|
|
|
|
sort out >actual &&
|
2007-12-01 06:22:38 +00:00
|
|
|
{
|
tests: fix broken &&-chains in `{...}` groups
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in `{...}` groups in order to reduce the number of
possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:08 +00:00
|
|
|
echo "R100 foo bar" &&
|
2007-12-01 06:22:38 +00:00
|
|
|
echo "R100 bar foo"
|
|
|
|
} | sort >expect &&
|
2008-03-12 21:36:36 +00:00
|
|
|
test_cmp expect actual
|
2007-12-01 06:22:38 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-06-07 20:53:32 +00:00
|
|
|
test_expect_success 'moves and renames' '
|
2022-12-02 00:06:29 +00:00
|
|
|
git diff-tree three four -r --name-status -B -M >out &&
|
|
|
|
sort out >actual &&
|
2007-12-01 06:22:38 +00:00
|
|
|
{
|
diff -B -M: fix output for "copy and then rewrite" case
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>
2014-10-23 17:02:02 +00:00
|
|
|
# see -B -M (#6) in t4008
|
tests: fix broken &&-chains in `{...}` groups
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in `{...}` groups in order to reduce the number of
possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:08 +00:00
|
|
|
echo "C100 foo bar" &&
|
2007-12-01 06:22:38 +00:00
|
|
|
echo "T100 foo"
|
|
|
|
} | sort >expect &&
|
2008-03-12 21:36:36 +00:00
|
|
|
test_cmp expect actual
|
2007-12-01 06:22:38 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|