5 chdir $dir || die "$dir: $!\n";
7 my $gitdesc = `git describe --always --dirty || echo -- \"0-gUNKNOWN\"`;
9 my $gitsuffix = ($gitdesc =~ /([0-9a-fA-F]{7}(-dirty)?)$/) ? "-g$1" : "-gUNKNOWN";
11 printf STDERR "git suffix: %s\n", $gitsuffix;
12 printf "#define GIT_SUFFIX \"%s\"\n", $gitsuffix;
14 my $gitcommit = `git log -1 --format=\"%H\" || echo DEADBEEF`;
16 open(BRANCHES, "git branch -a -v --abbrev=40|") || die "git branch: $!\n";
20 if (/\s+(.*?)\s+$gitcommit/) {
22 if ($branch =~ /^remotes\/(.*?)(\/.*)$/) {
24 my $url = `git config --get "remote.$1.url"`;
26 $url =~ s/^(git:|https?:|git@)\/\/github\.com/github/i;
27 $url =~ s/^(ssh|git):\/\/git\.sv\.gnu\.org\/srv\/git\//savannah:/i;
28 $url =~ s/^(ssh|git):\/\/git\.savannah\.nongnu\.org\//savannah:/i;
30 push @names, $url.$path;
32 push @names, 'local:'.$branch;
37 printf STDERR "git branches: %s\n", join(", ", @names);
40 printf <<EOF, $gitdesc, join($cr."\n\\t", @names);
42 This is a git build of %s$cr
43 Associated branch(es):$cr