Starting from "6035d6a fetch-pack: prepare updated shallow file before
fetching the pack" the shallow fetches of commits with tags can result
in broken git repo.  The following script illustrates the problem:


mkdir repo1 repo2
cd repo1
git init
for i in `seq 1 3`; do
        echo $i > foo
        git add foo
        git commit -m "Commit $i"
git tag tag HEAD~1

cd ../repo2
git init
git fetch --depth=2 ../repo1 master:branch
git fsck

The function fetch_pack in this case is called twice. During the
second called alternate_shallow_file contains "\0" (it is set to this
value by commit_lock_file(&shallow_lock) during first call of
fetch_pack). In the result the file .git/shallow, created during first
call to fetch_pack, is removed and the git repo ends with broken link.

The two possible fixes which I see are:

1) Replace back if (alternate_shallow_file) condition in fetch pack with 
   if (args->depth > 0) 

2) alternate_shallow_file should be copy of shallow_lock.filename not a
   reference to it

But I'm not able to determine by myself which one (if any) is a correct fix
to the problem.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to