Wrapper to use custom p4 scripts.
[profile.git] / opt / p4 / p4-diffchange
diff --git a/opt/p4/p4-diffchange b/opt/p4/p4-diffchange
new file mode 100755 (executable)
index 0000000..e6cd52e
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+. ${0%/*}/common
+
+diffopts=
+change=
+while [ $# -gt 0 ]; do
+  case "$1" in
+    -c) change="$2"; shift;;
+    -d[blnsw]|-f|-t|-s[abdelr]) diffopts="$diffopts $1";;
+    -dc)
+      diffopts="$diffopts $1";
+      if [ -n "$2" -a -z "${2//[0-9]/}" ]; then
+        diffopts="$diffopts $2"
+        shift
+      fi
+    ;;
+    -m)
+      diffopts="$diffopts $1 $2"
+      shift
+    ;;
+    *) break;;
+  esac
+  shift
+done
+
+if [ -z "$change" ]; then
+  change="${1:-default}"; shift
+fi
+
+files=$(p4 $p4opts opened -c "$change" ${1+"$@"} | sed 's/#.*//')
+[ -n "$files" ] && p4 $p4opts diff $diffopts $files