Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2023-08-10 17:40:50 +0300
committerJunio C Hamano <gitster@pobox.com>2023-08-10 19:15:27 +0300
commit7ba7c52d76630183b47c57bdd2da8eea033bdd2f (patch)
tree073b94e261e7348101b45ecbb8f7d5116501a433 /upload-pack.c
parentfb7d80edcae482f4fa5d4be0227dc3054734e5f3 (diff)
upload-pack: fix race condition in error messages
Test t5516-fetch-push.sh has a test 'deny fetch unreachable SHA1, allowtipsha1inwant=true' that checks stderr for a specific error string from the remote. In some build environments the error sent over the remote connection gets mingled with the error from the die() statement. Since both signals are being output to the same file descriptor (but from parent and child processes), the output we are matching with grep gets split. To reduce the risk of this failure, follow this process instead: 1. Write an error message to stderr. 2. Write an error message across the connection. 3. exit(1). This reorders the events so the error is written entirely before the client receives a message from the remote, removing the race condition. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/upload-pack.c b/upload-pack.c
index d3312006a3..ece111c629 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -777,11 +777,12 @@ error:
for (i = 0; i < data->want_obj.nr; i++) {
struct object *o = data->want_obj.objects[i].item;
if (!is_our_ref(o, data->allow_uor)) {
+ error("git upload-pack: not our ref %s",
+ oid_to_hex(&o->oid));
packet_writer_error(&data->writer,
"upload-pack: not our ref %s",
oid_to_hex(&o->oid));
- die("git upload-pack: not our ref %s",
- oid_to_hex(&o->oid));
+ exit(1);
}
}
}