* BUG: git_work_tree issue with git alias and scripting
@ 2015-09-18 7:33 Tuomo Tanskanen
0 siblings, 0 replies; 2+ messages in thread
From: Tuomo Tanskanen @ 2015-09-18 7:33 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
Hello,
Attached is a simple script exposing a possible bug when git alias is
combined with git commands in script. It should be pretty self-explanatory.
Check what it does and execute it. On my Linux and OSX, both with git 2.5.1
behave the same, ie. git add fails even the file "test" is in $PWD.
Summary: $GIT_WORK_TREE persists in env, and then some git commands operate
on repo in $PWD (like git log), while some others (like git add) operate on
repo in $GIT_WORK_TREE, making it inconsistent and results in very
unexpected results.
Cheers, Tuomo
[-- Attachment #2: gitbug.sh --]
[-- Type: application/x-sh, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* BUG: git_work_tree issue with git alias and scripting
@ 2015-09-18 8:09 Tuomo Tanskanen
0 siblings, 0 replies; 2+ messages in thread
From: Tuomo Tanskanen @ 2015-09-18 8:09 UTC (permalink / raw)
To: git
Hello,
Attached is a simple script exposing a possible bug when git alias is
combined with git commands in script. It should be pretty self-explanatory.
Check what it does and execute it. On my Linux and OSX, both with git 2.5.1
behave the same, ie. git add fails even the file "test" is in $PWD.
Summary: $GIT_WORK_TREE persists in env, and then some git commands operate
on repo in $PWD (like git log), while some others (like git add) operate on
repo in $GIT_WORK_TREE, making it inconsistent and results in very
unexpected results.
Cheers, Tuomo
---
#!/bin/sh
# setup a test repo
mkdir bar
cd bar
git init
echo "test" > bar
git add bar
git commit -m "test commit in bar"
echo "adding this will fail later on" > test
cd ..
# setup a repo with an alias and script alias will execute
mkdir foo
cd foo
git init
cat >foo.sh <<EOF
#!/bin/sh -x
cd $PWD/../bar
env | egrep "^(GIT_WORK_TREE|PWD)"
echo "Git log works (bar log shows up):"
git log --oneline | head -1
echo "Git add does not (tries to add files in GIT_WORK_TREE=foo, while
PWD=bar):"
git add test
EOF
chmod 755 foo.sh
cat >>.git/config <<EOF
[alias]
foo = !$PWD/foo.sh
EOF
git add foo.sh
git commit -m "committing foo.sh"
# run test via alias
git foo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-18 8:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-18 7:33 BUG: git_work_tree issue with git alias and scripting Tuomo Tanskanen
-- strict thread matches above, loose matches on Subject: below --
2015-09-18 8:09 Tuomo Tanskanen
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 NNTP newsgroup(s).