Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2019-06-27 17:12:46 +0300
committerJunio C Hamano <gitster@pobox.com>2019-06-27 20:31:02 +0300
commited5b1ca10b2644f1af3bdfa3da32c67f4df1aa46 (patch)
tree85c2843beda7c0002761d6abea7b4cef422763d6 /sequencer.c
parent3e81bccdf3ceab531e95ba3846083dbc8ba0e319 (diff)
status: do not report errors in sequencer/todo
commit 4a72486de9 ("fix cherry-pick/revert status after commit", 2019-04-16) used parse_insn_line() to parse the first line of the todo list to check if it was a pick or revert. However if the todo list is left over from an old cherry-pick or revert and references a commit that no longer exists then parse_insn_line() prints an error message which is confusing for users [1]. Instead parse just the command name so that the user is alerted to the presence of stale sequencer state by status reporting that a cherry-pick or revert is in progress. Note that we should not be leaving stale sequencer state lying around (or at least not as often) after commit b07d9bfd17 ("commit/reset: try to clean up sequencer state", 2019-04-16). However the user may still have stale state that predates that commit. Also avoid printing an error message if for some reason the user has a file called `sequencer` in $GIT_DIR. [1] https://public-inbox.org/git/3bc58c33-4268-4e7c-bf1a-fe349b3cb037@www.fastmail.com/ Reported-by: Espen Antonsen <espen@inspired.no> 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.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/sequencer.c b/sequencer.c
index 793f86bf9a..f8eab1697e 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2177,34 +2177,26 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
int sequencer_get_last_command(struct repository *r, enum replay_action *action)
{
- struct todo_item item;
- char *eol;
- const char *todo_file;
+ const char *todo_file, *bol;
struct strbuf buf = STRBUF_INIT;
- int ret = -1;
+ int ret = 0;
todo_file = git_path_todo_file();
if (strbuf_read_file(&buf, todo_file, 0) < 0) {
- if (errno == ENOENT)
+ if (errno == ENOENT || errno == ENOTDIR)
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, buf.buf, eol))
- goto fail;
- if (item.command == TODO_PICK)
+ bol = buf.buf + strspn(buf.buf, " \t\r\n");
+ if (is_command(TODO_PICK, &bol) && (*bol == ' ' || *bol == '\t'))
*action = REPLAY_PICK;
- else if (item.command == TODO_REVERT)
+ else if (is_command(TODO_REVERT, &bol) &&
+ (*bol == ' ' || *bol == '\t'))
*action = REPLAY_REVERT;
else
- goto fail;
-
- ret = 0;
+ ret = -1;
- fail:
strbuf_release(&buf);
return ret;