Subject: data loss when doing ls-remote and piped to command

From: Rolf Eike Beer <[email-masked]>
Date: Wed, 15 Sep 2021 14:43:10 +0200

The given repository is a clone of the vanilla kernel.

/usr/bin/git --git-dir=/home/ebeer/repos/upstream/linux/.git ls-remote origin 2>&1 | less

And I then see things like this:

6f38b5d6cfd43dde3058a10c68baae9cf17af912        refs/tags/v5.0-rc2
1c7fc5cbc33980acd13ae83d0b416db002fe95601e7f97f64b59514d936     refs/tags/v5.7-rc2^{}
d0709bb6da2ab6d49b11643e98abdf79b1a2817f        refs/tags/v5.7-rc3

This also happens when I cd into the repository and just run "git ls-remote" 
on some of my repositories, but much less often.

The remainder of the overly long line is the correct id for that tag. The 
error does not happen on every run, and on some of my repositories it also 
differs from run to run on which tag that happens. Here it seems that it is 
quite stable to happening on this tag. However, a different user on the same 
machine running the very same command had it happen on v5.7-rc3.

I have the same on my laptop, both run on Opensuse Tumbleweed, updated at the 
same time this morning. This seems to be quite fragile regarding latency or 
such: I can reproduce it with our internal git server, but not with 
kernel.org. This is not bound to less, we originally observed the error on a 
entirely different tool that tried to parse the output of ls-remote.

Given that there are quite a lot of tags missing I suspect it may be that the 
pipe handling is somewhere broken, i.e. too much data is written to a pipe 
that is already full. I have not been able to provoke that using pv by rate 
limiting the output so far.

[System Info]
git Version:
git version 2.33.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.14.1-1-default #1 SMP Sat Sep 4 08:22:51 UTC 2021 (67af907) x86_64
Compiler Info: gnuc: 11.2
libc Info: glibc: 2.33
$SHELL (typically, interactive shell): /bin/bash

[no hooks]

-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source