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

Re: exit code from git reset

From
Martin von Zweigbergk <martinvonz@gmail.com>
Date
Dec 9, 2012, 23:12 UTC
Message-ID
<CANiSa6gPGGDWxpWGsjX0dgBA_SB7-gRKPb5o7EfK0h+DOZauYw@mail.gmail.com>
In-Reply-To
<7vzk1mddzo.fsf@alter.siamese.dyndns.org>
On Sun, Dec 9, 2012 at 3:04 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Martin von Zweigbergk <martinvonz@gmail.com> writes:
>
>> "git reset" currently returns 0 (if successful) while "git reset
>> $pathspec" returns 0 iff the index matches HEAD after resetting (on
>> all paths, not just those matching $pathspec).
>
> So in short, you observed that either of them reports with its exit
> code if the resulting index (not just any subpart, but always the
> entire thing) matches the HEAD, e.g. "do we have change that will be
> listed on 'will be committed' section in git status output?"
>
> Sounds like one sane and consistent semantics to me.

Heh, true, the behavior according to my description does make sense, it's just that my description was wrong; sorry :-(.

What "git reset $pathspec" returns is not "whether HEAD differs from index" (as I wrote), but "whether worktree differs from index". So "git reset" and "git reset ." will return different exit codes if there are changes in the worktree as compared to HEAD before the invocation. I hope that's clearer.

Previous: Junio C Hamano
Message 3 of 3 in “exit code from git reset”
  1. Martin von ZweigbergkDec 9, 2012
  2. Junio C HamanoDec 9, 2012
  3. Martin von ZweigbergkDec 9, 2012

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.