diff-lib: use ce_mode_from_stat() rather than messing with modes manually
The diff helpers used to do the magic mode canonicalization and all the other special mode handling by hand ("trust executable bit" and "has symlink support" handling). That's bogus. Use "ce_mode_from_stat()" that does this all for us. This is also going to be required when we add support for links to other git repositories. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Apr 9, 2007 at 21:13 UTC
844c11ae259bd33b971b9ca389b3f9619427e9a8
1 file changed
+3
-12
diff-lib.c
+3
-12
@@ -357,7 +357,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
357
continue;
358
}
359
else
360
- dpath->mode = canon_mode(st.st_mode);
360
+ dpath->mode = ntohl(ce_mode_from_stat(ce, st.st_mode));
361
362
while (i < entries) {
363
struct cache_entry *nce = active_cache[i];
@@ -374,8 +374,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
374
int mode = ntohl(nce->ce_mode);
375
num_compare_stages++;
376
hashcpy(dpath->parent[stage-2].sha1, nce->sha1);
377
- dpath->parent[stage-2].mode =
378
- canon_mode(mode);
377
+ dpath->parent[stage-2].mode = ntohl(ce_mode_from_stat(nce, mode));
378
dpath->parent[stage-2].status =
379
DIFF_STATUS_MODIFIED;
380
}
@@ -424,15 +423,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
423
if (!changed && !revs->diffopt.find_copies_harder)
424
continue;
425
oldmode = ntohl(ce->ce_mode);
427
-
428
- newmode = canon_mode(st.st_mode);
429
- if (!trust_executable_bit &&
430
- S_ISREG(newmode) && S_ISREG(oldmode) &&
431
- ((newmode ^ oldmode) == 0111))
432
- newmode = oldmode;
433
- else if (!has_symlinks &&
434
- S_ISREG(newmode) && S_ISLNK(oldmode))
435
- newmode = oldmode;
426
+ newmode = ntohl(ce_mode_from_stat(ce, st.st_mode));
427
diff_change(&revs->diffopt, oldmode, newmode,
428
ce->sha1, (changed ? null_sha1 : ce->sha1),
429
ce->name, NULL);