Skip to content

Commit d8b8d59

Browse files
committed
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
2 parents 2511870 + 767a9c4 commit d8b8d59

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

builtin/rebase.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,21 +246,17 @@ static int edit_todo_file(unsigned flags)
246246
}
247247

248248
static int get_revision_ranges(struct commit *upstream, struct commit *onto,
249-
const char **head_hash,
249+
struct object_id *orig_head, const char **head_hash,
250250
char **revisions, char **shortrevisions)
251251
{
252252
struct commit *base_rev = upstream ? upstream : onto;
253253
const char *shorthead;
254-
struct object_id orig_head;
255-
256-
if (get_oid("HEAD", &orig_head))
257-
return error(_("no HEAD?"));
258254

259-
*head_hash = find_unique_abbrev(&orig_head, GIT_MAX_HEXSZ);
255+
*head_hash = find_unique_abbrev(orig_head, GIT_MAX_HEXSZ);
260256
*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
261257
*head_hash);
262258

263-
shorthead = find_unique_abbrev(&orig_head, DEFAULT_ABBREV);
259+
shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
264260

265261
if (upstream) {
266262
const char *shortrev;
@@ -314,12 +310,8 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
314310
struct replay_opts replay = get_replay_opts(opts);
315311
struct string_list commands = STRING_LIST_INIT_DUP;
316312

317-
if (prepare_branch_to_be_rebased(the_repository, &replay,
318-
opts->switch_to))
319-
return -1;
320-
321-
if (get_revision_ranges(opts->upstream, opts->onto, &head_hash,
322-
&revisions, &shortrevisions))
313+
if (get_revision_ranges(opts->upstream, opts->onto, &opts->orig_head,
314+
&head_hash, &revisions, &shortrevisions))
323315
return -1;
324316

325317
if (init_basic_state(&replay,

sequencer.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3716,20 +3716,6 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
37163716
return ret;
37173717
}
37183718

3719-
int prepare_branch_to_be_rebased(struct repository *r, struct replay_opts *opts,
3720-
const char *commit)
3721-
{
3722-
const char *action;
3723-
3724-
if (commit && *commit) {
3725-
action = reflog_message(opts, "start", "checkout %s", commit);
3726-
if (run_git_checkout(r, opts, commit, action))
3727-
return error(_("could not checkout %s"), commit);
3728-
}
3729-
3730-
return 0;
3731-
}
3732-
37333719
static int checkout_onto(struct repository *r, struct replay_opts *opts,
37343720
const char *onto_name, const struct object_id *onto,
37353721
const char *orig_head)

sequencer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ void commit_post_rewrite(struct repository *r,
190190
const struct commit *current_head,
191191
const struct object_id *new_head);
192192

193-
int prepare_branch_to_be_rebased(struct repository *r, struct replay_opts *opts,
194-
const char *commit);
195-
196193
#define SUMMARY_INITIAL_COMMIT (1 << 0)
197194
#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
198195
void print_commit_summary(struct repository *repo,

0 commit comments

Comments
 (0)