Skip to content

Commit 601b157

Browse files
committed
Merge branch 'jc/orphan-unborn'
Doc updates to clarify what an "unborn branch" means. * jc/orphan-unborn: orphan/unborn: fix use of 'orphan' in end-user facing messages orphan/unborn: add to the glossary and use them consistently
2 parents cce4778 + d44b517 commit 601b157

File tree

8 files changed

+30
-12
lines changed

8 files changed

+30
-12
lines changed

Documentation/config/advice.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ advice.*::
140140
Advice shown when a fast-forward is not possible.
141141
worktreeAddOrphan::
142142
Advice shown when a user tries to create a worktree from an
143-
invalid reference, to instruct how to create a new orphan
143+
invalid reference, to instruct how to create a new unborn
144144
branch instead.
145145
--

Documentation/git-checkout.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ variable.
217217
below for details.
218218

219219
--orphan <new-branch>::
220-
Create a new 'orphan' branch, named `<new-branch>`, started from
220+
Create a new unborn branch, named `<new-branch>`, started from
221221
`<start-point>` and switch to it. The first commit made on this
222222
new branch will have no parents and it will be the root of a new
223223
history totally disconnected from all the other branches and

Documentation/git-switch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ name, the guessing is aborted. You can explicitly give a name with
176176
`branch.autoSetupMerge` configuration variable is true.
177177

178178
--orphan <new-branch>::
179-
Create a new 'orphan' branch, named `<new-branch>`. All
179+
Create a new unborn branch, named `<new-branch>`. All
180180
tracked files are removed.
181181

182182
--ignore-other-worktrees::

Documentation/git-worktree.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ command will refuse to create the worktree (unless `--force` is used).
9999
If `<commit-ish>` is omitted, neither `--detach`, or `--orphan` is
100100
used, and there are no valid local branches (or remote branches if
101101
`--guess-remote` is specified) then, as a convenience, the new worktree is
102-
associated with a new orphan branch named `<branch>` (after
102+
associated with a new unborn branch named `<branch>` (after
103103
`$(basename <path>)` if neither `-b` or `-B` is used) as if `--orphan` was
104104
passed to the command. In the event the repository has a remote and
105105
`--guess-remote` is used, but no remote or local branches exist, then the
@@ -234,7 +234,7 @@ This can also be set up as the default behaviour by using the
234234

235235
--orphan::
236236
With `add`, make the new worktree and index empty, associating
237-
the worktree with a new orphan/unborn branch named `<new-branch>`.
237+
the worktree with a new unborn branch named `<new-branch>`.
238238

239239
--porcelain::
240240
With `list`, output in an easy-to-parse format for scripts.

Documentation/glossary-content.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ This commit is referred to as a "merge commit", or sometimes just a
314314
[[def_octopus]]octopus::
315315
To <<def_merge,merge>> more than two <<def_branch,branches>>.
316316

317+
[[def_orphan]]orphan::
318+
The act of getting on a <<def_branch,branch>> that does not
319+
exist yet (i.e., an <<def_unborn,unborn>> branch). After
320+
such an operation, the commit first created becomes a commit
321+
without a parent, starting a new history.
322+
317323
[[def_origin]]origin::
318324
The default upstream <<def_repository,repository>>. Most projects have
319325
at least one upstream project which they track. By default
@@ -697,6 +703,18 @@ The most notable example is `HEAD`.
697703
object,
698704
etc.
699705

706+
[[def_unborn]]unborn::
707+
The <<def_HEAD,HEAD>> can point at a <<def_branch,branch>>
708+
that does not yet exist and that does not have any commit on
709+
it yet, and such a branch is called an unborn branch. The
710+
most typical way users encounter an unborn branch is by
711+
creating a repository anew without cloning from elsewhere.
712+
The HEAD would point at the 'main' (or 'master', depending
713+
on your configuration) branch that is yet to be born. Also
714+
some operations can get you on an unborn branch with their
715+
<<def_orphan,orphan>> option.
716+
717+
700718
[[def_unmerged_index]]unmerged index::
701719
An <<def_index,index>> which contains unmerged
702720
<<def_index_entry,index entries>>.

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ static struct option *add_common_switch_branch_options(
16501650
parse_opt_tracking_mode),
16511651
OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"),
16521652
PARSE_OPT_NOCOMPLETE),
1653-
OPT_STRING(0, "orphan", &opts->new_orphan_branch, N_("new-branch"), N_("new unparented branch")),
1653+
OPT_STRING(0, "orphan", &opts->new_orphan_branch, N_("new-branch"), N_("new unborn branch")),
16541654
OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore,
16551655
N_("update ignored files (default)"),
16561656
PARSE_OPT_NOCOMPLETE),

builtin/worktree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
_("No possible source branch, inferring '--orphan'")
5050

5151
#define WORKTREE_ADD_ORPHAN_WITH_DASH_B_HINT_TEXT \
52-
_("If you meant to create a worktree containing a new orphan branch\n" \
52+
_("If you meant to create a worktree containing a new unborn branch\n" \
5353
"(branch with no commits) for this repository, you can do so\n" \
5454
"using the --orphan flag:\n" \
5555
"\n" \
5656
" git worktree add --orphan -b %s %s\n")
5757

5858
#define WORKTREE_ADD_ORPHAN_NO_DASH_B_HINT_TEXT \
59-
_("If you meant to create a worktree containing a new orphan branch\n" \
59+
_("If you meant to create a worktree containing a new unborn branch\n" \
6060
"(branch with no commits) for this repository, you can do so\n" \
6161
"using the --orphan flag:\n" \
6262
"\n" \
@@ -784,7 +784,7 @@ static int add(int ac, const char **av, const char *prefix)
784784
N_("create a new branch")),
785785
OPT_STRING('B', NULL, &new_branch_force, N_("branch"),
786786
N_("create or reset a branch")),
787-
OPT_BOOL(0, "orphan", &opts.orphan, N_("create unborn/orphaned branch")),
787+
OPT_BOOL(0, "orphan", &opts.orphan, N_("create unborn branch")),
788788
OPT_BOOL('d', "detach", &opts.detach, N_("detach HEAD at named commit")),
789789
OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")),
790790
OPT_BOOL(0, "lock", &keep_locked, N_("keep the new working tree locked")),

t/t2400-worktree-add.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ test_wt_add_orphan_hint () {
437437
git -C repo switch --orphan noref &&
438438
test_must_fail git -C repo worktree add $opts foobar/ 2>actual &&
439439
! grep "error: unknown switch" actual &&
440-
grep "hint: If you meant to create a worktree containing a new orphan branch" actual &&
440+
grep "hint: If you meant to create a worktree containing a new unborn branch" actual &&
441441
if [ $use_branch -eq 1 ]
442442
then
443443
grep -E "^hint: +git worktree add --orphan -b [^ ]+ [^ ]+$" actual
@@ -458,7 +458,7 @@ test_expect_success "'worktree add' doesn't show orphan hint in bad/orphan HEAD
458458
(cd repo && test_commit commit) &&
459459
test_must_fail git -C repo worktree add --quiet foobar_branch foobar/ 2>actual &&
460460
! grep "error: unknown switch" actual &&
461-
! grep "hint: If you meant to create a worktree containing a new orphan branch" actual
461+
! grep "hint: If you meant to create a worktree containing a new unborn branch" actual
462462
'
463463

464464
test_expect_success 'local clone from linked checkout' '
@@ -731,7 +731,7 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
731731
test_dwim_orphan () {
732732
local info_text="No possible source branch, inferring '--orphan'" &&
733733
local fetch_error_text="fatal: No local or remote refs exist despite at least one remote" &&
734-
local orphan_hint="hint: If you meant to create a worktree containing a new orphan branch" &&
734+
local orphan_hint="hint: If you meant to create a worktree containing a new unborn branch" &&
735735
local invalid_ref_regex="^fatal: invalid reference: " &&
736736
local bad_combo_regex="^fatal: options '[-a-z]*' and '[-a-z]*' cannot be used together" &&
737737

0 commit comments

Comments
 (0)