-
Notifications
You must be signed in to change notification settings - Fork 140
Quieter sequencer status parsing #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "wip/quieter\u00A0sequencer\u00A0status\u00A0parsing"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2076,6 +2076,18 @@ const char *todo_item_get_arg(struct todo_list *todo_list, | |
return todo_list->buf.buf + item->arg_offset; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, René Scharfe wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Phillip Wood wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Phillip Wood wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Phillip Wood wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
|
||
} | ||
|
||
static int is_command(enum todo_command command, const char **bol) | ||
{ | ||
const char *str = todo_command_info[command].str; | ||
const char nick = todo_command_info[command].c; | ||
const char *p = *bol + 1; | ||
|
||
return skip_prefix(*bol, str, bol) || | ||
((nick && **bol == nick) && | ||
(*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) && | ||
(*bol = p)); | ||
} | ||
|
||
static int parse_insn_line(struct repository *r, struct todo_item *item, | ||
const char *buf, const char *bol, char *eol) | ||
{ | ||
|
@@ -2097,12 +2109,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item, | |
} | ||
|
||
for (i = 0; i < TODO_COMMENT; i++) | ||
if (skip_prefix(bol, todo_command_info[i].str, &bol)) { | ||
item->command = i; | ||
break; | ||
} else if ((bol + 1 == eol || bol[1] == ' ') && | ||
*bol == todo_command_info[i].c) { | ||
bol++; | ||
if (is_command(i, &bol)) { | ||
item->command = i; | ||
break; | ||
} | ||
|
@@ -2170,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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Johannes Schindelin wrote (reply to this):