git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>
Cc: Git List <git@vger.kernel.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Denton Liu <liu.denton@gmail.com>,
	Junio C Hamano <gitster@pobox.com>, Taylor Blau <me@ttaylorr.com>,
	Taylor Blau <ttaylorr@github.com>,
	ZheNing Hu <adlternative@gmail.com>
Subject: Re: [PATCH v2] [GSOC][RFC] format-patch: pass --left-only to range-diff
Date: Tue, 9 Mar 2021 04:00:10 -0500	[thread overview]
Message-ID: <CAPig+cQ6oS8S1-AmRhM=Gb3EQ+7sdQxExoVPCoHKSRFivZq9Vw@mail.gmail.com> (raw)
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:
> 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.

> @@ -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.

> 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.

  reply	other threads:[~2021-03-09  9:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07  6:57 [PATCH] [GSOC][RFC] format-patch: pass --right-only to range-diff ZheNing Hu via GitGitGadget
2021-03-08 20:18 ` Taylor Blau
2021-03-09  7:28   ` ZheNing Hu
2021-03-12 21:55   ` Junio C Hamano
2021-03-12 22:09     ` Junio C Hamano
2021-03-09  8:33 ` [PATCH v2] [GSOC][RFC] format-patch: pass --left-only " ZheNing Hu via GitGitGadget
2021-03-09  9:00   ` Eric Sunshine [this message]
2021-03-09  9:35     ` ZheNing Hu
2021-03-09 10:28   ` [PATCH v3] " ZheNing Hu via GitGitGadget
2021-03-12 22:50     ` Junio C Hamano
2021-03-13  4:01       ` ZheNing Hu
2021-03-13 23:23         ` Junio C Hamano
2021-03-14  2:16           ` ZheNing Hu
2021-03-14  2:37             ` ZheNing Hu
2021-03-14  2:41               ` ZheNing Hu
2021-03-14  8:10     ` [PATCH v4] [GSOC] " ZheNing Hu via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPig+cQ6oS8S1-AmRhM=Gb3EQ+7sdQxExoVPCoHKSRFivZq9Vw@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=adlternative@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=ttaylorr@github.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).