Subject: Re: [PATCH v2 2/2] shallow.c: use '{commit,rollback}_shallow_file'

From: Jonathan Nieder <[email-masked]>
Date: Tue, 2 Jun 2020 20:42:13 -0700

Hi,

Taylor Blau wrote:

> Signed-off-by: Taylor Blau <[email-masked]>
> ---
>  builtin/receive-pack.c   |  4 ++--
>  commit.h                 |  2 ++
>  fetch-pack.c             | 10 +++++-----
>  shallow.c                | 30 +++++++++++++++++++++---------
>  t/t5537-fetch-shallow.sh | 29 +++++++++++++++++++++++++++++
>  5 files changed, 59 insertions(+), 16 deletions(-)

I haven't investigated the cause yet, but I've run into an interesting
bug that bisects to this commit.  Jay Conrod (cc-ed) reports:

| I believe this is also the cause of Go toolchain test failures we've
| been seeing. Go uses git to fetch dependencies.
|
| The problem we're seeing can be reproduced with the script below. It
| should print "success". Instead, the git merge-base command fails
| because the commit 7303f77963648d5f1ec5e55eccfad8e14035866c
| (origin/master) has no history.

-- 8< --
#!/bin/bash

set -euxo pipefail
if [ -d legacytest ]; then
  echo "legacytest directory already exists" >&2
  exit 1
fi
mkdir legacytest
cd legacytest
git init --bare
git config protocol.version 2
git config fetch.writeCommitGraph true
git remote add origin -- https://github.com/rsc/legacytest
git fetch -f --depth=1 origin refs/heads/master:refs/heads/master
git fetch -f origin 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
git fetch --unshallow -f origin
git merge-base --is-ancestor -- v2.0.0 7303f77963648d5f1ec5e55eccfad8e14035866c
echo success
-- >8 --

The fetch.writeCommitGraph part is interesting.  When does a commit
graph file get written in this sequence of operations?  In an
unshallow operation, does the usual guard against writing a commit
graph in a shallow repo get missed?

"rm -fr objects/info/commit-graphs" recovers the full history in the
repo, so this is not a case of writing the wrong shallows --- it's
only a commit graph issue.

I'll take a closer look, but thought I'd give others a chance to look
to in case there's something obvious. :)

Thanks,
Jonathan