From: keni Date: Mon, 2 Mar 2015 01:26:29 +0000 (-0500) Subject: Switch NHtext from "git branch" to "git symbolic-ref" to avoid corner cases. X-Git-Tag: NetHack-3.6.0_RC01~645 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=774e6c2f6f36f5d059cd3f53a642bf8da57a83fc;p=nethack Switch NHtext from "git branch" to "git symbolic-ref" to avoid corner cases. --- diff --git a/DEVEL/hooksdir/NHtext b/DEVEL/hooksdir/NHtext index 03550e513..861b9e6b1 100755 --- a/DEVEL/hooksdir/NHtext +++ b/DEVEL/hooksdir/NHtext @@ -12,9 +12,6 @@ use strict; #my $dbgfile = ($^O eq "MSWin32") ? "$ENV{TEMP}.$$" : "/tmp/trace.$$"; #open TRACE, ">>", ($debug==0)? $sink : $dbgfile; -# pick up the prefix for substitutions in this repo -#my $PREFIX = `git config --local --get nethack.substprefix`; -#chomp($PREFIX); sub git_config { my($section, $var) = @_; local($_); @@ -30,6 +27,7 @@ sub git_config { } die "Missing config var: [$section] $var\n"; } +# pick up the prefix for substitutions in this repo my $PREFIX = &git_config('nethack','substprefix'); my $submode = 0; # ok to make non-cleaning changes to file @@ -119,16 +117,17 @@ sub Date { #sub Author { #} -# NB: the standard-ish Revision line isn't enough - you need Branch/Revision - +# NB: the standard-ish Revision line isn't enough - you need Branch:Revision - # but we split it into 2 so we can use the standard processing code on Revision # and just slip Branch in. sub Branch { my($val, $mode, $submode) = @_; if($mode eq "c"){ if($submode==0){ - $val = `git branch --no-color --contains`; + $val = `git symbolic-ref -q --short HEAD`; $val =~ s/[\n\r]*$//; $val =~ s/^\*\s*//; + $val = "(unknown)" unless($val =~ m/^[[:print:]]+$/); } } # if($mode eq "s"){