]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase -i: simplify get_revision_ranges()
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Wed, 4 Nov 2020 15:29:40 +0000 (15:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Nov 2020 22:10:41 +0000 (14:10 -0800)
Now that all the external users of head_hash have been converted to
use a opts->orig_head instead we can stop returning head_hash from
get_revision_ranges().

Because we want to pass the full object names back to the caller in
`revisions` the find_unique_abbrev_r() call that was used to initialize
`head_hash` is replaced with oid_to_hex().

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c

index 28e7b7f5ceab850c8d4de84f4f15867f229d08a9..17450e9d9e2c76b6379d3dd61c9eefbe5edd4304 100644 (file)
@@ -270,15 +270,14 @@ static int edit_todo_file(unsigned flags)
 }
 
 static int get_revision_ranges(struct commit *upstream, struct commit *onto,
-                              struct object_id *orig_head, char *head_hash,
-                              char **revisions, char **shortrevisions)
+                              struct object_id *orig_head, char **revisions,
+                              char **shortrevisions)
 {
        struct commit *base_rev = upstream ? upstream : onto;
        const char *shorthead;
 
-       find_unique_abbrev_r(head_hash, orig_head, GIT_MAX_HEXSZ);
        *revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
-                                                  head_hash);
+                            oid_to_hex(orig_head));
 
        shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
 
@@ -328,7 +327,6 @@ static void split_exec_commands(const char *cmd, struct string_list *commands)
 static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 {
        int ret;
-       char head_hash[GIT_MAX_HEXSZ];
        char *revisions = NULL, *shortrevisions = NULL;
        struct strvec make_script_args = STRVEC_INIT;
        struct todo_list todo_list = TODO_LIST_INIT;
@@ -336,7 +334,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
        struct string_list commands = STRING_LIST_INIT_DUP;
 
        if (get_revision_ranges(opts->upstream, opts->onto, &opts->orig_head,
-                               head_hash, &revisions, &shortrevisions))
+                               &revisions, &shortrevisions))
                return -1;
 
        if (init_basic_state(&replay,