Compare
91642b317b16d7cd4aa91889cb28afa8d17bd3b3..d7e8ff85654db0af86abc1612e82557dfb8e0dff
Merge branch 'jc/history-missing-tree-errorfix'
Running "git history" in a corrupt repository can (unsurprisingly) segfault when a necessary tree object is not found. * jc/history-missing-tree-errorfix: history: do not dereference NULL when parent tree is missing
Junio C Hamano <gitster@pobox.com> · 2026-09-14 04:53 UTC
30 files changed,
+557
−84
- Documentation/RelNotes/2.56.0.adoc
- Documentation/config/maintenance.adoc
- Documentation/git-cherry-pick.adoc
- Documentation/git.adoc
- Documentation/gitdatamodel.adoc
- Documentation/gitglossary.adoc
- Documentation/glossary-content.adoc
- builtin/commit.c
- builtin/history.c
- builtin/submodule--helper.c
- ci/install-dependencies.sh
- command-list.txt
- compat/mingw.c
- config.mak.uname
- contrib/buildsystems/CMakeLists.txt
- fetch-pack.c
- meson.build
- meson_options.txt
- pathspec.c
- pathspec.h
- repository.c
- sequencer.c
- sequencer.h
- t/t0060-path-utils.sh
- t/t3404-rebase-interactive.sh
- t/t3507-cherry-pick-conflict.sh
- t/t4151-am-abort.sh
- t/t5702-protocol-v2.sh
- t/t7426-submodule-get-default-remote.sh
- wt-status.h
modified Documentation/RelNotes/2.56.0.adoc
| @@ -512,6 +512,12 @@ Performance, Internal Implementation, Development Support etc. | |||
| 512 | 512 | during a concurrent geometric repack, and 'git replay' has been | |
| 513 | 513 | fixed to not segfault when reading such missing objects. | |
| 514 | 514 | ||
| 515 | + | * A collection of patches from Git for Windows has been upstreamed, | |
| 516 | + | mostly focusing on simplifying and robustifying build configurations | |
| 517 | + | for MinGW/MSYS2, dropping obsolete compatibility options, and allowing | |
| 518 | + | the main 'git.exe' to be used directly without the extra wrapper | |
| 519 | + | process on Windows. | |
| 520 | + | ||
| 515 | 521 | ||
| 516 | 522 | Fixes since v2.55 | |
| 517 | 523 | ----------------- | |
| @@ -804,6 +810,17 @@ Fixes since v2.55 | |||
| 804 | 810 | trailing slashes. | |
| 805 | 811 | (merge 2e8a9d94b0 rs/worktree-add-basename-fixes later to maint). | |
| 806 | 812 | ||
| 813 | + | * The CI job for Debian 11 has been updated to use Debian 12, as the | |
| 814 | + | former is now out of the LTS period. | |
| 815 | + | (merge 00fa850235 jk/ci-bump-debian-to-12 later to maint). | |
| 816 | + | ||
| 817 | + | * The CI script to install dependencies for the documentation build | |
| 818 | + | has been updated to install asciidoctor directly via the system | |
| 819 | + | package manager instead of pinning to an older version via gem. | |
| 820 | + | Additionally, an obsolete variable used for retired Azure Pipelines | |
| 821 | + | environments has been removed. | |
| 822 | + | (merge 1c1eed13bd jk/ci-use-system-asciidoctor later to maint). | |
| 823 | + | ||
| 807 | 824 | * Other code cleanup, docfix, build fix, etc. | |
| 808 | 825 | (merge 026636128f ss/submittingpatches-typofix later to maint). | |
| 809 | 826 | (merge d2af22cc21 jc/rerere-doc-typofix later to maint). | |
modified Documentation/config/maintenance.adoc
| @@ -41,6 +41,7 @@ The possible strategies are: | |||
| 41 | 41 | This repacking strategy is a full replacement for the `gc` strategy and is | |
| 42 | 42 | recommended for large repositories. This is the default strategy for manual | |
| 43 | 43 | maintenance. | |
| 44 | + | + | |
| 44 | 45 | * `incremental`: This setting optimizes for performing small maintenance | |
| 45 | 46 | activities that do not delete any data. This does not schedule the `gc` | |
| 46 | 47 | task, but runs the `prefetch` and `commit-graph` tasks hourly, the | |
modified Documentation/git-cherry-pick.adoc
| @@ -25,7 +25,8 @@ happens: | |||
| 25 | 25 | 1. The current branch and `HEAD` pointer stay at the last commit | |
| 26 | 26 | successfully made. | |
| 27 | 27 | 2. The `CHERRY_PICK_HEAD` ref is set to point at the commit that | |
| 28 | - | introduced the change that is difficult to apply. | |
| 28 | + | introduced the change that is difficult to apply, unless the | |
| 29 | + | `--no-commit` option was given. | |
| 29 | 30 | 3. Paths in which the change applied cleanly are updated both | |
| 30 | 31 | in the index file and in your working tree. | |
| 31 | 32 | 4. For conflicting paths, the index file records up to three | |
| @@ -101,6 +102,11 @@ OPTIONS | |||
| 101 | 102 | + | |
| 102 | 103 | This is useful when cherry-picking more than one commits' | |
| 103 | 104 | effect to your index in a row. | |
| 105 | + | + | |
| 106 | + | This option does not record `CHERRY_PICK_HEAD`, so a plain `git commit` | |
| 107 | + | afterwards records you as the author. That is by design: what you are | |
| 108 | + | building is your own work, which you keep changing before committing, | |
| 109 | + | rather than a reproduction of the original commit. | |
| 104 | 110 | ||
| 105 | 111 | -s:: | |
| 106 | 112 | --signoff:: | |
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/commit.c
| @@ -515,13 +515,25 @@ static const char *prepare_index(const char **argv, const char *prefix, | |||
| 515 | 515 | */ | |
| 516 | 516 | commit_style = COMMIT_PARTIAL; | |
| 517 | 517 | ||
| 518 | - | if (whence != FROM_COMMIT) { | |
| 519 | - | if (whence == FROM_MERGE) | |
| 520 | - | die(_("cannot do a partial commit during a merge.")); | |
| 521 | - | else if (is_from_cherry_pick(whence)) | |
| 522 | - | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 523 | - | else if (is_from_rebase(whence)) | |
| 524 | - | die(_("cannot do a partial commit during a rebase.")); | |
| 518 | + | switch (sequencer_ongoing_operation(the_repository, whence)) { | |
| 519 | + | case ONGOING_NONE: | |
| 520 | + | break; | |
| 521 | + | case ONGOING_MERGE: | |
| 522 | + | die(_("cannot do a partial commit during a merge.")); | |
| 523 | + | case ONGOING_CHERRY_PICK: | |
| 524 | + | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 525 | + | case ONGOING_REBASE_NOW_EMPTY: | |
| 526 | + | /* | |
| 527 | + | * A pick that became empty is not a conflict, and creating | |
| 528 | + | * a new commit (partial or not) poses no problem. | |
| 529 | + | */ | |
| 530 | + | break; | |
| 531 | + | case ONGOING_REVERT: | |
| 532 | + | die(_("cannot do a partial commit during a revert.")); | |
| 533 | + | case ONGOING_AM: | |
| 534 | + | die(_("cannot do a partial commit during an am session.")); | |
| 535 | + | case ONGOING_REBASE_CONFLICT: | |
| 536 | + | die(_("cannot do a partial commit while resolving conflicts during a rebase.")); | |
| 525 | 537 | } | |
| 526 | 538 | ||
| 527 | 539 | if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec)) | |
| @@ -893,7 +905,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 893 | 905 | */ | |
| 894 | 906 | else if (whence == FROM_MERGE) | |
| 895 | 907 | hook_arg1 = "merge"; | |
| 896 | - | else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) { | |
| 908 | + | else if (is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) { | |
| 897 | 909 | hook_arg1 = "commit"; | |
| 898 | 910 | hook_arg2 = "CHERRY_PICK_HEAD"; | |
| 899 | 911 | } | |
| @@ -1086,7 +1098,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 1086 | 1098 | if (amend) | |
| 1087 | 1099 | fputs(_(empty_amend_advice), stderr); | |
| 1088 | 1100 | else if (is_from_cherry_pick(whence) || | |
| 1089 | - | whence == FROM_REBASE_PICK) { | |
| 1101 | + | is_from_rebase_now_empty(whence)) { | |
| 1090 | 1102 | fputs(_(empty_cherry_pick_advice), stderr); | |
| 1091 | 1103 | if (whence == FROM_CHERRY_PICK_SINGLE) | |
| 1092 | 1104 | fputs(_(empty_cherry_pick_advice_single), stderr); | |
| @@ -1326,15 +1338,30 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1326 | 1338 | use_editor = 0; | |
| 1327 | 1339 | ||
| 1328 | 1340 | /* Sanity check options */ | |
| 1329 | - | if (amend && !current_head) | |
| 1330 | - | die(_("You have nothing to amend.")); | |
| 1331 | - | if (amend && whence != FROM_COMMIT) { | |
| 1332 | - | if (whence == FROM_MERGE) | |
| 1341 | + | if (amend) { | |
| 1342 | + | if (!current_head) | |
| 1343 | + | die(_("You have nothing to amend.")); | |
| 1344 | + | /* | |
| 1345 | + | * Refuse to amend in the middle of any operation that is | |
| 1346 | + | * meant to record its result as a new commit on top of HEAD | |
| 1347 | + | * rather than by rewriting HEAD. | |
| 1348 | + | */ | |
| 1349 | + | switch (sequencer_ongoing_operation(s->repo, whence)) { | |
| 1350 | + | case ONGOING_NONE: | |
| 1351 | + | break; | |
| 1352 | + | case ONGOING_MERGE: | |
| 1333 | 1353 | die(_("You are in the middle of a merge -- cannot amend.")); | |
| 1334 | - | else if (is_from_cherry_pick(whence)) | |
| 1354 | + | case ONGOING_CHERRY_PICK: | |
| 1335 | 1355 | die(_("You are in the middle of a cherry-pick -- cannot amend.")); | |
| 1336 | - | else if (whence == FROM_REBASE_PICK) | |
| 1337 | - | die(_("You are in the middle of a rebase -- cannot amend.")); | |
| 1356 | + | case ONGOING_REBASE_NOW_EMPTY: | |
| 1357 | + | die(_("The now-empty commit has been dropped -- cannot amend.")); | |
| 1358 | + | case ONGOING_REVERT: | |
| 1359 | + | die(_("You are in the middle of a revert -- cannot amend.")); | |
| 1360 | + | case ONGOING_AM: | |
| 1361 | + | die(_("You are in the middle of an am session -- cannot amend.")); | |
| 1362 | + | case ONGOING_REBASE_CONFLICT: | |
| 1363 | + | die(_("You are resolving conflicts during a rebase -- cannot amend.")); | |
| 1364 | + | } | |
| 1338 | 1365 | } | |
| 1339 | 1366 | if (fixup_message && squash_message) | |
| 1340 | 1367 | die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup"); | |
| @@ -1353,7 +1380,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1353 | 1380 | if (amend && !use_message && !fixup_message) | |
| 1354 | 1381 | use_message = "HEAD"; | |
| 1355 | 1382 | if (!use_message && !is_from_cherry_pick(whence) && | |
| 1356 | - | !is_from_rebase(whence) && renew_authorship) | |
| 1383 | + | !is_from_rebase_now_empty(whence) && renew_authorship) | |
| 1357 | 1384 | die(_("--reset-author can be used only with -C, -c or --amend.")); | |
| 1358 | 1385 | if (use_message) { | |
| 1359 | 1386 | use_message_buffer = read_commit_message(use_message); | |
| @@ -1362,7 +1389,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1362 | 1389 | author_message_buffer = use_message_buffer; | |
| 1363 | 1390 | } | |
| 1364 | 1391 | } | |
| 1365 | - | if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) && | |
| 1392 | + | if ((is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) && | |
| 1366 | 1393 | !renew_authorship) { | |
| 1367 | 1394 | author_message = "CHERRY_PICK_HEAD"; | |
| 1368 | 1395 | author_message_buffer = read_commit_message(author_message); | |
| @@ -1887,7 +1914,7 @@ int cmd_commit(int argc, | |||
| 1887 | 1914 | if (!reflog_msg) | |
| 1888 | 1915 | reflog_msg = is_from_cherry_pick(whence) | |
| 1889 | 1916 | ? "commit (cherry-pick)" | |
| 1890 | - | : is_from_rebase(whence) | |
| 1917 | + | : is_from_rebase_now_empty(whence) | |
| 1891 | 1918 | ? "commit (rebase)" | |
| 1892 | 1919 | : "commit"; | |
| 1893 | 1920 | commit_list_insert(current_head, &parents); | |
modified builtin/history.c
| @@ -786,6 +786,10 @@ static int write_ondisk_index(struct repository *repo, | |||
| 786 | 786 | opts.dst_index = &index; | |
| 787 | 787 | ||
| 788 | 788 | tree = repo_parse_tree_indirect(repo, oid); | |
| 789 | + | if (!tree) { | |
| 790 | + | ret = error(_("unable to parse tree %s"), oid_to_hex(oid)); | |
| 791 | + | goto out; | |
| 792 | + | } | |
| 789 | 793 | init_tree_desc(&tree_desc, &tree->object.oid, tree->buffer, tree->size); | |
| 790 | 794 | ||
| 791 | 795 | if (unpack_trees(1, &tree_desc, &opts)) { | |
modified builtin/submodule--helper.c
| @@ -80,6 +80,7 @@ static int get_default_remote_submodule(const char *module_path, char **default_ | |||
| 80 | 80 | struct repository subrepo; | |
| 81 | 81 | const char *remote_name = NULL; | |
| 82 | 82 | char *url = NULL; | |
| 83 | + | int ret = 0; | |
| 83 | 84 | ||
| 84 | 85 | sub = submodule_from_path(the_repository, null_oid(the_hash_algo), module_path); | |
| 85 | 86 | if (sub && sub->url) { | |
| @@ -96,9 +97,11 @@ static int get_default_remote_submodule(const char *module_path, char **default_ | |||
| 96 | 97 | } | |
| 97 | 98 | ||
| 98 | 99 | if (repo_submodule_init(&subrepo, the_repository, module_path, | |
| 99 | - | null_oid(the_hash_algo)) < 0) | |
| 100 | - | return die_message(_("could not get a repository handle for submodule '%s'"), | |
| 100 | + | null_oid(the_hash_algo)) < 0) { | |
| 101 | + | ret = die_message(_("could not get a repository handle for submodule '%s'"), | |
| 101 | 102 | module_path); | |
| 103 | + | goto out; | |
| 104 | + | } | |
| 102 | 105 | ||
| 103 | 106 | /* Look up by URL first */ | |
| 104 | 107 | if (url) | |
| @@ -108,10 +111,11 @@ static int get_default_remote_submodule(const char *module_path, char **default_ | |||
| 108 | 111 | ||
| 109 | 112 | *default_remote = xstrdup(remote_name); | |
| 110 | 113 | ||
| 114 | + | out: | |
| 111 | 115 | repo_clear(&subrepo); | |
| 112 | 116 | free(url); | |
| 113 | 117 | ||
| 114 | - | return 0; | |
| 118 | + | return ret; | |
| 115 | 119 | } | |
| 116 | 120 | ||
| 117 | 121 | static int module_get_default_remote(int argc, const char **argv, const char *prefix, | |
modified ci/install-dependencies.sh
| @@ -164,9 +164,9 @@ sparse) | |||
| 164 | 164 | libexpat-dev gettext zlib1g-dev sparse | |
| 165 | 165 | ;; | |
| 166 | 166 | Documentation) | |
| 167 | - | sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make ruby | |
| 167 | + | sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make ruby \ | |
| 168 | + | asciidoctor | |
| 168 | 169 | ||
| 169 | - | sudo gem install --version 1.5.8 asciidoctor | |
| 170 | 170 | sudo gem install concurrent-ruby | |
| 171 | 171 | ;; | |
| 172 | 172 | esac | |
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 compat/mingw.c
| @@ -3157,6 +3157,45 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen) | |||
| 3157 | 3157 | return -1; | |
| 3158 | 3158 | } | |
| 3159 | 3159 | ||
| 3160 | + | #ifdef ENSURE_MSYSTEM_IS_SET | |
| 3161 | + | #if !defined(RUNTIME_PREFIX) || !defined(HAVE_WPGMPTR) || !defined(MINGW_PREFIX) | |
| 3162 | + | static size_t append_system_bin_dirs(char *path UNUSED, size_t size UNUSED) | |
| 3163 | + | { | |
| 3164 | + | return 0; | |
| 3165 | + | } | |
| 3166 | + | #else | |
| 3167 | + | static size_t append_system_bin_dirs(char *path, size_t size) | |
| 3168 | + | { | |
| 3169 | + | char prefix[32768]; | |
| 3170 | + | const char *slash; | |
| 3171 | + | size_t len = xwcstoutf(prefix, _wpgmptr, sizeof(prefix)), off = 0; | |
| 3172 | + | ||
| 3173 | + | if (len == 0 || len >= sizeof(prefix) || | |
| 3174 | + | !(slash = find_last_dir_sep(prefix))) | |
| 3175 | + | return 0; | |
| 3176 | + | /* strip trailing `git.exe` */ | |
| 3177 | + | len = slash - prefix; | |
| 3178 | + | ||
| 3179 | + | /* strip trailing `cmd` or `<mingw-prefix>\bin` or `bin` or `libexec\git-core` */ | |
| 3180 | + | if (strip_suffix_mem(prefix, &len, "\\" MINGW_PREFIX "\\libexec\\git-core") || | |
| 3181 | + | strip_suffix_mem(prefix, &len, "\\" MINGW_PREFIX "\\bin")) | |
| 3182 | + | off += xsnprintf(path + off, size - off, | |
| 3183 | + | "%.*s\\" MINGW_PREFIX "\\bin;", (int)len, prefix); | |
| 3184 | + | else if (strip_suffix_mem(prefix, &len, "\\cmd") || | |
| 3185 | + | strip_suffix_mem(prefix, &len, "\\bin") || | |
| 3186 | + | strip_suffix_mem(prefix, &len, "\\libexec\\git-core")) | |
| 3187 | + | off += xsnprintf(path + off, size - off, | |
| 3188 | + | "%.*s\\" MINGW_PREFIX "\\bin;", (int)len, prefix); | |
| 3189 | + | else | |
| 3190 | + | return 0; | |
| 3191 | + | ||
| 3192 | + | off += xsnprintf(path + off, size - off, | |
| 3193 | + | "%.*s\\usr\\bin;", (int)len, prefix); | |
| 3194 | + | return off; | |
| 3195 | + | } | |
| 3196 | + | #endif | |
| 3197 | + | #endif | |
| 3198 | + | ||
| 3160 | 3199 | static void setup_windows_environment(void) | |
| 3161 | 3200 | { | |
| 3162 | 3201 | char *tmp = getenv("TMPDIR"); | |
| @@ -3208,6 +3247,35 @@ static void setup_windows_environment(void) | |||
| 3208 | 3247 | if (!tmp && (tmp = getenv("USERPROFILE"))) | |
| 3209 | 3248 | setenv("HOME", tmp, 1); | |
| 3210 | 3249 | } | |
| 3250 | + | ||
| 3251 | + | if (!getenv("PLINK_PROTOCOL")) | |
| 3252 | + | setenv("PLINK_PROTOCOL", "ssh", 0); | |
| 3253 | + | ||
| 3254 | + | #ifdef ENSURE_MSYSTEM_IS_SET | |
| 3255 | + | if (!(tmp = getenv("MSYSTEM")) || !tmp[0]) { | |
| 3256 | + | const char *home = getenv("HOME"), *path = getenv("PATH"); | |
| 3257 | + | char buf[32768]; | |
| 3258 | + | size_t off = 0; | |
| 3259 | + | ||
| 3260 | + | setenv("MSYSTEM", ENSURE_MSYSTEM_IS_SET, 1); | |
| 3261 | + | ||
| 3262 | + | if (home) | |
| 3263 | + | off += xsnprintf(buf + off, sizeof(buf) - off, | |
| 3264 | + | "%s\\bin;", home); | |
| 3265 | + | off += append_system_bin_dirs(buf + off, sizeof(buf) - off); | |
| 3266 | + | if (path) | |
| 3267 | + | off += xsnprintf(buf + off, sizeof(buf) - off, | |
| 3268 | + | "%s", path); | |
| 3269 | + | else if (off > 0) | |
| 3270 | + | buf[off - 1] = '\0'; | |
| 3271 | + | else | |
| 3272 | + | buf[0] = '\0'; | |
| 3273 | + | setenv("PATH", buf, 1); | |
| 3274 | + | } | |
| 3275 | + | #endif | |
| 3276 | + | ||
| 3277 | + | if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG")) | |
| 3278 | + | setenv("LC_CTYPE", "C.UTF-8", 1); | |
| 3211 | 3279 | } | |
| 3212 | 3280 | ||
| 3213 | 3281 | int mingw_platform_has_symlinks(void) | |
modified config.mak.uname
| @@ -465,14 +465,8 @@ ifeq ($(uname_S),Windows) | |||
| 465 | 465 | GIT_VERSION := $(GIT_VERSION).MSVC | |
| 466 | 466 | pathsep = ; | |
| 467 | 467 | # Assume that this is built in Git for Windows' SDK | |
| 468 | - | ifeq (MINGW32,$(MSYSTEM)) | |
| 469 | - | prefix = /mingw32 | |
| 470 | - | else | |
| 471 | - | ifeq (CLANGARM64,$(MSYSTEM)) | |
| 472 | - | prefix = /clangarm64 | |
| 473 | - | else | |
| 474 | - | prefix = /mingw64 | |
| 475 | - | endif | |
| 468 | + | ifneq (,$(MSYSTEM)) | |
| 469 | + | prefix = $(MINGW_PREFIX) | |
| 476 | 470 | endif | |
| 477 | 471 | # Prepend MSVC 64-bit tool-chain to PATH. | |
| 478 | 472 | # | |
| @@ -525,7 +519,8 @@ ifeq ($(uname_S),Windows) | |||
| 525 | 519 | NO_POSIX_GOODIES = UnfortunatelyYes | |
| 526 | 520 | NATIVE_CRLF = YesPlease | |
| 527 | 521 | DEFAULT_HELP_FORMAT = html | |
| 528 | - | ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix)))) | |
| 522 | + | SKIP_DASHED_BUILT_INS = YabbaDabbaDoo | |
| 523 | + | ifneq (,$(MINGW_PREFIX)) | |
| 529 | 524 | # Move system config into top-level /etc/ | |
| 530 | 525 | ETC_GITCONFIG = ../etc/gitconfig | |
| 531 | 526 | ETC_GITATTRIBUTES = ../etc/gitattributes | |
| @@ -541,7 +536,9 @@ endif | |||
| 541 | 536 | compat/win32/pthread.o compat/win32/syslog.o \ | |
| 542 | 537 | compat/win32/trace2_win32_process_info.o \ | |
| 543 | 538 | compat/win32/dirent.o | |
| 544 | - | COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\" | |
| 539 | + | COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY \ | |
| 540 | + | -DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" \ | |
| 541 | + | -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\" | |
| 545 | 542 | BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE | |
| 546 | 543 | # invalidcontinue.obj allows Git's source code to close the same file | |
| 547 | 544 | # handle twice, or to access the osfhandle of an already-closed stdout | |
| @@ -718,6 +715,7 @@ ifeq ($(uname_S),MINGW) | |||
| 718 | 715 | FSMONITOR_DAEMON_BACKEND = win32 | |
| 719 | 716 | FSMONITOR_OS_SETTINGS = win32 | |
| 720 | 717 | ||
| 718 | + | SKIP_DASHED_BUILT_INS = YabbaDabbaDoo | |
| 721 | 719 | RUNTIME_PREFIX = YesPlease | |
| 722 | 720 | HAVE_WPGMPTR = YesWeDo | |
| 723 | 721 | NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease | |
| @@ -756,26 +754,25 @@ ifeq ($(uname_S),MINGW) | |||
| 756 | 754 | ifneq (,$(findstring -O,$(filter-out -O0 -Og,$(CFLAGS)))) | |
| 757 | 755 | BASIC_LDFLAGS += -Wl,--dynamicbase | |
| 758 | 756 | endif | |
| 759 | - | ifeq (MINGW32,$(MSYSTEM)) | |
| 760 | - | prefix = /mingw32 | |
| 761 | - | HOST_CPU = i686 | |
| 762 | - | BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup | |
| 763 | - | endif | |
| 764 | - | ifeq (MINGW64,$(MSYSTEM)) | |
| 765 | - | prefix = /mingw64 | |
| 766 | - | HOST_CPU = x86_64 | |
| 767 | - | BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup | |
| 768 | - | else ifeq (CLANGARM64,$(MSYSTEM)) | |
| 769 | - | prefix = /clangarm64 | |
| 770 | - | HOST_CPU = aarch64 | |
| 771 | - | BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup | |
| 772 | - | else | |
| 773 | - | COMPAT_CFLAGS += -D_USE_32BIT_TIME_T | |
| 774 | - | BASIC_LDFLAGS += -Wl,--large-address-aware | |
| 757 | + | ifneq (,$(MSYSTEM)) | |
| 758 | + | ifeq ($(MINGW_PREFIX),$(filter-out /%,$(MINGW_PREFIX))) | |
| 759 | + | # Override if empty or does not start with a slash | |
| 760 | + | MINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z) | |
| 761 | + | endif | |
| 762 | + | prefix = $(MINGW_PREFIX) | |
| 763 | + | HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST)) | |
| 764 | + | BASIC_LDFLAGS += -Wl,--pic-executable | |
| 765 | + | COMPAT_CFLAGS += -DDETECT_MSYS_TTY \ | |
| 766 | + | -DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" \ | |
| 767 | + | -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" | |
| 768 | + | ifeq (MINGW32,$(MSYSTEM)) | |
| 769 | + | BASIC_LDFLAGS += -Wl,--large-address-aware | |
| 770 | + | endif | |
| 771 | + | # Move system config into top-level /etc/ | |
| 772 | + | ETC_GITCONFIG = ../etc/gitconfig | |
| 773 | + | ETC_GITATTRIBUTES = ../etc/gitattributes | |
| 775 | 774 | endif | |
| 776 | - | CC = gcc | |
| 777 | - | COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \ | |
| 778 | - | -fstack-protector-strong | |
| 775 | + | COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -fstack-protector-strong | |
| 779 | 776 | EXTLIBS += -lntdll | |
| 780 | 777 | EXTRA_PROGRAMS += headless-git$X | |
| 781 | 778 | INSTALL = /bin/install | |
| @@ -783,11 +780,7 @@ ifeq ($(uname_S),MINGW) | |||
| 783 | 780 | HAVE_LIBCHARSET_H = YesPlease | |
| 784 | 781 | USE_GETTEXT_SCHEME = fallthrough | |
| 785 | 782 | USE_LIBPCRE = YesPlease | |
| 786 | - | ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix)))) | |
| 787 | - | # Move system config into top-level /etc/ | |
| 788 | - | ETC_GITCONFIG = ../etc/gitconfig | |
| 789 | - | ETC_GITATTRIBUTES = ../etc/gitattributes | |
| 790 | - | endif | |
| 783 | + | NO_PYTHON = | |
| 791 | 784 | endif | |
| 792 | 785 | ifeq ($(uname_S),QNX) | |
| 793 | 786 | COMPAT_CFLAGS += -DSA_RESTART=0 | |
modified contrib/buildsystems/CMakeLists.txt
| @@ -256,7 +256,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") | |||
| 256 | 256 | _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe" NO_SYMLINK_HEAD UNRELIABLE_FSTAT | |
| 257 | 257 | NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 | |
| 258 | 258 | OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP | |
| 259 | - | HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET HAVE_RTLGENRANDOM) | |
| 259 | + | HAVE_WPGMPTR HAVE_RTLGENRANDOM) | |
| 260 | + | if(CMAKE_GENERATOR_PLATFORM STREQUAL "x64") | |
| 261 | + | add_compile_definitions(ENSURE_MSYSTEM_IS_SET="MINGW64" MINGW_PREFIX="mingw64") | |
| 262 | + | elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "arm64") | |
| 263 | + | add_compile_definitions(ENSURE_MSYSTEM_IS_SET="CLANGARM64" MINGW_PREFIX="clangarm64") | |
| 264 | + | elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x86") | |
| 265 | + | add_compile_definitions(ENSURE_MSYSTEM_IS_SET="MINGW32" MINGW_PREFIX="mingw32") | |
| 266 | + | endif() | |
| 260 | 267 | list(APPEND compat_SOURCES | |
| 261 | 268 | compat/mingw.c | |
| 262 | 269 | compat/winansi.c | |
modified fetch-pack.c
| @@ -1853,6 +1853,13 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, | |||
| 1853 | 1853 | } | |
| 1854 | 1854 | } | |
| 1855 | 1855 | ||
| 1856 | + | if (packfile_uris.nr) { | |
| 1857 | + | trace2_region_enter("fetch-pack", "packfile-uris", | |
| 1858 | + | the_repository); | |
| 1859 | + | trace2_data_intmax("fetch-pack", the_repository, | |
| 1860 | + | "packfile-uris/count", packfile_uris.nr); | |
| 1861 | + | } | |
| 1862 | + | ||
| 1856 | 1863 | for (i = 0; i < packfile_uris.nr; i++) { | |
| 1857 | 1864 | bool created_keep; | |
| 1858 | 1865 | int j; | |
| @@ -1906,6 +1913,11 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, | |||
| 1906 | 1913 | repo_get_object_directory(the_repository), | |
| 1907 | 1914 | packhash)); | |
| 1908 | 1915 | } | |
| 1916 | + | ||
| 1917 | + | if (packfile_uris.nr) | |
| 1918 | + | trace2_region_leave("fetch-pack", "packfile-uris", | |
| 1919 | + | the_repository); | |
| 1920 | + | ||
| 1909 | 1921 | string_list_clear(&packfile_uris, 0); | |
| 1910 | 1922 | strvec_clear(&index_pack_args); | |
| 1911 | 1923 | ||
modified meson.build
| @@ -1318,7 +1318,6 @@ elif host_machine.system() == 'windows' | |||
| 1318 | 1318 | ||
| 1319 | 1319 | libgit_c_args += [ | |
| 1320 | 1320 | '-DDETECT_MSYS_TTY', | |
| 1321 | - | '-DENSURE_MSYSTEM_IS_SET', | |
| 1322 | 1321 | '-DNATIVE_CRLF', | |
| 1323 | 1322 | '-DNOGDI', | |
| 1324 | 1323 | '-DNO_POSIX_GOODIES', | |
| @@ -1328,6 +1327,20 @@ elif host_machine.system() == 'windows' | |||
| 1328 | 1327 | '-D__USE_MINGW_ANSI_STDIO=0', | |
| 1329 | 1328 | ] | |
| 1330 | 1329 | ||
| 1330 | + | msystem = get_option('msystem') | |
| 1331 | + | if msystem != '' | |
| 1332 | + | mingw_prefix = get_option('mingw_prefix') | |
| 1333 | + | if mingw_prefix == '' | |
| 1334 | + | mingw_prefix = msystem.to_lower() | |
| 1335 | + | elif mingw_prefix.startswith('/') | |
| 1336 | + | mingw_prefix = mingw_prefix.substring(1) | |
| 1337 | + | endif | |
| 1338 | + | libgit_c_args += [ | |
| 1339 | + | '-DENSURE_MSYSTEM_IS_SET="' + msystem + '"', | |
| 1340 | + | '-DMINGW_PREFIX="' + mingw_prefix + '"' | |
| 1341 | + | ] | |
| 1342 | + | endif | |
| 1343 | + | ||
| 1331 | 1344 | libgit_dependencies += compiler.find_library('ntdll') | |
| 1332 | 1345 | libgit_include_directories += 'compat/win32' | |
| 1333 | 1346 | if compiler.get_id() == 'msvc' | |
modified meson_options.txt
| @@ -21,6 +21,10 @@ option('runtime_prefix', type: 'boolean', value: false, | |||
| 21 | 21 | description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.') | |
| 22 | 22 | option('sane_tool_path', type: 'array', value: [], | |
| 23 | 23 | description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.') | |
| 24 | + | option('msystem', type: 'string', value: '', | |
| 25 | + | description: 'Fall-back on Windows when MSYSTEM is not set.') | |
| 26 | + | option('mingw_prefix', type: 'string', value: '', | |
| 27 | + | description: 'Fall-back on Windows when MINGW_PREFIX is not set.') | |
| 24 | 28 | ||
| 25 | 29 | # Build information compiled into Git and other parts like documentation. | |
| 26 | 30 | option('build_date', type: 'string', value: '', | |
modified pathspec.c
| @@ -749,8 +749,8 @@ void clear_pathspec(struct pathspec *pathspec) | |||
| 749 | 749 | int i, j; | |
| 750 | 750 | ||
| 751 | 751 | for (i = 0; i < pathspec->nr; i++) { | |
| 752 | - | free(pathspec->items[i].match); | |
| 753 | - | free(pathspec->items[i].original); | |
| 752 | + | free((void *)pathspec->items[i].match); | |
| 753 | + | free((void *)pathspec->items[i].original); | |
| 754 | 754 | ||
| 755 | 755 | for (j = 0; j < pathspec->items[i].attr_match_nr; j++) | |
| 756 | 756 | free(pathspec->items[i].attr_match[j].value); | |
modified pathspec.h
| @@ -35,8 +35,8 @@ struct pathspec { | |||
| 35 | 35 | unsigned magic; | |
| 36 | 36 | int max_depth; | |
| 37 | 37 | struct pathspec_item { | |
| 38 | - | char *match; | |
| 39 | - | char *original; | |
| 38 | + | const char *match; | |
| 39 | + | const char *original; | |
| 40 | 40 | unsigned magic; | |
| 41 | 41 | int len, prefix; | |
| 42 | 42 | int nowildcard_len; | |
modified repository.c
| @@ -386,7 +386,8 @@ void repo_clear(struct repository *repo) | |||
| 386 | 386 | odb_free(repo->objects); | |
| 387 | 387 | repo->objects = NULL; | |
| 388 | 388 | ||
| 389 | - | parsed_object_pool_clear(repo->parsed_objects); | |
| 389 | + | if (repo->parsed_objects) | |
| 390 | + | parsed_object_pool_clear(repo->parsed_objects); | |
| 390 | 391 | FREE_AND_NULL(repo->parsed_objects); | |
| 391 | 392 | ||
| 392 | 393 | repo_settings_clear(repo); | |
modified sequencer.c
| @@ -142,6 +142,13 @@ static GIT_PATH_FUNC(rebase_path_author_script, "rebase-merge/author-script") | |||
| 142 | 142 | * command is processed, this file is deleted. | |
| 143 | 143 | */ | |
| 144 | 144 | static GIT_PATH_FUNC(rebase_path_amend, "rebase-merge/amend") | |
| 145 | + | /* | |
| 146 | + | * The apply ("am") backend keeps its state in the rebase-apply directory; | |
| 147 | + | * the "applying" file within it marks a plain `git am` (as opposed to an | |
| 148 | + | * apply-based rebase). | |
| 149 | + | */ | |
| 150 | + | static GIT_PATH_FUNC(apply_dir, "rebase-apply") | |
| 151 | + | static GIT_PATH_FUNC(apply_path_applying, "rebase-apply/applying") | |
| 145 | 152 | /* | |
| 146 | 153 | * When we stop at a given patch via the "edit" command, this file contains | |
| 147 | 154 | * the commit object name of the corresponding patch. | |
| @@ -6956,7 +6963,7 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 6956 | 6963 | !repo_get_oid(r, "REBASE_HEAD", &rebase_head) && | |
| 6957 | 6964 | !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) && | |
| 6958 | 6965 | oideq(&rebase_head, &cherry_pick_head)) | |
| 6959 | - | *whence = FROM_REBASE_PICK; | |
| 6966 | + | *whence = FROM_REBASE_NOW_EMPTY; | |
| 6960 | 6967 | else | |
| 6961 | 6968 | *whence = FROM_CHERRY_PICK_SINGLE; | |
| 6962 | 6969 | ||
| @@ -6966,6 +6973,56 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 6966 | 6973 | return 0; | |
| 6967 | 6974 | } | |
| 6968 | 6975 | ||
| 6976 | + | enum ongoing_operation sequencer_ongoing_operation(struct repository *r, | |
| 6977 | + | enum commit_whence whence) | |
| 6978 | + | { | |
| 6979 | + | /* | |
| 6980 | + | * The merge, cherry-pick, and (empty) rebase-pick stops are already | |
| 6981 | + | * distinguished by 'whence'. | |
| 6982 | + | */ | |
| 6983 | + | switch (whence) { | |
| 6984 | + | case FROM_MERGE: | |
| 6985 | + | return ONGOING_MERGE; | |
| 6986 | + | case FROM_CHERRY_PICK_SINGLE: | |
| 6987 | + | case FROM_CHERRY_PICK_MULTI: | |
| 6988 | + | return ONGOING_CHERRY_PICK; | |
| 6989 | + | case FROM_REBASE_NOW_EMPTY: | |
| 6990 | + | return ONGOING_REBASE_NOW_EMPTY; | |
| 6991 | + | case FROM_COMMIT: | |
| 6992 | + | break; | |
| 6993 | + | } | |
| 6994 | + | ||
| 6995 | + | /* | |
| 6996 | + | * 'whence' is FROM_COMMIT, but we may still be in the middle of an | |
| 6997 | + | * operation that records its result on top of HEAD; detect those | |
| 6998 | + | * from their on-disk state. | |
| 6999 | + | */ | |
| 7000 | + | ||
| 7001 | + | /* In the middle of a revert? */ | |
| 7002 | + | if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) | |
| 7003 | + | return ONGOING_REVERT; | |
| 7004 | + | ||
| 7005 | + | /* In the middle of an `am`? */ | |
| 7006 | + | if (file_exists(apply_path_applying())) | |
| 7007 | + | return ONGOING_AM; | |
| 7008 | + | ||
| 7009 | + | /* | |
| 7010 | + | * In the middle of a rebase that stopped for conflict resolution? | |
| 7011 | + | * The apply backend only ever stops for conflicts, so the presence | |
| 7012 | + | * of its state directory is enough. The merge backend writes | |
| 7013 | + | * stopped-sha whenever it hands control back to the user, but omits | |
| 7014 | + | * `amend` unless it stopped with HEAD already pointing at the commit | |
| 7015 | + | * to be amended (a clean edit/reword stop); its absence therefore | |
| 7016 | + | * marks a conflicted stop. | |
| 7017 | + | */ | |
| 7018 | + | if (file_exists(apply_dir()) || | |
| 7019 | + | (file_exists(rebase_path_stopped_sha()) && | |
| 7020 | + | !file_exists(rebase_path_amend()))) | |
| 7021 | + | return ONGOING_REBASE_CONFLICT; | |
| 7022 | + | ||
| 7023 | + | return ONGOING_NONE; | |
| 7024 | + | } | |
| 7025 | + | ||
| 6969 | 7026 | int sequencer_get_update_refs_state(const char *wt_dir, | |
| 6970 | 7027 | struct string_list *refs) | |
| 6971 | 7028 | { | |
modified sequencer.h
| @@ -277,6 +277,30 @@ int sequencer_get_last_command(struct repository* r, | |||
| 277 | 277 | enum replay_action *action); | |
| 278 | 278 | int sequencer_determine_whence(struct repository *r, enum commit_whence *whence); | |
| 279 | 279 | ||
| 280 | + | /* | |
| 281 | + | * An in-progress operation that records its result (often a conflict | |
| 282 | + | * resolution) as a new commit on top of HEAD. Some ways of invoking | |
| 283 | + | * "git commit" -- amending HEAD, or a partial commit -- are almost | |
| 284 | + | * always a mistake during such an operation. | |
| 285 | + | */ | |
| 286 | + | enum ongoing_operation { | |
| 287 | + | ONGOING_NONE = 0, | |
| 288 | + | ONGOING_MERGE, | |
| 289 | + | ONGOING_CHERRY_PICK, | |
| 290 | + | ONGOING_REBASE_NOW_EMPTY, | |
| 291 | + | ONGOING_REVERT, | |
| 292 | + | ONGOING_AM, | |
| 293 | + | ONGOING_REBASE_CONFLICT | |
| 294 | + | }; | |
| 295 | + | ||
| 296 | + | /* | |
| 297 | + | * Return which in-progress operation, if any, is underway; see enum | |
| 298 | + | * ongoing_operation. 'whence' is the origin already computed for the | |
| 299 | + | * pending commit. | |
| 300 | + | */ | |
| 301 | + | enum ongoing_operation sequencer_ongoing_operation(struct repository *r, | |
| 302 | + | enum commit_whence whence); | |
| 303 | + | ||
| 280 | 304 | /** | |
| 281 | 305 | * Append the set of ref-OID pairs that are currently stored for the 'git | |
| 282 | 306 | * rebase --update-refs' feature if such a rebase is currently happening. | |
modified t/t0060-path-utils.sh
| @@ -602,7 +602,8 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX wor | |||
| 602 | 602 | echo "echo HERE" | write_script pretend/libexec/git-core/git-here && | |
| 603 | 603 | GIT_EXEC_PATH= ./pretend/bin/git here >actual && | |
| 604 | 604 | echo HERE >expect && | |
| 605 | - | test_cmp expect actual' | |
| 605 | + | test_cmp expect actual | |
| 606 | + | ' | |
| 606 | 607 | ||
| 607 | 608 | test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' ' | |
| 608 | 609 | git config yes.path "%(prefix)/yes" && | |
| @@ -611,4 +612,34 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' | |||
| 611 | 612 | test_cmp expect actual | |
| 612 | 613 | ' | |
| 613 | 614 | ||
| 615 | + | test_expect_success MINGW,RUNTIME_PREFIX 'MSYSTEM/PATH is adjusted if necessary' ' | |
| 616 | + | if test -z "$MINGW_PREFIX" | |
| 617 | + | then | |
| 618 | + | MINGW_PREFIX="/$(echo "${MSYSTEM:-MINGW64}" | tr A-Z a-z)" | |
| 619 | + | fi && | |
| 620 | + | mkdir -p "$HOME"/bin pretend"$MINGW_PREFIX"/bin \ | |
| 621 | + | pretend"$MINGW_PREFIX"/libexec/git-core pretend/usr/bin && | |
| 622 | + | cp "$GIT_EXEC_PATH"/git.exe pretend"$MINGW_PREFIX"/bin/ && | |
| 623 | + | cp "$GIT_EXEC_PATH"/git.exe pretend"$MINGW_PREFIX"/libexec/git-core/ && | |
| 624 | + | # copy the .dll files, if any (happens when building via CMake) | |
| 625 | + | if test -n "$(ls "$GIT_EXEC_PATH"/*.dll 2>/dev/null)" | |
| 626 | + | then | |
| 627 | + | cp "$GIT_EXEC_PATH"/*.dll pretend"$MINGW_PREFIX"/bin/ && | |
| 628 | + | cp "$GIT_EXEC_PATH"/*.dll pretend"$MINGW_PREFIX"/libexec/git-core/ | |
| 629 | + | fi && | |
| 630 | + | echo "env | grep MSYSTEM=" | write_script "$HOME"/bin/git-test-home && | |
| 631 | + | echo "echo ${MINGW_PREFIX#/}" | write_script pretend"$MINGW_PREFIX"/bin/git-test-bin && | |
| 632 | + | echo "echo usr" | write_script pretend/usr/bin/git-test-bin2 && | |
| 633 | + | ||
| 634 | + | ( | |
| 635 | + | MSYSTEM= && | |
| 636 | + | GIT_EXEC_PATH= && | |
| 637 | + | pretend"$MINGW_PREFIX"/libexec/git-core/git.exe test-home >actual && | |
| 638 | + | pretend"$MINGW_PREFIX"/libexec/git-core/git.exe test-bin >>actual && | |
| 639 | + | pretend"$MINGW_PREFIX"/bin/git.exe test-bin2 >>actual | |
| 640 | + | ) && | |
| 641 | + | test_write_lines MSYSTEM=$MSYSTEM "${MINGW_PREFIX#/}" usr >expect && | |
| 642 | + | test_cmp expect actual | |
| 643 | + | ' | |
| 644 | + | ||
| 614 | 645 | test_done | |
modified t/t3404-rebase-interactive.sh
| @@ -1858,7 +1858,7 @@ test_expect_success 'post-commit hook is called' ' | |||
| 1858 | 1858 | test_cmp expect actual | |
| 1859 | 1859 | ' | |
| 1860 | 1860 | ||
| 1861 | - | test_expect_success 'correct error message for partial commit after empty pick' ' | |
| 1861 | + | test_expect_success 'partial commit is allowed when a rebase pick becomes empty' ' | |
| 1862 | 1862 | test_when_finished "git rebase --abort" && | |
| 1863 | 1863 | ( | |
| 1864 | 1864 | set_fake_editor && | |
| @@ -1867,8 +1867,7 @@ test_expect_success 'correct error message for partial commit after empty pick' | |||
| 1867 | 1867 | test_must_fail git rebase -i A D | |
| 1868 | 1868 | ) && | |
| 1869 | 1869 | echo x >file1 && | |
| 1870 | - | test_must_fail git commit file1 2>err && | |
| 1871 | - | test_grep "cannot do a partial commit during a rebase." err | |
| 1870 | + | git commit file1 | |
| 1872 | 1871 | ' | |
| 1873 | 1872 | ||
| 1874 | 1873 | test_expect_success 'correct error message for commit --amend after empty pick' ' | |
| @@ -1881,7 +1880,128 @@ test_expect_success 'correct error message for commit --amend after empty pick' | |||
| 1881 | 1880 | ) && | |
| 1882 | 1881 | echo x>file1 && | |
| 1883 | 1882 | test_must_fail git commit -a --amend 2>err && | |
| 1884 | - | test_grep "middle of a rebase -- cannot amend." err | |
| 1883 | + | test_grep "now-empty commit has been dropped -- cannot amend." err | |
| 1884 | + | ' | |
| 1885 | + | ||
| 1886 | + | test_expect_success 'commit --amend is refused at a rebase conflict stop' ' | |
| 1887 | + | test_when_finished "git rebase --abort" && | |
| 1888 | + | git checkout --detach conflict-branch && | |
| 1889 | + | ( | |
| 1890 | + | set_fake_editor && | |
| 1891 | + | FAKE_LINES="1 3" && | |
| 1892 | + | export FAKE_LINES && | |
| 1893 | + | test_must_fail git rebase -i A | |
| 1894 | + | ) && | |
| 1895 | + | test_path_is_file .git/rebase-merge/patch && | |
| 1896 | + | test_path_is_missing .git/rebase-merge/amend && | |
| 1897 | + | echo resolved >conflict && | |
| 1898 | + | git add conflict && | |
| 1899 | + | test_must_fail git commit --amend --no-edit 2>err && | |
| 1900 | + | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1901 | + | ' | |
| 1902 | + | ||
| 1903 | + | test_expect_success 'commit --amend is refused when an "edit" pick conflicts' ' | |
| 1904 | + | test_when_finished "git rebase --abort" && | |
| 1905 | + | git checkout --detach conflict-branch && | |
| 1906 | + | ( | |
| 1907 | + | set_fake_editor && | |
| 1908 | + | FAKE_LINES="1 edit 3" && | |
| 1909 | + | export FAKE_LINES && | |
| 1910 | + | test_must_fail git rebase -i A | |
| 1911 | + | ) && | |
| 1912 | + | test_path_is_file .git/rebase-merge/patch && | |
| 1913 | + | test_path_is_missing .git/rebase-merge/amend && | |
| 1914 | + | echo resolved >conflict && | |
| 1915 | + | git add conflict && | |
| 1916 | + | test_must_fail git commit --amend --no-edit 2>err && | |
| 1917 | + | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1918 | + | ' | |
| 1919 | + | ||
| 1920 | + | test_expect_success 'commit --amend is allowed at a rebase edit stop' ' | |
| 1921 | + | test_when_finished "git rebase --abort" && | |
| 1922 | + | git checkout --detach no-conflict-branch && | |
| 1923 | + | ( | |
| 1924 | + | set_fake_editor && | |
| 1925 | + | FAKE_LINES="edit 1 2 3 4" && | |
| 1926 | + | export FAKE_LINES && | |
| 1927 | + | git rebase -i A | |
| 1928 | + | ) && | |
| 1929 | + | test_path_is_file .git/rebase-merge/amend && | |
| 1930 | + | echo tweak >fileJ && | |
| 1931 | + | git add fileJ && | |
| 1932 | + | git commit --amend --no-edit | |
| 1933 | + | ' | |
| 1934 | + | ||
| 1935 | + | test_expect_success 'commit --amend is allowed at a rebase break stop' ' | |
| 1936 | + | test_when_finished "git rebase --abort" && | |
| 1937 | + | git checkout --detach no-conflict-branch && | |
| 1938 | + | ( | |
| 1939 | + | set_fake_editor && | |
| 1940 | + | FAKE_LINES="break 1 2 3 4" && | |
| 1941 | + | export FAKE_LINES && | |
| 1942 | + | git rebase -i A | |
| 1943 | + | ) && | |
| 1944 | + | test_must_fail git rev-parse --verify REBASE_HEAD && | |
| 1945 | + | echo tweak >fileJ && | |
| 1946 | + | git add fileJ && | |
| 1947 | + | git commit --amend --no-edit | |
| 1948 | + | ' | |
| 1949 | + | ||
| 1950 | + | test_expect_success 'commit --amend is refused at an apply-backend conflict stop' ' | |
| 1951 | + | test_when_finished "rm -rf apply-backend" && | |
| 1952 | + | test_create_repo apply-backend && | |
| 1953 | + | ( | |
| 1954 | + | cd apply-backend && | |
| 1955 | + | test_commit base file && | |
| 1956 | + | git branch -M mainline && | |
| 1957 | + | test_commit upstream file upstream && | |
| 1958 | + | git checkout -b side mainline~1 && | |
| 1959 | + | test_commit conflicting file side && | |
| 1960 | + | test_commit unrelated other && | |
| 1961 | + | test_must_fail git rebase --apply mainline && | |
| 1962 | + | # the apply backend only ever stops for conflicts, and | |
| 1963 | + | # leaves HEAD on the previously-applied commit | |
| 1964 | + | test_path_is_dir .git/rebase-apply && | |
| 1965 | + | test_path_is_missing .git/rebase-apply/applying && | |
| 1966 | + | echo resolved >file && | |
| 1967 | + | git add file && | |
| 1968 | + | test_must_fail git commit --amend --no-edit 2>err && | |
| 1969 | + | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1970 | + | ) | |
| 1971 | + | ' | |
| 1972 | + | ||
| 1973 | + | test_expect_success 'partial commit is refused at a rebase conflict stop' ' | |
| 1974 | + | test_when_finished "git rebase --abort" && | |
| 1975 | + | git checkout --detach conflict-branch && | |
| 1976 | + | ( | |
| 1977 | + | set_fake_editor && | |
| 1978 | + | FAKE_LINES="1 3" && | |
| 1979 | + | export FAKE_LINES && | |
| 1980 | + | test_must_fail git rebase -i A | |
| 1981 | + | ) && | |
| 1982 | + | echo resolved >conflict && | |
| 1983 | + | git add conflict && | |
| 1984 | + | test_must_fail git commit conflict 2>err && | |
| 1985 | + | test_grep "cannot do a partial commit while resolving conflicts during a rebase." err | |
| 1986 | + | ' | |
| 1987 | + | ||
| 1988 | + | test_expect_success 'partial commit is refused at an apply-backend conflict stop' ' | |
| 1989 | + | test_when_finished "rm -rf apply-backend" && | |
| 1990 | + | test_create_repo apply-backend && | |
| 1991 | + | ( | |
| 1992 | + | cd apply-backend && | |
| 1993 | + | test_commit base file && | |
| 1994 | + | git branch -M mainline && | |
| 1995 | + | test_commit upstream file upstream && | |
| 1996 | + | git checkout -b side mainline~1 && | |
| 1997 | + | test_commit conflicting file side && | |
| 1998 | + | test_commit unrelated other && | |
| 1999 | + | test_must_fail git rebase --apply mainline && | |
| 2000 | + | echo resolved >file && | |
| 2001 | + | git add file && | |
| 2002 | + | test_must_fail git commit file 2>err && | |
| 2003 | + | test_grep "cannot do a partial commit while resolving conflicts during a rebase." err | |
| 2004 | + | ) | |
| 1885 | 2005 | ' | |
| 1886 | 2006 | ||
| 1887 | 2007 | test_expect_success 'todo has correct onto hash' ' | |
modified t/t3507-cherry-pick-conflict.sh
| @@ -79,7 +79,8 @@ test_expect_success 'advice from failed cherry-pick --no-commit' " | |||
| 79 | 79 | EOF | |
| 80 | 80 | test_must_fail git cherry-pick --no-commit picked 2>actual && | |
| 81 | 81 | ||
| 82 | - | test_cmp expected actual | |
| 82 | + | test_cmp expected actual && | |
| 83 | + | test_ref_missing CHERRY_PICK_HEAD | |
| 83 | 84 | " | |
| 84 | 85 | ||
| 85 | 86 | test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' ' | |
| @@ -364,6 +365,28 @@ test_expect_success 'failed revert sets REVERT_HEAD' ' | |||
| 364 | 365 | test_cmp_rev picked REVERT_HEAD | |
| 365 | 366 | ' | |
| 366 | 367 | ||
| 368 | + | test_expect_success 'commit --amend of revert fails' ' | |
| 369 | + | pristine_detach initial && | |
| 370 | + | ||
| 371 | + | test_must_fail git revert picked && | |
| 372 | + | echo resolved >foo && | |
| 373 | + | git add foo && | |
| 374 | + | test_must_fail git commit --amend 2>err && | |
| 375 | + | ||
| 376 | + | test_grep "in the middle of a revert -- cannot amend." err | |
| 377 | + | ' | |
| 378 | + | ||
| 379 | + | test_expect_success 'partial commit during a revert fails' ' | |
| 380 | + | pristine_detach initial && | |
| 381 | + | ||
| 382 | + | test_must_fail git revert picked && | |
| 383 | + | echo resolved >foo && | |
| 384 | + | git add foo && | |
| 385 | + | test_must_fail git commit foo 2>err && | |
| 386 | + | ||
| 387 | + | test_grep "cannot do a partial commit during a revert." err | |
| 388 | + | ' | |
| 389 | + | ||
| 367 | 390 | test_expect_success 'successful revert does not set REVERT_HEAD' ' | |
| 368 | 391 | pristine_detach base && | |
| 369 | 392 | git revert base && | |
modified t/t4151-am-abort.sh
| @@ -63,6 +63,28 @@ do | |||
| 63 | 63 | ||
| 64 | 64 | done | |
| 65 | 65 | ||
| 66 | + | test_expect_success 'commit --amend during a failed am fails' ' | |
| 67 | + | git reset --hard initial && | |
| 68 | + | cp file-2-expect file-2 && | |
| 69 | + | test_must_fail git am 000[1245]-*.patch && | |
| 70 | + | echo resolved >file-1 && | |
| 71 | + | git add file-1 && | |
| 72 | + | test_must_fail git commit --amend 2>err && | |
| 73 | + | test_grep "in the middle of an am session -- cannot amend." err && | |
| 74 | + | git am --abort | |
| 75 | + | ' | |
| 76 | + | ||
| 77 | + | test_expect_success 'partial commit during a failed am fails' ' | |
| 78 | + | git reset --hard initial && | |
| 79 | + | cp file-2-expect file-2 && | |
| 80 | + | test_must_fail git am 000[1245]-*.patch && | |
| 81 | + | echo resolved >file-1 && | |
| 82 | + | git add file-1 && | |
| 83 | + | test_must_fail git commit file-1 2>err && | |
| 84 | + | test_grep "cannot do a partial commit during an am session." err && | |
| 85 | + | git am --abort | |
| 86 | + | ' | |
| 87 | + | ||
| 66 | 88 | test_expect_success 'am -3 --skip removes otherfile-4' ' | |
| 67 | 89 | git reset --hard initial && | |
| 68 | 90 | test_must_fail git am -3 0003-*.patch && | |
modified t/t5702-protocol-v2.sh
| @@ -1223,7 +1223,7 @@ configure_exclusion () { | |||
| 1223 | 1223 | ||
| 1224 | 1224 | test_expect_success 'part of packfile response provided as URI' ' | |
| 1225 | 1225 | P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && | |
| 1226 | - | rm -rf "$P" http_child log && | |
| 1226 | + | rm -rf "$P" http_child log trace2 && | |
| 1227 | 1227 | ||
| 1228 | 1228 | git init "$P" && | |
| 1229 | 1229 | git -C "$P" config "uploadpack.allowsidebandall" "true" && | |
| @@ -1238,10 +1238,15 @@ test_expect_success 'part of packfile response provided as URI' ' | |||
| 1238 | 1238 | configure_exclusion "$P" other-blob >h2 && | |
| 1239 | 1239 | ||
| 1240 | 1240 | GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \ | |
| 1241 | + | GIT_TRACE2_EVENT="$(pwd)/trace2" \ | |
| 1241 | 1242 | git -c protocol.version=2 \ | |
| 1242 | 1243 | -c fetch.uriprotocols=http,https \ | |
| 1243 | 1244 | clone "$HTTPD_URL/smart/http_parent" http_child && | |
| 1244 | 1245 | ||
| 1246 | + | test_grep \"event\":\"region_enter\".*\"label\":\"packfile-uris\" trace2 && | |
| 1247 | + | test_grep \"key\":\"packfile-uris/count\",\"value\":\"2\" trace2 && | |
| 1248 | + | test_grep \"event\":\"region_leave\".*\"label\":\"packfile-uris\" trace2 && | |
| 1249 | + | ||
| 1245 | 1250 | # Ensure that my-blob and other-blob are in separate packfiles. | |
| 1246 | 1251 | for idx in http_child/.git/objects/pack/*.idx | |
| 1247 | 1252 | do | |
modified t/t7426-submodule-get-default-remote.sh
| @@ -60,6 +60,23 @@ test_expect_success 'get-default-remote fails with non-submodule path' ' | |||
| 60 | 60 | ) | |
| 61 | 61 | ' | |
| 62 | 62 | ||
| 63 | + | test_expect_success 'get-default-remote fails with uninitialized submodule' ' | |
| 64 | + | test_when_finished " | |
| 65 | + | git -C super config -f .gitmodules --remove-section submodule.uninitialized && | |
| 66 | + | git -C super update-index --force-remove uninitialized | |
| 67 | + | " && | |
| 68 | + | ( | |
| 69 | + | cd super && | |
| 70 | + | git config -f .gitmodules submodule.uninitialized.path uninitialized && | |
| 71 | + | git config -f .gitmodules submodule.uninitialized.url ../sub && | |
| 72 | + | head=$(git -C ../sub rev-parse HEAD) && | |
| 73 | + | git update-index --add --cacheinfo 160000,$head,uninitialized && | |
| 74 | + | test_must_fail git submodule--helper get-default-remote \ | |
| 75 | + | uninitialized 2>err && | |
| 76 | + | test_grep "could not get a repository handle" err | |
| 77 | + | ) | |
| 78 | + | ' | |
| 79 | + | ||
| 63 | 80 | test_expect_success 'get-default-remote fails without path argument' ' | |
| 64 | 81 | ( | |
| 65 | 82 | cd super && | |
modified wt-status.h
| @@ -41,7 +41,7 @@ enum commit_whence { | |||
| 41 | 41 | FROM_MERGE, /* commit came from merge */ | |
| 42 | 42 | FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ | |
| 43 | 43 | FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */ | |
| 44 | - | FROM_REBASE_PICK /* commit came from a pick/reword/edit */ | |
| 44 | + | FROM_REBASE_NOW_EMPTY /* rebase applied a pick that became empty */ | |
| 45 | 45 | }; | |
| 46 | 46 | ||
| 47 | 47 | static inline int is_from_cherry_pick(enum commit_whence whence) | |
| @@ -50,9 +50,9 @@ static inline int is_from_cherry_pick(enum commit_whence whence) | |||
| 50 | 50 | whence == FROM_CHERRY_PICK_MULTI; | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | - | static inline int is_from_rebase(enum commit_whence whence) | |
| 53 | + | static inline int is_from_rebase_now_empty(enum commit_whence whence) | |
| 54 | 54 | { | |
| 55 | - | return whence == FROM_REBASE_PICK; | |
| 55 | + | return whence == FROM_REBASE_NOW_EMPTY; | |
| 56 | 56 | } | |
| 57 | 57 | ||
| 58 | 58 | struct wt_status_change_data { | |