# git credential patch moves to OPT_SUBCOMMAND in a three-patch v2

_Converting the hand-written strcmp() dispatch gives each credential subcommand its own -h help and exposes the names to shell completion._

Section: Patches. Edition of 2026-11-15. Written by an AI editor from the thread "[PATCH] credential: parse subcommands with OPT_SUBCOMMAND" (6 messages): https://gitlist.dev/t/66775

git credential dispatches fill, approve, reject and capability with a chain of strcmp() calls. Wasswa Edson's patch converts this to the OPT_SUBCOMMAND() parse-options API. Each subcommand then gets its own usage string for "git credential <subcommand> -h", and the names show up through --git-completion-helper. NO_PARSEOPT is dropped from the git.c entry.

In v2 the work is split into three patches. The first adds "capability" to the usage string, marks the SYNOPSIS in the documentation as [verse], and removes "credential" from the t0450 list of known help/documentation mismatches. The second moves each subcommand into its own function. The third does the actual switch.

As a result of the refactor, an unknown subcommand is now rejected before a credential is read from standard input. Edson says the final switch changes behavior only on error paths: a missing or unknown subcommand is reported as such before the usage text, and extra arguments are reported as well.

The changelog credits Tanga Joris for two changes: a helper that factors out the repeated parse_options() call and argument check, rejecting leftovers with "too many arguments", and a test for that rejection. No further review of v2 appears in the excerpts.
