diff options
author | Matthieu Moy <Matthieu.Moy@imag.fr> | 2015-06-29 17:40:32 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-08-03 11:42:42 -0700 |
commit | fe67687bb1b38cbbdca4339caf14136b33e04783 (patch) | |
tree | 869cc93067f39a32772f318abd565a107dbd190e /git-bisect.sh | |
parent | 4a6ada32cb64b0eba8b6f995e4230f0c722fd580 (diff) | |
download | git-fe67687bb1b38cbbdca4339caf14136b33e04783.tar.gz |
bisect: sanity check on terms
This is currently only a defensive check since the only terms are
bad/good and new/old, which pass it, but this is a preparation step for
accepting user-supplied terms.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-bisect.sh')
-rwxr-xr-x | git-bisect.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/git-bisect.sh b/git-bisect.sh index ea63223ab3..761ca6cca0 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -535,9 +535,42 @@ get_terms () { write_terms () { TERM_BAD=$1 TERM_GOOD=$2 + if test "$TERM_BAD" = "$TERM_GOOD" + then + die "$(gettext "please use two different terms")" + fi + check_term_format "$TERM_BAD" bad + check_term_format "$TERM_GOOD" good printf '%s\n%s\n' "$TERM_BAD" "$TERM_GOOD" >"$GIT_DIR/BISECT_TERMS" } +check_term_format () { + term=$1 + git check-ref-format refs/bisect/"$term" || + die "$(eval_gettext "'\$term' is not a valid term")" + case "$term" in + help|start|terms|skip|next|reset|visualize|replay|log|run) + die "$(eval_gettext "can't use the builtin command '\$term' as a term")" + ;; + bad|new) + if test "$2" != bad + then + # In theory, nothing prevents swapping + # completely good and bad, but this situation + # could be confusing and hasn't been tested + # enough. Forbid it for now. + die "$(eval_gettext "can't change the meaning of term '\$term'")" + fi + ;; + good|old) + if test "$2" != good + then + die "$(eval_gettext "can't change the meaning of term '\$term'")" + fi + ;; + esac +} + check_and_set_terms () { cmd="$1" case "$cmd" in |