On Thu, Oct 06, 2016 at 06:41:24PM +0700, Nguyễn Thái Ngọc Duy wrote:
> Throwing something at the mailing list to see if anybody is
> interested.
>
> Current '!' aliases move cwd to $GIT_WORK_TREE first, which could make
> handling path arguments hard because they are relative to the original
> cwd. We set GIT_PREFIX to work around it, but I still think it's more
> natural to keep cwd where it is.
>
> We have a way to do that now after 441981b (git: simplify environment
> save/restore logic - 2016-01-26). It's just a matter of choosing the
> right syntax. I'm going with '!!'. I'm not very happy with it. But I
> do like this type of alias.
Hmm. I wonder if any commands will be fooled by not being moved to
GIT_WORK_TREE. I know that there is a bug already in this case:
export HOME=$PWD
for i in one two; do
git init $i &&
(cd $i &&
echo "* diff=$i" >.gitattributes &&
git add . &&
git commit -m $i) &&
git config --global diff.$i.textconv "sed s/^/$i:/"
done
cd two &&
git --git-dir=$(pwd)/../one/.git --work-tree=$(pwd)/../one show
This shows the contents of repo one using the .gitattributes from repo
two. I am not sure if the bug is that when GIT_WORK_TREE is set,
git-show doesn't position itself at the toplevel of that tree, or if the
attributes machinery should be more careful about looking up paths in
the work-tree versus the current directory.
This bug is tangential to your patch (it has nothing to do with aliases,
and should be fixed regardless). But I wonder if your "!!" aliases will
expose this bug more frequently.
-Peff
PS I think your "!!" syntax conflicts with something like:
git -c alias.has-changes="!! git diff --quiet' has-changes
I don't know if that is worth worrying about or not. I also notice
that using "!!git diff" with no space seems broken, as it seems to
skip using the shell. I wonder if that is a bug in run-command.