forked from cncf/gitdm.archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-lfs-diff.sh
executable file
·52 lines (42 loc) · 905 Bytes
/
git-lfs-diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
if [ $# -ne 3 ] ; then
echo "Usage: $0 <ref> <ref> <filename>"
exit 1
fi
RevA=$1
RevB=$2
File=$3
object() {
Rev=$1
File=$2
Object=""
if [ "$Rev" = "." ]; then
echo "$File"
return
fi
Oid=$(git show $Rev:$File 2> /dev/null | grep "sha256" | cut -d ":" -f 2)
if [ "$Oid" != "" ]; then
Oid12=$(echo $Oid | cut -b 1-2)
Oid34=$(echo $Oid | cut -b 3-4)
Object=.git/lfs/objects/$Oid12/$Oid34/$Oid
if [ ! -e "$Object" ]; then
echo "Missing file $File at revision $Rev"
exit 2
fi
fi
echo "$Object"
}
ObjectA=$(object $RevA $File)
EC="$?"
if [ "$EC" != "0" ]; then
echo "$ObjectA"
exit "$EC"
fi
ObjectB=$(object $RevB $File)
EC="$?"
if [ "$EC" != "0" ]; then
echo "$ObjectB"
exit "$EC"
fi
echo "diff -urN $ObjectA $ObjectB"
diff -urN "$ObjectA" "$ObjectB"