Thread (11 messages) 11 messages, 4 authors, 2016-06-15

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

flat view

From: Jeff King <hidden>
Date: 2016-06-15 23:09:06

On Tue, Mar 29, 2016 at 11:00:03PM +0100, John Keeping wrote:
quoted
We seem to get that wrong. I'm also not sure if it would make sense if
you explicitly set the two to be equal, like:

  # checking in your own refs?
  GIT_WORK_TREE=$(pwd) GIT_DIR=$(pwd) git add refs packed-refs

So the current behavior may just be weird-but-true.
This case definitely feels wrong:

	$ GIT_WORK_TREE=$(cd ..; pwd) GIT_DIR=$(pwd) git rev-parse --is-inside-git-dir
	false
Yeah, and not just the is-inside-git-dir test:

  $ echo content >../file
  $ GIT_WORK_TREE=$(cd ..; pwd) GIT_DIR=$(pwd) git add file
  fatal: pathspec 'file' did not match any files

I'd expect that to work, and it doesn't, because we pass ".git/" as the
"prefix" to cmd_add(). Which I guess is true, but it feels kind of weird
(I think most people who set both variables like that would generally
point to some other directory entirely, and we would have a NULL
prefix).

The --is-inside-git-dir thing is related, but a different problem. I
just got your follow-up mentioning that it doesn't take the prefix into
account, which I agree it probably should.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help