-
Notifications
You must be signed in to change notification settings - Fork 7
/
git-debug
executable file
·169 lines (161 loc) · 3.96 KB
/
git-debug
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env bash
set -euo pipefail
YP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
source ${YP_DIR}/sh/common.inc.sh
#- git-debug 1.0
## Usage: git-debug [OPTION] -- GIT_COMMAND ARGS...
## Debug execution of a git command.
## Verbosely by default. SSH and tracing can be optionally enabled.
##
## --curl
## --curl v
## --curl vv
## --fsmonitor
## --no-redact
## --packet
## --pack-access
## --performance
## --refs
## --setup
## --shallow
## --trace
##
## --ssh
## --ssh v
## --ssh vv
## --ssh vvv
##
## --trace2
## --trace2-event
## --trace2-perf
##
## -h, --help Display this help and exit
## -v, --version Output version information and exit
GIT_SSH_COMMAND=
export GIT_TRACE=false
export GIT_TRACE_CURL=false
export GIT_TRACE_CURL_NO_DATA=true
export GIT_TRACE_FSMONITOR=false
export GIT_TRACE_PACKET=false
export GIT_TRACE_PACK_ACCESS=false
export GIT_TRACE_PERFORMANCE=false
export GIT_TRACE_REDACT=1
export GIT_TRACE_REFS=false
export GIT_TRACE_SETUP=false
export GIT_TRACE_SHALLOW=false
export GIT_TRACE2=false
export GIT_TRACE2_EVENT=false
export GIT_TRACE2_PERF=false
if { getopt --test >/dev/null 2>&1 && false; } || [[ "$?" = "4" ]] || false; then
ARGS=$(getopt -o hv -l help,version,curl::,fsmonitor,no-redact,packet,pack-access,performance,refs,setup,shallow,ssh::,trace,trace2,trace2-event,trace2-perf, -n $(basename ${BASH_SOURCE[0]}) -- "$@") || sh_script_usage # editorconfig-checker-disable-line
eval set -- "${ARGS}"
fi
while [[ $# -gt 0 ]]; do
case "$1" in
--curl)
GIT_TRACE=true
GIT_TRACE_CURL=true
case $2 in
v)
shift 2
;;
vv)
GIT_TRACE_CURL_NO_DATA=false
shift 2
;;
*)
shift
;;
esac
;;
--fsmonitor)
GIT_TRACE=true
GIT_TRACE_FSMONITOR=true
shift
;;
--no-redact)
GIT_TRACE_REDACT=0
shift
;;
--packet)
GIT_TRACE=true
GIT_TRACE_PACKET=true
shift
;;
--pack-access)
GIT_TRACE=true
GIT_TRACE_PACK_ACCESS=true
shift
;;
--performance)
GIT_TRACE=true
GIT_TRACE_PERFORMANCE=true
shift
;;
--refs)
GIT_TRACE=true
GIT_TRACE_REFS=true
shift
;;
--setup)
GIT_TRACE=true
GIT_TRACE_SETUP=true
shift
;;
--shallow)
GIT_TRACE=true
GIT_TRACE_SHALLOW=true
shift
;;
--ssh)
export GIT_SSH_COMMAND="ssh -v"
case $2 in
v|vv|vvv)
export GIT_SSH_COMMAND="ssh -$2"
shift 2
;;
*)
shift
;;
esac
;;
--trace)
GIT_TRACE=true
shift
;;
--trace2)
GIT_TRACE2=true
shift
;;
--trace2-event)
GIT_TRACE2=true
GIT_TRACE2_EVENT=true
shift
;;
--trace2-perf)
GIT_TRACE2=true
GIT_TRACE2_PERF=true
shift
;;
-h|--help)
sh_script_usage
;;
-v|--version)
sh_script_version
;;
--)
shift
break
;;
-*)
sh_script_usage
;;
*)
break
;;
esac
done
# [[ $# -eq 0 ]] || sh_script_usage
GIT_ENV="$(printenv | grep -e "^GIT_TRACE=" -e "^GIT_TRACE_" -e "^GIT_SSH_COMMAND=" | tr "\n" " ")"
echo_info "${GIT_ENV} git $1 -v ${*:2}"
git $1 -v "${@:2}"