chiark / gitweb /
Dgit.pm: Move changedir_git_toplevel from git-debrebase
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Oct 2018 00:15:08 +0000 (01:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Oct 2018 00:15:08 +0000 (01:15 +0100)
NFC other than hardcoded qw(git).

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

index 5b1feff..bfe2ab9 100644 (file)
@@ -54,7 +54,7 @@ BEGIN {
                       waitstatusmsg failedcmd_waitstatus
                      failedcmd_report_cmd failedcmd
                       runcmd shell_cmd cmdoutput cmdoutput_errok
-                      git_rev_parse git_cat_file
+                      git_rev_parse changedir_git_toplevel git_cat_file
                      git_get_ref git_get_symref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
                      git_check_unmodified
@@ -500,6 +500,11 @@ sub git_rev_parse ($) {
     return cmdoutput qw(git rev-parse), "$_[0]~0";
 }
 
+sub changedir_git_toplevel () {
+    my $toplevel = cmdoutput qw(git rev-parse --show-toplevel);
+    chdir $toplevel or fail f_ "chdir toplevel %s: %s\n", $toplevel, $!;
+}
+
 sub git_cat_file ($;$) {
     my ($objname, $etype) = @_;
     # => ($type, $data) or ('missing', undef)
index 79c8321..5e8a8bb 100755 (executable)
@@ -3031,8 +3031,7 @@ getoptions_main
 initdebug('git-debrebase ');
 enabledebug if $debuglevel;
 
-my $toplevel = cmdoutput @git, qw(rev-parse --show-toplevel);
-chdir $toplevel or fail f_ "chdir toplevel %s: %s\n", $toplevel, $!;
+changedir_git_toplevel();
 
 $rd = fresh_playground "$playprefix/misc";