diff: add flag to indicate textconv was set via cmdline

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>

Brandon Williams committed Oct 31, 2017 at 11:19 UTC afa73c5384de1d01386e57bd575257d1420aeb21
3 files changed +5 -3
builtin/log.c
+1 -1
@@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
485 unsigned long size;
486
487 fflush(rev->diffopt.file);
488 - if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||
488 + if (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||
489 !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))
490 return stream_blob_to_fd(1, oid, NULL, 0);
491
diff.c
+3 -2
@@ -4762,9 +4762,10 @@ int diff_opt_parse(struct diff_options *options,
4762 DIFF_OPT_SET(options, ALLOW_EXTERNAL);
4763 else if (!strcmp(arg, "--no-ext-diff"))
4764 DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
4765 - else if (!strcmp(arg, "--textconv"))
4765 + else if (!strcmp(arg, "--textconv")) {
4766 DIFF_OPT_SET(options, ALLOW_TEXTCONV);
4767 - else if (!strcmp(arg, "--no-textconv"))
4767 + DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);
4768 + } else if (!strcmp(arg, "--no-textconv"))
4769 DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
4770 else if (!strcmp(arg, "--ignore-submodules")) {
4771 DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);
diff.h
+1
@@ -83,6 +83,7 @@ struct diff_flags {
83 unsigned DIRSTAT_CUMULATIVE:1;
84 unsigned DIRSTAT_BY_FILE:1;
85 unsigned ALLOW_TEXTCONV:1;
86 + unsigned TEXTCONV_SET_VIA_CMDLINE:1;
87 unsigned DIFF_FROM_CONTENTS:1;
88 unsigned DIRTY_SUBMODULES:1;
89 unsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;