{"thread":{"id":"30821","subject":"[PATCH v2] diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes","startedAt":"2012-06-15T20:06:47Z","lastAt":"2012-06-15T20:06:47Z","messageCount":1,"participants":["Tim Henigan"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"193729","messageId":"1339790807-28346-1-git-send-email-tim.henigan@gmail.com","threadId":"30821","inReplyTo":null,"subject":"[PATCH v2] diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-06-15T20:06:47Z","receivedAt":"2012-06-15T20:06:47Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"When running 'git diff --quiet <file1> <file2>', if file1 or file2\nis outside the repository, it will exit(0) even if the files differ.\nIt should exit(1) when they differ.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nChanges in v2:\n  - Implemented the fix in diff-no-index.c as suggested by Junio\n    Hamano.  The previous version affected the performance of all\n    diff commands that used the '--quiet' option by forcing the\n    code through the expensive (and in this case unneccesary)\n    'diff_flush_patch' code path.\n  - Updated the test to use 'test_expect_code' as suggested by\n    Jeff King.\n\n\n diff-no-index.c       | 3 ++-\n t/t4035-diff-quiet.sh | 4 ++++\n 2 files changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex f0b0010..b935d2a 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -273,5 +273,6 @@ void diff_no_index(struct rev_info *revs,\n \t * The return code for --no-index imitates diff(1):\n \t * 0 = no changes, 1 = changes, else error\n \t */\n-\texit(revs->diffopt.found_changes);\n+\tint result = diff_result_code(&revs->diffopt, 0);\n+\texit(result);\n }\ndiff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh\nindex cdb9202..0b83235 100755\n--- a/t/t4035-diff-quiet.sh\n+++ b/t/t4035-diff-quiet.sh\n@@ -76,4 +77,8 @@ test_expect_success 'git diff-index --cached HEAD' '\n \t}\n '\n \n+test_expect_success 'git diff <tracked file> <file outside repo>' '\n+\ttest_expect_code 1 git diff --quiet c /dev/null\n+'\n+\n test_done\n-- \n1.7.11.rc3.6.g894ec42.dirty\n"}]}