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

Re: Possible bug in 1.6.6 with reset --hard and $GIT_WORK_TREE

From
FFFyn Fynn <fynfynn@gmail.com>
Date
Dec 29, 2009, 21:09 UTC
Message-ID
<1a04eebf0912291309u7a222d9ch7e0926d30a5899b7@mail.gmail.com>
In-Reply-To
<fcaeb9bf0912290336m69303c3es8138c4e6497b801a@mail.gmail.com>

I went over the 952dfc6 patch, and it seems like it was designed to fix a specific bug - the one demonstrated by Nanako Shiraishi above.

Nowhere there do I see an intention to prevent the action described in the original post. And even if there was such intention, it should have been made explicit by providing a proper error message: the current one simply ignores the fact that we provided GIT_WORK_TREE, and is thus incorrect since the work tree can be found.

Moreover, if there is an intention to prevent resetting from outside the worktree (why?), then probably "checkout -f" should be limited as well.

But it is more likely that the breaking of the original action between 1.6.4 and 1.6.6 came about as an untended consequence of 952dfc6, which oversimplified by assuming that the worktree can only be found if we're inside it, ignoring the possibility that GIT_WORK_TREE was provided.

Thus, the current state should be considered a bug.
--
Fynn
On Tue, Dec 29, 2009 at 3:36 AM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
Show 35 quoted lines
> On 12/29/09, Nanako Shiraishi <nanako3@lavabit.com> wrote:
>> Quoting Nguyen Thai Ngoc Duy <pclouds@gmail.com>:
>>
>>  > On 12/29/09, Fyn Fynn <fynfynn@gmail.com> wrote:
>>  >> The exact same git reset command that works in 1.6.4, fails to work
>>  >>  under 1.6.6:
>>  >>
>>  >>  $ GIT_WORK_TREE=$HOME/rawdata/ GIT_DIR=$HOME/rawdata/.git
>>  >>  /usr/local/git-1.6.6/bin/git reset --hard
>>  >>  fatal: hard reset requires a work tree
>>  >>  $ GIT_WORK_TREE=$HOME/rawdata/ GIT_DIR=$HOME/rawdata/.git
>>  >>  /usr/local/git-1.6.4/bin/git reset --hard
>>  >>  HEAD is now at 77ec73f...
>>  >>
>>  >>  What gives?
>>  >
>>  > A recent patch by Jeff (952dfc6 (reset: improve worktree safety valves
>>  > - 2009-12-04)) makes sure that "git reset --hard" will not work
>>  > outside worktree (which is right).
>>
>>
>> Sorry, but I don't understand why it is *right*. Isn't 'git reset --hard' supposed to make all the files in the working tree match the HEAD, no matter where you start from?
>
> It is generally "right" to work from inside worktree, the way Git
> worked before GIT_WORK_TREE came. In case of "git reset --hard", yes
> it'd be best if Git could just go to worktree and reset it. I forgot
> that "git reset --hard" does not take pathspec. The situation may be a
> bit more complicated with "git status" (which also handles worktree as
> a whole) because you may need to represent the filename output to be
> relative to current working directory, not the GIT_WORK_TREE. Using
> GIT_WORK_TREE from outside worktree is imo stretching git to its
> limits.
> --
> Duy
>
Previous: Nguyen Thai Ngoc DuyNext: Jeff King
Message 6 of 9 in “Possible bug in 1.6.6 with reset --hard and $GIT_WORK_TREE”
  1. Fyn FynnDec 29, 2009
  2. Tay Ray ChuanDec 29, 2009
  3. Nguyen Thai Ngoc DuyDec 29, 2009
  4. Nanako ShiraishiDec 29, 2009
  5. Nguyen Thai Ngoc DuyDec 29, 2009
  6. Fyn FynnDec 29, 2009
  7. Jeff KingDec 29, 2009
  8. reset: unbreak hard resets with GIT_WORK_TREEJeff King, Dec 30, 2009
  9. Junio C HamanoDec 30, 2009

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.