diff: vary default prefix depending on what are compared
With a new configuration "diff.mnemonicprefix", "git diff" shows the differences between various combinations of preimage and postimage trees with prefixes different from the standard "a/" and "b/". Hopefully this will make the distinction stand out for some people. "git diff" compares the (i)ndex and the (w)ork tree; "git diff HEAD" compares a (c)ommit and the (w)ork tree; "git diff --cached" compares a (c)ommit and the (i)ndex; "git-diff HEAD:file1 file2" compares an (o)bject and a (w)ork tree entity; "git diff --no-index a b" compares two non-git things (1) and (2). Because these mnemonics now have meanings, they are swapped when reverse diff is in effect and this feature is enabled. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -63,6 +63,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
|
||||
? CE_MATCH_RACY_IS_DIRTY : 0);
|
||||
char symcache[PATH_MAX];
|
||||
|
||||
diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
|
||||
|
||||
if (diff_unmerged_stage < 0)
|
||||
diff_unmerged_stage = 2;
|
||||
entries = active_nr;
|
||||
@ -469,6 +471,7 @@ int run_diff_index(struct rev_info *revs, int cached)
|
||||
if (unpack_trees(1, &t, &opts))
|
||||
exit(128);
|
||||
|
||||
diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/");
|
||||
diffcore_std(&revs->diffopt);
|
||||
diff_flush(&revs->diffopt);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user