emacs-diffs
[Top][All Lists]
Advanced

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

master e26dcc0e144 2/3: ; Fix logic of Git pre-push hook when pushing a


From: Jim Porter
Subject: master e26dcc0e144 2/3: ; Fix logic of Git pre-push hook when pushing a new branch
Date: Sun, 23 Apr 2023 15:07:52 -0400 (EDT)

branch: master
commit e26dcc0e1441ded286b83eefb358d965748dd6db
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    ; Fix logic of Git pre-push hook when pushing a new branch
    
    * build-aux/git-hooks/pre-push: Update the Git command to run on each
    iteration.
---
 build-aux/git-hooks/pre-push | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/build-aux/git-hooks/pre-push b/build-aux/git-hooks/pre-push
index adcf27d4a5d..65c96bfdec9 100755
--- a/build-aux/git-hooks/pre-push
+++ b/build-aux/git-hooks/pre-push
@@ -49,19 +49,19 @@ $awk -v origin_name="$1" '
   $2 ~ /^[a-z0-9]{40}$/ {
     newref = $2
     # If the remote SHA is all zeroes, this is a new object to be
-    # pushed (likely a branch).  Go backwards until we find a SHA on
-    # an origin branch.
+    # pushed (likely a branch)...
     if ($4 ~ /^0{40}$/) {
       back = 0
-      cmd = ("git branch -r -l '\''" origin_name "/*'\'' --contains " \
-             newref "~" back)
-      while ((cmd | getline) == 0) {
-
-        # Only look back at most 1000 commits, just in case...
-        if (back++ > 1000)
+      # ... Go backwards until we find a SHA on an origin branch.
+      # Stop trying after 1000 commits, just in case...
+      for (back = 0; back < 1000; back++) {
+        cmd = ("git branch -r -l '\''" origin_name "/*'\''" \
+               " --contains " newref "~" back)
+        rv = (cmd | getline)
+        close(cmd)
+        if (rv > 0)
           break;
       }
-      close(cmd)
 
       cmd = ("git rev-parse " newref "~" back)
       cmd | getline oldref



reply via email to

[Prev in Thread] Current Thread [Next in Thread]