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

Re: [PATCH 05/16] t2018: don't lose return code of git commands

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 1, 2020, 09:21 UTC
Message-ID
<CAPig+cSeuZRySuaOAvNTiy1eyH0AQ4is-g8LLA7-wC+CztuH0A@mail.gmail.com>
In-Reply-To
<20200101084840.GC5152@generichostname>
On Wed, Jan 1, 2020 at 3:48 AM Denton Liu <liu.denton@gmail.com> wrote:
Show 15 quoted lines
> On Fri, Dec 27, 2019 at 04:42:53PM -0500, Eric Sunshine wrote:
> > On Fri, Dec 27, 2019 at 8:48 AM Denton Liu <liu.denton@gmail.com> wrote:
> > > We had some git commands wrapped in non-assignment command substitutions
> > > which would result in their return codes to be lost. Rewrite these
> > > instances so that their return codes are now checked.
> >
> > Try writing your commit messages in imperative mood:
> >
> >     Fix invocations of Git commands so their exit codes are not lost
> >     within command substitutions...
>
> I thought that the preferred form of commit messages is to introduce the
> problem that I'm trying to solve first ("We had some git commands losing
> return codes") then, after that, describe the changes I made in
> imperative mood ("Rewrite these instances...").

My suggested rewrite includes both the problem ("exit codes ... lost within command substitutions") and the change in one sentence. The shorter you can make the commit message without omitting important information and without being outright cryptic, the better. Let the patch itself do the talking as much as possible.

Here's an example, from another patch in this series, which provides too much information:

    While we're at it, replace the test_might_fail(), which should
    only be used on git commands, with a compound command that always
    returns 0, even if the underlying ls fails.

The bit about "...with a compound command..." is unnecessary and wastes reviewer time and is far more difficult to understand than simply looking at the code in the patch itself. This would have been sufficient:

    While here, stop using test_might_fail() with 'ls' since it should
    only be used with git commands.
Show 6 quoted lines
> From what I can tell,
> all of my commit messages conform to this template.
> I'd prefer to keep the "problem statement" introduction in my commit
> messages as it primes readers so they know "why" before "what" but I
> can't think of any way to phrase the "problem statement" part in a way
> that sounds good without resorting to past tense. Any suggestions?

Using past tense makes it ambiguous to reviewers whether you're talking about the state of the code which existed some time back or if you're talking about the state of the code immediately before this patch is applied. Try rewriting your commit messages without words like "previously", "before", "had", "now", etc. For instance, the commit message for this patch could be rewritten (keeping your wording as much as possible) like this:

    t2018: don't lose return code of git commands
    The exit code of git commands wrapped in non-assignment command
    substitutions is lost. Rewrite these invocations so the exit codes
    are checked.
Previous: Denton LiuNext: Junio C Hamano
Message 14 of 54 in “t: replace incorrect test_must_fail usage (part 2)”
  1. 00/16 t: replace incorrect test_must_fail usage (part 2)Denton Liu, Dec 27, 2019
  2. 01/16 t2018: remove trailing space from test descriptionDenton Liu, Dec 27, 2019
  3. 02/16 t2018: add space between function name and ()Denton Liu, Dec 27, 2019
  4. Eric SunshineDec 27, 2019
  5. 04/16 t2018: teach do_checkout() to accept `!` argDenton Liu, Dec 27, 2019
  6. Eric SunshineDec 28, 2019
  7. 03/16 t2018: use test_must_fail for failing git commandsDenton Liu, Dec 27, 2019
  8. Eric SunshineDec 28, 2019
  9. Jakub NarebskiDec 30, 2019
  10. 06/16 t2018: replace "sha" with "oid"Denton Liu, Dec 27, 2019
  11. 05/16 t2018: don't lose return code of git commandsDenton Liu, Dec 27, 2019
  12. Eric SunshineDec 27, 2019
  13. Denton LiuJan 1, 2020
  14. Eric SunshineJan 1, 2020
  15. Junio C HamanoJan 2, 2020
  16. 07/16 t3030: use test_path_is_missing()Denton Liu, Dec 27, 2019
  17. 10/16 t3415: increase granularity of test_auto_{fixup,squash}()Denton Liu, Dec 27, 2019
  18. 09/16 t3415: stop losing return codes of git commandsDenton Liu, Dec 27, 2019
  19. 12/16 t3504: don't use `test_must_fail test_cmp`Denton Liu, Dec 27, 2019
  20. Johannes SixtDec 27, 2019
  21. Junio C HamanoDec 27, 2019
  22. 13/16 t3507: fix indentationDenton Liu, Dec 27, 2019
  23. 15/16 t4124: only mark git command with test_must_failDenton Liu, Dec 27, 2019
  24. 16/16 t4124: let sed open its own filesDenton Liu, Dec 27, 2019
  25. Jakub NarebskiDec 30, 2019
  26. Junio C HamanoDec 30, 2019
  27. Denton LiuJan 1, 2020
  28. Eric SunshineJan 1, 2020
  29. Denton LiuJan 1, 2020
  30. 11/16 t3419: stop losing return code of git commandDenton Liu, Dec 27, 2019
  31. 14/16 t3507: use test_path_is_missing()Denton Liu, Dec 27, 2019
  32. 08/16 t3310: extract common no_notes_merge_left()Denton Liu, Dec 27, 2019
  33. Eric SunshineDec 28, 2019
  34. Jakub NarebskiDec 30, 2019
  35. 00/16 t: replace incorrect test_must_fail usage (part 2)Denton Liu, Jan 7, 2020
  36. 01/16 t2018: remove trailing space from test descriptionDenton Liu, Jan 7, 2020
  37. 02/16 t2018: add space between function name and ()Denton Liu, Jan 7, 2020
  38. 03/16 t2018: improve style of if-statementDenton Liu, Jan 7, 2020
  39. 04/16 t2018: use test_expect_code for failing git commandsDenton Liu, Jan 7, 2020
  40. Eric SunshineJan 12, 2020
  41. t2018: be more discerning when checking for expected exit codesDenton Liu, Jan 26, 2020
  42. 05/16 t2018: teach do_checkout() to accept `!` argDenton Liu, Jan 7, 2020
  43. 06/16 t2018: don't lose return code of git commandsDenton Liu, Jan 7, 2020
  44. 07/16 t2018: replace "sha" with "oid"Denton Liu, Jan 7, 2020
  45. 09/16 t3310: extract common notes_merge_files_gone()Denton Liu, Jan 7, 2020
  46. 10/16 t3415: stop losing return codes of git commandsDenton Liu, Jan 7, 2020
  47. 14/16 t3507: fix indentationDenton Liu, Jan 7, 2020
  48. 16/16 t4124: only mark git command with test_must_failDenton Liu, Jan 7, 2020
  49. 13/16 t3504: do check for conflict marker after failed cherry-pickDenton Liu, Jan 7, 2020
  50. 12/16 t3419: stop losing return code of git commandDenton Liu, Jan 7, 2020
  51. 15/16 t3507: use test_path_is_missing()Denton Liu, Jan 7, 2020
  52. 08/16 t3030: use test_path_is_missing()Denton Liu, Jan 7, 2020
  53. 11/16 t3415: increase granularity of test_auto_{fixup,squash}()Denton Liu, Jan 7, 2020
  54. Eric SunshineJan 10, 2020

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.