bisect--helper: rewrite `check_term_format` shell function in C
[gitweb.git] / git-bisect.sh
index ae3cb013e7d5679bc4c63fe4cea35d40167178c5..a727c59250f13b08ccbc559f50b0c1c60a3dc2ba 100755 (executable)
@@ -564,38 +564,11 @@ write_terms () {
        then
                die "$(gettext "please use two different terms")"
        fi
-       check_term_format "$TERM_BAD" bad
-       check_term_format "$TERM_GOOD" good
+       git bisect--helper --check-term-format "$TERM_BAD" bad || exit
+       git bisect--helper --check-term-format "$TERM_GOOD" good || exit
        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