mirror of
https://github.com/git/git
synced 2024-08-28 03:59:25 +00:00
git-jump: move valid-mode check earlier
We check if the "mode" argument supplied by the user is valid by seeing if we have a mode_$mode function defined. But we don't do that until after creating the tempfile. This is wasteful (we create a tempfile but never use it), and makes it harder to add new options (the recent stdout option exits before creating the tempfile, so it misses the check and "git jump --stdout foo" will produce "git-jump: 92: mode_foo: not found" rather than the regular usage message). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
cfb7b3b391
commit
64685cb855
|
@ -88,6 +88,8 @@ if test $# -lt 1; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mode=$1; shift
|
mode=$1; shift
|
||||||
|
type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
|
||||||
|
|
||||||
if test "$use_stdout" = "t"; then
|
if test "$use_stdout" = "t"; then
|
||||||
"mode_$mode" "$@"
|
"mode_$mode" "$@"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -95,7 +97,6 @@ fi
|
||||||
|
|
||||||
trap 'rm -f "$tmp"' 0 1 2 3 15
|
trap 'rm -f "$tmp"' 0 1 2 3 15
|
||||||
tmp=`mktemp -t git-jump.XXXXXX` || exit 1
|
tmp=`mktemp -t git-jump.XXXXXX` || exit 1
|
||||||
type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
|
|
||||||
"mode_$mode" "$@" >"$tmp"
|
"mode_$mode" "$@" >"$tmp"
|
||||||
test -s "$tmp" || exit 0
|
test -s "$tmp" || exit 0
|
||||||
open_editor "$tmp"
|
open_editor "$tmp"
|
||||||
|
|
Loading…
Reference in a new issue