Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vcs_info: an variable for the .git directory in hooks



Quentin Pradet wrote:
> vcs_info exposes the `base` variable in `hook_com` to get to the base directory
> of a repository. For git, the only use I know is to get to the .git directory
> in order to retrieve something there. For example, this hook
> <http://eseth.org/2010/git-in-zsh.html#show-stashed-changes> looks up
> $base/.git/refs/stash to see if there are any stashed changes.
>
> However, that's a bad idea, because it won't work in eg. submodules, where the
> real .git folder is in .git/modules/path/to/module/. The correct solution is to
> use `git rev-parse --git-dir` which will do the right thing. Would that make
> sense to expose the result of that command in a `miscN` variable?

I think that the most straight-forward solution would be to just call
the ‘rev-parse’ command when you need it in a hook. I'd like to not add
another command invocation if it can be avoided, unless there's a
legitimate use-case outside of a hook.


Regards, Frank



Messages sorted by: Reverse Date, Date, Thread, Author