-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitdiff
More file actions
executable file
·49 lines (41 loc) · 1.1 KB
/
gitdiff
File metadata and controls
executable file
·49 lines (41 loc) · 1.1 KB
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
#!/bin/sh
#it just insert a nouse value,
#beacuse the git config --unset value do not delete the section,if the section do not have items.
git config --global diff.nouse 0
diffTool=diffmerge
diffParameter=$1
#if [ $1 = "-c" ]; then
#diffParameter="--cached"
#else
#diffParameter=""
#fi
oldDiff=`git config --global diff.external`
echo 'oldDiff' $oldDiff
diffDirNum=0
diffDir="/tmp/gitDiff"${diffDirNum}
while [ -d "$diffDir" ] ; do
diffDirNum=`expr ${diffDirNum} + 1`
diffDir="/tmp/gitDiff"${diffDirNum}
done
#diffDir=${diffDir}${diffDirNum}
echo 'diffDir :' ${diffDir}
export diffDir
oldDir="old"
newDir="new"
export oldDir
export newDir
mkdir -p ${diffDir}/$oldDir
mkdir -p ${diffDir}/$newDir
newDiff='gitMyDiff'
git config --global diff.external /usr/local/bin/$newDiff
echo 'curDiff :' `git config --global diff.external`
git diff $diffParameter
if [ $oldDiff ]; then
git config --global diff.external $oldDiff
else
git config --global --unset diff.external
fi
echo 'curDiff :' `git config --global diff.external`
$diffTool ${diffDir}/$oldDir ${diffDir}/$newDir
rm -rf $diffDir
echo 'gitdiff finish'