From: Junio C Hamano Date: Wed, 26 Nov 2008 19:57:31 +0000 (-0800) Subject: Merge branch 'maint' X-Git-Tag: v1.6.1-rc1~19 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/aa14a0c3f191ee4df7344eed119be5b4a527a0ff?ds=inline;hp=-c Merge branch 'maint' * maint: Teach "git diff" to honour --[no-]ext-diff --- aa14a0c3f191ee4df7344eed119be5b4a527a0ff diff --combined builtin-diff.c index 7ceceeb6ff,26cf678591..b90d8bcdb6 --- a/builtin-diff.c +++ b/builtin-diff.c @@@ -74,8 -74,6 +74,8 @@@ static int builtin_diff_b_f(struct rev_ if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))) die("'%s': not a regular file or symlink", path); + diff_set_mnemonic_prefix(&revs->diffopt, "o/", "w/"); + if (blob[0].mode == S_IFINVALID) blob[0].mode = canon_mode(st.st_mode); @@@ -118,7 -116,7 +118,7 @@@ static int builtin_diff_index(struct re int cached = 0; while (1 < argc) { const char *arg = argv[1]; - if (!strcmp(arg, "--cached")) + if (!strcmp(arg, "--cached") || !strcmp(arg, "--staged")) cached = 1; else usage(builtin_diff_usage); @@@ -177,8 -175,10 +177,8 @@@ static int builtin_diff_combined(struc if (!revs->dense_combined_merges && !revs->combine_merges) revs->dense_combined_merges = revs->combine_merges = 1; parent = xmalloc(ents * sizeof(*parent)); - /* Again, the revs are all reverse */ for (i = 0; i < ents; i++) - hashcpy((unsigned char *)(parent + i), - ent[ents - 1 - i].item->sha1); + hashcpy((unsigned char *)(parent + i), ent[i].item->sha1); diff_tree_combined(parent[0], parent + 1, ents - 1, revs->dense_combined_merges, revs); return 0; @@@ -290,6 -290,9 +290,9 @@@ int cmd_diff(int argc, const char **arg /* Otherwise, we are doing the usual "git" diff */ rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index; + /* Default to let external be used */ + DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL); + if (nongit) die("Not a git repository"); argc = setup_revisions(argc, argv, &rev, NULL); @@@ -298,9 -301,8 +301,9 @@@ if (diff_setup_done(&rev.diffopt) < 0) die("diff_setup_done failed"); } - DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL); + DIFF_OPT_SET(&rev.diffopt, RECURSIVE); + DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV); /* * If the user asked for our exit code then don't start a @@@ -320,8 -322,7 +323,8 @@@ const char *arg = argv[i]; if (!strcmp(arg, "--")) break; - else if (!strcmp(arg, "--cached")) { + else if (!strcmp(arg, "--cached") || + !strcmp(arg, "--staged")) { add_head_to_pending(&rev); if (!rev.pending.nr) die("No HEAD commit to compare with (yet)"); diff --combined t/t4020-diff-external.sh index dfe3fbc74b,22ef7d44b0..caea292f15 --- a/t/t4020-diff-external.sh +++ b/t/t4020-diff-external.sh @@@ -43,6 -43,13 +43,13 @@@ test_expect_success 'GIT_EXTERNAL_DIFF ' + test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' ' + + GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff | + grep "^diff --git a/file b/file" + + ' + test_expect_success 'diff attribute' ' git config diff.parrot.command echo && @@@ -68,6 -75,13 +75,13 @@@ test_expect_success 'diff attribute sho ' + test_expect_success 'diff attribute and --no-ext-diff' ' + + git diff --no-ext-diff | + grep "^diff --git a/file b/file" + + ' + test_expect_success 'diff attribute' ' git config --unset diff.parrot.command && @@@ -94,6 -108,13 +108,13 @@@ test_expect_success 'diff attribute sho ' + test_expect_success 'diff attribute and --no-ext-diff' ' + + git diff --no-ext-diff | + grep "^diff --git a/file b/file" + + ' + test_expect_success 'no diff with -diff' ' echo >.gitattributes "file -diff" && git diff | grep Binary @@@ -104,7 -125,7 +125,7 @@@ echo NULZbetweenZwords | perl -pe 'y/Z/ test_expect_success 'force diff with "diff"' ' echo >.gitattributes "file diff" && git diff >actual && - test_cmp ../t4020/diff.NUL actual + test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual ' test_done