git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] reset: avoid reflog update on no-op reset

From
Jeff King <peff@peff.net>
Date
Jan 22, 2026, 19:09 UTC
Message-ID
<20260122190941.GB2098026@coredump.intra.peff.net>
In-Reply-To
<xmqqwm19mq69.fsf@gitster.g>
On Thu, Jan 22, 2026 at 10:57:02AM -0800, Junio C Hamano wrote:
Show 22 quoted lines
> Pushkar Singh <pushkarkumarsingh1970@gmail.com> writes:
> 
> > When "git reset" is invoked with a target that already matches HEAD,
> > it currently writes a reflog entry even though no reference is updated.
> >
> > Detect this no-op case and avoid updating ORIG_HEAD and HEAD, skipping
> > the reflog entry entirely.
> 
> I am mildly negative on this one.  A scripted use that gets which
> commit to reset to from the caller in the outside world, e.g.,
> 
>     #!/bin/sh
>     git reset --hard "$1"
>     git diff --stat @{1}
> 
> would be confused if reflog does not reliably store the state before
> running "reset --hard" to @{1}.  In other words ...
> 
> > Add a regression test to ensure no reflog entry is written for a no-op
> > reset.
> 
> ... this change may already be a regression for existing users.

I was just writing the same message. ;) In addition to scripted use, that reflog does contain some human-readable information: the message field tells us what name we "git reset --hard" to. That might be helpful when digging through it trying to piece together what happened.

-Peff
Previous: Junio C Hamano
Message 3 of 3 in “reset: avoid reflog update on no-op reset”
  1. reset: avoid reflog update on no-op resetPushkar Singh, Jan 22, 2026
  2. Junio C HamanoJan 22, 2026
  3. Jeff KingJan 22, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.