Skip to content
  • Ævar Arnfjörð Bjarmason's avatar
    commit: add support for --fixup <commit> -m"<extra message>" · 30884c9a
    Ævar Arnfjörð Bjarmason authored and Junio C Hamano's avatar Junio C Hamano committed
    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.
    
     * (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.
    
       In such a case you might want to leave a small message,
       e.g. "forgot this part, which broke XYZ".
    
    With this, --fixup <commit> -m"More" -m"Details" will result in a
    commit message like:
    
        !fixup <subject of <commit>>
    
        More
    
        Details
    
    The reason the test being added here seems to squash "More" at the end
    of the subject line of the commit being fixed up is because the test
    code is using "%s%b" so the body immediately follows the subject, it's
    not a bug in this code, and other tests t7500-commit.sh do the same
    thing.
    
    When the --fixup option was initially added the "Option -m cannot be
    combined" error was expanded from -c, -C and -F to also include
    --fixup[1]
    
    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. d71b8ba7
    
     ("commit: --fixup option for use with rebase
       --autosquash", 2010-11-02)
    
    Helped-by: default avatarEric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: default avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    30884c9a