]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
honor core.abbrev from git-config(1)
authorEric Wong <e@80x24.org>
Sat, 16 Jan 2016 03:21:06 +0000 (03:21 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Apr 2016 18:58:27 +0000 (18:58 +0000)
We will use core.abbrev=12 by default if unset, as the git
default of 7 is too low for long-term usability of links.
Some of our callers used 16, which was probably excessive.

lib/PublicInbox/Feed.pm
lib/PublicInbox/Git.pm
lib/PublicInbox/RepobrowseGitCommit.pm
lib/PublicInbox/RepobrowseGitLog.pm
lib/PublicInbox/RepobrowseGitPlain.pm
lib/PublicInbox/RepobrowseGitTree.pm

index 54fa6e5de6d389775d0297873fdda36a1c3aff20..d014434f2cd61ad01bdd7ba382113cbabc9e92dc 100644 (file)
@@ -216,7 +216,7 @@ sub each_recent_blob {
        # leave us with filenames with spaces in them..
        my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
        my $log = $git->popen(qw/log --no-notes --no-color --raw -r
-                               --abbrev=16 --abbrev-commit/,
+                               --abbrev-commit/, $git->abbrev,
                                "--format=%h%x00%ct%x00%an%x00%s%x00",
                                $range);
        my %deleted; # only an optimization at this point
index ac55642611f56c2d6924291cc803a81f5cc043b9..23a3e6c7bdf36fba1f908613eadd03e4fb56940b 100644 (file)
@@ -13,6 +13,11 @@ use POSIX qw(dup2);
 require IO::Handle;
 use PublicInbox::Spawn qw(spawn popen_rd);
 
+# Documentation/SubmittingPatches recommends 12 (Linux v4.4)
+my $abbrev = `git config core.abbrev` || 12;
+
+sub abbrev { "--abbrev=$abbrev" }
+
 sub new {
        my ($class, $git_dir) = @_;
        bless { git_dir => $git_dir }, $class
index 5c8407b2d68d23708f23efae40908be1912aac48..64d0b607352002d33d47d7b616116994b5d1f494 100644 (file)
@@ -122,8 +122,8 @@ sub call_git_commit {
        my $id = $q->{id};
        $id eq '' and $id = 'HEAD';
        my $git = $req->{repo_info}->{git};
-       my @cmd = qw(show -z --numstat -p --encoding=UTF-8
-                       --no-notes --no-color --abbrev=10 -c);
+       my @cmd = (qw(show -z --numstat -p --encoding=UTF-8
+                       --no-notes --no-color -c), $git->abbrev);
        my @path;
 
        # kill trailing slash
index 36664171abe05eaaf118ca40737454158bb95d1b..197d2cb1f1335d6e0f3972c5d6b7bacd1f7448d6 100644 (file)
@@ -25,7 +25,7 @@ sub call_git_log {
 
        my $git = $repo_info->{git};
        my $log = $git->popen(qw(log --no-notes --no-color --abbrev-commit),
-                               $LOG_FMT, "-$max", $h, '--');
+                               $git->abbrev, $LOG_FMT, "-$max", $h, '--');
        sub {
                my ($res) = @_; # Plack callback
                my $fh = $res->([200, ['Content-Type'=>'text/html']]);
index 89788a10703440d1100b65e3c5010a75da9dd179..0191989539fed3af6f4d6fcb3e3db3afc9a66b28 100644 (file)
@@ -57,7 +57,7 @@ sub git_tree_plain {
                        $pfx = "$last/";
                }
        }
-       my $ls = $git->popen(qw(ls-tree --name-only -z --abbrev=12), $hex);
+       my $ls = $git->popen(qw(ls-tree --name-only -z), $git->abbrev, $hex);
        sub {
                my ($res) = @_;
                my $fh = $res->([ 200, ['Content-Type' => 'text/html']]);
index e8012dde39e892ed4c0b9ae4beef0a4b6c765bb4..7c5ae60dea58b170baa281dc309a3a25fdc38430 100644 (file)
@@ -141,7 +141,7 @@ sub git_blob_show {
 sub git_tree_show {
        my ($req, $fh, $git, $hex, $q) = @_;
        $fh->write('<pre>');
-       my $ls = $git->popen(qw(ls-tree --abbrev=16 -l -z), $hex);
+       my $ls = $git->popen(qw(ls-tree -l -z), $git->abbrev, $hex);
        my $t = cur_path($req, $q);
        my $pfx;
        $fh->write("path: $t\n\n");