From: Ian Jackson Date: Tue, 26 Jun 2018 17:25:13 +0000 (+0100) Subject: ref updates: Introduce update_ref_cmd X-Git-Tag: archive/debian/5.3~11 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=11c8c965c3419fddf2444a7497b45b65f05d3db5 ref updates: Introduce update_ref_cmd 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 --- diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index 57b79e8a..2bac4859 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -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 5c9cdc3e..bbfaea1e 100755 --- 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"); diff --git a/git-debrebase b/git-debrebase index fd05c6b4..fe11251a 100755 --- a/git-debrebase +++ b/git-debrebase @@ -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) {