std.c: Don't use `EXIT_SUCCESS`/`EXIT_FAILURE` as function return values
[sunny256-utils.git] / git-context-diff
blob8614403d861871ada852092b4b8a1fdb1b131617
1 #!/usr/bin/env bash
3 # This script is used to produce git context diffs
5 # Supplied parameters:
6 # $1 $2 $3 $4 $5 $6 $7
7 # path old-file old-hash old-mode new-file new-hash new-mode
8 # 'path' is the git-tree-relative path of the file being diff'ed
10 old_hash="$3"
11 new_hash=$(git hash-object "$5")
13 # no change?
14 [ "$old_hash" = "$new_hash" ] && exit 0
16 [ "$DIFF_OPTS" = "" ] && DIFF_OPTS='-pcd'
18 echo "diff --git a/$1 b/$1"
19 echo "new file mode $7"
20 echo "index ${old_hash:0:7}..${new_hash:0:7}"
22 diff --label a/"$1" --label b/"$1" $DIFF_OPTS "$2" "$5"
24 exit 0