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

Re: [PATCH v2] range-diff: add --matched-only to skip one-sided commits

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2026, 16:33 UTC
Message-ID
<xmqqo6dz6bdw.fsf@gitster.g>
In-Reply-To
<pull.2401.v2.git.git.1789160138305.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> -	if (range_diff_opts->left_only && range_diff_opts->right_only)
> -		res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only");
> +	die_for_incompatible_opt3(range_diff_opts->left_only, "--left-only",
> +				  range_diff_opts->right_only, "--right-only",
> +				  range_diff_opts->matched_only, "--matched-only");

Sorry for suggesting this change during the review. After thinking about it a bit more, I think it is a bad change.

Top-level range-diff.c should be kept reusable from different front-ends, some of which may invent different ways to deal with errors coming from incorrect end-user settings. It would rob them of an opportunity to recover if we called die() from here like this. Calling error() and signaling an error to the caller, as the original code did, was the right thing to do.

In other words, this adds an unnecessary layering violation, and the original code was much better from that point of view.

We might eventually want to have error_for_incompatible_optN() so that this hunk becomes something like:

- if (range_diff_opts->left_only && range_diff_opts->right_only) - res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only"); + res |= incompatible_opt_error("--left-only", range_diff_opts->left_only, + "--right-only", range_diff_opts->right_only, + "--matched-only", range_diff_opts->matched_only, + NULL);

but I think we should leave that outside this topic.

In general, whenever I need to say "something like" (as opposed to "exactly this") in a suggestion, it is a sign that the overall idea might be OK, but the details need to be worked out and would take a lot of time. I think this is one of those cases that are better handled as a separate topic without holding this change hostage.

Thanks.
Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren via GitGitGadget
Message 8 of 23 in “range-diff: add --matched-only to skip one-sided commits”
  1. range-diff: add --matched-only to skip one-sided commitsHarald Nordgren via GitGitGadget, Sep 11, 2026
  2. Junio C HamanoSep 11, 2026
  3. Harald NordgrenSep 11, 2026
  4. Junio C HamanoSep 11, 2026
  5. Harald NordgrenSep 11, 2026
  6. Junio C HamanoSep 11, 2026
  7. range-diff: add --matched-only to skip one-sided commitsHarald Nordgren via GitGitGadget, Sep 11, 2026
  8. Junio C HamanoSep 14, 2026
  9. range-diff: add --matched-only to skip one-sided commitsHarald Nordgren via GitGitGadget, Sep 15, 2026
  10. Junio C HamanoNov 2, 2026
  11. Harald NordgrenNov 2, 2026
  12. Ben KnobleNov 2, 2026
  13. Harald NordgrenNov 2, 2026
  14. Harald NordgrenNov 2, 2026
  15. Matt HunterNov 3, 2026
  16. Junio C HamanoNov 3, 2026
  17. Ben KnobleNov 3, 2026
  18. Matt HunterNov 3, 2026
  19. Junio C HamanoNov 3, 2026
  20. Kristoffer HaugsbakkNov 4, 2026
  21. Ben KnobleNov 4, 2026
  22. Kristoffer HaugsbakkNov 4, 2026
  23. Junio C HamanoNov 2, 2026

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.