sequencer: change the way skip_unnecessary_picks() returns its result

Instead of skip_unnecessary_picks() printing its result to stdout, it
returns it into a struct object_id, as the rewrite of complete_action()
(to come in the next commit) will need it.

rebase--helper then is modified to fit this change.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alban Gruin 2018-08-10 18:51:36 +02:00 коммит произвёл Junio C Hamano
Родитель a9f5476fbc
Коммит d4ed5d7713
3 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -90,8 +90,14 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
return !!transform_todos(flags);
if (command == CHECK_TODO_LIST && argc == 1)
return !!check_todo_list();
if (command == SKIP_UNNECESSARY_PICKS && argc == 1)
return !!skip_unnecessary_picks();
if (command == SKIP_UNNECESSARY_PICKS && argc == 1) {
struct object_id oid;
int ret = skip_unnecessary_picks(&oid);
if (!ret)
puts(oid_to_hex(&oid));
return !!ret;
}
if (command == REARRANGE_SQUASH && argc == 1)
return !!rearrange_squash();
if (command == ADD_EXEC && argc == 2)

Просмотреть файл

@ -4416,17 +4416,17 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
}
/* skip picking commits whose parents are unchanged */
int skip_unnecessary_picks(void)
int skip_unnecessary_picks(struct object_id *output_oid)
{
const char *todo_file = rebase_path_todo();
struct strbuf buf = STRBUF_INIT;
struct todo_list todo_list = TODO_LIST_INIT;
struct object_id onto_oid, *oid = &onto_oid, *parent_oid;
struct object_id *parent_oid;
int fd, i;
if (!read_oneliner(&buf, rebase_path_onto(), 0))
return error(_("could not read 'onto'"));
if (get_oid(buf.buf, &onto_oid)) {
if (get_oid(buf.buf, output_oid)) {
strbuf_release(&buf);
return error(_("need a HEAD to fixup"));
}
@ -4456,9 +4456,9 @@ int skip_unnecessary_picks(void)
if (item->commit->parents->next)
break; /* merge commit */
parent_oid = &item->commit->parents->item->object.oid;
if (hashcmp(parent_oid->hash, oid->hash))
if (hashcmp(parent_oid->hash, output_oid->hash))
break;
oid = &item->commit->object.oid;
oidcpy(output_oid, &item->commit->object.oid);
}
if (i > 0) {
int offset = get_item_line_offset(&todo_list, i);
@ -4487,11 +4487,10 @@ int skip_unnecessary_picks(void)
todo_list.current = i;
if (is_fixup(peek_command(&todo_list, 0)))
record_in_rewritten(oid, peek_command(&todo_list, 0));
record_in_rewritten(output_oid, peek_command(&todo_list, 0));
}
todo_list_release(&todo_list);
printf("%s\n", oid_to_hex(oid));
return 0;
}

Просмотреть файл

@ -91,7 +91,7 @@ int sequencer_add_exec_commands(const char *command);
int transform_todos(unsigned flags);
enum missing_commit_check_level get_missing_commit_check_level(void);
int check_todo_list(void);
int skip_unnecessary_picks(void);
int skip_unnecessary_picks(struct object_id *output_oid);
int rearrange_squash(void);
extern const char sign_off_header[];