From: Phillip Wood <phillip.wood123@gmail.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Cc: Pablo Sabater <pabloosabaterr@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 5/9] reset: introduce ability to skip reference updates
Date: Fri, 5 Jun 2026 16:12:42 +0100 [thread overview]
Message-ID: <0fdaeec8-99cd-4dc9-9549-8a08133deebf@gmail.com> (raw)
In-Reply-To: <20260603-b4-pks-history-drop-v2-5-742cb5b5176d@pks.im>
Hi Patrick
On 03/06/2026 17:14, Patrick Steinhardt wrote:
> In a subsequent commit we'll introduce a new caller to `reset_head()`
> that really only wants to update the index and working tree, without
> updating any references. Introduce a new flag that lets the caller
> perform this operation.
We already have a flag to update ORIG_HEAD so would it make more sense
to have a flag to update HEAD, rather than adding a flag to disable the
updates? It would mean updating the existing callers but I think it is a
clearer api and it avoids the pitfall of
RESET_HEAD_ORIG_HEAD | RESET_HEAD_SKIP_REF_UPDATES
I wonder about the function name as well if we make updating HEAD
optional then what does reset_head() mean? Maybe we should rename it
something along the lines of reset_worktree() or update_working_copy()?
I'm not really sure what a good name would be.
Thanks
Phillip
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> reset.c | 7 ++++++-
> reset.h | 3 +++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/reset.c b/reset.c
> index a8d7eea4d6..ed9df6ca5c 100644
> --- a/reset.c
> +++ b/reset.c
> @@ -93,6 +93,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
> unsigned refs_only = opts->flags & RESET_HEAD_REFS_ONLY;
> unsigned update_orig_head = opts->flags & RESET_HEAD_ORIG_HEAD;
> unsigned dry_run = opts->flags & RESET_HEAD_DRY_RUN;
> + unsigned skip_ref_updates = opts->flags & RESET_HEAD_SKIP_REF_UPDATES;
> struct object_id *head = NULL, head_oid;
> struct tree_desc desc[2] = { { NULL }, { NULL } };
> struct lock_file lock = LOCK_INIT;
> @@ -112,6 +113,9 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
> if (opts->branch_msg && !opts->branch)
> BUG("branch reflog message given without a branch");
>
> + if (skip_ref_updates && (opts->branch || refs_only))
> + BUG("asked to perform ref updates and skip them at the same time");
> +
> if (!refs_only && !dry_run && repo_hold_locked_index(r, &lock, LOCK_REPORT_ON_ERROR) < 0) {
> ret = -1;
> goto leave_reset_head;
> @@ -196,7 +200,8 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
> goto leave_reset_head;
> }
>
> - if (oid != &head_oid || update_orig_head || switch_to_branch)
> + if (!skip_ref_updates &&
> + (oid != &head_oid || update_orig_head || switch_to_branch))
> ret = update_refs(r, opts, oid, head);
>
> leave_reset_head:
> diff --git a/reset.h b/reset.h
> index 9f696382c1..cb0700ffa7 100644
> --- a/reset.h
> +++ b/reset.h
> @@ -27,6 +27,9 @@ enum reset_head_flags {
> * any user-visible state.
> */
> RESET_HEAD_DRY_RUN = (1 << 5),
> +
> + /* Skip updating any references, only update the worktree and index. */
> + RESET_HEAD_SKIP_REF_UPDATES = (1 << 6),
> };
>
> struct reset_head_opts {
>
next prev parent reply other threads:[~2026-06-05 15:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 15:36 [PATCH 0/2] builtin/history: introduce "drop" subcommand Patrick Steinhardt
2026-06-01 15:36 ` [PATCH 1/2] builtin/history: split handling of ref updates into two phases Patrick Steinhardt
2026-06-01 15:36 ` [PATCH 2/2] builtin/history: implement "drop" subcommand Patrick Steinhardt
2026-06-01 23:43 ` Junio C Hamano
2026-06-03 10:06 ` Patrick Steinhardt
2026-06-02 7:31 ` Pablo Sabater
2026-06-03 10:06 ` Patrick Steinhardt
2026-06-03 16:13 ` [PATCH v2 0/9] builtin/history: introduce " Patrick Steinhardt
2026-06-03 16:14 ` [PATCH v2 1/9] read-cache: split out function to drop unmerged entries to stage 0 Patrick Steinhardt
2026-06-03 16:14 ` [PATCH v2 2/9] reset: drop `USE_THE_REPOSITORY_VARIABLE` Patrick Steinhardt
2026-06-03 16:14 ` [PATCH v2 3/9] reset: modernize flags passed to `reset_head()` Patrick Steinhardt
2026-06-03 18:01 ` Kristoffer Haugsbakk
2026-06-05 15:08 ` Phillip Wood
2026-06-03 16:14 ` [PATCH v2 4/9] reset: introduce dry-run mode Patrick Steinhardt
2026-06-03 18:18 ` Kristoffer Haugsbakk
2026-06-03 23:49 ` Junio C Hamano
2026-06-03 16:14 ` [PATCH v2 5/9] reset: introduce ability to skip reference updates Patrick Steinhardt
2026-06-03 23:51 ` Junio C Hamano
2026-06-04 9:01 ` Patrick Steinhardt
2026-06-05 15:12 ` Phillip Wood [this message]
2026-06-03 16:14 ` [PATCH v2 6/9] reset: allow the caller to specify the current HEAD object Patrick Steinhardt
2026-06-03 16:14 ` [PATCH v2 7/9] reset: stop assuming that the caller passes in a clean index Patrick Steinhardt
2026-06-03 16:14 ` [PATCH v2 8/9] builtin/history: split handling of ref updates into two phases Patrick Steinhardt
2026-06-03 16:14 ` [PATCH v2 9/9] builtin/history: implement "drop" subcommand Patrick Steinhardt
2026-06-03 19:04 ` Kristoffer Haugsbakk
2026-06-04 9:02 ` Patrick Steinhardt
2026-06-03 23:58 ` Junio C Hamano
2026-06-04 9:02 ` Patrick Steinhardt
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0fdaeec8-99cd-4dc9-9549-8a08133deebf@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pabloosabaterr@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox