Override "p4 diff" to handle change numbers.
authorIain Patterson <me@iain.cx>
Sat, 16 Apr 2011 11:43:00 +0000 (12:43 +0100)
committerIain Patterson <me@iain.cx>
Mon, 27 Jan 2014 14:50:15 +0000 (14:50 +0000)
Wrapper around "p4 diff" which detects use of the -c flag and calls
p4-diffchange, thus enabling uses such as "p4 diff -c 12345" which will
show diffs only for files opened in changelist 12345.

opt/p4/p4-diff [new file with mode: 0755]

diff --git a/opt/p4/p4-diff b/opt/p4/p4-diff
new file mode 100755 (executable)
index 0000000..2ecc0d5
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. ${0%/*}/common
+
+function parse_change() {
+  while getopts ":c:" opt; do
+    case $opt in
+      c) echo $OPTARG;;
+    esac
+  done
+}
+
+if [ -n "$(parse_change $*)" ]; then
+  exec ${0%/*}/p4-diffchange $p4opts diffchange ${1+"$@"}
+else
+  exec p4 $p4opts $p4command ${1+"$@"}
+fi