Skip to content

Commit 6327f0e

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 15f0028 commit 6327f0e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Documentation/git-branch.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SYNOPSIS
1616
[--points-at <object>] [--format=<format>]
1717
[(-r | --remotes) | (-a | --all)]
1818
[--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>]
2020
'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
2121
'git branch' --unset-upstream [<branchname>]
2222
'git branch' (-m | -M) [<oldbranch>] <newbranch>
@@ -206,7 +206,7 @@ This option is only applicable in non-verbose mode.
206206
Display the full sha1s in the output listing rather than abbreviating them.
207207

208208
-t::
209-
--track [inherit|direct]::
209+
--track[=(direct|inherit)]::
210210
When creating a new branch, set up `branch.<name>.remote` and
211211
`branch.<name>.merge` configuration entries to set "upstream" tracking
212212
configuration for the new branch. This
@@ -216,11 +216,11 @@ This option is only applicable in non-verbose mode.
216216
upstream when the new branch is checked out.
217217
+
218218
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.
222222
+
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.
224224
Set the branch.autoSetupMerge configuration variable to `false` if you
225225
want `git switch`, `git checkout` and `git branch` to always behave as if `--no-track`
226226
were given. Set it to `always` if you want this behavior when the

Documentation/git-checkout.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ of it").
156156
linkgit:git-branch[1] for details.
157157

158158
-t::
159-
--track [direct|inherit]::
159+
--track[=(direct|inherit)]::
160160
When creating a new branch, set up "upstream" configuration. See
161161
"--track" in linkgit:git-branch[1] for details.
162162
+

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
632632
OPT__VERBOSE(&filter.verbose,
633633
N_("show hash and subject, give twice for upstream branch")),
634634
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)",
636636
N_("set branch tracking configuration"),
637637
PARSE_OPT_OPTARG,
638638
parse_opt_tracking_mode),

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ static struct option *add_common_switch_branch_options(
15301530
{
15311531
struct option options[] = {
15321532
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)",
15341534
N_("set branch tracking configuration"),
15351535
PARSE_OPT_OPTARG,
15361536
parse_opt_tracking_mode),

0 commit comments

Comments
 (0)