git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Aleen 徐沛文" <pwxu@coremail.cn>
Cc: "Elijah Newren" <newren@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>,
	"徐沛文 (Aleen)" <aleen42@vip.qq.com>,
	"Aleen via GitGitGadget" <gitgitgadget@gmail.com>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: What's cooking in git.git (Nov 2021, #07; Mon, 29)
Date: Mon, 06 Dec 2021 09:23:55 -0800	[thread overview]
Message-ID: <xmqqwnkhhck4.fsf@gitster.g> (raw)
In-Reply-To: <6fa17536.18b.17d8e7c7a09.Coremail.pwxu@coremail.cn> ("Aleen 徐沛	文"'s message of "Mon, 6 Dec 2021 14:44:22 +0800 (CST)")

Aleen 徐沛文 <pwxu@coremail.cn> writes:

> The confusing point seems why "git am" stops into the middle and gives
> control back to the user when passing "die". In common cases, "die"
> should stop the whole process, and is it better to distinguish the case
> when passing "die" from the default behaviour? Like what the following
> snippet is implemented:
>
>     case ERR_EMPTY_COMMIT:
>         printf_ln(_("Patch is empty.\n"
>                     "If you want to record it as an empty commit, run \"git am --allow-empty\"."));
> 	die_user_resolve(state);
>     case DIE_EMPTY_COMMIT:
>         am_destroy(state);
>         die(_("Patch is empty."));
>         break;

Sorry, but I am afraid that I still don't get it.  

As we can see, the ERR_EMPTY_COMMIT case already exists and that is
the behaviour we want when we say "create commits from the messages
with patches, stop and give me control back when you see an empty
commit, so that I can decide what to do".  And one of the things you
can do at that point is "am --abort" that causes the am_destroy() to
be called.

That is very much in line with the behaviour the users are used to
see from "git am" when it detects conditions other than "there is no
patch" that needs to stop and give control back to the user,
e.g. when the patch does not apply cleanly or the log message did
not pass msg hook.  am_destroy() is destructive, and limiting such a
destructive operation to "am --abort" would avoid mistakes and
surprises.  I do not know where you got "In common cases, die should
stop the whole" from, but it is not a friendly thing to do to our
users.

Why should the "in addition, stop when there is no patch", which is
what we already handle just fine, needs to become different?  More
importantly, is it worth forcing the users to be aware of the
difference and be extra careful to avoid it?

It is my understanding that the ONLY reason the patch proposes to
add an option other than "skip the step" and "create an empty
commit" is to allow an earlier "--empty=skip" on the command line to
be overridden by a later "--empty=die".  If that option does not
make the command behave identically to "--empty=<anything>" option
on the command line, i.e. ERR_EMPTY_COMMIT case, it does not serve
the intended purpose of overriding the earlier option to revert the
behaviour back to the default.

By the way, I agree with an earlier comment (I think it was from Dscho)
that these names should say "${DO_THIS}_ON_EMPTY_COMMIT"; the above
without "ON" feels somewhat strange.

Thanks.

  parent reply	other threads:[~2021-12-06 17:26 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  2:16 What's cooking in git.git (Nov 2021, #07; Mon, 29) Junio C Hamano
2021-11-30  7:33 ` jk/loosen-urlmatch, was " Jeff King
2021-11-30 13:17   ` brian m. carlson
2021-11-30 20:54 ` ab/run-command + em/missing-pager (was: What's cooking in git.git (Nov 2021, #07; Mon, 29)) Ævar Arnfjörð Bjarmason
2021-11-30 21:17   ` Jeff King
2021-11-30 22:09   ` Eric Sunshine
2021-11-30 21:08 ` ab/ci-updates " Ævar Arnfjörð Bjarmason
2021-11-30 21:12 ` ab/config-based-hooks-2 " Ævar Arnfjörð Bjarmason
2021-11-30 21:17 ` fs/test-prereq " Ævar Arnfjörð Bjarmason
2021-12-01  8:53   ` Fabian Stelzer
2021-11-30 21:18 ` jc/c99-var-decl-in-for-loop " Ævar Arnfjörð Bjarmason
2021-11-30 23:07 ` ns/tmp-objdir and ns/remerge-diff Elijah Newren
2021-12-03 19:21   ` Junio C Hamano
2021-12-04  2:58     ` Neeraj Singh
2021-12-04  5:51       ` Elijah Newren
2021-11-30 23:35 ` What's cooking in git.git (Nov 2021, #07; Mon, 29) Elijah Newren
2021-12-01 19:29   ` Victoria Dye
2021-11-30 23:45 ` Elijah Newren
2021-12-01  1:42   ` Aleen 徐沛文
2021-12-01 20:56     ` Elijah Newren
2021-12-03 18:21       ` Ævar Arnfjörð Bjarmason
2021-12-03 19:28         ` Elijah Newren
2021-12-03 19:56           ` Ævar Arnfjörð Bjarmason
2021-12-06  1:25             ` Aleen 徐沛文
2021-12-06  6:28               ` Junio C Hamano
2021-12-06  6:44                 ` Aleen 徐沛文
2021-12-06  6:46                   ` Aleen 徐沛文
2021-12-06 17:23                   ` Junio C Hamano [this message]
2021-12-07  1:06                     ` Aleen 徐沛文
2021-12-07  1:29                       ` Junio C Hamano
2021-12-07  1:58                         ` Aleen 徐沛文
2021-12-06 17:37                 ` Elijah Newren
2021-12-06 17:50                   ` Junio C Hamano
2021-11-30 23:52 ` en/zdiff3 (was: Re: What's cooking in git.git (Nov 2021, #07; Mon, 29)) Elijah Newren
2021-12-01 22:15   ` en/zdiff3 Junio C Hamano
2021-12-01  8:59 ` What's cooking in git.git (Nov 2021, #07; Mon, 29) Fabian Stelzer
2021-12-03  1:12 ` Junio C Hamano
2021-12-03  5:10 ` [PATCH 0/3] unused-parameter cleanups on top of pw/xdiff-classify-record-in-histogram Jeff King
2021-12-03  5:11   ` [PATCH 1/3] xdiff: drop CMP_ENV macro from xhistogram Jeff King
2021-12-03  5:11   ` [PATCH 2/3] xdiff: drop xpparam_t parameter from histogram cmp_recs() Jeff King
2021-12-03  5:12   ` [PATCH 3/3] xdiff: drop unused flags parameter from recs_match Jeff King
2021-12-06 18:59   ` [PATCH 0/3] unused-parameter cleanups on top of pw/xdiff-classify-record-in-histogram Phillip Wood

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=xmqqwnkhhck4.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=aleen42@vip.qq.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=newren@gmail.com \
    --cc=pwxu@coremail.cn \
    /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).