{"thread":{"id":"21858","subject":"rev-parse --show-cdup in .git","startedAt":"2009-12-04T15:45:50Z","lastAt":"2009-12-05T13:19:07Z","messageCount":3,"participants":["Michael J Gruber","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"129182","messageId":"4B192EAE.8000806@drmicha.warpmail.net","threadId":"21858","inReplyTo":null,"subject":"rev-parse --show-cdup in .git","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-12-04T15:45:50Z","receivedAt":"2009-12-04T15:45:50Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"I'm sure this was discussed somewhere, but I can't find it:\n\nWhen called from within .git, git rev-parse --show-cdup returns nothing\nrather than \"..\", not even an error code. Is this intended?\n\nThis is all the more disturbing since the cwd of hooks seems to be\nGIT_DIR. Is that something one can rely upon? In that case one can\nsimply use \"..\" for cdup.\n\nMichael\n\nP.S.: The use case is a simple post-receive-hook that fast forwards a\nchecked out branch on receiving refs in refs/remotes/incoming/, but\nneeds to check the worktree against the index etc. 1.7.0 may be an\nopportunity to encourage usage of this rather than restoring the old\nbehavior through options.\n"},{"id":"129218","messageId":"7vhbs6skzi.fsf@alter.siamese.dyndns.org","threadId":"21858","inReplyTo":"4B192EAE.8000806@drmicha.warpmail.net","subject":"Re: rev-parse --show-cdup in .git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-04T17:32:49Z","receivedAt":"2009-12-04T17:32:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> I'm sure this was discussed somewhere, but I can't find it:\n>\n> When called from within .git, git rev-parse --show-cdup returns nothing\n> rather than \"..\", not even an error code. Is this intended?\n\nI do not think --show-cdup should be linked to --is-inside-work-tree in\nany way, if that is what you are getting at by mentioning \"error code\".\n\n> This is all the more disturbing since the cwd of hooks seems to be\n> GIT_DIR. Is that something one can rely upon? In that case one can\n> simply use \"..\" for cdup.\n\nI think you will see something that is different from and is more sensible\nthan \"..\" when you use GIT_WORK_TREE environment variable (or its\ncorresponding configuration variable).\n"},{"id":"129266","messageId":"4B1A5DCB.7020903@drmicha.warpmail.net","threadId":"21858","inReplyTo":"7vhbs6skzi.fsf@alter.siamese.dyndns.org","subject":"Re: rev-parse --show-cdup in .git","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-12-05T13:19:07Z","receivedAt":"2009-12-05T13:19:07Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 04.12.2009 18:32:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> I'm sure this was discussed somewhere, but I can't find it:\n>>\n>> When called from within .git, git rev-parse --show-cdup returns nothing\n>> rather than \"..\", not even an error code. Is this intended?\n> \n> I do not think --show-cdup should be linked to --is-inside-work-tree in\n> any way, if that is what you are getting at by mentioning \"error code\".\n\nIt's just difficult to tell from the output whether you are at the\ntoplevel (empty relative path) or you're within .git or somewhere else.\n\n>> This is all the more disturbing since the cwd of hooks seems to be\n>> GIT_DIR. Is that something one can rely upon? In that case one can\n>> simply use \"..\" for cdup.\n> \n> I think you will see something that is different from and is more sensible\n> than \"..\" when you use GIT_WORK_TREE environment variable (or its\n> corresponding configuration variable).\n\nAll that I want is a reliable method for a hook to cd to the toplevel of\nthe worktree of a non-bare repositity. cd_to_toplevel (from\ngit-sh-setup) does not work. I don't think I should have to set any\nworktree config in a non-bare repository with standard layout, should I?\n\nMichael\n"}]}