diff options
Diffstat (limited to 'builtin/rebase--helper.c')
-rw-r--r-- | builtin/rebase--helper.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c index acc71a6f99..0716bbfd78 100644 --- a/builtin/rebase--helper.c +++ b/builtin/rebase--helper.c @@ -10,7 +10,7 @@ static GIT_PATH_FUNC(path_squash_onto, "rebase-merge/squash-onto") static int get_revision_ranges(const char *upstream, const char *onto, const char **head_hash, - char **revisions) + char **revisions, char **shortrevisions) { const char *base_rev = upstream ? upstream : onto; struct object_id orig_head; @@ -19,7 +19,25 @@ static int get_revision_ranges(const char *upstream, const char *onto, return error(_("no HEAD?")); *head_hash = find_unique_abbrev(&orig_head, GIT_MAX_HEXSZ); - *revisions = xstrfmt("%s...%s", base_rev, *head_hash); + + if (revisions) + *revisions = xstrfmt("%s...%s", base_rev, *head_hash); + if (shortrevisions) { + const char *shorthead; + + shorthead = find_unique_abbrev(&orig_head, DEFAULT_ABBREV); + + if (upstream) { + const char *shortrev; + struct object_id rev_oid; + + get_oid(base_rev, &rev_oid); + shortrev = find_unique_abbrev(&rev_oid, DEFAULT_ABBREV); + + *shortrevisions = xstrfmt("%s..%s", shortrev, shorthead); + } else + *shortrevisions = xstrdup(shorthead); + } return 0; } @@ -116,7 +134,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) if (!upstream && squash_onto) write_file(path_squash_onto(), "%s\n", squash_onto); - ret = get_revision_ranges(upstream, onto, &head_hash, &revisions); + ret = get_revision_ranges(upstream, onto, &head_hash, &revisions, NULL); if (ret) return ret; @@ -145,9 +163,19 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) return !!edit_todo_list(flags); if (command == PREPARE_BRANCH && argc == 2) return !!prepare_branch_to_be_rebased(&opts, argv[1]); - if (command == COMPLETE_ACTION && argc == 6) - return !!complete_action(&opts, flags, argv[1], argv[2], argv[3], - argv[4], argv[5], autosquash); + if (command == COMPLETE_ACTION && argc == 3) { + char *shortrevisions = NULL; + + ret = get_revision_ranges(upstream, onto, &head_hash, NULL, &shortrevisions); + if (ret) + return ret; + + ret = complete_action(&opts, flags, shortrevisions, argv[1], onto, + head_hash, argv[2], autosquash); + + free(shortrevisions); + return !!ret; + } usage_with_options(builtin_rebase_helper_usage, options); } |