Subject: Re: [PATCH v2 5/9] reset: introduce ability to skip reference updates

From: Junio C Hamano <[email-masked]>
Date: Thu, 04 Jun 2026 08:51:47 +0900

Patrick Steinhardt <[email-masked]> writes:

> @@ -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?

>  	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 {