Re: [PATCH v2 5/9] reset: introduce ability to skip reference updates
From: Junio C Hamano <hidden>
Date: 2026-06-03 23:51:49
Patrick Steinhardt [off-list ref] writes:
quoted hunk ↗ jump to hunk
@@ -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");
;-) That's certainly a careful safety valve. Would we also want to catch skip_ref_updates && update_orig_head being both set as a bogus request?
quoted hunk ↗ jump to hunk
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 {