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

Re: What's cooking in git.git (Nov 2021, #07; Mon, 29)

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 6, 2021, 17:23 UTC
Message-ID
<xmqqwnkhhck4.fsf@gitster.g>
In-Reply-To
<6fa17536.18b.17d8e7c7a09.Coremail.pwxu@coremail.cn>
Aleen 徐沛文 <pwxu@coremail.cn> writes:
Show 14 quoted lines
> 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.
Previous: Aleen 徐沛文Next: Aleen 徐沛文
Message 28 of 42 in “What's cooking in git.git (Nov 2021, #07; Mon, 29)”
  1. Junio C HamanoNov 30, 2021
  2. jk/loosen-urlmatch, was What's cooking in git.git (Nov 2021, #07; Mon, 29)Jeff King, Nov 30, 2021
  3. brian m. carlsonNov 30, 2021
  4. ab/run-command + em/missing-pager (was: What's cooking in git.git (Nov 2021, #07; Mon, 29))Ævar Arnfjörð Bjarmason, Nov 30, 2021
  5. Jeff KingNov 30, 2021
  6. Eric SunshineNov 30, 2021
  7. ab/ci-updates (was: What's cooking in git.git (Nov 2021, #07; Mon, 29))Ævar Arnfjörð Bjarmason, Nov 30, 2021
  8. ab/config-based-hooks-2 (was: What's cooking in git.git (Nov 2021, #07; Mon, 29))Ævar Arnfjörð Bjarmason, Nov 30, 2021
  9. fs/test-prereq (was: What's cooking in git.git (Nov 2021, #07; Mon, 29))Ævar Arnfjörð Bjarmason, Nov 30, 2021
  10. Fabian StelzerDec 1, 2021
  11. jc/c99-var-decl-in-for-loop (was: What's cooking in git.git (Nov 2021, #07; Mon, 29))Ævar Arnfjörð Bjarmason, Nov 30, 2021
  12. ns/tmp-objdir and ns/remerge-diffElijah Newren, Nov 30, 2021
  13. Junio C HamanoDec 3, 2021
  14. Neeraj SinghDec 4, 2021
  15. Elijah NewrenDec 4, 2021
  16. Elijah NewrenNov 30, 2021
  17. Victoria DyeDec 1, 2021
  18. Elijah NewrenNov 30, 2021
  19. Aleen 徐沛文Dec 1, 2021
  20. Elijah NewrenDec 1, 2021
  21. Ævar Arnfjörð BjarmasonDec 3, 2021
  22. Elijah NewrenDec 3, 2021
  23. Ævar Arnfjörð BjarmasonDec 3, 2021
  24. Aleen 徐沛文Dec 6, 2021
  25. Junio C HamanoDec 6, 2021
  26. Aleen 徐沛文Dec 6, 2021
  27. Aleen 徐沛文Dec 6, 2021
  28. Junio C HamanoDec 6, 2021
  29. Aleen 徐沛文Dec 7, 2021
  30. Junio C HamanoDec 7, 2021
  31. Aleen 徐沛文Dec 7, 2021
  32. Elijah NewrenDec 6, 2021
  33. Junio C HamanoDec 6, 2021
  34. en/zdiff3 (was: Re: What's cooking in git.git (Nov 2021, #07; Mon, 29))Elijah Newren, Nov 30, 2021
  35. Junio C HamanoDec 1, 2021
  36. Fabian StelzerDec 1, 2021
  37. Junio C HamanoDec 3, 2021
  38. 0/3 unused-parameter cleanups on top of pw/xdiff-classify-record-in-histogramJeff King, Dec 3, 2021
  39. 1/3 xdiff: drop CMP_ENV macro from xhistogramJeff King, Dec 3, 2021
  40. 2/3 xdiff: drop xpparam_t parameter from histogram cmp_recs()Jeff King, Dec 3, 2021
  41. 3/3 xdiff: drop unused flags parameter from recs_matchJeff King, Dec 3, 2021
  42. Phillip WoodDec 6, 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.