summaryrefslogtreecommitdiffstats
path: root/builtin/rebase.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2022-10-17 15:17:40 +0200
committerJunio C Hamano <gitster@pobox.com>2022-10-17 20:53:00 +0200
commitb8dbfd030ccc8e5be6b22bc28a342119504e0c2b (patch)
treea7caa68dcf31b2bdef967c896fdfa10eebdb6334 /builtin/rebase.c
parentt3416: set $EDITOR in subshell (diff)
downloadgit-b8dbfd030ccc8e5be6b22bc28a342119504e0c2b.tar.xz
git-b8dbfd030ccc8e5be6b22bc28a342119504e0c2b.zip
rebase: be stricter when reading state files containing oids
The state files for 'onto' and 'orig_head' should contain a full hex oid, change the reading functions from get_oid() to get_oid_hex() to reflect this. They should also name commits and not tags so add and use a function that looks up a commit from an oid like lookup_commit_reference() but without dereferencing tags. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 70aa7c842f..4139562cdb 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -429,9 +429,9 @@ static int read_basic_state(struct rebase_options *opts)
opts->head_name = starts_with(head_name.buf, "refs/") ?
xstrdup(head_name.buf) : NULL;
strbuf_release(&head_name);
- if (get_oid(buf.buf, &oid))
- return error(_("could not get 'onto': '%s'"), buf.buf);
- opts->onto = lookup_commit_or_die(&oid, buf.buf);
+ if (get_oid_hex(buf.buf, &oid) ||
+ !(opts->onto = lookup_commit_object(the_repository, &oid)))
+ return error(_("invalid onto: '%s'"), buf.buf);
/*
* We always write to orig-head, but interactive rebase used to write to
@@ -446,7 +446,7 @@ static int read_basic_state(struct rebase_options *opts)
} else if (!read_oneliner(&buf, state_dir_path("head", opts),
READ_ONELINER_WARN_MISSING))
return -1;
- if (get_oid(buf.buf, &opts->orig_head))
+ if (get_oid_hex(buf.buf, &opts->orig_head))
return error(_("invalid orig-head: '%s'"), buf.buf);
if (file_exists(state_dir_path("quiet", opts)))