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

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

From
Sergey Organov <sorganov@gmail.com>
Date
Aug 31, 2020, 19:41 UTC
Message-ID
<87wo1eob5s.fsf@osv.gnss.ru>
In-Reply-To
<xmqq4koihgpk.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 57 quoted lines
> Sergey Organov <sorganov@gmail.com> writes:
>
>> Add separate 'diff_index_match_missing' field for diff-index to use
>> and set it
>> when we encounter "-m" option. This field won't then be cleared when another
>> meaning of "-m" is reverted (e.g., by "--no-diff-merges"), nor it will be
>> affected by future option(s) that might drive 'ignore_merges' field.
>>
>> Use this new field from diff-lib:do_oneway_diff() instead of reusing
>> 'ignore_merges' field.
>>
>> Signed-off-by: Sergey Organov <sorganov@gmail.com>
>> ---
>
> Much easier to reason about.  As I said, I think we would ideally
> want to detect and diagnose --[no-]diff-merges on the command line
> of "diff" or "diff-{files,index,trees}" as an error, but for now
> this is a good first step.
>
>>  	} else if (!strcmp(arg, "-m")) {
>>  		revs->ignore_merges = 0;
>> +		/*
>> +		 * Backward compatibility wart - "diff-index -m" does
>> +		 * not mean "do not ignore merges", but "match_missing",
>> +		 * so set separate flag for it.
>> +		 */
>> +		revs->diff_index_match_missing = 1;
>
> Half the wart has been removed thanks to this patch and the rest of
> the code can look at the right field for their purpose.  The parsing,
> unless we make a bigger change that allows us to detect and diagnose
> "diff-index --no-diff-merges" as an error, still needs to be tricky
> and may deserve a comment.
>
> The comment should apply to and treat both fields equally, perhaps
> like this:
>
> 	} else if (!strcmp(arg, "-m")) {
> 		/*
> 		 * To "diff-index", "-m" means "match missing", and to
> 		 * the "log" family of commands, it means "keep merges".
> 		 * Set both fields appropriately.
> 		 */
> 		revs->ignore_merges = 0;
> 		revs->match_missing = 1;
> 	}
>
> By the way, let's drop diff_index_ prefix from the name of the new
> field.  I do not see a strong reason to object to a possible update
> to "diff-files" to match the behaviour of "diff-index".  
>
> In a sparsely checked out working tree (e.g. start from "clone
> --no-checkout"), you can check out only paths that you want to
> modify, edit them, and then "git diff-files -m" would be able to
> show useful result without having to show deletions to all other
> files you are not interested in.  And that is exactly the same use
> case as "git diff-index -m HEAD" was invented for.
Fine with me, thanks! I'll re-roll soon.

Thanks, -- Sergey

Previous: Junio C HamanoNext: Sergey Organov
Message 8 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.