git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH (Eek!)] git diff does not honor --no-ext-diff

From
Nazri Ramliy <ayiehere@gmail.com>
Date
Nov 26, 2008, 07:12 UTC
Message-ID
<544dda350811252312u7ef5533bwb20b37640d861487@mail.gmail.com>
Hello list,

git-diff does not honor the --no-ext-diff option in both cases when the external diff program is set via diff.external and gitattributes.

Is this intentional? If not the following patch seems to fix it.

I think there must be a cleaner way of fixing this than doing it by `hand' hence the Eek!

Nazri.
 builtin-diff.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/builtin-diff.c b/builtin-diff.c
index 7ceceeb..4ac7e15 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -290,6 +290,19 @@ int cmd_diff(int argc, const char **argv, const
char *prefix)
        /* Otherwise, we are doing the usual "git" diff */
        rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;

+       DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
+       /*
+        * Do we have --no-ext-diff and have external diff setup via either
+        * gitconfig or gitattributes, then clear ALLOW_EXTERNAL by hand.  Eek.
+        */
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i];
+               if (!strcmp(arg, "--"))
+                       break;
+               else if (!strcmp(arg, "--no-ext-diff"))
+                       DIFF_OPT_CLR(&rev.diffopt, ALLOW_EXTERNAL);
+       }
+
        if (nongit)
                die("Not a git repository");
        argc = setup_revisions(argc, argv, &rev, NULL);
@@ -298,7 +311,6 @@ int cmd_diff(int argc, const char **argv, const
char *prefix)
                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);
Next: Junio C Hamano
Message 1 of 4 in “git diff does not honor --no-ext-diff”
  1. git diff does not honor --no-ext-diffNazri Ramliy, Nov 26, 2008
  2. Junio C HamanoNov 26, 2008
  3. René ScharfeNov 26, 2008
  4. Nazri RamliyNov 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.