diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2019-04-16 12:18:42 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-17 04:31:39 +0200 |
commit | 4a72486de97b5c6b0979b2b51e50c268bdb0d4f6 (patch) | |
tree | 59f14e26ef0542b206a0e991f0a9ac7a582f466a /sequencer.c | |
parent | commit/reset: try to clean up sequencer state (diff) | |
download | git-4a72486de97b5c6b0979b2b51e50c268bdb0d4f6.tar.xz git-4a72486de97b5c6b0979b2b51e50c268bdb0d4f6.zip |
fix cherry-pick/revert status after commit
If the user commits a conflict resolution using `git commit` in the
middle of a sequence of cherry-picks/reverts then `git status` missed
the fact that a cherry-pick/revert is still in progress.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c index 7c7b8a07c4..c6a9a35422 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2142,6 +2142,41 @@ static int parse_insn_line(struct repository *r, struct todo_item *item, return !item->commit; } +int sequencer_get_last_command(struct repository *r, enum replay_action *action) +{ + struct todo_item item; + char *eol; + const char *todo_file; + struct strbuf buf = STRBUF_INIT; + int ret = -1; + + todo_file = git_path_todo_file(); + if (strbuf_read_file(&buf, todo_file, 0) < 0) { + if (errno == ENOENT) + return -1; + else + return error_errno("unable to open '%s'", todo_file); + } + eol = strchrnul(buf.buf, '\n'); + if (buf.buf != eol && eol[-1] == '\r') + eol--; /* strip Carriage Return */ + if (parse_insn_line(r, &item, buf.buf, eol)) + goto fail; + if (item.command == TODO_PICK) + *action = REPLAY_PICK; + else if (item.command == TODO_REVERT) + *action = REPLAY_REVERT; + else + goto fail; + + ret = 0; + + fail: + strbuf_release(&buf); + + return ret; +} + static int parse_insn_buffer(struct repository *r, char *buf, struct todo_list *todo_list) { |