File tree Expand file tree Collapse file tree 1 file changed +61
-4
lines changed Expand file tree Collapse file tree 1 file changed +61
-4
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/sh
1
+ #! /usr/bin/env sh
2
+
3
+ # Git graph-diff tool.
4
+ # GIT_EXTERNAL_DIFF command line arguments are available <here>
5
+
6
+ set -eu
7
+
8
+ readonly SCRIPT_DIR=$( dirname $( readlink -f $0 ) )
9
+ readonly SCRIPT=$( basename $( readlink -f $0 ) )
10
+
11
+ perror ()
12
+ {
13
+ echo " ${SCRIPT} : ERROR: ${@ } " >&2
14
+ exit 1
15
+ }
16
+
17
+ help ()
18
+ {
19
+ (
20
+ cat << EOF
21
+ Git graph-diff tool.
22
+ See GIT_EXTERNAL_DIFF documentation for explanation of the arguments.
23
+
24
+ ./${SCRIPT} [-h] [-x] PATH OLD-FILE OLD-HEX OLD-MODE NEW-FILE NEW-HEX NEW-MODE
25
+ | * -h - print this help.
26
+ | * -x - set bash's -x flag.
27
+ EOF
28
+ ) | sed -r ' s/^\s*\|?//'
29
+ }
30
+
31
+ while getopts " :hx" option
32
+ do
33
+ case " ${option} " in
34
+ h) help
35
+ exit 0
36
+ ;;
37
+
38
+ x) set -x
39
+ ;;
40
+
41
+ \? ) perror " unknown option -${OPTARG} "
42
+ ;;
43
+ esac
44
+ done
45
+ shift $(( OPTIND- 1 ))
46
+
47
+ # validate number of arguments left
48
+ if [ " ${# } " -ne 7 ]
49
+ then
50
+ perror " Invalid number of arguments (use -h for help)."
51
+ fi
52
+
53
+ path=" ${1} "
54
+ old_file=" ${2} "
55
+ old_hex=" ${3} "
56
+ old_mode=" ${4} "
57
+ new_file=" ${5} "
58
+ new_hex=" ${6} "
59
+ new_mode=" ${7} "
60
+
61
+ python -m graphdiff " ${old_file} " " ${new_file} " | ${SCRIPT_DIR} /diff-graph-color
2
62
3
- script_name=$0
4
- script_dir=$( dirname " $0 " )
5
- python -m graphdiff $2 $5 | $script_dir /diff-graph-color
You can’t perform that action at this time.
0 commit comments