X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=diff-lib.c;h=2e09500c8210e22d6c81484aa198f1d811a9933d;hb=b4194828dc00e97dcd07ecb4bb4f87650a6fca1d;hp=2870de400ed533d83c77269ee1654af212c6510c;hpb=2eee1393f39953d27b63070fdb5c533082f28f0c;p=git.git diff --git a/diff-lib.c b/diff-lib.c index 2870de400..2e09500c8 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -102,9 +102,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) int changed; unsigned dirty_submodule = 0; - if (DIFF_OPT_TST(&revs->diffopt, QUICK) && - !revs->diffopt.filter && - DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) + if (diff_can_quit_early(&revs->diffopt)) break; if (!ce_path_match(ce, &revs->prune_data)) @@ -112,6 +110,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; @@ -130,7 +130,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); @@ -138,7 +138,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]; @@ -184,7 +186,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, 0, null_sha1); + pair = diff_unmerge(&revs->diffopt, ce->name); + if (wt_mode) + pair->two->mode = wt_mode; if (ce_stage(ce) != diff_unmerged_stage) continue; } @@ -373,8 +377,9 @@ static void do_oneway_diff(struct unpack_trees_options *o, match_missing = !revs->ignore_merges; if (cached && idx && ce_stage(idx)) { - diff_unmerge(&revs->diffopt, idx->name, idx->ce_mode, - idx->sha1); + struct diff_filepair *pair; + pair = diff_unmerge(&revs->diffopt, idx->name); + fill_filespec(pair->one, idx->sha1, idx->ce_mode); return; } @@ -428,8 +433,13 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o) if (tree == o->df_conflict_entry) tree = NULL; - if (ce_path_match(idx ? idx : tree, &revs->prune_data)) + if (ce_path_match(idx ? idx : tree, &revs->prune_data)) { do_oneway_diff(o, idx, tree); + if (diff_can_quit_early(&revs->diffopt)) { + o->exiting_early = 1; + return -1; + } + } return 0; }