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

Re: [PATCH v2 2/2] commit: add support for --fixup <commit> -m"<extra message>"

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 22, 2017, 21:28 UTC
Message-ID
<xmqqzi6api5a.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171222204152.4822-1-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 7 quoted lines
> Those options could also support combining with -m, but given what
> they do I can't think of a good use-case for doing that, so I have not
> made the more invasive change of splitting up the logic in commit.c to
> first act on those, and then on -m options.
>
> 1. d71b8ba7c9 ("commit: --fixup option for use with rebase
>    --autosquash", 2010-11-02)

To be fair, when "rebase --autosquash -i" is run (which is why you would use --fixup in the first place), the log message of the fixup one is used only for locating which one is to be corrected, and the contents of the log message is discarded. So "given what it does", I can't think of a good use-case for using --fixup and -m together, either. So "nobody immediately thought of it when it was added" is certainly not a reason to later make the combination possible.

But I personally am moderately negative on one of these two imagined use cases.

Show 10 quoted lines
> Add support for supplying the -m option with --fixup. Doing so has
> errored out ever since --fixup was introduced. Before this, the only
> way to amend the fixup message while committing was to use --edit and
> amend it in the editor.
>
> The use-case for this feature is one of:
>
>  * Leaving a quick note to self when creating a --fixup commit when
>    it's not self-evident why the commit should be squashed without a
>    note into another one.
This is probably OK.
Show 5 quoted lines
>  * (Ab)using the --fixup feature to "fix up" commits that have already
>    been pushed to a branch that doesn't allow non-fast-forwards,
>    i.e. just noting "this should have been part of that other commit",
>    and if the history ever got rewritten in the future the two should
>    be combined.
This has a smell of the tail wagging the dog.

Perhaps your editor does not have a good integration with external commands to allow you to insert a single-liner output from

    git show --date=short -s --pretty='format:%h ("%s", %ad)' "$1"
and that is what you are abusing --fixup for?  

It is simply bad practice to leave a log entry that begins with !fixup marker that would confuse automated tools like "rebase -i" machinery on a commit that you have no intention of squashing into another, as it invites mistakes.

I do agree with the scenario where you would wish you could take back an earlier mistake but you cannot. But the log for such a follow-up fix should be written just like any other follow-up fix commit, i.e. describe what was wrong and how the wrongness is corrected with the follow-up change. What was wrong in "which commit" is of course important part, but it is a relatively small part.

Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 11 of 16 in “commit doc: document that -c, -C, -F and --fixup with -m error”
  1. 1/2 commit doc: document that -c, -C, -F and --fixup with -m errorÆvar Arnfjörð Bjarmason, Dec 20, 2017
  2. 2/2 commit: add support for --fixup <commit> -m"<extra message>"Ævar Arnfjörð Bjarmason, Dec 20, 2017
  3. Eric SunshineDec 20, 2017
  4. Ævar Arnfjörð BjarmasonDec 20, 2017
  5. Eric SunshineDec 20, 2017
  6. 0/2 support -m"<msg>" combined with commit --fixupÆvar Arnfjörð Bjarmason, Dec 22, 2017
  7. 1/2 commit doc: document that -c, -C, -F and --fixup with -m errorÆvar Arnfjörð Bjarmason, Dec 22, 2017
  8. Eric SunshineDec 22, 2017
  9. Ævar Arnfjörð BjarmasonDec 22, 2017
  10. 2/2 commit: add support for --fixup <commit> -m"<extra message>"Ævar Arnfjörð Bjarmason, Dec 22, 2017
  11. Junio C HamanoDec 22, 2017
  12. Junio C HamanoDec 22, 2017
  13. Ævar Arnfjörð BjarmasonDec 22, 2017
  14. Junio C HamanoDec 22, 2017
  15. Ævar Arnfjörð BjarmasonDec 23, 2017
  16. Eric SunshineDec 20, 2017

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.