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 <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Nov 4, 2020 at 15:29 UTC a2bb10d06db8a90920f1f518705a0bb9d39aa1db
3 files changed +7 -5
builtin/rebase.c
+3 -2
@@ -296,7 +296,8 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
296 }
297
298 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)
301 {
302 FILE *interactive;
303
@@ -340,7 +341,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
341
342 if (init_basic_state(&replay,
343 opts->head_name ? opts->head_name : "detached HEAD",
343 - opts->onto, head_hash)) {
344 + opts->onto, &opts->orig_head)) {
345 free(revisions);
346 free(shortrevisions);
347
sequencer.c
+3 -2
@@ -2692,7 +2692,7 @@ static void write_strategy_opts(struct replay_opts *opts)
2692 }
2693
2694 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)
2696 {
2697 if (head_name)
2698 write_file(rebase_path_head_name(), "%s\n", head_name);
@@ -2700,7 +2700,8 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
2700 write_file(rebase_path_onto(), "%s\n",
2701 oid_to_hex(&onto->object.oid));
2702 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));
2705
2706 if (opts->quiet)
2707 write_file(rebase_path_quiet(), "%s", "");
sequencer.h
+1 -1
@@ -227,7 +227,7 @@ int read_author_script(const char *path, char **name, char **email, char **date,
227 int allow_missing);
228 void parse_strategy_opts(struct replay_opts *opts, char *raw_opts);
229 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);
231 void sequencer_post_commit_cleanup(struct repository *r, int verbose);
232 int sequencer_get_last_command(struct repository* r,
233 enum replay_action *action);