Bugfix: GIT_EXTERNAL_DIFF with more than one changed files
When there is more than one file that are changed, running git diff with GIT_EXTERNAL_DIFF incorrectly diagnoses an programming error and dies. The check introduced in 479b0ae (diff: refactor tempfile cleanup handling, 2009-01-22) to detect a temporary file slot that forgot to remove its temporary file was inconsistent with the way the codepath to remove the temporary to mark the slot that it is done with it. This patch fixes this problem and adds a test case for it. Signed-off-by: Nazri Ramliy <ayiehere@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nazri Ramliy committed
Feb 12, 2009 at 21:36 UTC
a8344abe0f70f9fc629ee055d73ffa65fbc58311
2 files changed
+12
-4
diff.c
+4
-4
@@ -184,11 +184,11 @@ static int remove_tempfile_installed;
184
static void remove_tempfile(void)
185
{
186
int i;
187
- for (i = 0; i < ARRAY_SIZE(diff_temp); i++)
188
- if (diff_temp[i].name == diff_temp[i].tmp_path) {
187
+ for (i = 0; i < ARRAY_SIZE(diff_temp); i++) {
188
+ if (diff_temp[i].name == diff_temp[i].tmp_path)
189
unlink(diff_temp[i].name);
190
- diff_temp[i].name = NULL;
191
- }
190
+ diff_temp[i].name = NULL;
191
+ }
192
}
193
194
static void remove_tempfile_on_signal(int signo)
t/t4020-diff-external.sh
+8
@@ -128,4 +128,12 @@ test_expect_success 'force diff with "diff"' '
128
test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
129
'
130
131
+test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '
132
+ echo anotherfile > file2 &&
133
+ git add file2 &&
134
+ git commit -m "added 2nd file" &&
135
+ echo modified >file2 &&
136
+ GIT_EXTERNAL_DIFF=echo git diff
137
+'
138
+
139
test_done