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

Re: [PATCH v2] [GSOC][RFC] format-patch: pass --left-only to range-diff

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 9, 2021, 09:00 UTC
Message-ID
<CAPig+cQ6oS8S1-AmRhM=Gb3EQ+7sdQxExoVPCoHKSRFivZq9Vw@mail.gmail.com>
In-Reply-To
<pull.898.v2.git.1615278830804.gitgitgadget@gmail.com>

On Tue, Mar 9, 2021 at 3:35 AM ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 21 quoted lines
> In https://lore.kernel.org/git/YBx5rmVsg1LJhSKN@nand.local/,
> Taylor Blau proposing `git format-patch --cover-letter
> --range-diff` may mistakenly place upstream commit in the
> range-diff output. Teach `format-patch` pass `--left-only`
> to range-diff,can avoid this kind of mistake.
>
> Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> ---
> diff --git a/builtin/log.c b/builtin/log.c
> @@ -2085,9 +2089,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>         if (creation_factor < 0)
>                 creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
> -       else if (!rdiff_prev)
> -               die(_("--creation-factor requires --range-diff"));
> -
> +       else if (!rdiff_prev) {
> +               if (creation_factor >= 0)
> +                       die(_("--creation-factor requires --range-diff"));
> +               if (left_only)
> +                       die(_("--left-only requires --range-diff"));
> +       }

This logic starts getting difficult to reason about. It would be easier to understand if written like this:

    if (!rdiff_prev) {
        if (creation_factor >= 0)
            die(_("--creation-factor requires --range-diff"));
        if (left_only)
            die(_("--left-only requires --range-diff"));
    }
    if (creation_factor < 0)
        creation_factor = RANGE_DIFF_..._DEFAULT;
or this (which reduces the indentation a bit):
    if (creation_factor >= 0 && !rdiff_prev)
        die(_("--creation-factor requires --range-diff"));
    if (left_only && !rdiff_prev)
        die(_("--left-only requires --range-diff"));
    if (creation_factor < 0)
        creation_factor = RANGE_DIFF_..._DEFAULT;
Subjective; not necessarily worth a re-roll.
Show 5 quoted lines
> @@ -2134,7 +2141,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>                 make_cover_letter(&rev, !!output_directory,
> -                                 origin, nr, list, branch_name, quiet);
> +                                 origin, nr, list, branch_name, quiet,
> +                                       left_only);
Nit: This indentation looks odd. One would expect `origin` and
`left_only` to have the same indentation.
Show 11 quoted lines
> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
> @@ -748,4 +748,32 @@ test_expect_success '--left-only/--right-only' '
> +test_expect_success 'format-patch --range-diff --left-only' '
> +       rm -fr repo &&
> +       git init repo &&
> +       ...
> +       ! grep  "> 1: .* feature$"  0000-cover-letter.patch
> +'
> +
> +
>  test_done
Nit: One blank line before test_done() is typical, not two.
Previous: ZheNing Hu via GitGitGadgetNext: ZheNing Hu
Message 7 of 16 in “[GSOC][RFC] format-patch: pass --right-only to range-diff”
  1. [GSOC][RFC] format-patch: pass --right-only to range-diffZheNing Hu via GitGitGadget, Mar 7, 2021
  2. Taylor BlauMar 8, 2021
  3. ZheNing HuMar 9, 2021
  4. Junio C HamanoMar 12, 2021
  5. Junio C HamanoMar 12, 2021
  6. [GSOC][RFC] format-patch: pass --left-only to range-diffZheNing Hu via GitGitGadget, Mar 9, 2021
  7. Eric SunshineMar 9, 2021
  8. ZheNing HuMar 9, 2021
  9. [GSOC][RFC] format-patch: pass --left-only to range-diffZheNing Hu via GitGitGadget, Mar 9, 2021
  10. Junio C HamanoMar 12, 2021
  11. ZheNing HuMar 13, 2021
  12. Junio C HamanoMar 13, 2021
  13. ZheNing HuMar 14, 2021
  14. ZheNing HuMar 14, 2021
  15. ZheNing HuMar 14, 2021
  16. [GSOC] format-patch: pass --left-only to range-diffZheNing Hu via GitGitGadget, Mar 14, 2021

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.