chiark / gitweb /
Add to stg-mdiff the ability to pass options to underlying diff opts.
authorYann Dirson <yann.dirson@sagem.com>
Tue, 24 Jul 2007 18:57:41 +0000 (20:57 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 24 Jul 2007 22:48:57 +0000 (23:48 +0100)
So we now have -O, similar to the existing option in stg diff, to pass
flags to git-diff when computing the 2 diffs to compare (-M, -C and -w
come to mind as being potentially useful here), and -o can be used to
tune the invocation of diff on those 2 diffs.

Note that -o is only there temporarily, and will disappear when a more
sophisticated process than plain diff will be used.

Signed-off-by: Yann Dirson <ydirson@altern.org>
contrib/stg-mdiff

index 9bb324a709780024bdf6caa9298668a345785656..61cba9e1639ef8b8198381b98fa2cb3efd854cfd 100755 (executable)
@@ -12,21 +12,38 @@ set -e
 
 usage()
 {
-    echo "Usage: $(basename $0) <from1>..[<to1>]|<patch1> <from2>..[<to2>]|<patch2>"
+    echo "Usage: [-o <diff-flags>] [-O <gitdiff-flags>] $(basename $0) <from1>..[<to1>]|<patch1> <from2>..[<to2>]|<patch2>"
     exit 1
 }
 
+diffopts=
+subdiffopts=
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+       -o) diffopts="$2"; shift ;;
+       -O) subdiffopts="-O $2"; shift ;;
+       -*) usage ;;
+       *) break ;;
+    esac
+    shift
+done
+
 if [ "$#" != 2 ]; then
     usage
 fi
 
+if [ -z "$diffopts" ]; then
+    diffopts="-u"
+fi
+
 case "$1" in
-*..*) cmd1="stg diff" ;;
-*)    cmd1="stg show" ;;
+*..*) cmd1="stg diff $subdiffopts -r" ;;
+*)    cmd1="stg show $subdiffopts" ;;
 esac
 case "$2" in
-*..*) cmd2="stg diff" ;;
-*)    cmd2="stg show" ;;
+*..*) cmd2="stg diff $subdiffopts -r" ;;
+*)    cmd2="stg show $subdiffopts" ;;
 esac
 
-colordiff -u <($cmd1 "$1") <($cmd2 "$2") | less -RFX
+colordiff $diffopts \
+    <($cmd1 "$1") <($cmd2 "$2") | less -RFX