diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2017-11-24 11:07:54 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-24 22:44:18 +0900 |
commit | e47c6cafcb5a2223ea3de3d0b65f668f717cb2ab (patch) | |
tree | a23212c2e44d612e391b37bd661a114d513ed3ab /sequencer.h | |
parent | a87a6f3c98ea80740fa31d2559b78f75f8138132 (diff) | |
download | git-e47c6cafcb5a2223ea3de3d0b65f668f717cb2ab.tar.gz |
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>
Diffstat (limited to 'sequencer.h')
-rw-r--r-- | sequencer.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sequencer.h b/sequencer.h index ec13b679c4..4f616c61a3 100644 --- a/sequencer.h +++ b/sequencer.h @@ -75,4 +75,9 @@ int update_head_with_reflog(const struct commit *old_head, struct strbuf *err); void commit_post_rewrite(const struct commit *current_head, const struct object_id *new_head); + +#define SUMMARY_INITIAL_COMMIT (1 << 0) +#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1) +void print_commit_summary(const char *prefix, const struct object_id *oid, + unsigned int flags); #endif |