On Tue, 26 May 2015 08:14:28 -0700 (PDT) Nick Kugaevsky <n...@kugaevsky.ru> wrote:
> It was really suprising when I find out that GIT_DIR variable is > missing in some hooks. > > I want to run hook before executing `git pull --rebase` command, so I > use `pre-rebase` hook for that. There is GIT_DIR variable in my > script and as I see it is unset. > > Is it expected behaviour or bug? What piece of documentation made you beleive this environment variable has to be set when a Git hook (or a pre-rebase hook in particular) is run? From what I gather from the git(5) and githooks(5) manual pages, the GIT_DIR env. variable is supposed to be set by external tools (like SCMs making use of Git), not by Git itself. That is, if this variable is set, Git obeys it (unless the --git-dir command-line option has been speficied when some of Git programs was run). The git(5) manual page even explicitly states the following at the start of its section on GIT_* env. variables: > These environment variables apply to all core Git commands. > Nb: it is worth noting that they may be used/overridden by SCMS > sitting above Git so take care if using Cogito etc. >From the sample pre-rebase script (in a freshly initialized Git repository) I gather that it just runs various Git commands, and hence it's supposedly run in the work tree (or in the repository folder in case of a bare repository). -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.