develooper Front page | perl.perl5.porters | Postings from June 2008

[PATCH] Porting: add a little script to find a perforce change

Thread Next
From:
Sam Vilain
Date:
June 16, 2008 03:59
Subject:
[PATCH] Porting: add a little script to find a perforce change
Message ID:
20080616105924.685D621C648@mail.utsl.gen.nz
Requested by Nicholas Clark
---
 Porting/git-find-p4-change |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100755 Porting/git-find-p4-change

diff --git a/Porting/git-find-p4-change b/Porting/git-find-p4-change
new file mode 100755
index 0000000..b777953
--- /dev/null
+++ b/Porting/git-find-p4-change
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+die "usage: $0 [git-log-options] num" unless @ARGV;
+
+my $num = 1;
+
+for (@ARGV) {
+	m{^\d+$} && (($change,$_) = ($_,undef));
+	m{^-\d+$} && (($num,$_) = (-$_,undef));
+}
+
+my $grep = "--grep=^p4raw-id:.*\@$change\$";
+@ARGV = grep { defined } @ARGV;
+
+if ( -t STDOUT or @ARGV ) {
+	system(qw(git log), $grep, "-$num", "--all", @ARGV);
+}
+else {
+	system(qw(git rev-list -1 --all), $grep);
+}
-- 
1.5.4.rc2.85.g7c8f5


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About