]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: add flag to indicate textconv was set via cmdline
authorBrandon Williams <bmwill@google.com>
Tue, 31 Oct 2017 18:19:06 +0000 (11:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Nov 2017 02:50:02 +0000 (11:50 +0900)
git-show is unique in that it wants to use textconv by default except
for when it is showing blobs.  When asked to show a blob, show doesn't
want to use textconv unless the user explicitly requested that it be
used by providing the command line flag '--textconv'.

Currently this is done by using a parallel set of 'touched' flags which
get set every time a particular flag is set or cleared.  In a future
patch we want to eliminate this parallel set of flags so instead of
relying on if the textconv flag has been touched, add a new flag
'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is set to true
via the command line.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
diff.c
diff.h

index dc28d43eb74aea3b0b0f791a0db5ce713bfa5b9b..82131751dd623d5dd6dd9aa0357e72037d2a6247 100644 (file)
@@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
        unsigned long size;
 
        fflush(rev->diffopt.file);
-       if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||
+       if (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||
            !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))
                return stream_blob_to_fd(1, oid, NULL, 0);
 
diff --git a/diff.c b/diff.c
index 3ad9c9b31c7980d0432e003d784b295762105773..11fccbd107a7f6ec9a709ced3d619402b971461f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4762,9 +4762,10 @@ int diff_opt_parse(struct diff_options *options,
                DIFF_OPT_SET(options, ALLOW_EXTERNAL);
        else if (!strcmp(arg, "--no-ext-diff"))
                DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
-       else if (!strcmp(arg, "--textconv"))
+       else if (!strcmp(arg, "--textconv")) {
                DIFF_OPT_SET(options, ALLOW_TEXTCONV);
-       else if (!strcmp(arg, "--no-textconv"))
+               DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);
+       } else if (!strcmp(arg, "--no-textconv"))
                DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
        else if (!strcmp(arg, "--ignore-submodules")) {
                DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);
diff --git a/diff.h b/diff.h
index e512cf44d0332cbb5bda15858d5f21749aeb0168..d077d3c10cf5d83ad117420124bc78383084586a 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -83,6 +83,7 @@ struct diff_flags {
        unsigned DIRSTAT_CUMULATIVE:1;
        unsigned DIRSTAT_BY_FILE:1;
        unsigned ALLOW_TEXTCONV:1;
+       unsigned TEXTCONV_SET_VIA_CMDLINE:1;
        unsigned DIFF_FROM_CONTENTS:1;
        unsigned DIRTY_SUBMODULES:1;
        unsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;