summaryrefslogtreecommitdiff
path: root/svn-git-hash.pl
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2017-05-08 19:34:57 +0100
committerRenato Golin <renato.golin@linaro.org>2017-05-08 19:36:47 +0100
commitb50982a58486e5bc6dfc9f4c181def3172e57522 (patch)
treeb59be5c398a88d73ffbe83e7764f69f97c6d0789 /svn-git-hash.pl
parent22259b91409bac424d562ac7519bf70d34df0996 (diff)
svn-git-hash.pl: Use git -C instead of push/pop dir
Change-Id: I419b36b027a4d979d5152274a0095bbe4596d4a9
Diffstat (limited to 'svn-git-hash.pl')
-rwxr-xr-xsvn-git-hash.pl13
1 files changed, 8 insertions, 5 deletions
diff --git a/svn-git-hash.pl b/svn-git-hash.pl
index af94fe8e..82e8b8f7 100755
--- a/svn-git-hash.pl
+++ b/svn-git-hash.pl
@@ -19,14 +19,17 @@
use strict;
use warnings;
-my $USAGE = "$0 rNNNNN\n";
+my $USAGE = "$0 <BASE-DIR> rNNNNN\n";
# Basic checks
# This should not be ran by users, so make sure we're at the base of the repo
-if (! -d ".git" and ! -f ".git") {
- die "Not in a git repository.\n$USAGE";
+my $BASE = $ARGV[0];
+if (not defined $BASE) {
+ die "$USAGE";
+} elsif (! -d "$BASE/.git" and ! -f "$BASE/.git") {
+ die "'$BASE' not a git repository.\n$USAGE";
}
-my $REVISION = $ARGV[0];
+my $REVISION = $ARGV[1];
if (not defined $REVISION) {
die $USAGE;
} elsif ($REVISION =~ /^r(\d+)$/) {
@@ -39,7 +42,7 @@ if (not defined $REVISION) {
my ($git, $svn);
# Walk the log until the exact (or lower) revision is found
-open LOG, "git log|" || die "Can't run git log command: $!\n";
+open LOG, "git -C \"$BASE\" log|" || die "Can't run git log command: $!\n";
foreach my $line (<LOG>) {
# Make sure we always update git hashes to the latest
# 11 chars, to be easy to compare to git log --pretty=oneline