Compare

99d74db4e62c84ef54a7c977ca6da7a06999c94a..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

Browse files
45 files changed, +853 −179
modified .github/workflows/main.yml
@@ -413,9 +413,9 @@ jobs:
413 413 # A RHEL 8 compatible distro. Supported until 2029-05-31.
414 414 - jobname: almalinux-8
415 415 image: almalinux:8
416 - # Supported until 2026-08-31.
417 - - jobname: debian-11
418 - image: debian:11
416 + # Supported until 2028-06-30.
417 + - jobname: debian-12
418 + image: debian:12
419 419 env:
420 420 jobname: ${{matrix.vector.jobname}}
421 421 CC: ${{matrix.vector.cc}}
modified .gitlab-ci.yml
@@ -71,9 +71,9 @@ test:linux:
71 71 # A RHEL 8 compatible distro. Supported until 2029-05-31.
72 72 - jobname: almalinux-8
73 73 image: almalinux:8
74 - # Supported until 2026-08-31.
75 - - jobname: debian-11
76 - image: debian:11
74 + # Supported until 2028-06-30.
75 + - jobname: debian-12
76 + image: debian:12
77 77 artifacts:
78 78 paths:
79 79 - t/failed-test-artifacts
modified Documentation/RelNotes/2.56.0.adoc
@@ -144,6 +144,10 @@ UI, Workflows & Features
144 144 remote-tracking branch cannot be uniquely identified, which has
145 145 been corrected.
146 146
147 + * The 'git replay' command has been taught the '--linearize' option to
148 + drop merge commits and linearize the replayed history, mimicking 'git
149 + rebase --no-rebase-merges'.
150 +
147 151
148 152 Performance, Internal Implementation, Development Support etc.
149 153 --------------------------------------------------------------
@@ -498,6 +502,22 @@ Performance, Internal Implementation, Development Support etc.
498 502 refactored to use the internal apply API directly, avoiding the need
499 503 to spawn a 'git apply' subprocess.
500 504
505 + * The memory ownership of argv elements passed to the revision
506 + machinery has been made more robust by keeping logically "freed"
507 + elements alive until the rev_info struct is released, preventing
508 + use-after-free bugs when options store references to them.
509 +
510 + * The object lookup machinery has been taught to gracefully recover
511 + when a multi-pack-index points to an owning pack that was removed
512 + during a concurrent geometric repack, and 'git replay' has been
513 + fixed to not segfault when reading such missing objects.
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 +
501 521
502 522 Fixes since v2.55
503 523 -----------------
@@ -779,6 +799,29 @@ Fixes since v2.55
779 799 the path originally recorded in the file was absolute, and this new
780 800 capability is used to correctly detect such mismatches.
781 801
802 + * GitHub Actions CI workflow runs triggered by pull requests have
803 + been configured to cancel older runs when a new push is made to the
804 + same pull request.
805 + (merge a251b1bd21 hn/ci-cancel-stale-pr-runs later to maint).
806 +
807 + * The string extraction logic for the branch name and worktree name
808 + from the given path in 'git worktree add' has been corrected and
809 + simplified to avoid out-of-bounds reads and improper handling of
810 + trailing slashes.
811 + (merge 2e8a9d94b0 rs/worktree-add-basename-fixes later to maint).
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 +
782 824 * Other code cleanup, docfix, build fix, etc.
783 825 (merge 026636128f ss/submittingpatches-typofix later to maint).
784 826 (merge d2af22cc21 jc/rerere-doc-typofix later to maint).
827 + (merge c486c1df72 hk/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 GIT-VERSION-GEN
@@ -1,6 +1,6 @@
1 1 #!/bin/sh
2 2
3 - DEF_VER=v2.55.GIT
3 + DEF_VER=v2.56.0-rc0
4 4
5 5 LF='
6 6 '
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/mktree.c
@@ -125,7 +125,6 @@ static void mktree_line(struct repository *repo, char *buf, int nul_term_line, i
125 125 oi.typep = &obj_type;
126 126 if (odb_read_object_info_extended(repo->objects, &oid, &oi,
127 127 OBJECT_INFO_LOOKUP_REPLACE |
128 - OBJECT_INFO_QUICK |
129 128 OBJECT_INFO_SKIP_FETCH_OBJECT) < 0)
130 129 obj_type = -1;
131 130
@@ -200,8 +199,11 @@ int cmd_mktree(int ac,
200 199 puts(oid_to_hex(&oid));
201 200 fflush(stdout);
202 201 }
202 + for (int i = 0; i < used; i++)
203 + free(entries[i]);
203 204 used=0; /* reset tree entry buffer for re-use in batch mode */
204 205 }
206 + free(entries);
205 207 strbuf_release(&sb);
206 208
207 209 return 0;
modified builtin/pack-objects.c
@@ -1790,7 +1790,7 @@ static int want_object_in_pack_mtime(const struct object_id *oid,
1790 1790 struct multi_pack_index *m = get_multi_pack_index(files->packed);
1791 1791 struct pack_entry e;
1792 1792
1793 - if (m && fill_midx_entry(m, oid, &e, NULL)) {
1793 + if (m && midx_fill_entry(m, oid, &e, NULL) == MIDX_FILL_HIT) {
1794 1794 want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime);
1795 1795 if (want != -1)
1796 1796 return want;
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,10 +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
167 + sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make ruby \
168 + asciidoctor
168 169
169 - test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
170 - sudo gem install --version 1.5.8 asciidoctor
171 170 sudo gem install concurrent-ruby
172 171 ;;
173 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 gitk-git/README.md
@@ -79,13 +79,14 @@ are also accepted.
79 79 All commits must be signed off (use `git commit --signoff`) and should
80 80 have commit messages prefixed with `gitk:`.
81 81
82 - Email Patches
83 - -------------
84 -
85 82 Send patches to git@vger.kernel.org and CC j6t@kdbg.org. See the Git
86 83 project's [patch submission guidelines](https://git-scm.com/docs/SubmittingPatches)
87 84 for detailed instructions on creating and sending patches.
88 85
86 + Please do not submit work that originated from AI, because this project
87 + is down-streamed to the Git project, which has a rather
88 + [strict AI guideline](https://git-scm.com/docs/SubmittingPatches#ai).
89 +
89 90 License
90 91 =======
91 92
modified gitk-git/gitk
@@ -11801,8 +11801,6 @@ proc prefspage_general {notebook} {
11801 11801 }
11802 11802
11803 11803 proc prefspage_colors {notebook} {
11804 - global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11805 - global diffbgcolors linkfgcolor
11806 11804 global themeloader
11807 11805
11808 11806 set page [create_prefs_page $notebook.colors]
@@ -11834,75 +11832,72 @@ proc prefspage_colors {notebook} {
11834 11832
11835 11833 ttk::label $page.cdisp -text [mc "Colors: press to choose"] -font mainfontbold
11836 11834 grid $page.cdisp - -sticky w -pady 10
11837 - label $page.bg -padx 40 -relief sunk -background $bgcolor
11838 - ttk::button $page.bgbut -text [mc "Background"] \
11839 - -command [list choosecolor bgcolor {} $page [mc "background"]]
11840 - grid x $page.bgbut $page.bg -sticky w
11841 -
11842 - label $page.fg -padx 40 -relief sunk -background $fgcolor
11843 - ttk::button $page.fgbut -text [mc "Foreground"] \
11844 - -command [list choosecolor fgcolor {} $page [mc "foreground"]]
11845 - grid x $page.fgbut $page.fg -sticky w
11846 -
11847 - label $page.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
11848 - ttk::button $page.diffoldbut -text [mc "Diff: old lines"] \
11849 - -command [list choosecolor diffcolors 0 $page [mc "diff old lines"]]
11850 - grid x $page.diffoldbut $page.diffold -sticky w
11851 -
11852 - label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]
11853 - ttk::button $page.diffoldbgbut -text [mc "Diff: old lines bg"] \
11854 - -command [list choosecolor diffbgcolors 0 $page [mc "diff old lines bg"]]
11855 - grid x $page.diffoldbgbut $page.diffoldbg -sticky w
11856 -
11857 - label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
11858 - ttk::button $page.diffnewbut -text [mc "Diff: new lines"] \
11859 - -command [list choosecolor diffcolors 1 $page [mc "diff new lines"]]
11860 - grid x $page.diffnewbut $page.diffnew -sticky w
11861 -
11862 - label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]
11863 - ttk::button $page.diffnewbgbut -text [mc "Diff: new lines bg"] \
11864 - -command [list choosecolor diffbgcolors 1 $page [mc "diff new lines bg"]]
11865 - grid x $page.diffnewbgbut $page.diffnewbg -sticky w
11866 -
11867 - label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
11868 - ttk::button $page.hunksepbut -text [mc "Diff: hunk header"] \
11869 - -command [list choosecolor diffcolors 2 $page [mc "diff hunk header"]]
11870 - grid x $page.hunksepbut $page.hunksep -sticky w
11871 -
11872 - label $page.markbgsep -padx 40 -relief sunk -background $markbgcolor
11873 - ttk::button $page.markbgbut -text [mc "Marked line bg"] \
11874 - -command [list choosecolor markbgcolor {} $page [mc "marked line background"]]
11875 - grid x $page.markbgbut $page.markbgsep -sticky w
11876 -
11877 - label $page.selbgsep -padx 40 -relief sunk -background $selectbgcolor
11878 - ttk::button $page.selbgbut -text [mc "Select bg"] \
11879 - -command [list choosecolor selectbgcolor {} $page [mc "background"]]
11880 - grid x $page.selbgbut $page.selbgsep -sticky w
11881 -
11882 - label $page.linkfg -padx 40 -relief sunk -background $linkfgcolor
11883 - ttk::button $page.linkfgbut -text [mc "Link"] \
11884 - -command [list choosecolor linkfgcolor {} $page [mc "link"]]
11885 - grid x $page.linkfgbut $page.linkfg -sticky w
11835 +
11836 + set coloruielems [list \
11837 + bg bgcolor {} \
11838 + [mc "Background"] \
11839 + [mc "choose background color"] \
11840 + fg fgcolor {} \
11841 + [mc "Main text"] \
11842 + [mc "choose main text color"] \
11843 + selbg selectbgcolor {} \
11844 + [mc "Selected text background"] \
11845 + [mc "choose background color of selected text"] \
11846 + linkfg linkfgcolor {} \
11847 + [mc "Link text"] \
11848 + [mc "choose color of link text"] \
11849 + diffold diffcolors 0 \
11850 + [mc "Old line text"] \
11851 + [mc "choose text color of old lines"] \
11852 + diffoldbg diffbgcolors 0 \
11853 + [mc "Old line background"] \
11854 + [mc "choose background color of old lines"] \
11855 + diffnew diffcolors 1 \
11856 + [mc "New line text"] \
11857 + [mc "choose text color of new lines"] \
11858 + diffnewbg diffbgcolors 1 \
11859 + [mc "New line background"] \
11860 + [mc "choose background color of new lines"] \
11861 + hunksep diffcolors 2 \
11862 + [mc "Hunk header text"] \
11863 + [mc "choose text color of hunk headers"] \
11864 + markbg markbgcolor {} \
11865 + [mc "Marked line background"] \
11866 + [mc "choose background color of marked lines"] \
11867 + ]
11868 +
11869 + foreach {uielem colorvar idx label title} $coloruielems {
11870 + ttk::label $page.$uielem -text $label
11871 + button $page.${uielem}btn -padx 40 -pady 0 -borderwidth 2 \
11872 + -command [list choosecolor $colorvar $idx $page $title]
11873 + grid x $page.$uielem $page.${uielem}btn -sticky w -pady 1
11874 + }
11886 11875
11887 11876 grid columnconfigure $page 2 -weight 1
11877 + prefspage_set_colorswatches $page
11888 11878
11889 11879 return $page
11890 11880 }
11891 11881
11892 11882 proc prefspage_set_colorswatches {page} {
11893 - global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11883 + global bgcolor fgcolor diffcolors selectbgcolor markbgcolor
11894 11884 global diffbgcolors linkfgcolor
11895 11885
11896 - $page.bg configure -background $bgcolor
11897 - $page.fg configure -background $fgcolor
11898 - $page.diffold configure -background [lindex $diffcolors 0]
11899 - $page.diffoldbg configure -background [lindex $diffbgcolors 0]
11900 - $page.diffnew configure -background [lindex $diffcolors 1]
11901 - $page.diffnewbg configure -background [lindex $diffbgcolors 1]
11902 - $page.hunksep configure -background [lindex $diffcolors 2]
11903 - $page.markbgsep configure -background $markbgcolor
11904 - $page.selbgsep configure -background $selectbgcolor
11905 - $page.linkfg configure -background $linkfgcolor
11886 + set coloruielems [list \
11887 + bg $bgcolor \
11888 + fg $fgcolor \
11889 + diffold [lindex $diffcolors 0] \
11890 + diffoldbg [lindex $diffbgcolors 0] \
11891 + diffnew [lindex $diffcolors 1] \
11892 + diffnewbg [lindex $diffbgcolors 1] \
11893 + hunksep [lindex $diffcolors 2] \
11894 + markbg $markbgcolor \
11895 + selbg $selectbgcolor \
11896 + linkfg $linkfgcolor \
11897 + ]
11898 + foreach {uielem color} $coloruielems {
11899 + $page.${uielem}btn configure -background $color -activebackground $color
11900 + }
11906 11901 }
11907 11902
11908 11903 proc prefspage_fonts {notebook} {
@@ -12019,11 +12014,11 @@ proc choose_themeloader {prefspage} {
12019 12014 }
12020 12015 }
12021 12016
12022 - proc choosecolor {v vi prefspage x} {
12017 + proc choosecolor {v vi prefspage title} {
12023 12018 global $v
12024 12019
12025 12020 set c [tk_chooseColor -initialcolor [lindex [set $v] $vi] \
12026 - -title [mc "Gitk: choose color for %s" $x]]
12021 + -title "Gitk: $title"]
12027 12022 if {$c eq {}} return
12028 12023 lset $v $vi $c
12029 12024 set_gui_colors
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 midx.c
@@ -589,23 +589,23 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos)
589 589 (off_t)pos * MIDX_CHUNK_OFFSET_WIDTH);
590 590 }
591 591
592 - int fill_midx_entry(struct multi_pack_index *m,
593 - const struct object_id *oid,
594 - struct pack_entry *e,
595 - struct packed_git **bad_pack)
592 + enum midx_fill_result midx_fill_entry(struct multi_pack_index *m,
593 + const struct object_id *oid,
594 + struct pack_entry *e,
595 + struct packed_git **bad_pack)
596 596 {
597 597 uint32_t pos;
598 598 uint32_t pack_int_id;
599 599 struct packed_git *p;
600 600
601 601 if (!bsearch_midx(oid, m, &pos))
602 - return 0;
602 + return MIDX_FILL_MISS;
603 603
604 604 midx_for_object(&m, pos);
605 605 pack_int_id = nth_midxed_pack_int_id(m, pos);
606 606
607 607 if (prepare_midx_pack(m, pack_int_id))
608 - return 0;
608 + return MIDX_FILL_OWNER_UNAVAILABLE;
609 609 p = m->packs[pack_int_id - m->num_packs_in_base];
610 610
611 611 /*
@@ -616,19 +616,19 @@ int fill_midx_entry(struct multi_pack_index *m,
616 616 * loaded!
617 617 */
618 618 if (!is_pack_valid(p))
619 - return 0;
619 + return MIDX_FILL_OWNER_UNAVAILABLE;
620 620
621 621 if (oidset_size(&p->bad_objects) &&
622 622 oidset_contains(&p->bad_objects, oid)) {
623 623 if (bad_pack && !*bad_pack)
624 624 *bad_pack = p;
625 - return 0;
625 + return MIDX_FILL_MISS;
626 626 }
627 627
628 628 e->offset = nth_midxed_offset(m, pos);
629 629 e->p = p;
630 630
631 - return 1;
631 + return MIDX_FILL_HIT;
632 632 }
633 633
634 634 /* Match "foo.idx" against either "foo.pack" _or_ "foo.idx". */
@@ -1032,7 +1032,7 @@ int verify_midx_file(struct odb_source_packed *source, unsigned flags)
1032 1032
1033 1033 nth_midxed_object_oid(&oid, m, pairs[i].pos);
1034 1034
1035 - if (!fill_midx_entry(m, &oid, &e, NULL)) {
1035 + if (midx_fill_entry(m, &oid, &e, NULL) != MIDX_FILL_HIT) {
1036 1036 midx_report(_("failed to load pack entry for oid[%d] = %s"),
1037 1037 pairs[i].pos, oid_to_hex(&oid));
1038 1038 continue;
modified midx.h
@@ -117,8 +117,25 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos);
117 117 struct object_id *nth_midxed_object_oid(struct object_id *oid,
118 118 struct multi_pack_index *m,
119 119 uint32_t n);
120 - int fill_midx_entry(struct multi_pack_index *m, const struct object_id *oid,
121 - struct pack_entry *e, struct packed_git **bad_pack);
120 + /*
121 + * Result of looking an object up in a multi-pack-index. MIDX_FILL_HIT means
122 + * "e was filled in"; the two miss variants distinguish an object the midx does
123 + * not know about (MIDX_FILL_MISS) from one it does know about but whose owning
124 + * pack we can no longer open (MIDX_FILL_OWNER_UNAVAILABLE -- the signature of a
125 + * concurrent repack having removed that pack). A known-bad (corrupt) object
126 + * reports MIDX_FILL_MISS but also sets *bad_pack, if provided, to the owning
127 + * pack so the caller can tell "corrupt" apart from "absent".
128 + */
129 + enum midx_fill_result {
130 + MIDX_FILL_MISS = 0,
131 + MIDX_FILL_HIT,
132 + MIDX_FILL_OWNER_UNAVAILABLE,
133 + };
134 +
135 + enum midx_fill_result midx_fill_entry(struct multi_pack_index *m,
136 + const struct object_id *oid,
137 + struct pack_entry *e,
138 + struct packed_git **bad_pack);
122 139 int midx_contains_pack(struct multi_pack_index *m,
123 140 const char *idx_or_pack_name);
124 141 int midx_layer_contains_pack(struct multi_pack_index *m,
modified odb/source-packed.c
@@ -17,13 +17,18 @@
17 17 static int find_pack_entry(struct odb_source_packed *store,
18 18 const struct object_id *oid,
19 19 struct pack_entry *e,
20 + enum object_info_flags flags,
20 21 struct packed_git **bad_pack)
21 22 {
22 23 struct packfile_list_entry *l;
24 + enum midx_fill_result midx_result = MIDX_FILL_MISS;
23 25
24 26 odb_source_prepare(&store->base, 0);
25 - if (store->midx && fill_midx_entry(store->midx, oid, e, bad_pack))
26 - return 1;
27 + if (store->midx) {
28 + midx_result = midx_fill_entry(store->midx, oid, e, bad_pack);
29 + if (midx_result == MIDX_FILL_HIT)
30 + return 1;
31 + }
27 32
28 33 for (l = store->packs.head; l; l = l->next) {
29 34 struct packed_git *p = l->pack;
@@ -35,6 +40,33 @@ static int find_pack_entry(struct odb_source_packed *store,
35 40 }
36 41 }
37 42
43 + /*
44 + * Recovery for a concurrent-repack race: a stale MIDX may still name a
45 + * vanished owning pack even though the object survives in another pack
46 + * the same MIDX covers. The regular fallback above skips MIDX-covered
47 + * packs, and repreparing the on-disk pack set does not reload the
48 + * borrowed, cached MIDX, so scan its packs directly for the survivor.
49 + *
50 + * Do this only on the second read, by which point repreparing packs has
51 + * already had a chance to find an object merely relocated into a new,
52 + * uncovered pack; only a genuine hidden duplicate reaches here.
53 + */
54 + if (midx_result == MIDX_FILL_OWNER_UNAVAILABLE &&
55 + (flags & OBJECT_INFO_SECOND_READ)) {
56 + struct multi_pack_index *m = store->midx;
57 + uint32_t i;
58 +
59 + for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
60 + struct packed_git *p;
61 +
62 + if (prepare_midx_pack(m, i))
63 + continue;
64 + p = nth_midxed_pack(m, i);
65 + if (p && packfile_fill_entry(p, oid, e, bad_pack))
66 + return 1;
67 + }
68 + }
69 +
38 70 return 0;
39 71 }
40 72
@@ -57,7 +89,7 @@ static enum odb_read_status odb_source_packed_read_object_info(struct odb_source
57 89 if (flags & OBJECT_INFO_SECOND_READ)
58 90 odb_source_prepare(source, ODB_PREPARE_FLUSH_CACHES);
59 91
60 - if (!find_pack_entry(packed, oid, &e, &bad_pack)) {
92 + if (!find_pack_entry(packed, oid, &e, flags, &bad_pack)) {
61 93 /*
62 94 * The lookup may have failed because the object is known to be
63 95 * corrupt in one of the packfiles. Report the object as
@@ -105,7 +137,7 @@ static int odb_source_packed_read_object_stream(struct odb_stream **out,
105 137 struct odb_source_packed *packed = odb_source_packed_downcast(source);
106 138 struct pack_entry e;
107 139
108 - if (!find_pack_entry(packed, oid, &e, NULL))
140 + if (!find_pack_entry(packed, oid, &e, 0, NULL))
109 141 return -1;
110 142
111 143 return packfile_read_object_stream(out, oid, e.p, e.offset);
@@ -611,7 +643,7 @@ static int odb_source_packed_freshen_object(struct odb_source *source,
611 643 timesp = &times;
612 644 }
613 645
614 - if (!find_pack_entry(packed, oid, &e, NULL))
646 + if (!find_pack_entry(packed, oid, &e, 0, NULL))
615 647 return 0;
616 648 if (e.p->is_cruft)
617 649 return 0;
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 replay.c
@@ -336,6 +336,13 @@ static struct commit *pick_regular_commit(struct repository *repo,
336 336 merge_opt->ancestor = NULL;
337 337 merge_opt->branch2 = NULL;
338 338
339 + if (result->clean < 0) {
340 + error(_("merge of %s onto %s failed"),
341 + oid_to_hex(&pickme->object.oid),
342 + oid_to_hex(&replayed_base->object.oid));
343 + return NULL;
344 + }
345 +
339 346 if (!result->clean)
340 347 return NULL;
341 348
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/helper/test-read-midx.c
@@ -82,7 +82,7 @@ static int read_midx_file(const char *object_dir, const char *checksum,
82 82 for (i = 0; i < m->num_objects; i++) {
83 83 nth_midxed_object_oid(&oid, m,
84 84 i + m->num_objects_in_base);
85 - fill_midx_entry(m, &oid, &e, NULL);
85 + midx_fill_entry(m, &oid, &e, NULL);
86 86
87 87 printf("%s %"PRIu64"\t%s\n",
88 88 oid_to_hex(&oid), e.offset, e.p->pack_name);
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/t1010-mktree.sh
@@ -69,4 +69,52 @@ test_expect_success 'mktree refuses to read ls-tree -r output (2)' '
69 69 test_must_fail git mktree <all.withsub
70 70 '
71 71
72 + test_expect_success PIPE 'mktree --batch survives a concurrent repack retiring a pack' '
73 + test_when_finished "rm -fr race" &&
74 + git init race &&
75 + (
76 + cd race &&
77 + test_commit seed &&
78 + a=$(echo A | git hash-object -w --stdin) &&
79 + b=$(echo B | git hash-object -w --stdin) &&
80 + echo "$a" | git pack-objects .git/objects/pack/pack >pack-a &&
81 + echo "$b" | git pack-objects .git/objects/pack/pack >pack-b &&
82 +
83 + # Drop the loose copies so the blobs resolve only through the
84 + # packs the multi-pack-index names.
85 + git prune-packed &&
86 + git multi-pack-index write &&
87 + printf "100644 blob %s\ta\n" "$a" >tree-a &&
88 + printf "100644 blob %s\tb\n" "$b" >tree-b &&
89 +
90 + victim=".git/objects/pack/pack-$(cat pack-b)" &&
91 + mkfifo in out &&
92 +
93 + # mktree --batch stays resident, so its pack view predates the
94 + # repack below; feed it one tree at a time over a fifo. The
95 + # subshell exit closes the fifos, letting mktree see EOF and quit.
96 + (git mktree --batch <in >out 2>err &) &&
97 + exec 9>in &&
98 + exec 8<out &&
99 +
100 + # The first tree makes the reader cache its (soon stale) view.
101 + cat tree-a >&9 && echo >&9 && read tree_a <&8 &&
102 +
103 + # Mimic a concurrent repack: a replacement pack holds every
104 + # object, and the pack for b loses its .idx (its .pack lingers),
105 + # matching the order in which unlink_pack_path() removes files.
106 + git cat-file --batch-all-objects --batch-check="%(objectname)" >oids &&
107 + git pack-objects .git/objects/pack/pack <oids >/dev/null &&
108 + rm -f "$victim.idx" &&
109 +
110 + # Resolving b used to fail, as its QUICK lookup accepted the
111 + # miss; without QUICK the reader repreps and finds b in the
112 + # replacement pack.
113 + cat tree-b >&9 && echo >&9 && read tree_b <&8 &&
114 + exec 9>&- &&
115 +
116 + test -n "$tree_b"
117 + )
118 + '
119 +
72 120 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/t3650-replay-basics.sh
@@ -672,4 +672,38 @@ test_expect_success 'replay --revert with --linearize reverts a range containing
672 672 test_must_fail git cat-file -e $tip:Y.t
673 673 '
674 674
675 + test_expect_success 'replay fails without segfault when objects are missing' '
676 + test_when_finished "rm -fr unreadable" &&
677 + git init unreadable &&
678 + (
679 + cd unreadable &&
680 +
681 + test_write_lines l1 l2 l3 l4 l5 l6 l7 l8 >f &&
682 + git add f &&
683 + git commit -m base &&
684 + git branch base &&
685 +
686 + test_write_lines l1 l2 l3 l4 l5 l6 l7 CHANGED >f &&
687 + git commit -am side &&
688 + git branch side &&
689 +
690 + git switch -c onto base &&
691 + test_write_lines CHANGED l2 l3 l4 l5 l6 l7 l8 >f &&
692 + git commit -am onto &&
693 +
694 + # The replay works while every object is readable.
695 + git replay --onto onto base..side &&
696 +
697 + # Removing the onto tree makes parse_tree() fail during the
698 + # incore merge, driving clean < 0 with a NULL result tree.
699 + onto_tree=$(git rev-parse onto^{tree}) &&
700 + obj=$(test_oid_to_path "$onto_tree") &&
701 + mv .git/objects/${obj} saved-tree &&
702 +
703 + # Ensure replay gracefully handles the missing object
704 + test_must_fail git replay --onto onto base..side 2>err &&
705 + test_grep -e "Could not read" -e "collecting merge info failed" err
706 + )
707 + '
708 +
675 709 test_done
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/t5319-multi-pack-index.sh
@@ -1393,4 +1393,44 @@ test_expect_success 'pack.preferBitmapTips interprets patterns as hierarchy' '
1393 1393 )
1394 1394 '
1395 1395
1396 + test_expect_success 'lookup recovers object whose midx-owning pack was removed' '
1397 + test_when_finished "rm -fr repo" &&
1398 + git init repo &&
1399 + (
1400 + cd repo &&
1401 +
1402 + # "keep" ends up only in the big pack; "dup" is deliberately
1403 + # placed in two packs so the midx has to choose an owner.
1404 + test_commit keep &&
1405 + echo duplicated-content >dup &&
1406 + git add dup &&
1407 + git commit -m dup &&
1408 + dup_oid=$(git rev-parse HEAD:dup) &&
1409 +
1410 + # Roll every object, including dup, into a single big pack.
1411 + git repack -adq &&
1412 +
1413 + # Build a second, "moderate" pack that also contains dup, so dup
1414 + # now lives in two packs that the midx will cover.
1415 + moderate=$(echo "$dup_oid" |
1416 + git pack-objects --quiet $objdir/pack/pack) &&
1417 +
1418 + # Attribute dup to the moderate pack in the midx.
1419 + git multi-pack-index write \
1420 + --preferred-pack="pack-$moderate.idx" &&
1421 +
1422 + # Simulate a concurrent "git repack" retiring the moderate pack:
1423 + # its files disappear, but the now-stale midx still names it as
1424 + # the owner of dup. A valid copy of dup survives in the big pack.
1425 + rm -f $objdir/pack/pack-$moderate.* &&
1426 +
1427 + # The midx routes the lookup to the deleted pack, and the regular
1428 + # pack fallback skips midx-covered packs, so without recovery dup
1429 + # would appear missing even though it is physically present.
1430 + echo blob >expect &&
1431 + git cat-file -t "$dup_oid" >actual &&
1432 + test_cmp expect actual
1433 + )
1434 + '
1435 +
1396 1436 test_done
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 {