diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-04-22 16:19:27 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-04-23 22:35:13 -0700 |
commit | 095ce9538b738db28d5e9a6e05d94c7e3f55f39d (patch) | |
tree | f7555f789e822aa73266c354caa4f6cb36fc6578 /diff-lib.c | |
parent | fa7b290895ba2c4407ae818911ba620eaca53bbd (diff) | |
download | git-095ce9538b738db28d5e9a6e05d94c7e3f55f39d.tar.gz |
diff-files: show unmerged entries correctly
Earlier, e9c8409 (diff-index --cached --raw: show tree entry on the LHS
for unmerged entries., 2007-01-05) taught the command to show the object
name and the mode from the entry coming from the tree side when comparing
a tree with an unmerged index.
This is a belated companion patch that teaches diff-files to show the mode
from the entry coming from the working tree side, when comparing an
unmerged index and the working tree.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-lib.c')
-rw-r--r-- | diff-lib.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/diff-lib.c b/diff-lib.c index a98385538c..b782476e4e 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -111,6 +111,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) if (ce_stage(ce)) { struct combine_diff_path *dpath; + struct diff_filepair *pair; + unsigned int wt_mode = 0; int num_compare_stages = 0; size_t path_len; @@ -129,7 +131,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) changed = check_removed(ce, &st); if (!changed) - dpath->mode = ce_mode_from_stat(ce, st.st_mode); + wt_mode = ce_mode_from_stat(ce, st.st_mode); else { if (changed < 0) { perror(ce->name); @@ -137,7 +139,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option) } if (silent_on_removed) continue; + wt_mode = 0; } + dpath->mode = wt_mode; while (i < entries) { struct cache_entry *nce = active_cache[i]; @@ -183,7 +187,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option) * Show the diff for the 'ce' if we found the one * from the desired stage. */ - diff_unmerge(&revs->diffopt, ce->name); + pair = diff_unmerge(&revs->diffopt, ce->name); + if (wt_mode) + pair->two->mode = wt_mode; if (ce_stage(ce) != diff_unmerged_stage) continue; } |