Skip to content

Commit d4ed5d7

Browse files
agrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a9f5476 commit d4ed5d7

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

builtin/rebase--helper.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,14 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
9090
return !!transform_todos(flags);
9191
if (command == CHECK_TODO_LIST && argc == 1)
9292
return !!check_todo_list();
93-
if (command == SKIP_UNNECESSARY_PICKS && argc == 1)
94-
return !!skip_unnecessary_picks();
93+
if (command == SKIP_UNNECESSARY_PICKS && argc == 1) {
94+
struct object_id oid;
95+
int ret = skip_unnecessary_picks(&oid);
96+
97+
if (!ret)
98+
puts(oid_to_hex(&oid));
99+
return !!ret;
100+
}
95101
if (command == REARRANGE_SQUASH && argc == 1)
96102
return !!rearrange_squash();
97103
if (command == ADD_EXEC && argc == 2)

sequencer.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4416,17 +4416,17 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
44164416
}
44174417

44184418
/* skip picking commits whose parents are unchanged */
4419-
int skip_unnecessary_picks(void)
4419+
int skip_unnecessary_picks(struct object_id *output_oid)
44204420
{
44214421
const char *todo_file = rebase_path_todo();
44224422
struct strbuf buf = STRBUF_INIT;
44234423
struct todo_list todo_list = TODO_LIST_INIT;
4424-
struct object_id onto_oid, *oid = &onto_oid, *parent_oid;
4424+
struct object_id *parent_oid;
44254425
int fd, i;
44264426

44274427
if (!read_oneliner(&buf, rebase_path_onto(), 0))
44284428
return error(_("could not read 'onto'"));
4429-
if (get_oid(buf.buf, &onto_oid)) {
4429+
if (get_oid(buf.buf, output_oid)) {
44304430
strbuf_release(&buf);
44314431
return error(_("need a HEAD to fixup"));
44324432
}
@@ -4456,9 +4456,9 @@ int skip_unnecessary_picks(void)
44564456
if (item->commit->parents->next)
44574457
break; /* merge commit */
44584458
parent_oid = &item->commit->parents->item->object.oid;
4459-
if (hashcmp(parent_oid->hash, oid->hash))
4459+
if (hashcmp(parent_oid->hash, output_oid->hash))
44604460
break;
4461-
oid = &item->commit->object.oid;
4461+
oidcpy(output_oid, &item->commit->object.oid);
44624462
}
44634463
if (i > 0) {
44644464
int offset = get_item_line_offset(&todo_list, i);
@@ -4487,11 +4487,10 @@ int skip_unnecessary_picks(void)
44874487

44884488
todo_list.current = i;
44894489
if (is_fixup(peek_command(&todo_list, 0)))
4490-
record_in_rewritten(oid, peek_command(&todo_list, 0));
4490+
record_in_rewritten(output_oid, peek_command(&todo_list, 0));
44914491
}
44924492

44934493
todo_list_release(&todo_list);
4494-
printf("%s\n", oid_to_hex(oid));
44954494

44964495
return 0;
44974496
}

sequencer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int sequencer_add_exec_commands(const char *command);
9191
int transform_todos(unsigned flags);
9292
enum missing_commit_check_level get_missing_commit_check_level(void);
9393
int check_todo_list(void);
94-
int skip_unnecessary_picks(void);
94+
int skip_unnecessary_picks(struct object_id *output_oid);
9595
int rearrange_squash(void);
9696

9797
extern const char sign_off_header[];

0 commit comments

Comments
 (0)