Re: [PATCH] t4069: test diff behavior with i-t-a paths
From: Junio C Hamano <hidden>
Date: 2020-08-10 16:22:31
"Raymond E. Pasco" [off-list ref] writes:
Add a small test suite to test the behavior of diff with intent-to-add paths. Specifically, the diff between an i-t-a entry and a file in the worktree should be a "new file" diff, and the diff between an i-t-a entry and no file in the worktree should be a "deleted file" diff. However, if --ita-visible-in-index is passed, the former should instead be a diff from the empty blob. Signed-off-by: Raymond E. Pasco <redacted> --- t/t4069-diff-intent-to-add.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 t/t4069-diff-intent-to-add.sh
It indeed is that "add -N" appears only once in our test suite and tests around it is lacking, but I'd prefer to see i-t-a to be taken as just one of the normal things by not adding a special test for it. I wonder if there is a reason why these are not part of say t4013 (diff-various)? By adjusting and adding to existing test, we'd avoid a mistake of adding a test script that is not executable (didn't your "make DEVELOPER=1 test" catch the error?) ;-) Thanks.
quoted hunk
diff --git a/t/t4069-diff-intent-to-add.sh b/t/t4069-diff-intent-to-add.sh new file mode 100644 index 0000000000..85c1a35ca7 --- /dev/null +++ b/t/t4069-diff-intent-to-add.sh@@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='behavior of diff with intent-to-add entries' + +. ./test-lib.sh + +test_expect_success setup ' + test_write_lines 1 2 3 4 5 >blueprint +' + +test_expect_success 'diff between i-t-a and file should be new file' ' + cat blueprint >test-file && + git add -N test-file && + git diff >output && + grep "new file mode 100644" output +' + +test_expect_success 'diff between i-t-a and no file should be deletion' ' + rm -f test-file && + git diff >output && + grep "deleted file mode 100644" output +' + +test_expect_success '--ita-visible-in-index diff should be from empty blob' ' + cat blueprint >test-file && + git diff --ita-visible-in-index >output && + grep "index e69de29" output +' + +test_done