From: Junio C Hamano Date: Wed, 6 May 2015 04:00:24 +0000 (-0700) Subject: Merge branch 'jc/diff-no-index-d-f' X-Git-Tag: v2.5.0-rc0~160 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/03761c922bf938ae4d22c62eda712c8ff0c1a8d7?hp=-c Merge branch 'jc/diff-no-index-d-f' The usual "git diff" when seeing a file turning into a directory showed a patchset to remove the file and create all files in the directory, but "git diff --no-index" simply refused to work. Also, when asked to compare a file and a directory, imitate POSIX "diff" and compare the file with the file with the same name in the directory, instead of refusing to run. * jc/diff-no-index-d-f: diff-no-index: align D/F handling with that of normal Git diff-no-index: DWIM "diff D F" into "diff D/F F" --- 03761c922bf938ae4d22c62eda712c8ff0c1a8d7 diff --combined t/t4053-diff-no-index.sh index 075ece6db1,596dfe712d..6eb83211b5 --- a/t/t4053-diff-no-index.sh +++ b/t/t4053-diff-no-index.sh @@@ -17,8 -17,8 +17,8 @@@ test_expect_success 'setup' ' test_expect_success 'git diff --no-index directories' ' - git diff --no-index a b >cnt - test $? = 1 && test_line_count = 14 cnt + test_expect_code 1 git diff --no-index a b >cnt && + test_line_count = 14 cnt ' test_expect_success 'git diff --no-index relative path outside repo' ' @@@ -55,4 -55,38 +55,38 @@@ test_expect_success 'git diff --no-inde ) ' + test_expect_success 'diff D F and diff F D' ' + ( + cd repo && + echo in-repo >a && + echo non-repo >../non/git/a && + mkdir sub && + echo sub-repo >sub/a && + + test_must_fail git diff --no-index sub/a ../non/git/a >expect && + test_must_fail git diff --no-index sub/a ../non/git/ >actual && + test_cmp expect actual && + + test_must_fail git diff --no-index a ../non/git/a >expect && + test_must_fail git diff --no-index a ../non/git/ >actual && + test_cmp expect actual && + + test_must_fail git diff --no-index ../non/git/a a >expect && + test_must_fail git diff --no-index ../non/git a >actual && + test_cmp expect actual + ) + ' + + test_expect_success 'turning a file into a directory' ' + ( + cd non/git && + mkdir d e e/sub && + echo 1 >d/sub && + echo 2 >e/sub/file && + printf "D\td/sub\nA\te/sub/file\n" >expect && + test_must_fail git diff --no-index --name-status d e >actual && + test_cmp expect actual + ) + ' + test_done