Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-02-14 23:54:20 +0300
committerJunio C Hamano <gitster@pobox.com>2020-02-14 23:54:21 +0300
commitd8b8d59054ed5ba2f79d3cb2fad0b5f0bfeb3ac1 (patch)
treed7433bfd5fbf38f9f2282be27007ecd03019e09e
parent251187084d5ebdb3ba898ba4a8f9b005b7626655 (diff)
parent767a9c417eb2109dda71995c8fb8a884d3a35e6f (diff)
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
-rw-r--r--builtin/rebase.c18
-rw-r--r--sequencer.c14
-rw-r--r--sequencer.h3
3 files changed, 5 insertions, 30 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 8081741f8a..6154ad8fa5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -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,
diff --git a/sequencer.c b/sequencer.c
index df6d18f9ab..18b2b1f4ca 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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)
diff --git a/sequencer.h b/sequencer.h
index 9f9ae291e3..74f1e2673e 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -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,