chiark / gitweb /
ref updates: Introduce update_ref_cmd
[dgit.git] / Debian / Dgit.pm
index aec5a23980ed0bb72450834df43840dd31aaf7d6..2bac4859f887ee5a17788755e00cfa5537503669 100644 (file)
@@ -47,11 +47,11 @@ BEGIN {
                       fail failmsg ensuredir must_getcwd executable_on_path
                       waitstatusmsg failedcmd_waitstatus
                      failedcmd_report_cmd failedcmd
-                      runcmd cmdoutput cmdoutput_errok
+                      runcmd shell_cmd cmdoutput cmdoutput_errok
                       git_rev_parse git_cat_file
                      git_get_ref git_get_symref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
-                     git_check_unmodified
+                     git_check_unmodified git_update_ref_cmd
                       $package_re $component_re $deliberately_re
                      $distro_re $versiontag_re $series_filename_re
                      $extra_orig_namepart_re
@@ -225,11 +225,11 @@ sub _us () {
 }
 
 sub failmsg {
-    my $s = "@_\n";
+    my $s = "error: @_\n";
     $s =~ s/\n\n$/\n/;
     my $prefix = _us().": ";
     $s =~ s/^/$prefix/gm;
-    return $s;
+    return "\n".$s;
 }
 
 sub fail {
@@ -315,6 +315,11 @@ sub runcmd {
     failedcmd @_ if system @_;
 }
 
+sub shell_cmd {
+    my ($first_shell, @cmd) = @_;
+    return qw(sh -ec), $first_shell.'; exec "$@"', 'x', @cmd;
+}
+
 sub cmdoutput_errok {
     confess Dumper(\@_)." ?" if grep { !defined } @_;
     debugcmd "|",@_;
@@ -487,6 +492,13 @@ sub is_fast_fwd ($$) {
     }
 }
 
+sub git_update_ref_cmd {
+    # returns  qw(git update-ref), qw(-m), @_
+    # except that message may be modified to honour GIT_REFLOG_ACTION
+    my $msg = shift @_;
+    return qw(git update-ref -m), $msg, @_;
+}
+
 sub changedir ($) {
     my ($newdir) = @_;
     printdebug "CD $newdir\n";