summaryrefslogtreecommitdiff
path: root/Porting/git-find-p4-change
diff options
context:
space:
mode:
authorSam Vilain <sam@vilain.net>2008-06-16 23:02:43 +1200
committerSam Vilain <sam@vilain.net>2008-12-19 14:35:35 +1300
commit1a95a0fc1d08604e251c0f7ff5da9078aec9eaa7 (patch)
treee26bdcf97d3194d1020f76d4f39b43f3869fb127 /Porting/git-find-p4-change
parentfb063f91dc7f31f7c1489f10462283ee145673d0 (diff)
downloadperl-1a95a0fc1d08604e251c0f7ff5da9078aec9eaa7.tar.gz
Porting: add a little script to find a perforce change
Requested by Nicholas Clark
Diffstat (limited to 'Porting/git-find-p4-change')
-rwxr-xr-xPorting/git-find-p4-change20
1 files changed, 20 insertions, 0 deletions
diff --git a/Porting/git-find-p4-change b/Porting/git-find-p4-change
new file mode 100755
index 0000000000..b77795355f
--- /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);
+}