X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fdiff.c;h=945e7583a8294f0612682f3228687498e5c61822;hb=5b38456ec7bd0229bb35146ab8a905c4b63daeec;hp=ffcdd055ca0b9b30bec2ce1f22e348ec15d58c81;hpb=567323d387dda559dbdba8c15453aba629393955;p=git.git diff --git a/builtin/diff.c b/builtin/diff.c index ffcdd055c..945e7583a 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -13,6 +13,7 @@ #include "revision.h" #include "log-tree.h" #include "builtin.h" +#include "submodule.h" struct blobinfo { unsigned char sha1[20]; @@ -21,7 +22,7 @@ struct blobinfo { }; static const char builtin_diff_usage[] = -"git diff {0,2} -- *"; +"git diff [] [ []] [--] [...]"; static void stuff_change(struct diff_options *opt, unsigned old_mode, unsigned new_mode, @@ -279,6 +280,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) */ prefix = setup_git_directory_gently(&nongit); + gitmodules_config(); git_config(git_diff_ui_config, NULL); if (diff_use_color_default == -1) @@ -407,17 +409,19 @@ int cmd_diff(int argc, const char **argv, const char *prefix) result = builtin_diff_index(&rev, argc, argv); else if (ents == 2) result = builtin_diff_tree(&rev, argc, argv, ent); - else if ((ents == 3) && (ent[0].item->flags & UNINTERESTING)) { - /* diff A...B where there is one sane merge base between - * A and B. We have ent[0] == merge-base, ent[1] == A, - * and ent[2] == B. Show diff between the base and B. + else if (ent[0].item->flags & UNINTERESTING) { + /* + * diff A...B where there is at least one merge base + * between A and B. We have ent[0] == merge-base, + * ent[ents-2] == A, and ent[ents-1] == B. Show diff + * between the base and B. Note that we pick one + * merge base at random if there are more than one. */ - ent[1] = ent[2]; + ent[1] = ent[ents-1]; result = builtin_diff_tree(&rev, argc, argv, ent); - } - else + } else result = builtin_diff_combined(&rev, argc, argv, - ent, ents); + ent, ents); result = diff_result_code(&rev.diffopt, result); if (1 < rev.diffopt.skip_stat_unmatch) refresh_index_quietly();