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

Re: `git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 29, 2016, 19:56 UTC
Message-ID
<xmqq60w5xdl2.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160329194156.GA9527@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> On Tue, Mar 29, 2016 at 08:08:29AM -0700, Junio C Hamano wrote:
>
>> So it is a misconfiguration if you only set GIT_WORK_TREE without
>> setting GIT_DIR.
>
> Hmm. I have frequently done this when my cwd is a git repository (e.g.,
> a bare one), and it works as you'd expect (find the git-dir in the
> current path, then the working tree via $GIT_WORK_TREE).

Hmm, does what is done by "git add HEAD" in such a situation match what you'd expect?

        git init work
        cd work; date >HEAD; git commit -m initial
        git push ../bare master:master
	date >>HEAD
        export GIT_WORK_TREE=$(pwd)
	cd ..
	git --bare init bare
	cd bare
	git add HEAD

I'd have to say that this invites unnecessary confusion, even though I agree that "go to the GIT_WORK_TREE and take pathspecs relative to that directory" is the only sensible thing for us to be doing.

But that is not an issue about "set only work-tree" (it is about "run from outside the work-tree").

Previous: Jeff KingNext: Jeff King
Message 6 of 16 in “`git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE”
  1. Elliott CableMar 29, 2016
  2. Elliott CableMar 29, 2016
  3. John KeepingMar 29, 2016
  4. Junio C HamanoMar 29, 2016
  5. Jeff KingMar 29, 2016
  6. Junio C HamanoMar 29, 2016
  7. Jeff KingMar 29, 2016
  8. Jeff KingMar 29, 2016
  9. John KeepingMar 29, 2016
  10. Jeff KingMar 29, 2016
  11. John KeepingMar 29, 2016
  12. John KeepingMar 29, 2016
  13. Jeff KingMar 29, 2016
  14. Junio C HamanoMar 29, 2016
  15. Duy NguyenMar 30, 2016
  16. Elliott CableApr 1, 2016

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.