]> git.ipfire.org Git - thirdparty/git.git/commit - sequencer.h
commit: move print_commit_summary() to libgit
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 24 Nov 2017 11:07:54 +0000 (11:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Nov 2017 13:44:18 +0000 (22:44 +0900)
commite47c6cafcb5a2223ea3de3d0b65f668f717cb2ab
treea23212c2e44d612e391b37bd661a114d513ed3ab
parenta87a6f3c98ea80740fa31d2559b78f75f8138132
commit: move print_commit_summary() to libgit

Move print_commit_summary() from builtin/commit.c to sequencer.c so it
can be shared with other commands. The function is modified by
changing the last argument to a flag so callers can specify whether
they want to show the author date in addition to specifying if this is
an initial commit.

If the sequencer dies in print_commit_summary() (which can only happen
when cherry-picking or reverting) then neither the todo list nor the
abort safety file are updated to reflect the commit that was just
made. print_commit_summary() can die if:

 - The commit that was just created cannot be found or parsed.

 - HEAD cannot be resolved either because some other process is
   updating it (which is bad news in the middle of a cherry-pick) or
   because it is corrupt.

 - log_tree_commit() cannot read some objects.

In all those cases dying will leave the sequencer in a sane state for
aborting; 'git cherry-pick --abort' will rewind HEAD to the last
successful commit before there was a problem with HEAD or the object
database. If the user somehow fixes the problem and runs 'git
cherry-pick --continue' then the sequencer will try and pick the same
commit again which may or may not be what the user wants depending on
what caused print_commit_summary() to die. If print_commit_summary()
returned an error instead then update_abort_safety_file() would try to
resolve HEAD which may or may not be successful. If it is successful
then running 'git rebase --abort' would not rewind HEAD to the last
successful commit which is not what we want.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c
sequencer.c
sequencer.h