1
0
mirror of https://github.com/git/git.git synced 2024-09-28 10:00:54 +02:00

Merge branch 'ag/rebase-avoid-unneeded-checkout'

"git rebase -i" (and friends) used to unnecessarily check out the
tip of the branch to be rebased, which has been corrected.

* ag/rebase-avoid-unneeded-checkout:
  rebase -i: stop checking out the tip of the branch to rebase
This commit is contained in:
Junio C Hamano 2020-02-14 12:54:20 -08:00
commit d8b8d59054
3 changed files with 5 additions and 30 deletions

View File

@ -246,21 +246,17 @@ static int edit_todo_file(unsigned flags)
}
static int get_revision_ranges(struct commit *upstream, struct commit *onto,
const char **head_hash,
struct object_id *orig_head, const char **head_hash,
char **revisions, char **shortrevisions)
{
struct commit *base_rev = upstream ? upstream : onto;
const char *shorthead;
struct object_id orig_head;
if (get_oid("HEAD", &orig_head))
return error(_("no HEAD?"));
*head_hash = find_unique_abbrev(&orig_head, GIT_MAX_HEXSZ);
*head_hash = find_unique_abbrev(orig_head, GIT_MAX_HEXSZ);
*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
*head_hash);
shorthead = find_unique_abbrev(&orig_head, DEFAULT_ABBREV);
shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
if (upstream) {
const char *shortrev;
@ -314,12 +310,8 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
struct replay_opts replay = get_replay_opts(opts);
struct string_list commands = STRING_LIST_INIT_DUP;
if (prepare_branch_to_be_rebased(the_repository, &replay,
opts->switch_to))
return -1;
if (get_revision_ranges(opts->upstream, opts->onto, &head_hash,
&revisions, &shortrevisions))
if (get_revision_ranges(opts->upstream, opts->onto, &opts->orig_head,
&head_hash, &revisions, &shortrevisions))
return -1;
if (init_basic_state(&replay,

View File

@ -3716,20 +3716,6 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
return ret;
}
int prepare_branch_to_be_rebased(struct repository *r, struct replay_opts *opts,
const char *commit)
{
const char *action;
if (commit && *commit) {
action = reflog_message(opts, "start", "checkout %s", commit);
if (run_git_checkout(r, opts, commit, action))
return error(_("could not checkout %s"), commit);
}
return 0;
}
static int checkout_onto(struct repository *r, struct replay_opts *opts,
const char *onto_name, const struct object_id *onto,
const char *orig_head)

View File

@ -190,9 +190,6 @@ void commit_post_rewrite(struct repository *r,
const struct commit *current_head,
const struct object_id *new_head);
int prepare_branch_to_be_rebased(struct repository *r, struct replay_opts *opts,
const char *commit);
#define SUMMARY_INITIAL_COMMIT (1 << 0)
#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
void print_commit_summary(struct repository *repo,