]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase -i: use struct object_id when writing state
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Wed, 4 Nov 2020 15:29:39 +0000 (15:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Nov 2020 22:10:41 +0000 (14:10 -0800)
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>
builtin/rebase.c
sequencer.c
sequencer.h

index 4e4a5e774eadf44da06fd6ea3138c6b3d9f05516..28e7b7f5ceab850c8d4de84f4f15867f229d08a9 100644 (file)
@@ -296,7 +296,8 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
 }
 
 static int init_basic_state(struct replay_opts *opts, const char *head_name,
-                           struct commit *onto, const char *orig_head)
+                           struct commit *onto,
+                           const struct object_id *orig_head)
 {
        FILE *interactive;
 
@@ -340,7 +341,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 
        if (init_basic_state(&replay,
                             opts->head_name ? opts->head_name : "detached HEAD",
-                            opts->onto, head_hash)) {
+                            opts->onto, &opts->orig_head)) {
                free(revisions);
                free(shortrevisions);
 
index f79c3df86142a73628b05980acefbd668f519f61..2037f0ba66937b2f564992c302225196b136a6cf 100644 (file)
@@ -2692,7 +2692,7 @@ static void write_strategy_opts(struct replay_opts *opts)
 }
 
 int write_basic_state(struct replay_opts *opts, const char *head_name,
-                     struct commit *onto, const char *orig_head)
+                     struct commit *onto, const struct object_id *orig_head)
 {
        if (head_name)
                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,
                write_file(rebase_path_onto(), "%s\n",
                           oid_to_hex(&onto->object.oid));
        if (orig_head)
-               write_file(rebase_path_orig_head(), "%s\n", orig_head);
+               write_file(rebase_path_orig_head(), "%s\n",
+                          oid_to_hex(orig_head));
 
        if (opts->quiet)
                write_file(rebase_path_quiet(), "%s", "");
index ea56825488c66bd074abe3dd1a2a9fdca2709b34..cf201f2406e94076400aa048adb9cfd1191426c1 100644 (file)
@@ -227,7 +227,7 @@ int read_author_script(const char *path, char **name, char **email, char **date,
                       int allow_missing);
 void parse_strategy_opts(struct replay_opts *opts, char *raw_opts);
 int write_basic_state(struct replay_opts *opts, const char *head_name,
-                     struct commit *onto, const char *orig_head);
+                     struct commit *onto, const struct object_id *orig_head);
 void sequencer_post_commit_cleanup(struct repository *r, int verbose);
 int sequencer_get_last_command(struct repository* r,
                               enum replay_action *action);