chiark / gitweb /
Add to stg-mdiff the ability to pass options to underlying diff opts.
[stgit] / contrib / stg-whatchanged
CommitLineData
a3e45643
YD
1#!/bin/bash
2set -e
3
4# stg-whatchanged - show a metadiff for the patch being modified,
5# especially when resolving a merge.
6
7# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
8# Subject to the GNU GPL, version 2.
9
10# FIXME:
11# - should only exclude hunk headers differing only in line offsets
12# - diff coloring should show changes in context lines differently than
13# changes in contents
14# - filter on ^index lines is a bit wide
15# - we should be able to ask diff to force a new hunk on "^@@ " to better
16# handle them
17# - we should always show the hunk header for any changes within a hunk
18
19# default to unified diff
20if [ "$#" = 0 ]; then
21 set -- -u
22fi
23
24# Merges via "push" leave top=bottom so we must look at old patch
25# in this case (unlike, eg., "pick --fold")
b778633b 26patchdir="$(git-rev-parse --git-dir)/patches/$(stg branch)/patches/$(stg top)"
af27af8e
YD
27case $(stg log | head -n1) in
28 *push\(c\)*) current_cmd="stg show //top.old" ;;
29 *) current_cmd="stg show" ;;
30esac
a3e45643
YD
31
32colordiff "$@" \
33 -I '^index [0-9a-b]*..[0-9a-b]*' \
34 -I '^@@ .* @@' \
35 <($current_cmd) <(stg diff -r//bottom) | less -RFX