-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 16656 b: refs/heads/master c: 117a93d h: refs/heads/master v: v3
- Loading branch information
Rene Scharfe
authored and
Sam Ravnborg
committed
Jan 6, 2006
1 parent
52a9f1f
commit abaaece
Showing
2 changed files
with
18 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 253dfa6e465c054a73bd3b13af51c34c9d8d233d | ||
refs/heads/master: 117a93db1dcd6ed61336b27e4e2938f791c1841b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,22 @@ | ||
#!/usr/bin/perl | ||
# Copyright 2004 - Ryan Anderson <ryan@michonline.com> GPL v2 | ||
#!/bin/sh | ||
# Print additional version information for non-release trees. | ||
|
||
use strict; | ||
use warnings; | ||
use Digest::MD5; | ||
require 5.006; | ||
|
||
if (@ARGV != 1) { | ||
print <<EOT; | ||
Usage: setlocalversion <srctree> | ||
EOT | ||
exit(1); | ||
usage() { | ||
echo "Usage: $0 [srctree]" >&2 | ||
exit 1 | ||
} | ||
|
||
my ($srctree) = @ARGV; | ||
chdir($srctree); | ||
|
||
my @LOCALVERSIONS = (); | ||
|
||
# We are going to use the following commands to try and determine if this | ||
# repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We | ||
# currently assume that all meaningful version boundaries are marked by a tag. | ||
# We don't care what the tag is, just that something exists. | ||
|
||
# Git/Cogito store the top-of-tree "commit" in .git/HEAD | ||
# A list of known tags sits in .git/refs/tags/ | ||
# | ||
# The simple trick here is to just compare the two of these, and if we get a | ||
# match, return nothing, otherwise, return a subset of the SHA-1 hash in | ||
# .git/HEAD | ||
|
||
sub do_git_checks { | ||
open(H,"<.git/HEAD") or return; | ||
my $head = <H>; | ||
chomp $head; | ||
close(H); | ||
cd "${1:-.}" || usage | ||
|
||
opendir(D,".git/refs/tags") or return; | ||
foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) { | ||
open(F,"<.git/refs/tags/" . $tagfile) or return; | ||
my $tag = <F>; | ||
chomp $tag; | ||
close(F); | ||
return if ($tag eq $head); | ||
} | ||
closedir(D); | ||
|
||
push @LOCALVERSIONS, "g" . substr($head,0,8); | ||
} | ||
|
||
if ( -d ".git") { | ||
do_git_checks(); | ||
} | ||
# Check for git and a git repo. | ||
if head=`git rev-parse --verify HEAD 2>/dev/null`; then | ||
# Do we have an untagged version? | ||
if [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then | ||
printf '%s%s' -g `echo "$head" | cut -c1-8` | ||
fi | ||
|
||
printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0); | ||
# Are there uncommitted changes? | ||
if git diff-files | read dummy; then | ||
printf '%s' -git_dirty | ||
fi | ||
fi |