chiark / gitweb /
changelog: finalise 5.8
[dgit.git] / Debian / Dgit.pm
index 960f505aa1579036d27f3d7374b18d74490f6e37..5106f8517c4e08c26a67661c5e3fcbb17575cc5e 100644 (file)
@@ -47,11 +47,12 @@ 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_reflog_action_msg  git_update_ref_cmd
                       $package_re $component_re $deliberately_re
                      $distro_re $versiontag_re $series_filename_re
                      $extra_orig_namepart_re
@@ -101,7 +102,9 @@ sub NOCOMMITCHECK () { return 0x8; }
 our $debugprefix;
 our $debuglevel = 0;
 
-our $negate_harmful_gitattrs = "-text -eol -crlf -ident -filter";
+our $negate_harmful_gitattrs =
+    "-text -eol -crlf -ident -filter -working-tree-encoding";
+    # ^ when updating this, alter the regexp in dgit:is_gitattrs_setup
 
 our $forkcheck_mainprocess;
 
@@ -223,11 +226,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 {
@@ -313,6 +316,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 "|",@_;
@@ -485,6 +493,21 @@ sub is_fast_fwd ($$) {
     }
 }
 
+sub git_reflog_action_msg ($) {
+    my ($msg) = @_;
+    my $rla = $ENV{GIT_REFLOG_ACTION};
+    $msg = "$rla: $msg" if length $rla;
+    return $msg;
+}
+
+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 @_;
+    $msg = git_reflog_action_msg $msg;
+    return qw(git update-ref -m), $msg, @_;
+}
+
 sub changedir ($) {
     my ($newdir) = @_;
     printdebug "CD $newdir\n";