git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* rev-parse --show-cdup in .git
@ 2009-12-04 15:45 Michael J Gruber
  2009-12-04 17:32 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Michael J Gruber @ 2009-12-04 15:45 UTC (permalink / raw)
  To: Git Mailing List

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?

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.

Michael

P.S.: The use case is a simple post-receive-hook that fast forwards a
checked out branch on receiving refs in refs/remotes/incoming/, but
needs to check the worktree against the index etc. 1.7.0 may be an
opportunity to encourage usage of this rather than restoring the old
behavior through options.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rev-parse --show-cdup in .git
  2009-12-04 15:45 rev-parse --show-cdup in .git Michael J Gruber
@ 2009-12-04 17:32 ` Junio C Hamano
  2009-12-05 13:19   ` Michael J Gruber
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-12-04 17:32 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: Git Mailing List

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".

> 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).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rev-parse --show-cdup in .git
  2009-12-04 17:32 ` Junio C Hamano
@ 2009-12-05 13:19   ` Michael J Gruber
  0 siblings, 0 replies; 3+ messages in thread
From: Michael J Gruber @ 2009-12-05 13:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

Junio C Hamano venit, vidit, dixit 04.12.2009 18:32:
> 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.

>> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-05 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-04 15:45 rev-parse --show-cdup in .git Michael J Gruber
2009-12-04 17:32 ` Junio C Hamano
2009-12-05 13:19   ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).