git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Josh England" <jjengla@sandia.gov>
To: "Git Mailing List" <git@vger.kernel.org>
Subject: how to access working tree from .git dir?
Date: Thu, 06 Sep 2007 17:20:00 -0600	[thread overview]
Message-ID: <1189120800.6203.23.camel@beauty> (raw)

In messsing around with hooks, I've discovered that not all hooks are
run in the same environment.  In particular, the current working
directory in the post-receive hook (maybe others as well) is the GIT_DIR
(.git) directory, instead of the root of the working tree (as in
pre-commit).

This wouldn't be so bad, but it seems that `git rev-parse --show-cdup`
does not show anything valid if your current working directory is inside
the .git dir.  This creates a scenario where there is no consistent way
to access the root of the working tree from within a hook.  To make
things worse, the behavior changes subtly whether $GIT_DIR is defined or
not.

I've got a patch that changes the current working directory before
calling the post-receive hook, but that's more of a workaround than a
fix.  I'd like to be able to run `git rev-parse --show-cdup` from with
a .git directory and have it produce a valid result.

So:  I'm poking around around and trying to find the right answer but
some things look weird.  If anyone knows the quick-and-easy answer here
please let me know.  Otherwise, I'll continue to poke around some more.

Thanks,

-JE

             reply	other threads:[~2007-09-06 23:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-06 23:20 Josh England [this message]
2007-09-07 20:43 ` how to access working tree from .git dir? Junio C Hamano
2007-09-07 21:27   ` Josh England
2007-09-07 21:44     ` Junio C Hamano
2007-09-07 22:11       ` Josh England
2007-09-07 22:12         ` Junio C Hamano
2007-09-07 22:34           ` Josh England
2007-09-07 23:42             ` Junio C Hamano
2007-09-08  1:02               ` Josh England

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1189120800.6203.23.camel@beauty \
    --to=jjengla@sandia.gov \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).