From: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Caspar Duregger <herr.kaste@gmail.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH 2/4] rebase -i: use struct object_id rather than looking up commit
Date: Tue, 27 Oct 2020 14:02:15 +0000 [thread overview]
Message-ID: <589aed08f18c50979c210ca97c6dc0a01eac76c3.1603807338.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.773.git.1603807337.gitgitgadget@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We already have a struct object_id containing the oid that we want to
set ORIG_HEAD to so use that rather than converting it to a string and
then calling get_oid() on that string.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
builtin/rebase.c | 5 +++--
sequencer.c | 10 +++-------
sequencer.h | 5 +++--
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 6def28a533..d975918de6 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -370,8 +370,9 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
split_exec_commands(opts->cmd, &commands);
ret = complete_action(the_repository, &replay, flags,
- shortrevisions, opts->onto_name, opts->onto, head_hash,
- &commands, opts->autosquash, &todo_list);
+ shortrevisions, opts->onto_name, opts->onto,
+ &opts->orig_head, &commands, opts->autosquash,
+ &todo_list);
}
string_list_clear(&commands, 0);
diff --git a/sequencer.c b/sequencer.c
index 00acb12496..f79c3df861 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3965,21 +3965,17 @@ static int run_git_checkout(struct repository *r, struct replay_opts *opts,
static int checkout_onto(struct repository *r, struct replay_opts *opts,
const char *onto_name, const struct object_id *onto,
- const char *orig_head)
+ const struct object_id *orig_head)
{
- struct object_id oid;
const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
- if (get_oid(orig_head, &oid))
- return error(_("%s: not a valid OID"), orig_head);
-
if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
apply_autostash(rebase_path_autostash());
sequencer_remove_state(opts);
return error(_("could not detach HEAD"));
}
- return update_ref(NULL, "ORIG_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
+ return update_ref(NULL, "ORIG_HEAD", orig_head, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
}
static int stopped_at_head(struct repository *r)
@@ -5314,7 +5310,7 @@ static int skip_unnecessary_picks(struct repository *r,
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
const char *shortrevisions, const char *onto_name,
- struct commit *onto, const char *orig_head,
+ struct commit *onto, const struct object_id *orig_head,
struct string_list *commands, unsigned autosquash,
struct todo_list *todo_list)
{
diff --git a/sequencer.h b/sequencer.h
index b2a501e445..ea56825488 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -163,8 +163,9 @@ void todo_list_add_exec_commands(struct todo_list *todo_list,
struct string_list *commands);
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
const char *shortrevisions, const char *onto_name,
- struct commit *onto, const char *orig_head, struct string_list *commands,
- unsigned autosquash, struct todo_list *todo_list);
+ struct commit *onto, const struct object_id *orig_head,
+ struct string_list *commands, unsigned autosquash,
+ struct todo_list *todo_list);
int todo_list_rearrange_squash(struct todo_list *todo_list);
/*
--
gitgitgadget
next prev parent reply other threads:[~2020-10-27 18:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-27 14:02 [PATCH 0/4] rebase -i: fix ORIG_HEAD handling Phillip Wood via GitGitGadget
2020-10-27 14:02 ` [PATCH 1/4] rebase -i: stop overwriting ORIG_HEAD buffer Phillip Wood via GitGitGadget
2020-10-27 21:10 ` Junio C Hamano
2020-10-31 10:55 ` Phillip Wood
2020-11-02 19:40 ` herr.kaste
2020-11-03 0:21 ` Junio C Hamano
2020-11-03 11:02 ` herr.kaste
2020-10-27 14:02 ` Phillip Wood via GitGitGadget [this message]
2020-10-27 14:02 ` [PATCH 3/4] rebase -i: use struct object_id when writing state Phillip Wood via GitGitGadget
2020-10-27 14:02 ` [PATCH 4/4] rebase -i: simplify get_revision_ranges() Phillip Wood via GitGitGadget
2020-11-04 15:29 ` [PATCH v2 0/4] rebase -i: fix ORIG_HEAD handling Phillip Wood via GitGitGadget
2020-11-04 15:29 ` [PATCH v2 1/4] rebase -i: stop overwriting ORIG_HEAD buffer Phillip Wood via GitGitGadget
2020-11-04 15:29 ` [PATCH v2 2/4] rebase -i: use struct object_id rather than looking up commit Phillip Wood via GitGitGadget
2020-11-04 15:29 ` [PATCH v2 3/4] rebase -i: use struct object_id when writing state Phillip Wood via GitGitGadget
2020-11-04 15:29 ` [PATCH v2 4/4] rebase -i: simplify get_revision_ranges() Phillip Wood via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=589aed08f18c50979c210ca97c6dc0a01eac76c3.1603807338.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=herr.kaste@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).