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

Re: rev-parse --show-cdup in .git

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Dec 5, 2009, 13:19 UTC
Message-ID
<4B1A5DCB.7020903@drmicha.warpmail.net>
In-Reply-To
<7vhbs6skzi.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 04.12.2009 18:32:
Show 9 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> I'm sure this was discussed somewhere, but I can't find it:
>>
>> When called from within .git, git rev-parse --show-cdup returns nothing
>> rather than "..", not even an error code. Is this intended?
> 
> I do not think --show-cdup should be linked to --is-inside-work-tree in
> any way, if that is what you are getting at by mentioning "error code".

It's just difficult to tell from the output whether you are at the toplevel (empty relative path) or you're within .git or somewhere else.

Show 7 quoted lines
>> This is all the more disturbing since the cwd of hooks seems to be
>> GIT_DIR. Is that something one can rely upon? In that case one can
>> simply use ".." for cdup.
> 
> I think you will see something that is different from and is more sensible
> than ".." when you use GIT_WORK_TREE environment variable (or its
> corresponding configuration variable).

All that I want is a reliable method for a hook to cd to the toplevel of the worktree of a non-bare repositity. cd_to_toplevel (from git-sh-setup) does not work. I don't think I should have to set any worktree config in a non-bare repository with standard layout, should I?

Michael
Previous: Junio C Hamano
Message 3 of 3 in “rev-parse --show-cdup in .git”
  1. Michael J GruberDec 4, 2009
  2. Junio C HamanoDec 4, 2009
  3. Michael J GruberDec 5, 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.