Re: [PATCH perf] perf tools: .git/ORIG_HEAD might not exist
From: Andres Freund
Date: Thu Mar 31 2022 - 13:33:54 EST
Hi,
On 2022-03-29 11:31:20 +0200, Matthieu Baerts wrote:
> It seems it cannot be assumed .git/ORIG_HEAD exists if .git/HEAD is
> there.
>
> Indeed, recently our public CI reported[1] the following error when
> compiling Perf tool:
>
> $ cd tools/perf
> $ make -j4 -l4 O=/tmp/(...)/perf DESTDIR=/usr install
> (...)
> make[2]: *** No rule to make target '../../.git/ORIG_HEAD', needed by '/tmp/(...)/perf/PERF-VERSION-FILE'.
>
> This is because apparently[2] Cirrus Ci uses a Git client implemented
> purely in Go[3] to perform a clone. Most likely, this tool doesn't
> create any .git/ORIG_HEAD file but .git/HEAD is there. The error can
> indeed be reproduced by renaming this .git/ORIG_HEAD file while keeping
> .git/HEAD. In other words, it means it is not enough to check the
> presence of .git/HEAD to assume .git/ORIG_HEAD exists as well.
FWIW, It's not just custom git implementations, stock git doesn't ensure it's
there either. I build a nightly VM image with Linus' kernel for postgres
testing, and as part of that I do a minimal clone:
git clone --single-branch --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git /usr/src/linux
and then build the kernel. The build recently started failing like this:
https://cirrus-ci.com/task/4648999113195520?logs=build_image#L3121
It's not a question of "--single-branch --depth 1" - ORIG_HEAD just isn't
there in a new clone. Which makes sense, because there's no previous value for
HEAD.
Greetings,
Andres Freund