From: Eric Wong Date: Sat, 16 Jan 2016 03:21:06 +0000 (+0000) Subject: honor core.abbrev from git-config(1) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ceeea662e01a65951d5d07fc9993087242d6206;p=thirdparty%2Fpublic-inbox.git honor core.abbrev from git-config(1) 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. --- diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 54fa6e5de..d014434f2 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -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 diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index ac5564261..23a3e6c7b 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -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 diff --git a/lib/PublicInbox/RepobrowseGitCommit.pm b/lib/PublicInbox/RepobrowseGitCommit.pm index 5c8407b2d..64d0b6073 100644 --- a/lib/PublicInbox/RepobrowseGitCommit.pm +++ b/lib/PublicInbox/RepobrowseGitCommit.pm @@ -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 diff --git a/lib/PublicInbox/RepobrowseGitLog.pm b/lib/PublicInbox/RepobrowseGitLog.pm index 36664171a..197d2cb1f 100644 --- a/lib/PublicInbox/RepobrowseGitLog.pm +++ b/lib/PublicInbox/RepobrowseGitLog.pm @@ -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']]); diff --git a/lib/PublicInbox/RepobrowseGitPlain.pm b/lib/PublicInbox/RepobrowseGitPlain.pm index 89788a107..019198953 100644 --- a/lib/PublicInbox/RepobrowseGitPlain.pm +++ b/lib/PublicInbox/RepobrowseGitPlain.pm @@ -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']]); diff --git a/lib/PublicInbox/RepobrowseGitTree.pm b/lib/PublicInbox/RepobrowseGitTree.pm index e8012dde3..7c5ae60de 100644 --- a/lib/PublicInbox/RepobrowseGitTree.pm +++ b/lib/PublicInbox/RepobrowseGitTree.pm @@ -141,7 +141,7 @@ sub git_blob_show { sub git_tree_show { my ($req, $fh, $git, $hex, $q) = @_; $fh->write('
');
-	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");