Package: chiark-scripts
Version: 7.0.2

Hello,

Currently there is no way to prevent pre-push hooks from blocking a
branchmove operation, which is annoying.  Here is a patch.

-- 
Sean Whitton
>From 24e444256e5b360de0601cb986998b83abb9e857 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email protected]>
Date: Fri, 30 Aug 2024 12:16:03 +0100
Subject: [PATCH] git-branchmove: Always pass --no-verify to 'git push'

We are not doing the kind of push for which git pre-push hooks are written, so
they will often fail.  In particular, 'git branchmove' is primarily intended
for moving WIP branches around, whereas pre-push hooks are usually for the
purpose of preventing accidental pushes of unpolished work to public branches.
With this in mind, I think we should try passing --no-verify unconditionally,
instead of providing an option.

Signed-off-by: Sean Whitton <[email protected]>
---
 scripts/git-branchmove | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/git-branchmove b/scripts/git-branchmove
index 156078f..270d78a 100755
--- a/scripts/git-branchmove
+++ b/scripts/git-branchmove
@@ -187,13 +187,13 @@ foreach my $source_branch (@source_branches) {
 my @refspecs      = map { "$_->{ref}:$_->{ref}" } @source_branches;
 my @nuke_refspecs = map { ":$_->{ref}" } @source_branches;
 if ($op eq 'put') {
-    $git->push('--no-follow-tags', $remote, @refspecs);
+    $git->push(qw(--no-follow-tags --no-verify), $remote, @refspecs);
     $git->update_ref('-m', "git-branchmove: moved to $remote ($rurl)",
         '-d', $_->{ref}, $_->{hash})
       for @source_branches;
 } elsif ($op eq 'get') {
     $git->fetch('--no-tags', $remote, @refspecs);
-    $git->push('--no-follow-tags', $remote, @nuke_refspecs);
+    $git->push(qw(--no-follow-tags --no-verify), $remote, @nuke_refspecs);
 }
 
 # if the remote is a named remote, rather than just a URI, update
-- 
2.39.2

Reply via email to