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

Re: [PATCH v2] revision: add separate field for "-m" of "diff-index -m"

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 31, 2020, 04:49 UTC
Message-ID
<xmqqo8mrh12b.fsf@gitster.c.googlers.com>
In-Reply-To
<20200829201140.23425-1-sorganov@gmail.com>
Sergey Organov <sorganov@gmail.com> writes:
> Historically, in "diff-index -m", "-m" does not mean "do not ignore merges", but
> "match missing". Despite this, diff-index abuses 'ignore_merges' field being set
> by "-m", that in turn causes more troubles.

"causes more troubles"? When there is no trouble, and no "more" trouble, concretely mentioned, it is a quite weak justfiication.

There is no reason to say "historically" here, as it has been like so from beginning of the time, it still is so and it is relied upon. "diff-{files,index,tree}" are about comparing two things, and not about history (where a "merge" might influence "now we are showing this commit. which parent do we compare it with?"), so giving short-and-sweet "-m" its own meaning that is sensible within the context of "diff" was and is perfectly sensible thing to do.

What is worth fixing is not "-m" in diff-index means "match missing" while "-m" in log wants to mean "show merges". It is that, even both commands use the same option parsing machinery, and the use of these two options are mutually exclusive so there is no risk of confusion, the flag internally used to record the presense of the "em" option is not named neutrally (e.g. "revs->seen_em_option").

	The "log" family of commands and "diff" family of commands
	share the same command line parsiong machinery.  For the
	former, "-m" means "show merges" while for the latter it
	means "match missing".  Tnis is not a problem at the UI
	level, as "show/not show merges" is meaningless in the
	context of "diff", and similarly "match/not match missing"
	is meaningless in the context of "log".
	But there are two problems with this arrangement.
	1. the field the presense of the option on the command line
	   is recorded in has to be given a name.  It is currently
	   called "ignore_merges", which gives an incorrect
	   impression that using it for "diff" family is somehow a
	   mistake, and renaming it to "match_missing" would not be
	   a solution, as it will give an incorrect impression that
	   "log" family is abusing it.  However, naming the field to
	   something neutral, e.g. "em_option", would make the code
	   harder to understand.
	2. because it uses the same command line parser, giving a
    	   default for "diff -m" in a way that is different from the
    	   default for "log -m" is quite cumbersome if they use the
    	   same field to record it.
	Introduce a separate "match_missing" field, and flip it and
	"ignore_merges" when we see the "-m" option on the command
	line.  That way, even when ignore_merges's default is
	affected by end-user configuration, the default for
	"match_missing" would not be affected.

I think the above would be in line with what you wanted to say but didn't, and I think it supports the split fairly well.

I have a very strong objection against changing the built-in default of "log -m", but I do agree that this split of the single field into two is a fairly good idea. So I do not want to be in the position that must reject this change because "log -m" and "diff-index -m" will never be on by default. Basing the justification of this change on end-user configurability would be a good way to sidestep the issue, and avoids taking this change hostage to the discussion on what should be the built-in default for "log/diff-index -m".

Previous: Sergey OrganovNext: Sergey Organov
Message 3 of 12 in “revision: add separate field for "-m" of "diff-index -m"”
  1. revision: add separate field for "-m" of "diff-index -m"Sergey Organov, Aug 29, 2020
  2. revision: add separate field for "-m" of "diff-index -m"Sergey Organov, Aug 29, 2020
  3. Junio C HamanoAug 31, 2020
  4. Sergey OrganovAug 31, 2020
  5. Junio C HamanoAug 31, 2020
  6. revision: add separate field for "-m" of "diff-index -m"Sergey Organov, Aug 31, 2020
  7. Junio C HamanoAug 31, 2020
  8. Sergey OrganovAug 31, 2020
  9. revision: add separate field for "-m" of "diff-index -m"Sergey Organov, Aug 31, 2020
  10. Junio C HamanoAug 31, 2020
  11. Sergey OrganovAug 31, 2020
  12. revision: wording tweak in comment for parsing "-m"Junio C Hamano, Oct 23, 2020

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.