mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-04 01:05:48 -05:00
reset: allow the caller to specify the current HEAD object
When calling `reset_head()` we automatically derive the commit that the callers wants to move from by reading the HEAD commit. Some callers may already have resolved it, or they may want to move from a different commit that doesn't match HEAD. Introduce a new `oid_from` option that lets the caller specify the commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8825305623
commit
7192525ea4
5
reset.c
5
reset.c
@@ -121,7 +121,10 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
|
||||
goto leave_reset_head;
|
||||
}
|
||||
|
||||
if (!repo_get_oid(r, "HEAD", &head_oid)) {
|
||||
if (opts->oid_from) {
|
||||
oidcpy(&head_oid, opts->oid_from);
|
||||
head = &head_oid;
|
||||
} else if (!repo_get_oid(r, "HEAD", &head_oid)) {
|
||||
head = &head_oid;
|
||||
} else if (!oid || !reset_hard) {
|
||||
ret = error(_("could not determine HEAD revision"));
|
||||
|
||||
5
reset.h
5
reset.h
@@ -37,6 +37,11 @@ struct reset_head_opts {
|
||||
* The commit to checkout/reset to. Defaults to HEAD.
|
||||
*/
|
||||
const struct object_id *oid;
|
||||
/*
|
||||
* The commit to checkout/reset from when doing a two-way merge. This
|
||||
* is used as one of the sides to merge.
|
||||
*/
|
||||
const struct object_id *oid_from;
|
||||
/*
|
||||
* Optional value to set ORIG_HEAD. Defaults to HEAD.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user