]> git.ipfire.org Git - thirdparty/git.git/commit
sequencer: unify label lookup
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 10 Nov 2022 16:43:40 +0000 (16:43 +0000)
committerTaylor Blau <me@ttaylorr.com>
Fri, 11 Nov 2022 04:36:24 +0000 (23:36 -0500)
commit82766b29611aea7c3fb42a99debfba1436852d38
tree288e0457bb82c5a6909dae93abcca6da0db58ec6
parent319605f8f00e402f3ea758a02c63534ff800a711
sequencer: unify label lookup

The arguments to the `reset` and `merge` commands may be a label created
with a `label` command or an arbitrary commit name. The `merge` command
uses the lookup_label() function to lookup its arguments but `reset` has
a slightly different version of that function in do_reset(). Reduce this
code duplication by calling lookup_label() from do_reset() as well.

This change improves the behavior of `reset` when the argument is a
tree.  Previously `reset` would accept a tree only for the rebase to
fail with

       update_ref failed for ref 'HEAD': cannot update ref 'HEAD': trying to write non-commit object da5497437fd67ca928333aab79c4b4b55036ea66 to branch 'HEAD'

Using lookup_label() means do_reset() will now error out straight away
if its argument is not a commit.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
sequencer.c
t/t3430-rebase-merges.sh