summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-04-22 23:19:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-04-24 05:35:13 (GMT)
commit095ce9538b738db28d5e9a6e05d94c7e3f55f39d (patch)
treef7555f789e822aa73266c354caa4f6cb36fc6578 /diff-lib.c
parentfa7b290895ba2c4407ae818911ba620eaca53bbd (diff)
downloadgit-095ce9538b738db28d5e9a6e05d94c7e3f55f39d.zip
git-095ce9538b738db28d5e9a6e05d94c7e3f55f39d.tar.gz
git-095ce9538b738db28d5e9a6e05d94c7e3f55f39d.tar.bz2
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.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/diff-lib.c b/diff-lib.c
index a983855..b782476 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;
}