Re: git checkout under 1.7.6 does not properly list untracked files and aborts
From: Michael J Gruber <hidden>
Date: 2016-06-15 22:52:05
Michael J Gruber venit, vidit, dixit 21.09.2011 09:47:
Interesting. So, it is related to sparse, it seems, and there is also a
mistake in the documentation (which contradicts itself, btw). With your
script, since all files are requested to be checked out ('*'), none
should have skip-worktree set, and the result should be the same as with
my version. But I get this:
Initialized empty Git repository in /tmp/t/utest/.git/
[master (root-commit) 5929c8b] a
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 a
[master 60ad69e] b
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 b
tracked
Switched to branch 'side'
cat: b: No such file or directory
untracked
untracked
That is probably the same output as for you. The final "git checkout
master" errored out without doing anything and without message. I'll
send a few cleanups now, and do some bisecting and thinking later;
though there are people whose sparse-knowledge is way less sparse than
mine ;)
So, I bisected it. The first bad commit is
9037026 (unpack-trees: fix sparse checkout's "unable to match
directories", 2010-11-27)
although the real culprit may be its predecessor
2431afb (unpack-trees: move all skip-worktree checks back to
unpack_trees(), 2010-11-27)
which does not compile:
CC unpack-trees.o
unpack-trees.c: In function 'mark_new_skip_worktree':
unpack-trees.c:852:75: error: 'o' undeclared (first use in this function)
unpack-trees.c:852:75: note: each undeclared identifier is reported only
once for each function it appears in
make: *** [unpack-trees.o] Error 1
So, this problem was introduced after v1.7.3.2. Given the extent of
those two commits, I can't help further (but your proposed fix may be fine).
Duy, sorry for prodding you again. My bisect script was (based on
Joshua's, based on mine):
#!/bin/sh
GIT_EXEC_DIR=~/src/git
PATH=$GIT_EXEC_DIR:$PATH
export GIT_EXEC_DIR
d=/tmp/t/utest
rm -Rf $d || exit 1
mkdir $d || exit 1
cd $d || exit 1
git init
git config core.sparseCheckout true
echo *>.git/info/sparse-checkout
echo tracked>a
git add a
git commit -m a a
git branch side
echo tracked>b
git add b
git commit -m b
git checkout side
echo untracked>b
git checkout master 2>&1 | grep "would be"
Hope this helps.
Michael