Compare
2e8a9d94b009c69628e29bc7c50d9a3fc12e14ba..ec602484bd9f265a6eb2dd211d066e1116d61cfc
doc: datamodel: link to the glossary
We linked from the glossary to the data model page in the last commit. It can also be useful to link the other way for readers who might want to reference more terminology. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kristoffer Haugsbakk <code@khaugsbakk.name> · 2026-09-05 17:28 UTC · committed by Junio C Hamano
7 files changed,
+43
−38
- Documentation/git.adoc
- Documentation/gitdatamodel.adoc
- Documentation/gitglossary.adoc
- Documentation/glossary-content.adoc
- builtin/worktree.c
- command-list.txt
- t/t2400-worktree-add.sh
modified Documentation/git.adoc
| @@ -25,7 +25,8 @@ and full access to internals. | |||
| 25 | 25 | See linkgit:gittutorial[7] to get started, then see | |
| 26 | 26 | linkgit:giteveryday[7] for a useful minimum set of | |
| 27 | 27 | commands. The link:user-manual.html[Git User's Manual] has a more | |
| 28 | - | in-depth introduction. | |
| 28 | + | in-depth introduction. See linkgit:gitdatamodel[7] if you want to | |
| 29 | + | learn about the data model and important terminology. | |
| 29 | 30 | ||
| 30 | 31 | After you mastered the basic concepts, you can come back to this | |
| 31 | 32 | page to learn what commands Git offers. You can learn more about | |
| @@ -469,7 +470,9 @@ Higher level SCMs may provide and manage additional information in the | |||
| 469 | 470 | ||
| 470 | 471 | Terminology | |
| 471 | 472 | ----------- | |
| 472 | - | Please see linkgit:gitglossary[7]. | |
| 473 | + | Please see linkgit:gitglossary[7]. See linkgit:gitdatamodel[7] for a | |
| 474 | + | discussion of the core data model, which includes important terminology | |
| 475 | + | used throughout the documentation. | |
| 473 | 476 | ||
| 474 | 477 | ||
| 475 | 478 | Environment Variables | |
| @@ -1199,8 +1202,9 @@ SEE ALSO | |||
| 1199 | 1202 | -------- | |
| 1200 | 1203 | linkgit:gittutorial[7], linkgit:gittutorial-2[7], | |
| 1201 | 1204 | linkgit:giteveryday[7], linkgit:gitcvs-migration[7], | |
| 1202 | - | linkgit:gitglossary[7], linkgit:gitcore-tutorial[7], | |
| 1203 | - | linkgit:gitcli[7], link:user-manual.html[The Git User's Manual], | |
| 1205 | + | linkgit:gitglossary[7], linkgit:gitdatamodel[7], | |
| 1206 | + | linkgit:gitcore-tutorial[7], linkgit:gitcli[7], | |
| 1207 | + | link:user-manual.html[The Git User's Manual], | |
| 1204 | 1208 | linkgit:gitworkflows[7] | |
| 1205 | 1209 | ||
| 1206 | 1210 | GIT | |
modified Documentation/gitdatamodel.adoc
| @@ -300,6 +300,10 @@ $ git reflog main --date=iso --no-decorate | |||
| 300 | 300 | 4ccb6d7 main@{2025-09-29 15:16:48 -0400}: commit (initial): Initial commit | |
| 301 | 301 | ---- | |
| 302 | 302 | ||
| 303 | + | SEE ALSO | |
| 304 | + | -------- | |
| 305 | + | linkgit:gitglossary[7] | |
| 306 | + | ||
| 303 | 307 | GIT | |
| 304 | 308 | --- | |
| 305 | 309 | Part of the linkgit:git[1] suite | |
modified Documentation/gitglossary.adoc
| @@ -16,6 +16,7 @@ include::glossary-content.adoc[] | |||
| 16 | 16 | ||
| 17 | 17 | SEE ALSO | |
| 18 | 18 | -------- | |
| 19 | + | linkgit:gitdatamodel[7], | |
| 19 | 20 | linkgit:gittutorial[7], | |
| 20 | 21 | linkgit:gittutorial-2[7], | |
| 21 | 22 | linkgit:gitcvs-migration[7], | |
modified Documentation/glossary-content.adoc
| @@ -251,7 +251,8 @@ for a more flexible and robust system to do the same thing. | |||
| 251 | 251 | as objects. The index is a stored version of your | |
| 252 | 252 | <<def_working_tree,working tree>>. Truth be told, it can also contain a second, and even | |
| 253 | 253 | a third version of a working tree, which are used | |
| 254 | - | when <<def_merge,merging>>. | |
| 254 | + | when <<def_merge,merging>>. See "THE INDEX" in | |
| 255 | + | linkgit:gitdatamodel[7] for details. | |
| 255 | 256 | ||
| 256 | 257 | [[def_index_entry]]index entry:: | |
| 257 | 258 | The information regarding a particular file, stored in the | |
| @@ -290,7 +291,8 @@ This commit is referred to as a "merge commit", or sometimes just a | |||
| 290 | 291 | [[def_object]]object:: | |
| 291 | 292 | The unit of storage in Git. It is uniquely identified by the | |
| 292 | 293 | <<def_SHA1,SHA-1>> of its contents. Consequently, an | |
| 293 | - | object cannot be changed. | |
| 294 | + | object cannot be changed. See "OBJECTS" in | |
| 295 | + | linkgit:gitdatamodel[7] for details. | |
| 294 | 296 | ||
| 295 | 297 | [[def_object_database]]object database:: | |
| 296 | 298 | Stores a set of "objects", and an individual <<def_object,object>> is | |
| @@ -587,12 +589,17 @@ extended in the future: | |||
| 587 | 589 | Different subhierarchies are used for different purposes. For example, | |
| 588 | 590 | the `refs/heads/` hierarchy is used to represent local branches whereas | |
| 589 | 591 | the `refs/tags/` hierarchy is used to represent local tags.. | |
| 592 | + | + | |
| 593 | + | See also "REFERENCES" in linkgit:gitdatamodel[7]. | |
| 590 | 594 | ||
| 591 | 595 | [[def_reflog]]reflog:: | |
| 592 | 596 | A reflog shows the local "history" of a ref. In other words, | |
| 593 | 597 | it can tell you what the 3rd last revision in _this_ repository | |
| 594 | 598 | was, and what was the current state in _this_ repository, | |
| 595 | - | yesterday 9:14pm. See linkgit:git-reflog[1] for details. | |
| 599 | + | yesterday 9:14pm. | |
| 600 | + | + | |
| 601 | + | See "REFLOGS" in linkgit:gitdatamodel[7] for a short explanation of the | |
| 602 | + | format. See linkgit:git-reflog[1] for details. | |
| 596 | 603 | ||
| 597 | 604 | [[def_refspec]]refspec:: | |
| 598 | 605 | A "refspec" is used by <<def_fetch,fetch>> and | |
modified builtin/worktree.c
| @@ -294,7 +294,7 @@ static void remove_junk_on_signal(int signo) | |||
| 294 | 294 | raise(signo); | |
| 295 | 295 | } | |
| 296 | 296 | ||
| 297 | - | static char *worktree_basename_dup(const char *path) | |
| 297 | + | static const char *worktree_basename(const char *path, int *olen) | |
| 298 | 298 | { | |
| 299 | 299 | const char *name; | |
| 300 | 300 | int len; | |
| @@ -303,11 +303,14 @@ static char *worktree_basename_dup(const char *path) | |||
| 303 | 303 | while (len && is_dir_sep(path[len - 1])) | |
| 304 | 304 | len--; | |
| 305 | 305 | ||
| 306 | - | name = path + len; | |
| 307 | - | while (name > path && !is_dir_sep(name[-1])) | |
| 308 | - | name--; | |
| 306 | + | for (name = path + len - 1; name > path; name--) | |
| 307 | + | if (is_dir_sep(*name)) { | |
| 308 | + | name++; | |
| 309 | + | break; | |
| 310 | + | } | |
| 309 | 311 | ||
| 310 | - | return xmemdupz(name, path + len - name); | |
| 312 | + | *olen = len; | |
| 313 | + | return name; | |
| 311 | 314 | } | |
| 312 | 315 | ||
| 313 | 316 | /* check that path is viable location for worktree */ | |
| @@ -461,7 +464,6 @@ static int add_worktree(const char *path, const char *refname, | |||
| 461 | 464 | struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT; | |
| 462 | 465 | struct strbuf sb = STRBUF_INIT; | |
| 463 | 466 | const char *name; | |
| 464 | - | char *name_to_free = NULL; | |
| 465 | 467 | struct strvec child_env = STRVEC_INIT; | |
| 466 | 468 | unsigned int counter = 0; | |
| 467 | 469 | int len, ret; | |
| @@ -489,12 +491,12 @@ static int add_worktree(const char *path, const char *refname, | |||
| 489 | 491 | if (!commit && !opts->orphan) | |
| 490 | 492 | die(_("invalid reference: %s"), refname); | |
| 491 | 493 | ||
| 492 | - | name = name_to_free = worktree_basename_dup(path); | |
| 493 | - | if (!*name) | |
| 494 | - | die(_("invalid path '%s'"), path); | |
| 495 | - | sanitize_refname_component(name, &sb_name); | |
| 494 | + | name = worktree_basename(path, &len); | |
| 495 | + | strbuf_add(&sb, name, path + len - name); | |
| 496 | + | sanitize_refname_component(sb.buf, &sb_name); | |
| 496 | 497 | if (!sb_name.len) | |
| 497 | - | BUG("How come '%s' becomes empty after sanitization?", name); | |
| 498 | + | BUG("How come '%s' becomes empty after sanitization?", sb.buf); | |
| 499 | + | strbuf_reset(&sb); | |
| 498 | 500 | name = sb_name.buf; | |
| 499 | 501 | repo_git_path_replace(the_repository, &sb_repo, "worktrees/%s", name); | |
| 500 | 502 | len = sb_repo.len; | |
| @@ -627,7 +629,6 @@ done: | |||
| 627 | 629 | strbuf_release(&sb_git); | |
| 628 | 630 | strbuf_release(&sb_name); | |
| 629 | 631 | free_worktree(wt); | |
| 630 | - | free(name_to_free); | |
| 631 | 632 | return ret; | |
| 632 | 633 | } | |
| 633 | 634 | ||
| @@ -764,8 +765,10 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote) | |||
| 764 | 765 | ||
| 765 | 766 | static char *dwim_branch(const char *path, char **new_branch) | |
| 766 | 767 | { | |
| 768 | + | int n; | |
| 767 | 769 | int branch_exists; | |
| 768 | - | char *branchname = worktree_basename_dup(path); | |
| 770 | + | const char *s = worktree_basename(path, &n); | |
| 771 | + | char *branchname = xstrndup(s, n); | |
| 769 | 772 | struct strbuf ref = STRBUF_INIT; | |
| 770 | 773 | ||
| 771 | 774 | branch_exists = !check_branch_ref(&ref, branchname) && | |
| @@ -872,7 +875,9 @@ static int add(int ac, const char **av, const char *prefix, | |||
| 872 | 875 | } | |
| 873 | 876 | ||
| 874 | 877 | if (opts.orphan && !new_branch) { | |
| 875 | - | new_branch = new_branch_to_free = worktree_basename_dup(path); | |
| 878 | + | int n; | |
| 879 | + | const char *s = worktree_basename(path, &n); | |
| 880 | + | new_branch = new_branch_to_free = xstrndup(s, n); | |
| 876 | 881 | } else if (opts.orphan) { | |
| 877 | 882 | ; /* no-op */ | |
| 878 | 883 | } else if (opts.detach) { | |
modified command-list.txt
| @@ -217,6 +217,7 @@ gitcli userinterfaces | |||
| 217 | 217 | gitcore-tutorial guide | |
| 218 | 218 | gitcredentials guide | |
| 219 | 219 | gitcvs-migration guide | |
| 220 | + | gitdatamodel guide | |
| 220 | 221 | gitdiffcore guide | |
| 221 | 222 | giteveryday guide | |
| 222 | 223 | gitfaq guide | |
modified t/t2400-worktree-add.sh
| @@ -46,10 +46,6 @@ test_expect_success '"add" refuses to checkout locked branch' ' | |||
| 46 | 46 | test_path_is_missing .git/worktrees/zere | |
| 47 | 47 | ' | |
| 48 | 48 | ||
| 49 | - | test_expect_success '"add" rejects an empty path' ' | |
| 50 | - | test_must_fail git worktree add "" HEAD | |
| 51 | - | ' | |
| 52 | - | ||
| 53 | 49 | test_expect_success 'checking out paths not complaining about linked checkouts' ' | |
| 54 | 50 | ( | |
| 55 | 51 | cd existing_empty && | |
| @@ -298,11 +294,6 @@ test_expect_success '"add" with <branch> omitted' ' | |||
| 298 | 294 | test_cmp_rev HEAD bat | |
| 299 | 295 | ' | |
| 300 | 296 | ||
| 301 | - | test_expect_success '"add" with trailing slash and <branch> omitted' ' | |
| 302 | - | git worktree add waffle/bit/ && | |
| 303 | - | test_cmp_rev HEAD bit | |
| 304 | - | ' | |
| 305 | - | ||
| 306 | 297 | test_expect_success '"add" checks out existing branch of dwimd name' ' | |
| 307 | 298 | git branch dwim HEAD~1 && | |
| 308 | 299 | git worktree add dwim && | |
| @@ -393,14 +384,6 @@ test_expect_success '"add --orphan (no -b)"' ' | |||
| 393 | 384 | test_cmp expected actual | |
| 394 | 385 | ' | |
| 395 | 386 | ||
| 396 | - | test_expect_success '"add --orphan with trailing slash (no -b)"' ' | |
| 397 | - | test_when_finished "git worktree remove -f -f neworphan" && | |
| 398 | - | git worktree add --orphan ./neworphan/ && | |
| 399 | - | echo refs/heads/neworphan >expected && | |
| 400 | - | git -C neworphan symbolic-ref HEAD >actual && | |
| 401 | - | test_cmp expected actual | |
| 402 | - | ' | |
| 403 | - | ||
| 404 | 387 | test_expect_success '"add --orphan --quiet"' ' | |
| 405 | 388 | test_when_finished "git worktree remove -f -f orphandir" && | |
| 406 | 389 | git worktree add --quiet --orphan -b neworphan orphandir 2>log.actual && | |