+ #Git can give us:
+ #
+ # A big ugly hash: git rev-parse HEAD
+ # 1ddc83849075addb0cac69a6fe3782f4325337b9
+ #
+ # A small ugly hash: git rev-parse --short HEAD
+ # 1ddc838
+ #
+ # The upstream branch path: git rev-parse --abbrev-ref --symbolic-full-name @{upstream}
+ # origin/master
+ #
+ # A version description: git describe --tags --dirty
+ # wireshark-1.8.12-15-g1ddc838
+ #
+ # Number of commits in this branch: git rev-list --count HEAD
+ # 48879
+ #
+ # Number of commits since 1.8.0: git rev-list --count 5e212d72ce098a7fec4332cbe6c22fcda796a018..HEAD
+ # 320
+ #
+ # Refs: git ls-remote code.wireshark.org:wireshark
+ # ea19c7f952ce9fc53fe4c223f1d9d6797346258b (r48972, changed version to 1.11.0)
+
+ if ($version_pref{"git_client"}) {
+ eval {
+ use warnings "all";
+ no warnings "all";
+
+ chomp($line = qx{$git_executable --git-dir="$srcdir"/.git log -1 --pretty=format:%at});
+ if ($? == 0 && length($line) > 1) {
+ $last_change = $line;
+ }
+
+ # Commits since last annotated tag.
+ chomp($line = qx{$git_executable --git-dir="$srcdir"/.git describe --long --always --match "v*"});
+ if ($? == 0 && length($line) > 1) {
+ my @parts = split(/-/, $line);
+ $git_description = $line;
+ $num_commits = $parts[-2];
+ $commit_id = $parts[-1];
+ }
+
+ # This will break in some cases. Hopefully not during
+ # official package builds.
+ chomp($line = qx{$git_executable --git-dir="$srcdir"/.git rev-parse --abbrev-ref --symbolic-full-name \@\{upstream\} 2> $devnull});
+ if ($? == 0 && length($line) > 1) {
+ $repo_branch = basename($line);
+ }
+
+ 1;
+ };
+
+ if ($last_change && $num_commits && $repo_branch) {
+ $do_hack = 0;
+ }
+ } elsif ($version_pref{"svn_client"}) {
+ my $repo_root = undef;
+ my $repo_url = undef;