Subject: ERROR: is not a git repo.


> On Feb 15, 2020, at 6:41 AM, Pierre Smits <[EMAIL PROTECTED]> wrote:

Correct. Tilde prefix expansion is not currently supported.

First the causes:

- The interactive shell isn't expanding ~ due to the tilde not being in front of a word.  e.g., ~/ will expand but --foo=~/ will not.
- precommit isn't expanding it because the code base properly quotes it's variables to specifically avoid unexpected shell meta character expansions, deal with spaces in paths, etc, etc.

Is this fixable?  Maybe?

For those unfamiliar, a quick lesson in ~:

There are basically 7 different forms of ~ that bash supports. Everyone has probably seen two of them:

~/  == $HOME
~username/ == username's $HOME

But there are 5 other forms that are fairly rare to see in the wild:

~+/  == ${PWD}
~-/  == ${OLDPWD}

~N/ == dirs +N
~+N/ == dirs +N
~-N/ == dirs -N

There are a few different ways to make these work.  One would be to completely rewrite how parameters are passed and processed. :)  The second would be to eval the variables, but that has a HIGH degree of risk of getting it wrong (e.g., what does PWD mean at that point?). The third would be to create a special ~ evaluator and do the work itself.    

Substituting ~/ for $HOME is trivial.
~username/ is almost certainly going to require getent or eval.  I can't think of any other way off the top of my head that would work for places where user's don't come from /etc/passwd.
~+/ should be precommit's $STARTINGDIR
~-/ would need like a $PRESTARTINGDIR==$OLDPWD or something
dirs support would mean getting a copy of the pre-existing directory stack and referencing it, since precommit uses pushd and popd liberally.

It'd probably be worthwhile to at least handle the ~/ form since I suspect that's going to be by and far the most common use case.