aboutsummaryrefslogtreecommitdiff
path: root/src/tools/git-external-diff
blob: 59fa36624c7c4911f11d09b0b273e87f9074da8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

# This script is used to produce git context diffs

# Supplied parameters:
# $1   $2       $3       $4       $5       $6       $7
# path old-file old-hash old-mode new-file new-hash new-mode
# 'path' is the git-tree-relative path of the file being diff'ed

old_hash="$3"
new_hash=$(git hash-object "$5")

# no change?
[ "$old_hash" = "$new_hash" ] && exit 0

[ "$DIFF_OPTS" = "" ] && DIFF_OPTS='-pcd'

echo "diff --git a/$1 b/$1"
echo "new file mode $7"
echo "index ${old_hash:0:7}..${new_hash:0:7}"

diff --label a/"$1" --label b/"$1" $DIFF_OPTS "$2" "$5"

exit 0