Skip to content

Commit 89753dc

Browse files
committed
Merge branch 'en/git-debugger'
Dev support. * en/git-debugger: Make running git under other debugger-like programs easy
2 parents 41267e9 + 8424364 commit 89753dc

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

t/test-lib-functions.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,28 @@ test_pause () {
145145
"$SHELL_PATH" <&6 >&5 2>&7
146146
}
147147

148-
# Wrap git in gdb. Adding this to a command can make it easier to
149-
# understand what is going on in a failing test.
148+
# Wrap git with a debugger. Adding this to a command can make it easier
149+
# to understand what is going on in a failing test.
150150
#
151-
# Example: "debug git checkout master".
151+
# Examples:
152+
# debug git checkout master
153+
# debug --debugger=nemiver git $ARGS
154+
# debug -d "valgrind --tool=memcheck --track-origins=yes" git $ARGS
152155
debug () {
153-
GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7
156+
case "$1" in
157+
-d)
158+
GIT_DEBUGGER="$2" &&
159+
shift 2
160+
;;
161+
--debugger=*)
162+
GIT_DEBUGGER="${1#*=}" &&
163+
shift 1
164+
;;
165+
*)
166+
GIT_DEBUGGER=1
167+
;;
168+
esac &&
169+
GIT_DEBUGGER="${GIT_DEBUGGER}" "$@" <&6 >&5 2>&7
154170
}
155171

156172
# Call test_commit with the arguments

wrap-for-bin.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
2020

2121
export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
2222

23-
if test -n "$GIT_TEST_GDB"
24-
then
25-
unset GIT_TEST_GDB
26-
exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
27-
else
23+
case "$GIT_DEBUGGER" in
24+
'')
2825
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
29-
fi
26+
;;
27+
1)
28+
unset GIT_DEBUGGER
29+
exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
30+
;;
31+
*)
32+
GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
33+
unset GIT_DEBUGGER
34+
exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
35+
;;
36+
esac

0 commit comments

Comments
 (0)