Commit | Line | Data |
---|---|---|
92172b2b YD |
1 | #!/bin/bash |
2 | set -e | |
3 | ||
4 | # stg-mdiff - display meta-diffs, ie. diffs of diffs | |
5 | ||
6 | # Main use: show evolutions of a patch. | |
7 | # eg. stg-mdiff foo@stable foo | |
8 | # stg-mdiff foo 012345567ABCD # sha1 for "foo" as integrated upstream | |
9 | ||
10 | # Copyright (c) 2007 Yann Dirson <ydirson@altern.org> | |
11 | # Subject to the GNU GPL, version 2. | |
12 | ||
13 | usage() | |
14 | { | |
124f286c | 15 | echo "Usage: [-o <diff-flags>] [-O <gitdiff-flags>] $(basename $0) <from1>..[<to1>]|<patch1> <from2>..[<to2>]|<patch2>" |
92172b2b YD |
16 | exit 1 |
17 | } | |
18 | ||
124f286c YD |
19 | diffopts= |
20 | subdiffopts= | |
21 | while [ "$#" -gt 0 ]; do | |
22 | case "$1" in | |
23 | -o) diffopts="$2"; shift ;; | |
24 | -O) subdiffopts="-O $2"; shift ;; | |
25 | -*) usage ;; | |
26 | *) break ;; | |
27 | esac | |
28 | shift | |
29 | done | |
30 | ||
92172b2b YD |
31 | if [ "$#" != 2 ]; then |
32 | usage | |
33 | fi | |
34 | ||
124f286c YD |
35 | if [ -z "$diffopts" ]; then |
36 | diffopts="-u" | |
37 | fi | |
38 | ||
67e5c1c6 | 39 | case "$1" in |
124f286c YD |
40 | *..*) cmd1="stg diff $subdiffopts -r" ;; |
41 | *) cmd1="stg show $subdiffopts" ;; | |
67e5c1c6 YD |
42 | esac |
43 | case "$2" in | |
124f286c YD |
44 | *..*) cmd2="stg diff $subdiffopts -r" ;; |
45 | *) cmd2="stg show $subdiffopts" ;; | |
67e5c1c6 YD |
46 | esac |
47 | ||
124f286c | 48 | colordiff $diffopts \ |
f4fec498 YD |
49 | -I '^index [0-9a-b]*..[0-9a-b]*' \ |
50 | -I '^@@ .* @@' \ | |
124f286c | 51 | <($cmd1 "$1") <($cmd2 "$2") | less -RFX |