3 # Show differences between $1 and $2 with selection
14 git diff --no-prefix $* 2>/dev/null | \
15 csplit -z -b %04d -f $TMP/hunk# - "/^diff --git/" "{*}" > /dev/null
17 if [ ! -f $TMP/hunk#0000 ] ; then
22 LIST=( ${(f)"$(head -qn1 $TMP/* 2>/dev/null | awk '{print "<s>" $3;}')"} )
24 if [ -z "$LIST" ] ; then
25 read 'x?Nothing to show. Push enter'
29 # translate a given selection index, if for a submodule, into the
30 # commit ids for the submodule
31 function submodule_delta() {
32 # Determine which diff-hunk is selected
33 HUNK="$(grep -lF "diff --git $1 " $TMP/* )"
34 # If the hunk ends with "+Subproject commit ", then it's a sub project
35 tail -n 2 $HUNK | grep "^.Subproject commit " | sed 's/.* //'
38 PROJECT="$(git rev-parse --show-toplevel| sed 's/.*\///')"
39 if [ -n "$FOCUS" ] ; then
40 # point at the focused item
41 LAST=${$(echo "${(F)LIST}" | grep -nF "<s>$FOCUS")%%:*}
43 [ -z "$LAST" ] && LAST=1
45 X="$(iselect -f -n "git-show-i" -K -t "$PROJECT: commit $1" -p $LAST \
48 LAST=${$(echo "${(F)LIST}" | grep -nF "<s>${X#*:}")%%:*}
52 [ "${X#*:}" = Done ] && exit 0
53 # If the selection is a sub module, then use git-show-i
54 # recursively for the submodule versions
55 SUBS=( $(submodule_delta "${X#*:}" ) )
56 if [ -z "$SUBS" ] ; then
57 #git meld $* -- "${X#*:}"
58 git-differ $* -- "${X#*:}"
60 ( cd ${X#*:} ; $0 $SUBS )