When git operations fail (e.g., due to VREF checks), gitolite-shell continues execution and runs POST_GIT triggers as if the operation succeeded. This leads to incorrect behavior where post-processing occurs even when the underlying git operation failed. We have custom VREF hooks that get executed as part of git pushes and we observe that the vref check does return the exit code but gitolite-shell doesnt handle the non zero exit code.
In src/gitolite-shell lines 140-146, the code calls _system() to execute git commands but doesn't check the return value.
From eb423d9ba5c6e6736d0fb019631e67547d71de74 Mon Sep 17 00:00:00 2001
From: rashmi-prithyani-1 <
rashmipr...@gmail.com>
Date: Thu, 24 Jul 2025 13:07:00 -0700
Subject: [PATCH] handle exit code returned by _system call and dont run post
git triggers if git operation fails
---
src/gitolite-shell | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/gitolite-shell b/src/gitolite-shell
index 072e0ff..0a52bee 100755
--- a/src/gitolite-shell
+++ b/src/gitolite-shell
@@ -137,11 +137,17 @@ sub main {
}
trigger( 'PRE_GIT', $repo, $user, $aa, 'any', $verb );
+
+ my $exit_code;
if ( $ENV{REQUEST_URI} ) {
- _system( "git", "http-backend" );
+ $exit_code = _system( "git", "http-backend" );
} else {
my $repodir = "'$rc{GL_REPO_BASE}/$repo.git'";
- _system( "git", "shell", "-c", "$verb $repodir" );
+ $exit_code = _system( "git", "shell", "-c", "$verb $repodir" );
+ }
+
+ if ( $exit_code != 0 ) {
+ exit $exit_code;
}
trigger( 'POST_GIT', $repo, $user, $aa, 'any', $verb );
}
--
2.48.1