branch,checkout: fix --track documentation

Document that the accepted variants of the --track option are --track, --track=direct, and --track=inherit. The equal sign in the latter two cannot be replaced with whitespace; in general optional arguments need to be attached firmly to their option. Put "direct" consistently before "inherit", if only for the reasons that the former is the default, explained first in the documentation, and comes before the latter alphabetically. Mention both modes in the short help so that readers don't have to look them up in the full documentation. They are literal strings and thus untranslatable. PARSE_OPT_LITERAL_ARGHELP is inferred due to the pipe and parenthesis characters, so we don't have to provide that flag explicitly. Mention that -t has the same effect as --track and --track=direct. There is no way to specify inherit mode using the short option, because short options generally don't accept optional arguments. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jan 20, 2022 at 13:35 UTC 6327f0efed36c64d98a140110171362b7cb75a52
4 files changed +9 -9
Documentation/git-branch.txt
+6 -6
@@ -16,7 +16,7 @@ SYNOPSIS
16 [--points-at <object>] [--format=<format>]
17 [(-r | --remotes) | (-a | --all)]
18 [--list] [<pattern>...]
19 -'git branch' [--track [direct|inherit] | --no-track] [-f] <branchname> [<start-point>]
19 +'git branch' [--track[=(direct|inherit)] | --no-track] [-f] <branchname> [<start-point>]
20 'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
21 'git branch' --unset-upstream [<branchname>]
22 'git branch' (-m | -M) [<oldbranch>] <newbranch>
@@ -206,7 +206,7 @@ This option is only applicable in non-verbose mode.
206 Display the full sha1s in the output listing rather than abbreviating them.
207
208 -t::
209 ---track [inherit|direct]::
209 +--track[=(direct|inherit)]::
210 When creating a new branch, set up `branch.<name>.remote` and
211 `branch.<name>.merge` configuration entries to set "upstream" tracking
212 configuration for the new branch. This
@@ -216,11 +216,11 @@ This option is only applicable in non-verbose mode.
216 upstream when the new branch is checked out.
217 +
218 The exact upstream branch is chosen depending on the optional argument:
219 -`--track` or `--track direct` means to use the start-point branch itself as the
220 -upstream; `--track inherit` means to copy the upstream configuration of the
221 -start-point branch.
219 +`-t`, `--track`, or `--track=direct` means to use the start-point branch
220 +itself as the upstream; `--track=inherit` means to copy the upstream
221 +configuration of the start-point branch.
222 +
223 -`--track direct` is the default when the start point is a remote-tracking branch.
223 +`--track=direct` is the default when the start point is a remote-tracking branch.
224 Set the branch.autoSetupMerge configuration variable to `false` if you
225 want `git switch`, `git checkout` and `git branch` to always behave as if `--no-track`
226 were given. Set it to `always` if you want this behavior when the
Documentation/git-checkout.txt
+1 -1
@@ -156,7 +156,7 @@ of it").
156 linkgit:git-branch[1] for details.
157
158 -t::
159 ---track [direct|inherit]::
159 +--track[=(direct|inherit)]::
160 When creating a new branch, set up "upstream" configuration. See
161 "--track" in linkgit:git-branch[1] for details.
162 +
builtin/branch.c
+1 -1
@@ -632,7 +632,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
632 OPT__VERBOSE(&filter.verbose,
633 N_("show hash and subject, give twice for upstream branch")),
634 OPT__QUIET(&quiet, N_("suppress informational messages")),
635 - OPT_CALLBACK_F('t', "track", &track, N_("mode"),
635 + OPT_CALLBACK_F('t', "track", &track, "(direct|inherit)",
636 N_("set branch tracking configuration"),
637 PARSE_OPT_OPTARG,
638 parse_opt_tracking_mode),
builtin/checkout.c
+1 -1
@@ -1530,7 +1530,7 @@ static struct option *add_common_switch_branch_options(
1530 {
1531 struct option options[] = {
1532 OPT_BOOL('d', "detach", &opts->force_detach, N_("detach HEAD at named commit")),
1533 - OPT_CALLBACK_F('t', "track", &opts->track, N_("mode"),
1533 + OPT_CALLBACK_F('t', "track", &opts->track, "(direct|inherit)",
1534 N_("set branch tracking configuration"),
1535 PARSE_OPT_OPTARG,
1536 parse_opt_tracking_mode),