diff-files: careful when inspecting work tree items
This fixes the same breakage in diff-files. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 30, 2008 at 17:30 UTC
f58dbf23c33e0e79622f4344b48ab5bc9bc360cc
2 files changed
+14
-9
diff-lib.c
+11
-6
@@ -362,10 +362,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
362
int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
363
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
364
? CE_MATCH_RACY_IS_DIRTY : 0);
365
+ char symcache[PATH_MAX];
366
367
if (diff_unmerged_stage < 0)
368
diff_unmerged_stage = 2;
369
entries = active_nr;
370
+ symcache[0] = '\0';
371
for (i = 0; i < entries; i++) {
372
struct stat st;
373
unsigned int oldmode, newmode;
@@ -397,16 +399,17 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
399
memset(&(dpath->parent[0]), 0,
400
sizeof(struct combine_diff_parent)*5);
401
400
- if (lstat(ce->name, &st) < 0) {
401
- if (errno != ENOENT && errno != ENOTDIR) {
402
+ changed = check_work_tree_entity(ce, &st, symcache);
403
+ if (!changed)
404
+ dpath->mode = ce_mode_from_stat(ce, st.st_mode);
405
+ else {
406
+ if (changed < 0) {
407
perror(ce->name);
408
continue;
409
}
410
if (silent_on_removed)
411
continue;
412
}
408
- else
409
- dpath->mode = ce_mode_from_stat(ce, st.st_mode);
413
414
while (i < entries) {
415
struct cache_entry *nce = active_cache[i];
@@ -459,8 +462,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
462
463
if (ce_uptodate(ce))
464
continue;
462
- if (lstat(ce->name, &st) < 0) {
463
- if (errno != ENOENT && errno != ENOTDIR) {
465
+
466
+ changed = check_work_tree_entity(ce, &st, symcache);
467
+ if (changed) {
468
+ if (changed < 0) {
469
perror(ce->name);
470
continue;
471
}
t/t2201-add-update-typechange.sh
+3
-3
@@ -104,7 +104,7 @@ test_expect_success modify '
104
} >expect-final
105
'
106
107
-test_expect_failure diff-files '
107
+test_expect_success diff-files '
108
git diff-files --raw >actual &&
109
diff -u expect-files actual
110
'
@@ -114,7 +114,7 @@ test_expect_success diff-index '
114
diff -u expect-index actual
115
'
116
117
-test_expect_failure 'add -u' '
117
+test_expect_success 'add -u' '
118
rm -f ".git/saved-index" &&
119
cp -p ".git/index" ".git/saved-index" &&
120
git add -u &&
@@ -122,7 +122,7 @@ test_expect_failure 'add -u' '
122
diff -u expect-final actual
123
'
124
125
-test_expect_failure 'commit -a' '
125
+test_expect_success 'commit -a' '
126
if test -f ".git/saved-index"
127
then
128
rm -f ".git/index" &&