Bug report: null bytes in pre-receive hook output stream drops lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am reporting an issue where if a pre-receive hook sleeps and then
returns null bytes in the output stream, the git client that is
pushing will drop those lines intermittently.

## What did you do before the bug happened? (Steps to reproduce your issue)

1. Create a local "server" repo with a pre-receive hook that includes
null bytes in output: mkdir /tmp/server && cd $_ && git init --bare &&
echo -e '#!/usr/bin/env bash\nfor n in {1..3}; do echo -ne "\\x00" &&
echo "-----> Log line #${n}..." && sleep 1; done' > hooks/pre-receive
&& chmod +x hooks/pre-receive

2. Create a local "client" repo: mkdir /tmp/client && cd $_ && git init

3. Push a commit from client to server: git commit -m . --allow-empty
&& git push file:///tmp/server master

## What did you expect to happen? (Expected behavior)

I would expect to see all the lines output to the client. The null
bytes should not be printed.

## What happened instead? (Actual behavior)

One or more of the log lines are dropped.  Run Step 3 multiple times
and it will be a different line(s) each time.

For example:

root@5c7434417f1f:/tmp/client# git commit -m . --allow-empty && git
push file:///tmp/server master
[master b4f02d7] .
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 175 bytes | 175.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: -----> Log line #1...
remote: -----> Log line #3...
To file:///tmp/server
   ae04465..b4f02d7  master -> master

## What's different between what you expected and what actually happened?

I would expect all the lines like this:

root@5c7434417f1f:/tmp/client# git commit -m . --allow-empty && git
push file:///tmp/server master
[master b4f02d7] .
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 175 bytes | 175.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: -----> Log line #1...
remote: -----> Log line #2...
remote: -----> Log line #3...
To file:///tmp/server
   ae04465..b4f02d7  master -> master

## Anything else you want to add:

Tried this on multiple versions of git on both macOS and Ubuntu,
including the latest 2.46.1.

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.46.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.5.0
zlib: 1.3
uname: Linux 6.6.12-linuxkit #1 SMP PREEMPT_DYNAMIC Fri Jan 19
12:50:23 UTC 2024 x86_64
compiler info: gnuc: 13.2
libc info: glibc: 2.39
$SHELL (typically, interactive shell): <unset>


[Enabled Hooks]




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux