Skip to content

Commit a2bb10d

Browse files
phillipwoodgitster
authored andcommitted
rebase -i: use struct object_id when writing state
Rather than passing a string around pass the struct object_id that the string was created from call oid_hex() when we write the file. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f3e27a0 commit a2bb10d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

builtin/rebase.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
296296
}
297297

298298
static int init_basic_state(struct replay_opts *opts, const char *head_name,
299-
struct commit *onto, const char *orig_head)
299+
struct commit *onto,
300+
const struct object_id *orig_head)
300301
{
301302
FILE *interactive;
302303

@@ -340,7 +341,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
340341

341342
if (init_basic_state(&replay,
342343
opts->head_name ? opts->head_name : "detached HEAD",
343-
opts->onto, head_hash)) {
344+
opts->onto, &opts->orig_head)) {
344345
free(revisions);
345346
free(shortrevisions);
346347

sequencer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,15 +2692,16 @@ static void write_strategy_opts(struct replay_opts *opts)
26922692
}
26932693

26942694
int write_basic_state(struct replay_opts *opts, const char *head_name,
2695-
struct commit *onto, const char *orig_head)
2695+
struct commit *onto, const struct object_id *orig_head)
26962696
{
26972697
if (head_name)
26982698
write_file(rebase_path_head_name(), "%s\n", head_name);
26992699
if (onto)
27002700
write_file(rebase_path_onto(), "%s\n",
27012701
oid_to_hex(&onto->object.oid));
27022702
if (orig_head)
2703-
write_file(rebase_path_orig_head(), "%s\n", orig_head);
2703+
write_file(rebase_path_orig_head(), "%s\n",
2704+
oid_to_hex(orig_head));
27042705

27052706
if (opts->quiet)
27062707
write_file(rebase_path_quiet(), "%s", "");

sequencer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int read_author_script(const char *path, char **name, char **email, char **date,
227227
int allow_missing);
228228
void parse_strategy_opts(struct replay_opts *opts, char *raw_opts);
229229
int write_basic_state(struct replay_opts *opts, const char *head_name,
230-
struct commit *onto, const char *orig_head);
230+
struct commit *onto, const struct object_id *orig_head);
231231
void sequencer_post_commit_cleanup(struct repository *r, int verbose);
232232
int sequencer_get_last_command(struct repository* r,
233233
enum replay_action *action);

0 commit comments

Comments
 (0)