chiark / gitweb /
ref updates: Introduce update_ref_cmd
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jun 2018 17:25:13 +0000 (18:25 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jun 2018 18:20:52 +0000 (19:20 +0100)
Currently the comment about `message may be modified' is rather
misleading, since there is no code to do that - but it explains the
semantics of the new function.

We change the appropriate subset of the git update-ref call sites.
These are precisely the ones where we previously specified a message
with -m, except for the quilt cache (where we use the reflog message
as the cache lookup key).

The calls are updates of internal refs etc.

We end up using qw(git) rather than @git.
Otherwise no functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
dgit
git-debrebase

index 57b79e8a195dfdc35f2c12540ec652935ad81479..2bac4859f887ee5a17788755e00cfa5537503669 100644 (file)
@@ -51,7 +51,7 @@ BEGIN {
                       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
@@ -492,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";
diff --git a/dgit b/dgit
index 5c9cdc3e2a8d24819199c69d4f61b4735a18d78f..bbfaea1ec6fe326a3f8f0a6022bc06453b607c55 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2851,15 +2851,14 @@ sub mergeinfo_version ($) {
 
 sub fetch_from_archive_record_1 ($) {
     my ($hash) = @_;
-    runcmd @git, qw(update-ref -m), "dgit fetch $csuite",
-           'DGIT_ARCHIVE', $hash;
+    runcmd git_update_ref_cmd "dgit fetch $csuite", 'DGIT_ARCHIVE', $hash;
     cmdoutput @git, qw(log -n2), $hash;
     # ... gives git a chance to complain if our commit is malformed
 }
 
 sub fetch_from_archive_record_2 ($) {
     my ($hash) = @_;
-    my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
+    my @upd_cmd = (git_update_ref_cmd 'dgit fetch', lrref(), $hash);
     if (act_local()) {
        cmdoutput @upd_cmd;
     } else {
@@ -3850,7 +3849,7 @@ sub maybe_split_brain_save ($$$) {
     # => message fragment "$saved" describing disposition of $dgitview
     return "commit id $dgitview" unless defined $split_brain_save;
     my @cmd = (shell_cmd 'cd "$1"; shift', $maindir,
-              @git, qw(update-ref -m),
+              git_update_ref_cmd
               "dgit --dgit-view-save $msg HEAD=$headref",
               $split_brain_save, $dgitview);
     runcmd @cmd;
@@ -4050,7 +4049,7 @@ sub plain_overwrite_pseudomerge ($$$) {
        $clogp, $head, $archive_hash, $i_arch_v,
        "dgit", $m;
 
-    runcmd @git, qw(update-ref -m), $m, 'HEAD', $r, $head;
+    runcmd git_update_ref_cmd $m, 'HEAD', $r, $head;
 
     progress "Make pseudo-merge of $i_arch_v->[0] into your HEAD.";
     return $r;
@@ -4496,7 +4495,7 @@ END
 
     runcmd_ordryrun @git,
        qw(-c push.followTags=false push), access_giturl(), @pushrefs;
-    runcmd_ordryrun @git, qw(update-ref -m), 'dgit push', lrref(), $dgithead;
+    runcmd_ordryrun git_update_ref_cmd 'dgit push', lrref(), $dgithead;
 
     supplementary_message(<<'END');
 Push failed, while obtaining signatures on the .changes and .dsc.
@@ -6437,7 +6436,7 @@ sub cmd_quilt_fixup {
 
 sub import_dsc_result {
     my ($dstref, $newhash, $what_log, $what_msg) = @_;
-    my @cmd = (@git, qw(update-ref -m), $what_log, $dstref, $newhash);
+    my @cmd = (git_update_ref_cmd $what_log, $dstref, $newhash);
     runcmd @cmd;
     check_gitattrs($newhash, "source tree");
 
index fd05c6b46a67ab92e2db225e198910d17cb5c9ec..fe11251a9a7d95022af614537c5a3cd09d42c182 100755 (executable)
@@ -118,7 +118,7 @@ sub run_deferred_updates ($) {
 
     confess 'dangerous internal error' unless all_snags_summarised();
 
-    my @upd_cmd = (@git, qw(update-ref --stdin -m), "debrebase: $mrest");
+    my @upd_cmd = (git_update_ref_cmd "debrebase: $mrest", qw(--stdin));
     debugcmd '>|', @upd_cmd;
     open U, "|-", @upd_cmd or die $!;
     foreach (@deferred_updates) {