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

Re: [PATCH v3 2/2] diff: add SUBMODULE_DIFF format to display submodule diff

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 10, 2016, 22:05 UTC
Message-ID
<xmqqziok2sbg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160810211710.23173-2-jacob.e.keller@intel.com>
Jacob Keller <jacob.e.keller@intel.com> writes:
Show 13 quoted lines
> @@ -2305,6 +2311,15 @@ static void builtin_diff(const char *name_a,
>  	struct strbuf header = STRBUF_INIT;
>  	const char *line_prefix = diff_line_prefix(o);
>  
> +	diff_set_mnemonic_prefix(o, "a/", "b/");
> +	if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
> +		a_prefix = o->b_prefix;
> +		b_prefix = o->a_prefix;
> +	} else {
> +		a_prefix = o->a_prefix;
> +		b_prefix = o->b_prefix;
> +	}
> +

Hmph, is it safe to raise this when SUBMODULE_DIFF is not in effect? Not objecting, just asking.

>  	if (DIFF_OPT_TST(o, SUBMODULE_LOG) &&
> ...
> +	} else if (DIFF_OPT_TST(o, SUBMODULE_DIFF) &&

This makes clear that SUBMODULE_LOG and SUBMODULE_DIFF should not be independent bits in the diff-opt flag word. We used to run something like "log --oneline --left-right A...B" and your new code runs "diff A B", but the next month somebody else would want to do "log -p --left-right A...B" or something else, and they are clearly mutually exclusive.

Show 10 quoted lines
> diff --git a/diff.h b/diff.h
> index 6a91a1139686..65df44b1fcba 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -69,7 +69,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)
>  #define DIFF_OPT_FIND_COPIES_HARDER  (1 <<  6)
>  #define DIFF_OPT_FOLLOW_RENAMES      (1 <<  7)
>  #define DIFF_OPT_RENAME_EMPTY        (1 <<  8)
> -/* (1 <<  9) unused */
> +#define DIFF_OPT_SUBMODULE_DIFF      (1 <<  9)

So I'd really prefer not to see this change; instead, we should move in the direction where we _REMOVE_ DIFF_OPT_SUBMODULE_LOG from these, and introduce an enum to hold "how would we show submodule changes" in the diff_options structure.

Previous: Jacob KellerNext: Jacob Keller
Message 3 of 7 in “diff: add --line-prefix option for passing in a prefix”
  1. 1/2 diff: add --line-prefix option for passing in a prefixJacob Keller, Aug 10, 2016
  2. 2/2 diff: add SUBMODULE_DIFF format to display submodule diffJacob Keller, Aug 10, 2016
  3. Junio C HamanoAug 10, 2016
  4. Jacob KellerAug 10, 2016
  5. Junio C HamanoAug 10, 2016
  6. Jacob KellerAug 10, 2016
  7. Jacob KellerAug 10, 2016

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.