Compare

f0ef1b96a076d08dc972a8d2cb0d1cfd60931eb6..995251109fa3e631e6fc7204e8cad128e8da2217

doc/refs: backtick-quote commands and options consistently

The git-refs doc was converted to the synopsis style in 89be7d2774
(builtin/refs: add '--no-reflog' flag to drop reflogs, 2025-02-21).  The
commands and options were not backtick-quoted at that time.  84f3d6e11e
(doc lint: check that synopsis manpages have synopsis inlines,
2025-08-11) applied backtick-quotes to the existing commands and
options.

Subsequently, a number of commands and options were added without such
quoting, leaving the documentation rendered inconsistently.  Apply
backtick-quotes to all entries.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Todd Zullinger <tmz@pobox.com> · 2026-09-15 13:10 UTC · committed by Junio C Hamano

Browse files
91 files changed, +732 −1645
modified Documentation/RelNotes/2.56.0.adoc
@@ -148,21 +148,6 @@ UI, Workflows & Features
148 148 drop merge commits and linearize the replayed history, mimicking 'git
149 149 rebase --no-rebase-merges'.
150 150
151 - * The documentation for 'git cherry-pick' has been updated to clarify
152 - that the '--no-commit' option intentionally skips setting the
153 - 'CHERRY_PICK_HEAD' ref. A test has also been added to ensure this
154 - behavior holds even when the operation stops for conflicts.
155 -
156 - * The 'git imap-send' command has been taught to take the '--draft'
157 - option to mark uploaded messages as drafts, which helps some email
158 - clients render them properly for editing and sending.
159 -
160 - * The git rev-list command has been augmented with a '--missing-only'
161 - option that filters the output to only show missing objects,
162 - stripping the leading '?' character and suppressing present objects,
163 - which is useful when used in combination with '--missing=print' or
164 - '--missing=print-info'.
165 -
166 151
167 152 Performance, Internal Implementation, Development Support etc.
168 153 --------------------------------------------------------------
@@ -533,33 +518,6 @@ Performance, Internal Implementation, Development Support etc.
533 518 the main 'git.exe' to be used directly without the extra wrapper
534 519 process on Windows.
535 520
536 - * The process of downloading packfile URIs in protocol v2 has been
537 - instrumented with a Trace2 region. This visibility allows tracking
538 - the cumulative time spent downloading external packs and the number
539 - of advertised URIs without emitting a separate event per pack.
540 -
541 - * CGI helper scripts used by HTTP-related test scripts have been updated
542 - to use atomic filesystem operations, preventing race conditions when
543 - Apache handles concurrent requests.
544 -
545 - * "git maintenance" triggered "rerere gc" in unappropriate times and
546 - interfered with "git rebase" etc. too much. The conditions "rerere
547 - gc" gets triggered have been tweaked.
548 -
549 - * Windows build switches from MINGW64 to URCR64 runtime starting Git
550 - 2.56.0; switch the cmake based build at the same time.
551 -
552 - * The mechanism to register in-memory alternate object sources has
553 - been removed, as submodule object databases are now accessed
554 - natively via their own repository structures. This simplifies
555 - object database management and prepares the codebase for migrating
556 - alternate tracking into the files backend.
557 -
558 - * The consistency checks for the object database (fsck) have been
559 - decoupled from the generic builtin implementation and moved into the
560 - backend-specific object source layers, making them pluggable for
561 - different object storage formats.
562 -
563 521
564 522 Fixes since v2.55
565 523 -----------------
@@ -861,41 +819,7 @@ Fixes since v2.55
861 819 package manager instead of pinning to an older version via gem.
862 820 Additionally, an obsolete variable used for retired Azure Pipelines
863 821 environments has been removed.
864 -
865 - * Teach 'am', 'revert', and 'rebase' that running 'commit --amend' or a
866 - partial 'commit <paths>' makes no sense during operations that stop
867 - and return control to the user to resolve conflicts left in the
868 - working tree, just like 'cherry-pick' and 'merge' do.
869 - (merge cc499d40e5 en/no-amend-during-conflicts later to maint).
870 -
871 - * The error path in 'git submodule--helper' has been updated to plug a
872 - memory leak when a repository handle could not be obtained,
873 - leveraging an updated idempotent repo_clear().
874 - (merge 2c03739705 jk/submodule-error-leak later to maint).
875 -
876 - * Two members in "struct pathspec_item" were of type "char *", but
877 - nobody updated the string through these pointers. They have been
878 - made "const char *" instead.
879 - (merge 88d06b1c91 jc/pathspec-match-const later to maint).
880 -
881 - * The gitdatamodel documentation page has been linked from a handful
882 - of key documentaiton pages.
883 - (merge ec602484bd kh/doc-datamodel later to maint).
884 -
885 - * Running "git history" in a corrupt repository can (unsurprisingly)
886 - segfault when a necessary tree object is not found.
887 - (merge 76621488e8 jc/history-missing-tree-errorfix later to maint).
888 -
889 - * The development helper script to lint gitlink references in the
890 - documentation has been updated to avoid a newer Perl regular
891 - expression syntax that breaks on older Perl versions.
892 - (merge 8a631963a9 ta/lint-gitlink-older-perl-fix later to maint).
893 -
894 - * The autostash fallback in 'git checkout -m' has been refined to only
895 - retry when there are local changes. Additionally, a blank line now
896 - visually separates autostash conflict advice from the subsequent
897 - branch-switch message.
898 - (merge 2ba77ea828 hn/checkout-m-autostash-refine later to maint).
822 + (merge 1c1eed13bd jk/ci-use-system-asciidoctor later to maint).
899 823
900 824 * Other code cleanup, docfix, build fix, etc.
901 825 (merge 026636128f ss/submittingpatches-typofix later to maint).
modified Documentation/config/maintenance.adoc
@@ -41,7 +41,6 @@ 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 - +
45 44 * `incremental`: This setting optimizes for performing small maintenance
46 45 activities that do not delete any data. This does not schedule the `gc`
47 46 task, but runs the `prefetch` and `commit-graph` tasks hourly, the
@@ -122,10 +121,10 @@ maintenance.rerere-gc.auto::
122 121 This integer config option controls how often the `rerere-gc` task
123 122 should be run as part of `git maintenance run --auto`. If zero, then
124 123 the `rerere-gc` task will not run with the `--auto` option. A negative
125 - value will force the task to run every time. Otherwise, a positive
126 - value implies the command should run when the estimated number of stale
127 - entries that would be pruned is greater than or equal to the configured
128 - value. The default value is 512.
124 + value will force the task to run every time. Otherwise, any positive
125 + value implies the command will run when the "rr-cache" directory exists
126 + and has at least one entry, regardless of whether it is stale or not.
127 + This heuristic may be refined in the future. The default value is 1.
129 128
130 129 maintenance.worktree-prune.auto::
131 130 This integer config option controls how often the `worktree-prune` task
modified Documentation/git-cherry-pick.adoc
@@ -25,8 +25,7 @@ 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, unless the
29 - `--no-commit` option was given.
28 + introduced the change that is difficult to apply.
30 29 3. Paths in which the change applied cleanly are updated both
31 30 in the index file and in your working tree.
32 31 4. For conflicting paths, the index file records up to three
@@ -102,11 +101,6 @@ OPTIONS
102 101 +
103 102 This is useful when cherry-picking more than one commits'
104 103 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.
110 104
111 105 -s::
112 106 --signoff::
modified Documentation/git-imap-send.adoc
@@ -9,7 +9,7 @@ git-imap-send - Send a collection of patches from stdin to an IMAP folder
9 9 SYNOPSIS
10 10 --------
11 11 [synopsis]
12 - git imap-send [-v] [-q] [--[no-]curl] [--[no-]draft] [(--folder|-f) <folder>]
12 + git imap-send [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]
13 13 git imap-send --list
14 14
15 15
@@ -55,13 +55,6 @@ OPTIONS
55 55 using libcurl. Ignored if Git was built with the NO_OPENSSL option
56 56 set.
57 57
58 - `--draft`::
59 - `--no-draft`::
60 - Mark uploaded messages with the IMAP `\Draft` flag. The default is `--no-draft`.
61 - +
62 - With libcurl, `--draft` requires version 8.13.0 or later.
63 - Older libcurl still uploads the message but cannot set the flag.
64 -
65 58 `--list`::
66 59 Run the IMAP LIST command to output a list of all the folders present.
67 60
modified Documentation/git-pack-refs.adoc
@@ -7,8 +7,8 @@ git-pack-refs - Pack heads and tags for efficient repository access
7 7
8 8 SYNOPSIS
9 9 --------
10 - [verse]
11 - 'git pack-refs' [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>]
10 + [synopsis]
11 + git pack-refs [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>]
12 12
13 13 DESCRIPTION
14 14 -----------
@@ -52,8 +52,8 @@ BUGS
52 52 ----
53 53
54 54 Older documentation written before the packed-refs mechanism was
55 - introduced may still say things like ".git/refs/heads/<branch> file
56 - exists" when it means "branch <branch> exists".
55 + introduced may still say things like ".git/refs/heads/_<branch>_ file
56 + exists" when it means "branch _<branch>_ exists".
57 57
58 58
59 59 GIT
modified Documentation/git-refs.adoc
@@ -54,40 +54,40 @@ These limitations may eventually be lifted.
54 54 `verify`::
55 55 Verify reference database consistency.
56 56
57 - list::
57 + `list`::
58 58 List references in the repository with support for filtering,
59 59 formatting, and sorting. This subcommand is an alias for
60 60 linkgit:git-for-each-ref[1] and offers identical functionality.
61 61
62 - exists::
62 + `exists`::
63 63 Check whether the given reference exists. Returns an exit code of 0 if
64 64 it does, 2 if it is missing, and 1 in case looking up the reference
65 65 failed with an error other than the reference being missing. This does
66 66 not verify whether the reference resolves to an actual object.
67 67
68 - optimize::
68 + `optimize`::
69 69 Optimizes references to improve repository performance and reduce disk
70 70 usage. This subcommand is an alias for linkgit:git-pack-refs[1] and
71 71 offers identical functionality.
72 72
73 - create::
73 + `create`::
74 74 Create the given reference, which must not already exist, pointing at
75 75 `<new-value>`.
76 76
77 - delete::
77 + `delete`::
78 78 Delete the given reference. This subcommand mirrors `git update-ref -d`
79 79 (see linkgit:git-update-ref[1]). When `<old-value>` is given, the
80 80 reference is only deleted after verifying that it currently contains
81 81 `<old-value>`.
82 82
83 - update::
83 + `update`::
84 84 Update the given reference to point at `<new-value>`. If `<old-value>`
85 85 is given, the reference is only updated after verifying that it
86 86 currently contains `<old-value>`. As a special case, an all-zeroes
87 87 `<new-value>` deletes the branch, whereas an all-zeroes `<old-value>`
88 88 ensures that the branch does not yet exist.
89 89
90 - rename::
90 + `rename`::
91 91 Rename the reference `<oldref>` to `<newref>`. The old reference must
92 92 exist and the new reference must not yet exist, and both must have a
93 93 well-formed name (see linkgit:git-check-ref-format[1]).
modified Documentation/git-stash.adoc
@@ -426,15 +426,6 @@ include::includes/cmd-config-section-all.adoc[]
426 426 :git-stash: 1
427 427 include::config/stash.adoc[]
428 428
429 - EXIT STATUS
430 - -----------
431 -
432 - The `git stash` subcommands exit with status 0 on success. The
433 - subcommands that apply a stash entry, i.e. `apply`, `pop` and `branch`,
434 - exit with status 1 when applying the stash entry resulted in conflicts,
435 - in which case the stash entry is left in place, and with a non-zero
436 - status other than 1 when they fail for other reasons.
437 -
438 429
439 430 SEE ALSO
440 431 --------
modified Documentation/git.adoc
@@ -25,8 +25,7 @@ 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. See linkgit:gitdatamodel[7] if you want to
29 - learn about the data model and important terminology.
28 + in-depth introduction.
30 29
31 30 After you mastered the basic concepts, you can come back to this
32 31 page to learn what commands Git offers. You can learn more about
@@ -470,9 +469,7 @@ Higher level SCMs may provide and manage additional information in the
470 469
471 470 Terminology
472 471 -----------
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.
472 + Please see linkgit:gitglossary[7].
476 473
477 474
478 475 Environment Variables
@@ -1202,9 +1199,8 @@ SEE ALSO
1202 1199 --------
1203 1200 linkgit:gittutorial[7], linkgit:gittutorial-2[7],
1204 1201 linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
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],
1202 + linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
1203 + linkgit:gitcli[7], link:user-manual.html[The Git User's Manual],
1208 1204 linkgit:gitworkflows[7]
1209 1205
1210 1206 GIT
modified Documentation/gitdatamodel.adoc
@@ -300,10 +300,6 @@ $ 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 -
307 303 GIT
308 304 ---
309 305 Part of the linkgit:git[1] suite
modified Documentation/gitglossary.adoc
@@ -16,7 +16,6 @@ include::glossary-content.adoc[]
16 16
17 17 SEE ALSO
18 18 --------
19 - linkgit:gitdatamodel[7],
20 19 linkgit:gittutorial[7],
21 20 linkgit:gittutorial-2[7],
22 21 linkgit:gitcvs-migration[7],
modified Documentation/glossary-content.adoc
@@ -251,8 +251,7 @@ 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>>. See "THE INDEX" in
255 - linkgit:gitdatamodel[7] for details.
254 + when <<def_merge,merging>>.
256 255
257 256 [[def_index_entry]]index entry::
258 257 The information regarding a particular file, stored in the
@@ -291,8 +290,7 @@ This commit is referred to as a "merge commit", or sometimes just a
291 290 [[def_object]]object::
292 291 The unit of storage in Git. It is uniquely identified by the
293 292 <<def_SHA1,SHA-1>> of its contents. Consequently, an
294 - object cannot be changed. See "OBJECTS" in
295 - linkgit:gitdatamodel[7] for details.
293 + object cannot be changed.
296 294
297 295 [[def_object_database]]object database::
298 296 Stores a set of "objects", and an individual <<def_object,object>> is
@@ -589,17 +587,12 @@ extended in the future:
589 587 Different subhierarchies are used for different purposes. For example,
590 588 the `refs/heads/` hierarchy is used to represent local branches whereas
591 589 the `refs/tags/` hierarchy is used to represent local tags..
592 - +
593 - See also "REFERENCES" in linkgit:gitdatamodel[7].
594 590
595 591 [[def_reflog]]reflog::
596 592 A reflog shows the local "history" of a ref. In other words,
597 593 it can tell you what the 3rd last revision in _this_ repository
598 594 was, and what was the current state in _this_ repository,
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.
595 + yesterday 9:14pm. See linkgit:git-reflog[1] for details.
603 596
604 597 [[def_refspec]]refspec::
605 598 A "refspec" is used by <<def_fetch,fetch>> and
modified Documentation/lint-gitlink.perl
@@ -42,7 +42,7 @@ die "BUG: No list of valid linkgit:* files given" unless @ARGV;
42 42 while (<>) {
43 43 my $line = $_;
44 44 next if $line =~ /^\s*(ifn?def|endif)::/;
45 - while ($line =~ m/(.{0,8})((git[-a-z]+|scalar)\[(\d)*\])/g) {
45 + while ($line =~ m/(.{,8})((git[-a-z]+|scalar)\[(\d)*\])/g) {
46 46 my $pos = pos $line;
47 47 my ($macro, $target, $page, $section) = ($1, $2, $3, $4);
48 48 if ( $macro ne "linkgit:" ) {
modified Documentation/pack-refs-options.adoc
@@ -1,4 +1,4 @@
1 - --all::
1 + `--all`::
2 2
3 3 The command by default packs all tags and refs that are already
4 4 packed, and leaves other refs
@@ -8,12 +8,12 @@ This option causes all refs to be packed as well, with the exception
8 8 of hidden refs, broken refs, and symbolic refs. Useful for a repository
9 9 with many branches of historical interests.
10 10
11 - --no-prune::
11 + `--no-prune`::
12 12
13 13 The command usually removes loose refs under `$GIT_DIR/refs`
14 14 hierarchy after packing them. This option tells it not to.
15 15
16 - --auto::
16 + `--auto`::
17 17
18 18 Pack refs as needed depending on the current state of the ref database. The
19 19 behavior depends on the ref format used by the repository and may change in the
@@ -29,7 +29,7 @@ future.
29 29 maintains the property that N is at least twice as big as N+1. Only
30 30 tables that violate this property are compacted.
31 31
32 - --include <pattern>::
32 + `--include <pattern>`::
33 33
34 34 Pack refs based on a `glob(7)` pattern. Repetitions of this option
35 35 accumulate inclusion patterns. If a ref is both included in `--include` and
@@ -38,7 +38,7 @@ tags from being included by default. Symbolic refs and broken refs will never
38 38 be packed. When used with `--all`, it will be a noop. Use `--no-include` to clear
39 39 and reset the list of patterns.
40 40
41 - --exclude <pattern>::
41 + `--exclude <pattern>`::
42 42
43 43 Do not pack refs matching the given `glob(7)` pattern. Repetitions of this option
44 44 accumulate exclusion patterns. Use `--no-exclude` to clear and reset the list of
modified Documentation/rev-list-options.adoc
@@ -1083,19 +1083,6 @@ If some tips passed to the traversal are missing, they will be
1083 1083 considered as missing too, and the traversal will ignore them. In case
1084 1084 we cannot get their Object ID though, an error will be raised.
1085 1085
1086 - `--missing-only`::
1087 - When used together with `--missing=print` or `--missing=print-info`,
1088 - suppress all output for present objects and print only the missing
1089 - ones. The selected `--missing=` format is preserved (so
1090 - `--missing=print-info` still emits `path=` / `type=` fields), but the
1091 - leading ``?'' prefix used by the non-`-z` forms is omitted. This is
1092 - useful for scripting, as a simpler and faster alternative to
1093 - post-processing the output of `--missing=print`.
1094 - +
1095 - This option is incompatible with `--count` and `--disk-usage`.
1096 - It is an error to use `--missing-only` without `--missing=print` or
1097 - `--missing=print-info`.
1098 -
1099 1086 `--exclude-promisor-objects`::
1100 1087 (For internal use only.) Prefilter object traversal at
1101 1088 promisor boundary. This is used with partial clone. This is
modified builtin/checkout.c
@@ -921,7 +921,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
921 921 }
922 922 }
923 923
924 - if (!cache_tree_fully_valid(the_repository->index))
924 + if (!cache_tree_fully_valid(the_repository->index->cache_tree))
925 925 cache_tree_update(the_repository->index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
926 926
927 927 if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
@@ -1166,7 +1166,6 @@ static int switch_branches(const struct checkout_opts *opts,
1166 1166 int flag, writeout_error = 0;
1167 1167 int do_merge = 1;
1168 1168 int created_autostash = 0;
1169 - enum stash_apply_result autostash_res = STASH_APPLY_CLEAN;
1170 1169 struct strbuf old_commit_shortname = STRBUF_INIT;
1171 1170 struct strbuf autostash_msg = STRBUF_INIT;
1172 1171 const char *stash_label_base = NULL;
@@ -1238,12 +1237,12 @@ static int switch_branches(const struct checkout_opts *opts,
1238 1237 git_config_push_parameter(cfg.buf);
1239 1238 strbuf_release(&cfg);
1240 1239 }
1241 - autostash_res = apply_autostash_ref(the_repository,
1242 - "CHECKOUT_AUTOSTASH_HEAD",
1243 - new_branch_info->name,
1244 - "local",
1245 - stash_label_base,
1246 - autostash_msg.buf);
1240 + apply_autostash_ref(the_repository,
1241 + "CHECKOUT_AUTOSTASH_HEAD",
1242 + new_branch_info->name,
1243 + "local",
1244 + stash_label_base,
1245 + autostash_msg.buf);
1247 1246 }
1248 1247 if (ret) {
1249 1248 branch_info_release(&old_branch_info);
@@ -1256,8 +1255,6 @@ static int switch_branches(const struct checkout_opts *opts,
1256 1255 if (!opts->quiet && !old_branch_info.path && old_branch_info.commit && new_branch_info->commit != old_branch_info.commit)
1257 1256 orphaned_commit_warning(old_branch_info.commit, new_branch_info->commit);
1258 1257
1259 - if (autostash_res == STASH_APPLY_CONFLICT && !opts->quiet)
1260 - fputc('\n', stderr);
1261 1258 update_refs_for_switch(opts, &old_branch_info, new_branch_info);
1262 1259
1263 1260 if (created_autostash) {
modified builtin/commit.c
@@ -484,7 +484,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
484 484 LOCK_DIE_ON_ERROR);
485 485 refresh_cache_or_die(refresh_flags);
486 486 if (the_repository->index->cache_changed
487 - || !cache_tree_fully_valid(the_repository->index))
487 + || !cache_tree_fully_valid(the_repository->index->cache_tree))
488 488 cache_tree_update(the_repository->index, WRITE_TREE_SILENT);
489 489 if (write_locked_index(the_repository->index, &index_lock,
490 490 COMMIT_LOCK | SKIP_IF_UNCHANGED))
@@ -515,25 +515,13 @@ static const char *prepare_index(const char **argv, const char *prefix,
515 515 */
516 516 commit_style = COMMIT_PARTIAL;
517 517
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."));
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."));
537 525 }
538 526
539 527 if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec))
@@ -905,7 +893,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
905 893 */
906 894 else if (whence == FROM_MERGE)
907 895 hook_arg1 = "merge";
908 - else if (is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) {
896 + else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) {
909 897 hook_arg1 = "commit";
910 898 hook_arg2 = "CHERRY_PICK_HEAD";
911 899 }
@@ -1098,7 +1086,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1098 1086 if (amend)
1099 1087 fputs(_(empty_amend_advice), stderr);
1100 1088 else if (is_from_cherry_pick(whence) ||
1101 - is_from_rebase_now_empty(whence)) {
1089 + whence == FROM_REBASE_PICK) {
1102 1090 fputs(_(empty_cherry_pick_advice), stderr);
1103 1091 if (whence == FROM_CHERRY_PICK_SINGLE)
1104 1092 fputs(_(empty_cherry_pick_advice_single), stderr);
@@ -1338,30 +1326,15 @@ static int parse_and_validate_options(int argc, const char *argv[],
1338 1326 use_editor = 0;
1339 1327
1340 1328 /* Sanity check options */
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:
1329 + if (amend && !current_head)
1330 + die(_("You have nothing to amend."));
1331 + if (amend && whence != FROM_COMMIT) {
1332 + if (whence == FROM_MERGE)
1353 1333 die(_("You are in the middle of a merge -- cannot amend."));
1354 - case ONGOING_CHERRY_PICK:
1334 + else if (is_from_cherry_pick(whence))
1355 1335 die(_("You are in the middle of a cherry-pick -- 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 - }
1336 + else if (whence == FROM_REBASE_PICK)
1337 + die(_("You are in the middle of a rebase -- cannot amend."));
1365 1338 }
1366 1339 if (fixup_message && squash_message)
1367 1340 die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup");
@@ -1380,7 +1353,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
1380 1353 if (amend && !use_message && !fixup_message)
1381 1354 use_message = "HEAD";
1382 1355 if (!use_message && !is_from_cherry_pick(whence) &&
1383 - !is_from_rebase_now_empty(whence) && renew_authorship)
1356 + !is_from_rebase(whence) && renew_authorship)
1384 1357 die(_("--reset-author can be used only with -C, -c or --amend."));
1385 1358 if (use_message) {
1386 1359 use_message_buffer = read_commit_message(use_message);
@@ -1389,7 +1362,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
1389 1362 author_message_buffer = use_message_buffer;
1390 1363 }
1391 1364 }
1392 - if ((is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) &&
1365 + if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) &&
1393 1366 !renew_authorship) {
1394 1367 author_message = "CHERRY_PICK_HEAD";
1395 1368 author_message_buffer = read_commit_message(author_message);
@@ -1914,7 +1887,7 @@ int cmd_commit(int argc,
1914 1887 if (!reflog_msg)
1915 1888 reflog_msg = is_from_cherry_pick(whence)
1916 1889 ? "commit (cherry-pick)"
1917 - : is_from_rebase_now_empty(whence)
1890 + : is_from_rebase(whence)
1918 1891 ? "commit (rebase)"
1919 1892 : "commit";
1920 1893 commit_list_insert(current_head, &parents);
modified builtin/fetch.c
@@ -2681,7 +2681,7 @@ int cmd_fetch(int argc,
2681 2681 int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT
2682 2682 ? &config.recurse_submodules : NULL;
2683 2683
2684 - fetch_config_from_gitmodules(the_repository, sfjc, rs);
2684 + fetch_config_from_gitmodules(sfjc, rs);
2685 2685 }
2686 2686
2687 2687
modified builtin/fsck.c
@@ -7,11 +7,13 @@
7 7 #include "blob.h"
8 8 #include "tag.h"
9 9 #include "refs.h"
10 + #include "pack.h"
10 11 #include "cache-tree.h"
11 12 #include "fsck.h"
12 13 #include "parse-options.h"
13 14 #include "progress.h"
14 15 #include "packfile.h"
16 + #include "object-file.h"
15 17 #include "object-name.h"
16 18 #include "odb.h"
17 19 #include "odb/streaming.h"
@@ -22,6 +24,8 @@
22 24 #include "run-command.h"
23 25 #include "sparse-index.h"
24 26 #include "worktree.h"
27 + #include "pack-revindex.h"
28 + #include "pack-bitmap.h"
25 29
26 30 #define REACHABLE 0x0001
27 31 #define SEEN 0x0002
@@ -33,8 +37,10 @@ static int show_root;
33 37 static int show_tags;
34 38 static int show_unreachable;
35 39 static int include_reflogs = 1;
40 + static int check_full = 1;
36 41 static int connectivity_only;
37 42 static int check_strict;
43 + static int keep_cache_objects;
38 44 static struct fsck_options fsck_walk_options;
39 45 static struct fsck_options fsck_obj_options;
40 46 static int errors_found;
@@ -42,11 +48,17 @@ static int write_lost_and_found;
42 48 static int verbose;
43 49 static int show_progress = -1;
44 50 static int show_dangling = 1;
51 + static int name_objects;
52 + static int check_references = 1;
45 53 static timestamp_t now;
46 54 #define ERROR_OBJECT 01
47 55 #define ERROR_REACHABLE 02
56 + #define ERROR_PACK 04
48 57 #define ERROR_REFS 010
49 58 #define ERROR_COMMIT_GRAPH 020
59 + #define ERROR_MULTI_PACK_INDEX 040
60 + #define ERROR_PACK_REV_INDEX 0100
61 + #define ERROR_BITMAP 0200
50 62
51 63 static const char *describe_object(const struct object_id *oid)
52 64 {
@@ -389,27 +401,14 @@ static void check_connectivity(struct repository *repo)
389 401 }
390 402 }
391 403
392 - static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
393 - unsigned long size, void *buffer, int *eaten, void *cb_data)
404 + static int fsck_obj(struct repository *repo,
405 + struct object *obj, void *buffer, unsigned long size)
394 406 {
395 - struct repository *repo = cb_data;
396 - struct object *obj;
397 407 int err;
398 408
399 - /*
400 - * Note, buffer may be NULL if type is OBJ_BLOB. See
401 - * verify_packfile(), data_valid variable for details.
402 - */
403 - obj = parse_object_buffer(repo, oid, type, size, buffer, eaten);
404 - if (!obj) {
405 - errors_found |= ERROR_OBJECT;
406 - err = error(_("%s: object corrupt or missing"),
407 - oid_to_hex(oid));
408 - goto out;
409 - }
410 -
411 - obj->flags &= ~REACHABLE;
412 - obj->flags |= HAS_OBJ | SEEN;
409 + if (obj->flags & SEEN)
410 + return 0;
411 + obj->flags |= SEEN;
413 412
414 413 if (verbose)
415 414 fprintf_ln(stderr, _("Checking %s %s"),
@@ -418,7 +417,6 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
418 417
419 418 if (fsck_walk(obj, NULL, &fsck_obj_options))
420 419 objerror(repo, obj, _("broken links"));
421 -
422 420 err = fsck_object(obj, buffer, size, &fsck_obj_options);
423 421 if (err)
424 422 goto out;
@@ -444,11 +442,32 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
444 442 }
445 443
446 444 out:
447 - if (obj && obj->type == OBJ_TREE)
445 + if (obj->type == OBJ_TREE)
448 446 free_tree_buffer((struct tree *)obj);
449 447 return err;
450 448 }
451 449
450 + static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
451 + unsigned long size, void *buffer, int *eaten, void *cb_data)
452 + {
453 + struct repository *repo = cb_data;
454 + struct object *obj;
455 +
456 + /*
457 + * Note, buffer may be NULL if type is OBJ_BLOB. See
458 + * verify_packfile(), data_valid variable for details.
459 + */
460 + obj = parse_object_buffer(repo, oid, type, size, buffer, eaten);
461 + if (!obj) {
462 + errors_found |= ERROR_OBJECT;
463 + return error(_("%s: object corrupt or missing"),
464 + oid_to_hex(oid));
465 + }
466 + obj->flags &= ~(REACHABLE | SEEN);
467 + obj->flags |= HAS_OBJ;
468 + return fsck_obj(repo, obj, buffer, size);
469 + }
470 +
452 471 static int default_refs;
453 472
454 473 static void fsck_handle_reflog_oid(struct repository *repo,
@@ -694,6 +713,103 @@ static void process_refs(struct repository *repo, struct snapshot *snap)
694 713 }
695 714 }
696 715
716 + struct for_each_loose_cb {
717 + struct repository *repo;
718 + struct progress *progress;
719 + };
720 +
721 + static int fsck_loose(const struct object_id *oid, const char *path,
722 + void *cb_data)
723 + {
724 + struct for_each_loose_cb *data = cb_data;
725 + struct object *obj;
726 + enum object_type type = OBJ_NONE;
727 + size_t size;
728 + void *contents = NULL;
729 + int eaten;
730 + struct object_info oi = OBJECT_INFO_INIT;
731 + struct object_id real_oid = *null_oid(data->repo->hash_algo);
732 + int err = 0;
733 +
734 + oi.sizep = &size;
735 + oi.typep = &type;
736 +
737 + if (read_loose_object(data->repo, path, oid, &real_oid, &contents, &oi) < 0) {
738 + if (contents && !oideq(&real_oid, oid))
739 + err = error(_("%s: hash-path mismatch, found at: %s"),
740 + oid_to_hex(&real_oid), path);
741 + else
742 + err = error(_("%s: object corrupt or missing: %s"),
743 + oid_to_hex(oid), path);
744 + }
745 + if (err < 0) {
746 + errors_found |= ERROR_OBJECT;
747 + free(contents);
748 + return 0; /* keep checking other objects */
749 + }
750 +
751 + if (!contents && type != OBJ_BLOB)
752 + BUG("read_loose_object streamed a non-blob");
753 +
754 + obj = parse_object_buffer(data->repo, oid, type, size,
755 + contents, &eaten);
756 +
757 + if (!obj) {
758 + errors_found |= ERROR_OBJECT;
759 + error(_("%s: object could not be parsed: %s"),
760 + oid_to_hex(oid), path);
761 + if (!eaten)
762 + free(contents);
763 + return 0; /* keep checking other objects */
764 + }
765 +
766 + obj->flags &= ~(REACHABLE | SEEN);
767 + obj->flags |= HAS_OBJ;
768 + if (fsck_obj(data->repo, obj, contents, size))
769 + errors_found |= ERROR_OBJECT;
770 +
771 + if (!eaten)
772 + free(contents);
773 + return 0; /* keep checking other objects, even if we saw an error */
774 + }
775 +
776 + static int fsck_cruft(const char *basename, const char *path,
777 + void *data UNUSED)
778 + {
779 + if (!starts_with(basename, "tmp_obj_"))
780 + fprintf_ln(stderr, _("bad sha1 file: %s"), path);
781 + return 0;
782 + }
783 +
784 + static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *data)
785 + {
786 + struct for_each_loose_cb *cb_data = data;
787 + struct progress *progress = cb_data->progress;
788 + display_progress(progress, nr + 1);
789 + return 0;
790 + }
791 +
792 + static void fsck_source(struct repository *repo, struct odb_source *source)
793 + {
794 + struct progress *progress = NULL;
795 + struct for_each_loose_cb cb_data = {
796 + .repo = source->odb->repo,
797 + .progress = progress,
798 + };
799 +
800 + if (verbose)
801 + fprintf_ln(stderr, _("Checking object directory"));
802 +
803 + if (show_progress)
804 + progress = start_progress(repo,
805 + _("Checking object directories"), 256);
806 +
807 + for_each_loose_file_in_source(source, fsck_loose,
808 + fsck_cruft, fsck_subdir, &cb_data);
809 + display_progress(progress, 256);
810 + stop_progress(&progress);
811 + }
812 +
697 813 static int fsck_cache_tree(struct repository *repo, struct cache_tree *it, const char *index_path)
698 814 {
699 815 int i;
@@ -802,6 +918,40 @@ static int mark_object_for_connectivity(const struct object_id *oid,
802 918 return 0;
803 919 }
804 920
921 + static int check_pack_rev_indexes(struct repository *r, int show_progress)
922 + {
923 + struct progress *progress = NULL;
924 + struct packed_git *p;
925 + uint32_t pack_count = 0;
926 + int res = 0;
927 +
928 + if (show_progress) {
929 + repo_for_each_pack(r, p)
930 + pack_count++;
931 + progress = start_delayed_progress(r,
932 + "Verifying reverse pack-indexes", pack_count);
933 + pack_count = 0;
934 + }
935 +
936 + repo_for_each_pack(r, p) {
937 + int load_error = load_pack_revindex_from_disk(p);
938 +
939 + if (load_error < 0) {
940 + error(_("unable to load rev-index for pack '%s'"), p->pack_name);
941 + res = ERROR_PACK_REV_INDEX;
942 + } else if (!load_error &&
943 + !load_pack_revindex(r, p) &&
944 + verify_pack_revindex(p)) {
945 + error(_("invalid rev-index for pack '%s'"), p->pack_name);
946 + res = ERROR_PACK_REV_INDEX;
947 + }
948 + display_progress(progress, ++pack_count);
949 + }
950 + stop_progress(&progress);
951 +
952 + return res;
953 + }
954 +
805 955 static void fsck_refs(struct repository *r)
806 956 {
807 957 struct child_process refs_verify = CHILD_PROCESS_INIT;
@@ -836,38 +986,30 @@ static char const * const fsck_usage[] = {
836 986 NULL
837 987 };
838 988
989 + static struct option fsck_opts[] = {
990 + OPT__VERBOSE(&verbose, N_("be verbose")),
991 + OPT_BOOL(0, "unreachable", &show_unreachable, N_("show unreachable objects")),
992 + OPT_BOOL(0, "dangling", &show_dangling, N_("show dangling objects")),
993 + OPT_BOOL(0, "tags", &show_tags, N_("report tags")),
994 + OPT_BOOL(0, "root", &show_root, N_("report root nodes")),
995 + OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")),
996 + OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")),
997 + OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")),
998 + OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")),
999 + OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")),
1000 + OPT_BOOL(0, "lost-found", &write_lost_and_found,
1001 + N_("write dangling objects in .git/lost-found")),
1002 + OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
1003 + OPT_BOOL(0, "name-objects", &name_objects, N_("show verbose names for reachable objects")),
1004 + OPT_BOOL(0, "references", &check_references, N_("check reference database consistency")),
1005 + OPT_END(),
1006 + };
1007 +
839 1008 int cmd_fsck(int argc,
840 1009 const char **argv,
841 1010 const char *prefix,
842 1011 struct repository *repo)
843 1012 {
844 - struct odb_fsck_options odb_fsck_opts = {
845 - .flags = ODB_FSCK_FULL,
846 - .object_cb = fsck_obj_buffer,
847 - .object_payload = repo,
848 - };
849 - int keep_cache_objects = 0;
850 - int name_objects = 0;
851 - int check_references = 1;
852 - struct option fsck_opts[] = {
853 - OPT__VERBOSE(&verbose, N_("be verbose")),
854 - OPT_BOOL(0, "unreachable", &show_unreachable, N_("show unreachable objects")),
855 - OPT_BOOL(0, "dangling", &show_dangling, N_("show dangling objects")),
856 - OPT_BOOL(0, "tags", &show_tags, N_("report tags")),
857 - OPT_BOOL(0, "root", &show_root, N_("report root nodes")),
858 - OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")),
859 - OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")),
860 - OPT_BIT(0, "full", &odb_fsck_opts.flags,
861 - N_("also consider packs and alternate objects"), ODB_FSCK_FULL),
862 - OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")),
863 - OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")),
864 - OPT_BOOL(0, "lost-found", &write_lost_and_found,
865 - N_("write dangling objects in .git/lost-found")),
866 - OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
867 - OPT_BOOL(0, "name-objects", &name_objects, N_("show verbose names for reachable objects")),
868 - OPT_BOOL(0, "references", &check_references, N_("check reference database consistency")),
869 - OPT_END(),
870 - };
871 1013 struct odb_source *source;
872 1014 struct snapshot snap = {
873 1015 .nr = 0,
@@ -895,15 +1037,11 @@ int cmd_fsck(int argc,
895 1037
896 1038 if (show_progress == -1)
897 1039 show_progress = isatty(2);
898 - if (verbose) {
1040 + if (verbose)
899 1041 show_progress = 0;
900 - odb_fsck_opts.flags |= ODB_FSCK_VERBOSE;
901 - }
902 - if (show_progress)
903 - odb_fsck_opts.flags |= ODB_FSCK_PROGRESS;
904 1042
905 1043 if (write_lost_and_found) {
906 - odb_fsck_opts.flags |= ODB_FSCK_FULL;
1044 + check_full = 1;
907 1045 include_reflogs = 0;
908 1046 }
909 1047
@@ -931,8 +1069,35 @@ int cmd_fsck(int argc,
931 1069 odb_for_each_object(repo->objects, NULL,
932 1070 mark_object_for_connectivity, repo, 0);
933 1071 } else {
934 - if (odb_fsck(repo->objects, &odb_fsck_opts) < 0)
935 - errors_found |= ERROR_OBJECT;
1072 + for (source = repo->objects->sources; source; source = source->next)
1073 + fsck_source(repo, source);
1074 +
1075 + if (check_full) {
1076 + struct packed_git *p;
1077 + uint32_t total = 0, count = 0;
1078 + struct progress *progress = NULL;
1079 +
1080 + if (show_progress) {
1081 + repo_for_each_pack(repo, p) {
1082 + if (open_pack_index(p))
1083 + continue;
1084 + total += p->num_objects;
1085 + }
1086 +
1087 + progress = start_progress(repo,
1088 + _("Checking objects"), total);
1089 + }
1090 +
1091 + repo_for_each_pack(repo, p) {
1092 + /* verify gives error messages itself */
1093 + if (verify_pack(repo,
1094 + p, fsck_obj_buffer, repo,
1095 + progress, count))
1096 + errors_found |= ERROR_PACK;
1097 + count += p->num_objects;
1098 + }
1099 + stop_progress(&progress);
1100 + }
936 1101
937 1102 if (fsck_finish(&fsck_obj_options))
938 1103 errors_found |= ERROR_OBJECT;
@@ -980,6 +1145,10 @@ int cmd_fsck(int argc,
980 1145 free_worktrees(worktrees);
981 1146 }
982 1147
1148 + errors_found |= check_pack_rev_indexes(repo, show_progress);
1149 + if (verify_bitmap_files(repo))
1150 + errors_found |= ERROR_BITMAP;
1151 +
983 1152 check_connectivity(repo);
984 1153
985 1154 if (repo->settings.core_commit_graph) {
@@ -999,6 +1168,23 @@ int cmd_fsck(int argc,
999 1168 }
1000 1169 }
1001 1170
1171 + if (repo->settings.core_multi_pack_index) {
1172 + struct child_process midx_verify = CHILD_PROCESS_INIT;
1173 +
1174 + for (source = repo->objects->sources; source; source = source->next) {
1175 + child_process_init(&midx_verify);
1176 + midx_verify.git_cmd = 1;
1177 + strvec_pushl(&midx_verify.args, "multi-pack-index",
1178 + "verify", "--object-dir", source->path, NULL);
1179 + if (show_progress)
1180 + strvec_push(&midx_verify.args, "--progress");
1181 + else
1182 + strvec_push(&midx_verify.args, "--no-progress");
1183 + if (run_command(&midx_verify))
1184 + errors_found |= ERROR_MULTI_PACK_INDEX;
1185 + }
1186 + }
1187 +
1002 1188 free_snapshot_refs(&snap);
1003 1189 return errors_found;
1004 1190 }
modified builtin/gc.c
@@ -396,15 +396,31 @@ static int maintenance_task_rerere_gc(struct maintenance_run_opts *opts UNUSED,
396 396
397 397 static int rerere_gc_condition(struct gc_config *cfg UNUSED)
398 398 {
399 - int limit = 512;
399 + struct strbuf path = STRBUF_INIT;
400 + int should_gc = 0, limit = 1;
401 + DIR *dir = NULL;
400 402
401 403 repo_config_get_int(the_repository, "maintenance.rerere-gc.auto", &limit);
402 - if (!limit)
403 - return 0; /* never prune */
404 - if (limit < 0)
405 - return 1; /* always prune */
404 + if (limit <= 0) {
405 + should_gc = limit < 0;
406 + goto out;
407 + }
408 +
409 + /*
410 + * We skip garbage collection in case we either have no "rr-cache"
411 + * directory or when it doesn't contain at least one entry.
412 + */
413 + repo_git_path_replace(the_repository, &path, "rr-cache");
414 + dir = opendir(path.buf);
415 + if (!dir)
416 + goto out;
417 + should_gc = !!readdir_skip_dot_and_dotdot(dir);
406 418
407 - return rerere_gc_needed(the_repository, (size_t)limit);
419 + out:
420 + strbuf_release(&path);
421 + if (dir)
422 + closedir(dir);
423 + return should_gc;
408 424 }
409 425
410 426 #define OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, aggressive) \
modified builtin/grep.c
@@ -463,6 +463,16 @@ static int grep_submodule(struct grep_opt *opt,
463 463 ALLOC_GROW(repos_to_free, repos_to_free_nr + 1, repos_to_free_alloc);
464 464 repos_to_free[repos_to_free_nr++] = subrepo;
465 465
466 + /*
467 + * NEEDSWORK: repo_read_gitmodules() might call
468 + * odb_add_to_alternates_memory() via config_from_gitmodules(). This
469 + * operation causes a race condition with concurrent object readings
470 + * performed by the worker threads. That's why we need obj_read_lock()
471 + * here. It should be removed once it's no longer necessary to add the
472 + * subrepo's odbs to the in-memory alternates list.
473 + */
474 + obj_read_lock();
475 +
466 476 /*
467 477 * NEEDSWORK: when reading a submodule, the sparsity settings in the
468 478 * superproject are incorrectly forgotten or misused. For example:
@@ -488,14 +498,18 @@ static int grep_submodule(struct grep_opt *opt,
488 498 * ditto.
489 499 *
490 500 * Note that this list is not exhaustive.
491 - *
492 - * NEEDSWORK: initializing the subrepository is not thread-safe,
493 - * either, as it may cause us to race around `get_main_ref_store()`. We
494 - * thus need to hold the object-read lock to serialize all readers with
495 - * one another.
496 501 */
497 - obj_read_lock();
498 502 repo_read_gitmodules(subrepo, 0);
503 +
504 + /*
505 + * All code paths tested by test code no longer need submodule ODBs to
506 + * be added as alternates, but add it to the list just in case.
507 + * Submodule ODBs added through add_submodule_odb_by_path() will be
508 + * lazily registered as alternates when needed (and except in an
509 + * unexpected code interaction, it won't be needed).
510 + */
511 + odb_add_submodule_source_by_path(the_repository->objects,
512 + subrepo->objects->sources->path);
499 513 obj_read_unlock();
500 514
501 515 memcpy(&subopt, opt, sizeof(subopt));
@@ -883,7 +897,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
883 897 if (recurse_submodules) {
884 898 submodule_free(opt->repo);
885 899 obj_read_lock();
886 - gitmodules_config_oid(the_repository, &real_obj->oid);
900 + gitmodules_config_oid(&real_obj->oid);
887 901 obj_read_unlock();
888 902 }
889 903 if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
modified builtin/history.c
@@ -786,10 +786,6 @@ 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 - }
793 789 init_tree_desc(&tree_desc, &tree->object.oid, tree->buffer, tree->size);
794 790
795 791 if (unpack_trees(1, &tree_desc, &opts)) {
modified builtin/multi-pack-index.c
@@ -90,8 +90,7 @@ static struct odb_source_files *handle_object_dir_option(struct repository *repo
90 90 {
91 91 struct odb_source *source = odb_find_source(repo->objects, opts.object_dir);
92 92 if (!source)
93 - die(_("object directory is not an alternate of the current repository: '%s'"),
94 - opts.object_dir);
93 + source = odb_add_to_alternates_memory(repo->objects, opts.object_dir);
95 94 return odb_source_files_downcast(source);
96 95 }
97 96
modified builtin/rev-list.c
@@ -111,13 +111,6 @@ enum missing_action {
111 111 MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */
112 112 };
113 113 static enum missing_action arg_missing_action;
114 - static int arg_missing_only;
115 -
116 - static inline int should_collect_missing(void)
117 - {
118 - return arg_missing_action == MA_PRINT ||
119 - arg_missing_action == MA_PRINT_INFO;
120 - }
121 114
122 115 /* display only the oid of each object encountered */
123 116 static int arg_show_object_names = 1;
@@ -163,14 +156,7 @@ static void print_missing_object(struct missing_objects_map_entry *entry,
163 156 {
164 157 struct strbuf sb = STRBUF_INIT;
165 158
166 - /*
167 - * --missing-only filters present objects out of the walk output.
168 - * It still uses the selected --missing= format for missing ones,
169 - * except the human "?" prefix is omitted (script-friendly OIDs).
170 - */
171 - if (arg_missing_only && line_term)
172 - printf("%s", oid_to_hex(&entry->entry.oid));
173 - else if (line_term)
159 + if (line_term)
174 160 printf("?%s", oid_to_hex(&entry->entry.oid));
175 161 else
176 162 printf("%s%cmissing=yes", oid_to_hex(&entry->entry.oid),
@@ -260,11 +246,6 @@ static void show_commit(struct commit *commit, void *data)
260 246 return;
261 247 }
262 248
263 - if (arg_missing_only) {
264 - finish_commit(commit);
265 - return;
266 - }
267 -
268 249 if (show_disk_usage)
269 250 total_disk_usage += get_object_disk_usage(&commit->object);
270 251
@@ -403,8 +384,6 @@ static void show_object(struct object *obj, const char *name, void *cb_data)
403 384 if (finish_object(obj, name, cb_data))
404 385 return;
405 386 display_progress(progress, ++progress_counter);
406 - if (arg_missing_only)
407 - return;
408 387 if (show_disk_usage)
409 388 total_disk_usage += get_object_disk_usage(obj);
410 389 if (info->flags & REV_LIST_QUIET)
@@ -771,17 +750,12 @@ int cmd_rev_list(int argc,
771 750 revs.exclude_promisor_objects = 1;
772 751 } else if (skip_prefix(arg, "--missing=", &arg)) {
773 752 parse_missing_action_value(repo, arg);
774 - } else if (!strcmp(arg, "--missing-only")) {
775 - arg_missing_only = 1;
776 753 } else if (!strcmp(arg, "-z")) {
777 754 line_term = '\0';
778 755 info_term = '\0';
779 756 }
780 757 }
781 758
782 - if (arg_missing_only && !should_collect_missing())
783 - die(_("--missing-only requires --missing=print or --missing=print-info"));
784 -
785 759 die_for_incompatible_opt2(revs.exclude_promisor_objects,
786 760 "--exclude_promisor_objects",
787 761 arg_missing_action, "--missing");
@@ -891,9 +865,6 @@ int cmd_rev_list(int argc,
891 865 continue;
892 866 }
893 867
894 - if (!strcmp(arg, "--missing-only"))
895 - continue;
896 -
897 868 usage(rev_list_usage);
898 869
899 870 }
@@ -940,11 +911,6 @@ int cmd_rev_list(int argc,
940 911 (revs.left_right || revs.cherry_mark))
941 912 die(_("marked counting and '%s' cannot be used together"), "--objects");
942 913
943 - die_for_incompatible_opt2(arg_missing_only, "--missing-only",
944 - revs.count, "--count");
945 - die_for_incompatible_opt2(arg_missing_only, "--missing-only",
946 - show_disk_usage, "--disk-usage");
947 -
948 914 save_commit_buffer = (revs.verbose_header ||
949 915 revs.grep_filter.pattern_list ||
950 916 revs.grep_filter.header_list);
@@ -1002,7 +968,8 @@ int cmd_rev_list(int argc,
1002 968
1003 969 if (arg_print_omitted)
1004 970 oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE);
1005 - if (should_collect_missing()) {
971 + if (arg_missing_action == MA_PRINT ||
972 + arg_missing_action == MA_PRINT_INFO) {
1006 973 struct oidset_iter iter;
1007 974 struct object_id *oid;
1008 975
@@ -1028,7 +995,8 @@ int cmd_rev_list(int argc,
1028 995 printf("~%s\n", oid_to_hex(oid));
1029 996 oidset_clear(&omitted_objects);
1030 997 }
1031 - if (should_collect_missing()) {
998 + if (arg_missing_action == MA_PRINT ||
999 + arg_missing_action == MA_PRINT_INFO) {
1032 1000 struct missing_objects_map_entry *entry;
1033 1001 struct oidmap_iter iter;
1034 1002
modified builtin/stash.c
@@ -10,7 +10,6 @@
10 10 #include "object-name.h"
11 11 #include "parse-options.h"
12 12 #include "refs.h"
13 - #include "stash.h"
14 13 #include "lockfile.h"
15 14 #include "cache-tree.h"
16 15 #include "unpack-trees.h"
@@ -641,12 +640,10 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
641 640 die(_("could not write index"));
642 641 }
643 642
644 - static enum stash_apply_result do_apply_stash(const char *prefix,
645 - struct stash_info *info,
646 - int index, int quiet,
647 - const char *label_ours,
648 - const char *label_theirs,
649 - const char *label_base)
643 + static int do_apply_stash(const char *prefix, struct stash_info *info,
644 + int index, int quiet,
645 + const char *label_ours, const char *label_theirs,
646 + const char *label_base)
650 647 {
651 648 int clean, ret;
652 649 int has_index = index;
@@ -720,8 +717,8 @@ static enum stash_apply_result do_apply_stash(const char *prefix,
720 717
721 718 /*
722 719 * If 'clean' >= 0, reverse the value for 'ret' so 'ret' is 0 when the
723 - * merge was clean, and 1 if the merge was unclean or a negative value
724 - * if it encountered an error.
720 + * merge was clean, and nonzero if the merge was unclean or encountered
721 + * an error.
725 722 */
726 723 ret = clean >= 0 ? !clean : clean;
727 724
@@ -2495,22 +2492,10 @@ int cmd_stash(int argc,
2495 2492 strbuf_addf(&stash_index_path, "%s.stash.%" PRIuMAX, index_file,
2496 2493 (uintmax_t)pid);
2497 2494
2498 - if (fn) {
2499 - ret = fn(argc, argv, prefix, repo);
2500 -
2501 - /*
2502 - * The subcommand implementations return 0 on success, a
2503 - * negative value on failure, and STASH_APPLY_CONFLICT
2504 - * when applying a stash entry resulted in conflicts.
2505 - * Map failures to 128, the status die() uses, so that
2506 - * exit status 1 unambiguously indicates conflicts.
2507 - */
2508 - if (ret < 0)
2509 - return 128;
2510 - return ret;
2511 - } else if (!argc) {
2495 + if (fn)
2496 + return !!fn(argc, argv, prefix, repo);
2497 + else if (!argc)
2512 2498 return !!push_stash_unassumed(0, NULL, prefix, repo);
2513 - }
2514 2499
2515 2500 /* Assume 'stash push' */
2516 2501 strvec_push(&args, "push");
modified builtin/submodule--helper.c
@@ -80,7 +80,6 @@ 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;
84 83
85 84 sub = submodule_from_path(the_repository, null_oid(the_hash_algo), module_path);
86 85 if (sub && sub->url) {
@@ -97,11 +96,9 @@ static int get_default_remote_submodule(const char *module_path, char **default_
97 96 }
98 97
99 98 if (repo_submodule_init(&subrepo, the_repository, module_path,
100 - null_oid(the_hash_algo)) < 0) {
101 - ret = die_message(_("could not get a repository handle for submodule '%s'"),
99 + null_oid(the_hash_algo)) < 0)
100 + return die_message(_("could not get a repository handle for submodule '%s'"),
102 101 module_path);
103 - goto out;
104 - }
105 102
106 103 /* Look up by URL first */
107 104 if (url)
@@ -111,11 +108,10 @@ static int get_default_remote_submodule(const char *module_path, char **default_
111 108
112 109 *default_remote = xstrdup(remote_name);
113 110
114 - out:
115 111 repo_clear(&subrepo);
116 112 free(url);
117 113
118 - return ret;
114 + return 0;
119 115 }
120 116
121 117 static int module_get_default_remote(int argc, const char **argv, const char *prefix,
@@ -3045,7 +3041,7 @@ static int module_update(int argc, const char **argv, const char *prefix,
3045 3041 NULL
3046 3042 };
3047 3043
3048 - update_clone_config_from_gitmodules(the_repository, &opt.max_jobs);
3044 + update_clone_config_from_gitmodules(&opt.max_jobs);
3049 3045 repo_config(the_repository, git_update_clone_config, &opt.max_jobs);
3050 3046
3051 3047 argc = parse_options(argc, argv, prefix, module_update_options,
@@ -3259,7 +3255,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix,
3259 3255 path);
3260 3256
3261 3257 config_name = xstrfmt("submodule.%s.url", sub->name);
3262 - ret = config_set_in_gitmodules_file_gently(the_repository, config_name, newurl);
3258 + ret = config_set_in_gitmodules_file_gently(config_name, newurl);
3263 3259
3264 3260 if (!ret) {
3265 3261 repo_read_gitmodules(the_repository, 0);
@@ -3315,7 +3311,7 @@ static int module_set_branch(int argc, const char **argv, const char *prefix,
3315 3311 path);
3316 3312
3317 3313 config_name = xstrfmt("submodule.%s.branch", sub->name);
3318 - ret = config_set_in_gitmodules_file_gently(the_repository, config_name, opt_branch);
3314 + ret = config_set_in_gitmodules_file_gently(config_name, opt_branch);
3319 3315
3320 3316 free(config_name);
3321 3317 return !!ret;
@@ -3514,7 +3510,7 @@ static int config_submodule_in_gitmodules(const char *name, const char *var, con
3514 3510 die(_("please make sure that the .gitmodules file is in the working tree"));
3515 3511
3516 3512 key = xstrfmt("submodule.%s.%s", name, var);
3517 - ret = config_set_in_gitmodules_file_gently(the_repository, key, value);
3513 + ret = config_set_in_gitmodules_file_gently(key, value);
3518 3514 free(key);
3519 3515
3520 3516 return ret;
modified cache-tree.c
@@ -1,3 +1,4 @@
1 + #define USE_THE_REPOSITORY_VARIABLE
1 2 #define DISABLE_SIGN_COMPARE_WARNINGS
2 3
3 4 #include "git-compat-util.h"
@@ -274,37 +275,28 @@ static void discard_unused_subtrees(struct cache_tree *it)
274 275 }
275 276 }
276 277
277 - static int cache_tree_fully_valid_recursive(struct object_database *odb,
278 - struct cache_tree *it)
278 + int cache_tree_fully_valid(struct cache_tree *it)
279 279 {
280 280 int i;
281 281 if (!it)
282 282 return 0;
283 283 if (it->entry_count < 0 ||
284 - !odb_has_object(odb, &it->oid,
284 + !odb_has_object(the_repository->objects, &it->oid,
285 285 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
286 286 return 0;
287 287 for (i = 0; i < it->subtree_nr; i++) {
288 - if (!cache_tree_fully_valid_recursive(odb, it->down[i]->cache_tree))
288 + if (!cache_tree_fully_valid(it->down[i]->cache_tree))
289 289 return 0;
290 290 }
291 291 return 1;
292 292 }
293 293
294 - int cache_tree_fully_valid(struct index_state *istate)
294 + static int must_check_existence(const struct cache_entry *ce)
295 295 {
296 - return cache_tree_fully_valid_recursive(istate->repo->objects,
297 - istate->cache_tree);
296 + return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
298 297 }
299 298
300 - static int must_check_existence(const struct cache_entry *ce, void *cb_data)
301 - {
302 - struct repository *repo = cb_data;
303 - return !(repo_has_promisor_remote(repo) && ce_skip_worktree(ce));
304 - }
305 -
306 - static int update_one(struct repository *repo,
307 - struct cache_tree *it,
299 + static int update_one(struct cache_tree *it,
308 300 struct cache_entry **cache,
309 301 int entries,
310 302 const char *base,
@@ -342,7 +334,7 @@ static int update_one(struct repository *repo,
342 334 }
343 335
344 336 if (0 <= it->entry_count &&
345 - odb_has_object(repo->objects, &it->oid,
337 + odb_has_object(the_repository->objects, &it->oid,
346 338 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
347 339 return it->entry_count;
348 340
@@ -383,8 +375,7 @@ static int update_one(struct repository *repo,
383 375 sub = find_subtree(it, path + baselen, sublen, 1);
384 376 if (!sub->cache_tree)
385 377 sub->cache_tree = cache_tree();
386 - subcnt = update_one(repo,
387 - sub->cache_tree,
378 + subcnt = update_one(sub->cache_tree,
388 379 cache + i, entries - i,
389 380 path,
390 381 baselen + sublen + 1,
@@ -448,10 +439,10 @@ static int update_one(struct repository *repo,
448 439 }
449 440
450 441 ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
451 - !must_check_existence(ce, repo);
442 + !must_check_existence(ce);
452 443 if (is_null_oid(oid) ||
453 444 (!ce_missing_ok &&
454 - !odb_has_object(repo->objects, oid,
445 + !odb_has_object(the_repository->objects, oid,
455 446 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))) {
456 447 strbuf_release(&buffer);
457 448 if (expected_missing)
@@ -483,12 +474,12 @@ static int update_one(struct repository *repo,
483 474 /*
484 475 * "sub" can be an empty tree if all subentries are i-t-a.
485 476 */
486 - if (contains_ita && is_empty_tree_oid(oid, repo->hash_algo))
477 + if (contains_ita && is_empty_tree_oid(oid, the_repository->hash_algo))
487 478 continue;
488 479
489 480 strbuf_grow(&buffer, entlen + 100);
490 481 strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
491 - strbuf_add(&buffer, oid->hash, repo->hash_algo->rawsz);
482 + strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);
492 483
493 484 #if DEBUG_CACHE_TREE
494 485 fprintf(stderr, "cache-tree update-one %o %.*s\n",
@@ -498,16 +489,16 @@ static int update_one(struct repository *repo,
498 489
499 490 if (repair) {
500 491 struct object_id oid;
501 - hash_object_file(repo->hash_algo, buffer.buf, buffer.len,
492 + hash_object_file(the_hash_algo, buffer.buf, buffer.len,
502 493 OBJ_TREE, &oid);
503 - if (odb_has_object(repo->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
494 + if (odb_has_object(the_repository->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
504 495 oidcpy(&it->oid, &oid);
505 496 else
506 497 to_invalidate = 1;
507 498 } else if (dryrun) {
508 - hash_object_file(repo->hash_algo, buffer.buf, buffer.len,
499 + hash_object_file(the_hash_algo, buffer.buf, buffer.len,
509 500 OBJ_TREE, &it->oid);
510 - } else if (odb_write_object_ext(repo->objects, buffer.buf, buffer.len, OBJ_TREE,
501 + } else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE,
511 502 &it->oid, NULL, flags & WRITE_TREE_SILENT ? ODB_WRITE_OBJECT_SILENT : 0)) {
512 503 strbuf_release(&buffer);
513 504 return -1;
@@ -525,7 +516,7 @@ static int update_one(struct repository *repo,
525 516
526 517 int cache_tree_update(struct index_state *istate, int flags)
527 518 {
528 - int inflight = !!istate->repo->objects->transaction;
519 + int inflight = !!the_repository->objects->transaction;
529 520 struct odb_transaction *transaction;
530 521 int skip, i;
531 522
@@ -537,14 +528,14 @@ int cache_tree_update(struct index_state *istate, int flags)
537 528 if (!istate->cache_tree)
538 529 istate->cache_tree = cache_tree();
539 530
540 - if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(istate->repo))
541 - prefetch_cache_entries(istate, must_check_existence, istate->repo);
531 + if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
532 + prefetch_cache_entries(istate, must_check_existence);
542 533
543 534 trace_performance_enter();
544 535 trace2_region_enter("cache_tree", "update", istate->repo);
545 536 if (!inflight)
546 - odb_transaction_begin_or_die(istate->repo->objects, &transaction, 0);
547 - i = update_one(istate->repo, istate->cache_tree, istate->cache, istate->cache_nr,
537 + odb_transaction_begin_or_die(the_repository->objects, &transaction, 0);
538 + i = update_one(istate->cache_tree, istate->cache, istate->cache_nr,
548 539 "", 0, &skip, flags);
549 540 if (!inflight)
550 541 odb_transaction_commit_and_finalize_or_die(transaction);
@@ -556,8 +547,7 @@ int cache_tree_update(struct index_state *istate, int flags)
556 547 return 0;
557 548 }
558 549
559 - static void write_one(struct repository *repo,
560 - struct strbuf *buffer, struct cache_tree *it,
550 + static void write_one(struct strbuf *buffer, struct cache_tree *it,
561 551 const char *path, int pathlen)
562 552 {
563 553 int i;
@@ -583,7 +573,7 @@ static void write_one(struct repository *repo,
583 573 #endif
584 574
585 575 if (0 <= it->entry_count) {
586 - strbuf_add(buffer, it->oid.hash, repo->hash_algo->rawsz);
576 + strbuf_add(buffer, it->oid.hash, the_hash_algo->rawsz);
587 577 }
588 578 for (i = 0; i < it->subtree_nr; i++) {
589 579 struct cache_tree_sub *down = it->down[i];
@@ -593,16 +583,15 @@ static void write_one(struct repository *repo,
593 583 prev->name, prev->namelen) <= 0)
594 584 die("fatal - unsorted cache subtree");
595 585 }
596 - write_one(repo, buffer, down->cache_tree, down->name, down->namelen);
586 + write_one(buffer, down->cache_tree, down->name, down->namelen);
597 587 }
598 588 }
599 589
600 - void cache_tree_write(struct repository *repo,
601 - struct strbuf *sb, struct cache_tree *root)
590 + void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
602 591 {
603 - trace2_region_enter("cache_tree", "write", repo);
604 - write_one(repo, sb, root, "", 0);
605 - trace2_region_leave("cache_tree", "write", repo);
592 + trace2_region_enter("cache_tree", "write", the_repository);
593 + write_one(sb, root, "", 0);
594 + trace2_region_leave("cache_tree", "write", the_repository);
606 595 }
607 596
608 597 static int parse_int(const char **ptr, unsigned long *len_p, int *out)
@@ -636,14 +625,13 @@ static int parse_int(const char **ptr, unsigned long *len_p, int *out)
636 625 return 0;
637 626 }
638 627
639 - static struct cache_tree *read_one(struct repository *repo,
640 - const char **buffer, unsigned long *size_p)
628 + static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
641 629 {
642 630 const char *buf = *buffer;
643 631 unsigned long size = *size_p;
644 632 struct cache_tree *it;
645 633 int i, subtree_nr;
646 - const unsigned rawsz = repo->hash_algo->rawsz;
634 + const unsigned rawsz = the_hash_algo->rawsz;
647 635
648 636 it = NULL;
649 637 /* skip name, but make sure name exists */
@@ -670,7 +658,7 @@ static struct cache_tree *read_one(struct repository *repo,
670 658 if (size < rawsz)
671 659 goto free_return;
672 660 oidread(&it->oid, (const unsigned char *)buf,
673 - repo->hash_algo);
661 + the_repository->hash_algo);
674 662 buf += rawsz;
675 663 size -= rawsz;
676 664 }
@@ -698,7 +686,7 @@ static struct cache_tree *read_one(struct repository *repo,
698 686 struct cache_tree_sub *subtree;
699 687 const char *name = buf;
700 688
701 - sub = read_one(repo, &buf, &size);
689 + sub = read_one(&buf, &size);
702 690 if (!sub)
703 691 goto free_return;
704 692 subtree = cache_tree_sub(it, name);
@@ -715,17 +703,16 @@ static struct cache_tree *read_one(struct repository *repo,
715 703 return NULL;
716 704 }
717 705
718 - struct cache_tree *cache_tree_read(struct repository *repo,
719 - const char *buffer, unsigned long size)
706 + struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
720 707 {
721 708 struct cache_tree *result;
722 709
723 710 if (buffer[0])
724 711 return NULL; /* not the whole tree */
725 712
726 - trace2_region_enter("cache_tree", "read", repo);
727 - result = read_one(repo, &buffer, &size);
728 - trace2_region_leave("cache_tree", "read", repo);
713 + trace2_region_enter("cache_tree", "read", the_repository);
714 + result = read_one(&buffer, &size);
715 + trace2_region_leave("cache_tree", "read", the_repository);
729 716
730 717 return result;
731 718 }
@@ -788,7 +775,7 @@ struct tree *write_in_core_index_as_tree(struct repository *repo,
788 775 int was_valid, ret;
789 776
790 777 was_valid = index_state->cache_tree &&
791 - cache_tree_fully_valid(index_state);
778 + cache_tree_fully_valid(index_state->cache_tree);
792 779
793 780 ret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);
794 781 if (ret == WRITE_TREE_UNMERGED_INDEX) {
@@ -816,7 +803,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
816 803 hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
817 804
818 805 entries = read_index_from(index_state, index_path,
819 - repo_get_git_dir(index_state->repo));
806 + repo_get_git_dir(the_repository));
820 807 if (entries < 0) {
821 808 ret = WRITE_TREE_UNREADABLE_INDEX;
822 809 goto out;
@@ -824,7 +811,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
824 811
825 812 was_valid = !(flags & WRITE_TREE_IGNORE_CACHE_TREE) &&
826 813 index_state->cache_tree &&
827 - cache_tree_fully_valid(index_state);
814 + cache_tree_fully_valid(index_state->cache_tree);
828 815
829 816 ret = write_index_as_tree_internal(oid, index_state, was_valid, flags,
830 817 prefix);
@@ -872,7 +859,7 @@ static void prime_cache_tree_rec(struct repository *r,
872 859 struct cache_tree_sub *sub;
873 860 struct tree *subtree = lookup_tree(r, &entry.oid);
874 861
875 - if (repo_parse_tree(r, subtree) < 0)
862 + if (repo_parse_tree(the_repository, subtree) < 0)
876 863 exit(128);
877 864 sub = cache_tree_sub(it, entry.path);
878 865 sub->cache_tree = cache_tree();
modified cache-tree.h
@@ -28,11 +28,10 @@ struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
28 28
29 29 int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen);
30 30
31 - void cache_tree_write(struct repository *repo, struct strbuf *, struct cache_tree *root);
32 - struct cache_tree *cache_tree_read(struct repository *repo,
33 - const char *buffer, unsigned long size);
31 + void cache_tree_write(struct strbuf *, struct cache_tree *root);
32 + struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
34 33
35 - int cache_tree_fully_valid(struct index_state *);
34 + int cache_tree_fully_valid(struct cache_tree *);
36 35 int cache_tree_update(struct index_state *, int);
37 36 int cache_tree_verify(struct repository *, struct index_state *);
38 37
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 \
168 - asciidoctor
167 + sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make ruby
169 168
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,7 +217,6 @@ gitcli userinterfaces
217 217 gitcore-tutorial guide
218 218 gitcredentials guide
219 219 gitcvs-migration guide
220 - gitdatamodel guide
221 220 gitdiffcore guide
222 221 giteveryday guide
223 222 gitfaq guide
modified contrib/buildsystems/CMakeLists.txt
@@ -258,7 +258,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
258 258 OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
259 259 HAVE_WPGMPTR HAVE_RTLGENRANDOM)
260 260 if(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
261 - add_compile_definitions(ENSURE_MSYSTEM_IS_SET="UCRT64" MINGW_PREFIX="ucrt64")
261 + add_compile_definitions(ENSURE_MSYSTEM_IS_SET="MINGW64" MINGW_PREFIX="mingw64")
262 262 elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "arm64")
263 263 add_compile_definitions(ENSURE_MSYSTEM_IS_SET="CLANGARM64" MINGW_PREFIX="clangarm64")
264 264 elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x86")
modified fetch-pack.c
@@ -1853,13 +1853,6 @@ 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 -
1863 1856 for (i = 0; i < packfile_uris.nr; i++) {
1864 1857 bool created_keep;
1865 1858 int j;
@@ -1913,11 +1906,6 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1913 1906 repo_get_object_directory(the_repository),
1914 1907 packhash));
1915 1908 }
1916 -
1917 - if (packfile_uris.nr)
1918 - trace2_region_leave("fetch-pack", "packfile-uris",
1919 - the_repository);
1920 -
1921 1909 string_list_clear(&packfile_uris, 0);
1922 1910 strvec_clear(&index_pack_args);
1923 1911
modified git-curl-compat.h
@@ -67,12 +67,4 @@
67 67 #define GIT_CURL_HAVE_CURLOPT_TCP_KEEPCNT
68 68 #endif
69 69
70 - /**
71 - * CURLOPT_UPLOAD_FLAGS and CURLULFLAG_* were added in 8.13.0,
72 - * released in April 2025.
73 - */
74 - #if LIBCURL_VERSION_NUM >= 0x080D00
75 - #define GIT_CURL_HAVE_CURLOPT_UPLOAD_FLAGS
76 - #endif
77 -
78 70 #endif
modified imap-send.c
@@ -35,7 +35,6 @@
35 35 #include "setup.h"
36 36 #include "strbuf.h"
37 37 #ifdef USE_CURL_FOR_IMAP_SEND
38 - #include "git-curl-compat.h"
39 38 #include "http.h"
40 39 #endif
41 40
@@ -50,11 +49,10 @@
50 49 static int verbosity;
51 50 static int list_folders;
52 51 static int use_curl = USE_CURL_DEFAULT;
53 - static int opt_draft;
54 52 static char *opt_folder;
55 53
56 54 static char const * const imap_send_usage[] = {
57 - N_("git imap-send [-v] [-q] [--[no-]curl] [--[no-]draft] [(--folder|-f) <folder>] < <mbox>"),
55 + N_("git imap-send [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>] < <mbox>"),
58 56 "git imap-send --list",
59 57 NULL
60 58 };
@@ -62,7 +60,6 @@ static char const * const imap_send_usage[] = {
62 60 static struct option imap_send_options[] = {
63 61 OPT__VERBOSITY(&verbosity),
64 62 OPT_BOOL(0, "curl", &use_curl, "use libcurl to communicate with the IMAP server"),
65 - OPT_BOOL(0, "draft", &opt_draft, "mark uploaded messages with the IMAP \\Draft flag"),
66 63 OPT_STRING('f', "folder", &opt_folder, "folder", "specify the IMAP folder"),
67 64 OPT_BOOL(0, "list", &list_folders, "list all folders on the IMAP server"),
68 65 OPT_END()
@@ -1419,8 +1416,7 @@ static int imap_store_msg(struct imap_store *ctx, struct strbuf *msg)
1419 1416
1420 1417 box = ctx->name;
1421 1418 prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
1422 - ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" %s", prefix, box,
1423 - opt_draft ? "(\\Draft) " : "");
1419 + ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box);
1424 1420 imap->caps = imap->rcaps;
1425 1421 if (ret != DRV_OK)
1426 1422 return ret;
@@ -1722,13 +1718,6 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,
1722 1718
1723 1719 curl_easy_setopt(curl, CURLOPT_READDATA, &msgbuf);
1724 1720
1725 - if (opt_draft) {
1726 - #ifdef GIT_CURL_HAVE_CURLOPT_UPLOAD_FLAGS
1727 - curl_easy_setopt(curl, CURLOPT_UPLOAD_FLAGS, CURLULFLAG_DRAFT);
1728 - #else
1729 - warning("--draft requires libcurl 8.13.0 or later");
1730 - #endif
1731 - }
1732 1721 fprintf(stderr, "Sending %d message%s to %s folder...\n",
1733 1722 total, (total != 1) ? "s" : "", server->folder);
1734 1723 while (1) {
modified odb.c
@@ -247,6 +247,12 @@ void odb_add_to_alternates_file(struct object_database *odb,
247 247 odb_add_alternate_recursively(odb, dir, 0);
248 248 }
249 249
250 + struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
251 + const char *dir)
252 + {
253 + return odb_add_alternate_recursively(odb, dir, 0);
254 + }
255 +
250 256 struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,
251 257 const char *dir, int will_destroy,
252 258 struct odb_source **prev_source)
@@ -382,6 +388,12 @@ struct odb_source *odb_find_source_or_die(struct object_database *odb, const cha
382 388 return source;
383 389 }
384 390
391 + void odb_add_submodule_source_by_path(struct object_database *odb,
392 + const char *path)
393 + {
394 + string_list_insert(&odb->submodule_source_paths, path);
395 + }
396 +
385 397 static void fill_alternate_refs_command(struct repository *repo,
386 398 struct child_process *cmd,
387 399 const char *repo_path)
@@ -537,6 +549,23 @@ void disable_obj_read_lock(void)
537 549 pthread_mutex_destroy(&obj_read_mutex);
538 550 }
539 551
552 + static int register_all_submodule_sources(struct object_database *odb)
553 + {
554 + int ret = odb->submodule_source_paths.nr;
555 +
556 + for (size_t i = 0; i < odb->submodule_source_paths.nr; i++)
557 + odb_add_to_alternates_memory(odb,
558 + odb->submodule_source_paths.items[i].string);
559 + if (ret) {
560 + string_list_clear(&odb->submodule_source_paths, 0);
561 + trace2_data_intmax("submodule", odb->repo,
562 + "register_all_submodule_sources/registered", ret);
563 + if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0))
564 + BUG("register_all_submodule_sources() called");
565 + }
566 + return ret;
567 + }
568 +
540 569 static enum odb_read_status do_oid_object_info_extended(struct object_database *odb,
541 570 const struct object_id *oid,
542 571 struct object_info *oi, unsigned flags)
@@ -585,6 +614,16 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database *
585 614 }
586 615 }
587 616
617 + /*
618 + * This might be an attempt at accessing a submodule object as
619 + * if it were in main object store (having called
620 + * `odb_add_submodule_source_by_path()` on that submodule's
621 + * ODB). If any such ODBs exist, register them and try again.
622 + */
623 + if (register_all_submodule_sources(odb))
624 + /* We added some alternates; retry */
625 + continue;
626 +
588 627 /* Check if it is a missing object */
589 628 if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
590 629 !already_retried &&
@@ -1070,6 +1109,7 @@ struct object_database *odb_new(struct repository *repo,
1070 1109 CALLOC_ARRAY(o, 1);
1071 1110 o->repo = repo;
1072 1111 pthread_mutex_init(&o->replace_mutex, NULL);
1112 + string_list_init_dup(&o->submodule_source_paths);
1073 1113 hashmap_init(&o->source_by_path, odb_source_by_path_cmp, o, 0);
1074 1114 o->source_paths_icase = -1;
1075 1115
@@ -1126,6 +1166,8 @@ void odb_free(struct object_database *o)
1126 1166 odb_close(o);
1127 1167 odb_free_sources(o);
1128 1168
1169 + string_list_clear(&o->submodule_source_paths, 0);
1170 +
1129 1171 free(o);
1130 1172 }
1131 1173
@@ -1157,11 +1199,3 @@ void odb_reprepare(struct object_database *o)
1157 1199 {
1158 1200 odb_prepare(o, ODB_PREPARE_FLUSH_CACHES);
1159 1201 }
1160 -
1161 - int odb_fsck(struct object_database *odb, struct odb_fsck_options *options)
1162 - {
1163 - int ret = 0;
1164 - for (struct odb_source *source = odb->sources; source; source = source->next)
1165 - ret |= odb_source_fsck(source, options);
1166 - return ret;
1167 - }
modified odb.h
@@ -89,6 +89,12 @@ struct object_database {
89 89 unsigned long object_count;
90 90 unsigned object_count_flags;
91 91 unsigned object_count_valid : 1;
92 +
93 + /*
94 + * Submodule source paths that will be added as additional sources to
95 + * allow lookup of submodule objects via the main object database.
96 + */
97 + struct string_list submodule_source_paths;
92 98 };
93 99
94 100 enum odb_new_flags {
@@ -192,39 +198,6 @@ void odb_prepare(struct object_database *o, enum odb_prepare_flags flags);
192 198 /* Equivalent to `odb_prepare(o, ODB_PREPARE_FLUSH_CACHES)`. */
193 199 void odb_reprepare(struct object_database *o);
194 200
195 - enum odb_fsck_flags {
196 - /*
197 - * If set, perform a full consistency check for the full object
198 - * database, including all of its sources and the contents of their
199 - * optimized formats. Otherwise, only check the local source, and
200 - * restrict checks of its optimized formats to cheap structural
201 - * verification of their metadata.
202 - */
203 - ODB_FSCK_FULL = (1 << 0),
204 -
205 - /* Display a progress meter, if sensible. */
206 - ODB_FSCK_PROGRESS = (1 << 1),
207 -
208 - /* Be extra verbose when checking the database. */
209 - ODB_FSCK_VERBOSE = (1 << 2),
210 - };
211 -
212 - /* Options that shall be passed to `odb_fsck()`. */
213 - struct odb_fsck_options {
214 - enum odb_fsck_flags flags;
215 -
216 - int (*object_cb)(const struct object_id *oid, enum object_type type,
217 - unsigned long size, void *buffer, int *eaten, void *cb_data);
218 - void *object_payload;
219 - };
220 -
221 - /*
222 - * Run backend-specific integrity checks on all object sources. Each source
223 - * performs the checks appropriate to its type. Returns 0 on success, a
224 - * negative error code otherwise.
225 - */
226 - int odb_fsck(struct object_database *odb, struct odb_fsck_options *opts);
227 -
228 201 /*
229 202 * Find source by its object directory path. Returns a `NULL` pointer in case
230 203 * the source could not be found.
@@ -251,6 +224,14 @@ void odb_restore_primary_source(struct object_database *odb,
251 224 struct odb_source *restore_source,
252 225 const char *old_path);
253 226
227 + /*
228 + * Call odb_add_submodule_source_by_path() to add the submodule at the given
229 + * path to a list. The object stores of all submodules in that list will be
230 + * added as additional sources in the object store when looking up objects.
231 + */
232 + void odb_add_submodule_source_by_path(struct object_database *odb,
233 + const char *path);
234 +
254 235 /*
255 236 * Iterate through all alternates of the database and execute the provided
256 237 * callback function for each of them. Stop iterating once the callback
@@ -291,6 +272,14 @@ int odb_has_alternates(struct object_database *odb);
291 272 void odb_add_to_alternates_file(struct object_database *odb,
292 273 const char *dir);
293 274
275 + /*
276 + * Add the directory to the in-memory list of alternate sources (along with any
277 + * recursive alternates it points to), but do not modify the on-disk alternates
278 + * file.
279 + */
280 + struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
281 + const char *dir);
282 +
294 283 /*
295 284 * Read an object from the database. Returns the object data and assigns object
296 285 * type and size to the `type` and `size` pointers, if these pointers are
modified odb/source-files.c
@@ -909,21 +909,6 @@ static int odb_source_files_generate_pack(struct odb_source *source UNUSED,
909 909 return 0;
910 910 }
911 911
912 - static int odb_source_files_fsck(struct odb_source *source,
913 - struct odb_fsck_options *opts)
914 - {
915 - struct odb_source_files *files = odb_source_files_downcast(source);
916 - int ret = 0;
917 -
918 - if (!(opts->flags & ODB_FSCK_FULL) && !source->local)
919 - return 0;
920 -
921 - ret |= odb_source_fsck(&files->loose->base, opts);
922 - ret |= odb_source_fsck(&files->packed->base, opts);
923 -
924 - return ret;
925 - }
926 -
927 912 struct odb_source_files *odb_source_files_new(struct object_database *odb,
928 913 const char *path,
929 914 bool local)
@@ -939,7 +924,6 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,
939 924 files->base.close = odb_source_files_close;
940 925 files->base.create_on_disk = odb_source_files_create_on_disk;
941 926 files->base.prepare = odb_source_files_prepare;
942 - files->base.fsck = odb_source_files_fsck;
943 927 files->base.read_object_info = odb_source_files_read_object_info;
944 928 files->base.read_object_stream = odb_source_files_read_object_stream;
945 929 files->base.for_each_object = odb_source_files_for_each_object;
modified odb/source-inmemory.c
@@ -1,7 +1,6 @@
1 1 #include "git-compat-util.h"
2 2 #include "object-file.h"
3 3 #include "odb.h"
4 - #include "fsck.h"
5 4 #include "odb/source-inmemory.h"
6 5 #include "odb/streaming.h"
7 6 #include "oidtree.h"
@@ -370,12 +369,6 @@ static void odb_source_inmemory_free(struct odb_source *source)
370 369 free(inmemory);
371 370 }
372 371
373 - static int odb_source_inmemory_fsck(struct odb_source *source UNUSED,
374 - struct odb_fsck_options *opts UNUSED)
375 - {
376 - return 0;
377 - }
378 -
379 372 struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb)
380 373 {
381 374 struct odb_source_inmemory *source;
@@ -386,7 +379,6 @@ struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb)
386 379 source->base.free = odb_source_inmemory_free;
387 380 source->base.close = odb_source_inmemory_close;
388 381 source->base.prepare = odb_source_inmemory_prepare;
389 - source->base.fsck = odb_source_inmemory_fsck;
390 382 source->base.read_object_info = odb_source_inmemory_read_object_info;
391 383 source->base.read_object_stream = odb_source_inmemory_read_object_stream;
392 384 source->base.for_each_object = odb_source_inmemory_for_each_object;
modified odb/source-loose.c
@@ -12,7 +12,6 @@
12 12 #include "odb/streaming.h"
13 13 #include "oidtree.h"
14 14 #include "path.h"
15 - #include "progress.h"
16 15 #include "repository.h"
17 16 #include "strbuf.h"
18 17 #include "tempfile.h"
@@ -1039,96 +1038,6 @@ static void odb_source_loose_free(struct odb_source *source)
1039 1038 free(loose);
1040 1039 }
1041 1040
1042 - struct fsck_loose_data {
1043 - struct odb_source_loose *source;
1044 - struct odb_fsck_options *opts;
1045 - struct progress *progress;
1046 - bool error_found;
1047 - };
1048 -
1049 - static int fsck_loose(const struct object_id *oid, const char *path,
1050 - void *cb_data)
1051 - {
1052 - struct fsck_loose_data *data = cb_data;
1053 - enum object_type type = OBJ_NONE;
1054 - size_t size;
1055 - void *contents = NULL;
1056 - int eaten = 0;
1057 - struct object_info oi = OBJECT_INFO_INIT;
1058 - struct object_id real_oid = *null_oid(data->source->base.odb->repo->hash_algo);
1059 - int err = 0;
1060 -
1061 - oi.sizep = &size;
1062 - oi.typep = &type;
1063 -
1064 - if (read_loose_object(data->source->base.odb->repo,
1065 - path, oid, &real_oid, &contents, &oi) < 0) {
1066 - if (contents && !oideq(&real_oid, oid))
1067 - err = error(_("%s: hash-path mismatch, found at: %s"),
1068 - oid_to_hex(&real_oid), path);
1069 - else
1070 - err = error(_("%s: object corrupt or missing: %s"),
1071 - oid_to_hex(oid), path);
1072 - }
1073 - if (err < 0)
1074 - goto out;
1075 -
1076 - if (!contents && type != OBJ_BLOB)
1077 - BUG("read_loose_object streamed a non-blob");
1078 -
1079 - if (data->opts->object_cb(oid, type, size, contents, &eaten,
1080 - data->opts->object_payload)) {
1081 - err = -1;
1082 - goto out;
1083 - }
1084 -
1085 - out:
1086 - if (err)
1087 - data->error_found = true;
1088 - if (!eaten)
1089 - free(contents);
1090 - return 0; /* keep checking other objects, even if we saw an error */
1091 - }
1092 -
1093 - static int fsck_cruft(const char *basename, const char *path,
1094 - void *data UNUSED)
1095 - {
1096 - if (!starts_with(basename, "tmp_obj_"))
1097 - fprintf_ln(stderr, _("bad sha1 file: %s"), path);
1098 - return 0;
1099 - }
1100 -
1101 - static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *cb_data)
1102 - {
1103 - struct fsck_loose_data *data = cb_data;
1104 - display_progress(data->progress, nr + 1);
1105 - return 0;
1106 - }
1107 -
1108 - static int odb_source_loose_fsck(struct odb_source *source,
1109 - struct odb_fsck_options *opts)
1110 - {
1111 - struct odb_source_loose *loose = odb_source_loose_downcast(source);
1112 - struct fsck_loose_data data = {
1113 - .source = loose,
1114 - .opts = opts,
1115 - };
1116 -
1117 - if (opts->flags & ODB_FSCK_VERBOSE)
1118 - fprintf_ln(stderr, _("Checking object directory"));
1119 -
1120 - if (opts->flags & ODB_FSCK_PROGRESS)
1121 - data.progress = start_progress(source->odb->repo,
1122 - _("Checking object directories"), 256);
1123 -
1124 - for_each_loose_file_in_source(source, fsck_loose,
1125 - fsck_cruft, fsck_subdir, &data);
1126 - display_progress(data.progress, 256);
1127 - stop_progress(&data.progress);
1128 -
1129 - return data.error_found ? -1 : 0;
1130 - }
1131 -
1132 1041 struct odb_source_loose *odb_source_loose_new(struct object_database *odb,
1133 1042 const char *path,
1134 1043 bool local)
@@ -1141,7 +1050,6 @@ struct odb_source_loose *odb_source_loose_new(struct object_database *odb,
1141 1050 loose->base.free = odb_source_loose_free;
1142 1051 loose->base.close = odb_source_loose_close;
1143 1052 loose->base.prepare = odb_source_loose_prepare;
1144 - loose->base.fsck = odb_source_loose_fsck;
1145 1053 loose->base.read_object_info = odb_source_loose_read_object_info;
1146 1054 loose->base.read_object_stream = odb_source_loose_read_object_stream;
1147 1055 loose->base.for_each_object = odb_source_loose_for_each_object;
modified odb/source-packed.c
@@ -3,7 +3,6 @@
3 3 #include "chdir-notify.h"
4 4 #include "dir.h"
5 5 #include "gettext.h"
6 - #include "fsck.h"
7 6 #include "git-zlib.h"
8 7 #include "hex.h"
9 8 #include "list-objects-filter-options.h"
@@ -11,13 +10,9 @@
11 10 #include "midx.h"
12 11 #include "odb/source-packed.h"
13 12 #include "odb/streaming.h"
14 - #include "pack.h"
15 - #include "pack-revindex.h"
16 13 #include "packfile.h"
17 14 #include "pack-bitmap.h"
18 15 #include "strbuf.h"
19 - #include "progress.h"
20 - #include "run-command.h"
21 16
22 17 static int find_pack_entry(struct odb_source_packed *store,
23 18 const struct object_id *oid,
@@ -881,7 +876,6 @@ static void odb_source_packed_free(struct odb_source *source)
881 876
882 877 chdir_notify_unregister(odb_source_packed_reparent, packed);
883 878
884 - odb_source_close(source);
885 879 for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next)
886 880 free(e->pack);
887 881 packfile_list_clear(&packed->packs);
@@ -891,117 +885,6 @@ static void odb_source_packed_free(struct odb_source *source)
891 885 free(packed);
892 886 }
893 887
894 - static int verify_packs(struct odb_source_packed *source,
895 - struct odb_fsck_options *opts)
896 - {
897 - struct progress *progress = NULL;
898 - struct packfile_list_entry *e;
899 - uint32_t total = 0, count = 0;
900 - int ret = 0;
901 -
902 - if (opts->flags & ODB_FSCK_PROGRESS) {
903 - for (e = packfile_store_get_packs(source); e; e = e->next) {
904 - if (open_pack_index(e->pack))
905 - continue;
906 - total += e->pack->num_objects;
907 - }
908 -
909 - progress = start_progress(source->base.odb->repo,
910 - _("Checking objects"), total);
911 - }
912 -
913 - for (e = packfile_store_get_packs(source); e; e = e->next) {
914 - /* verify gives error messages itself */
915 - if (verify_pack(source->base.odb->repo, e->pack,
916 - opts->object_cb, opts->object_payload,
917 - progress, count))
918 - ret = -1;
919 - count += e->pack->num_objects;
920 - }
921 - stop_progress(&progress);
922 -
923 - return ret;
924 - }
925 -
926 - static int verify_reverse_indices(struct odb_source_packed *source,
927 - struct odb_fsck_options *opts)
928 - {
929 - struct progress *progress = NULL;
930 - struct packfile_list_entry *e;
931 - uint32_t pack_count = 0;
932 - int res = 0;
933 -
934 - if (opts->flags & ODB_FSCK_PROGRESS) {
935 - for (e = packfile_store_get_packs(source); e; e = e->next)
936 - pack_count++;
937 - progress = start_delayed_progress(source->base.odb->repo,
938 - "Verifying reverse pack-indexes", pack_count);
939 - pack_count = 0;
940 - }
941 -
942 - for (e = packfile_store_get_packs(source); e; e = e->next) {
943 - int load_error = load_pack_revindex_from_disk(e->pack);
944 -
945 - if (load_error < 0) {
946 - error(_("unable to load rev-index for pack '%s'"), e->pack->pack_name);
947 - res = -1;
948 - } else if (!load_error &&
949 - !load_pack_revindex(source->base.odb->repo, e->pack) &&
950 - verify_pack_revindex(e->pack)) {
951 - error(_("invalid rev-index for pack '%s'"), e->pack->pack_name);
952 - res = -1;
953 - }
954 - display_progress(progress, ++pack_count);
955 - }
956 - stop_progress(&progress);
957 -
958 - return res;
959 - }
960 -
961 - static int verify_midx(struct odb_source_packed *source,
962 - struct odb_fsck_options *opts)
963 - {
964 - struct child_process midx_verify = CHILD_PROCESS_INIT;
965 -
966 - prepare_repo_settings(source->base.odb->repo);
967 - if (!source->base.odb->repo->settings.core_multi_pack_index)
968 - return 0;
969 -
970 - child_process_init(&midx_verify);
971 - midx_verify.git_cmd = 1;
972 - strvec_pushl(&midx_verify.args, "multi-pack-index",
973 - "verify", "--object-dir", source->base.path, NULL);
974 - if (opts->flags & ODB_FSCK_PROGRESS)
975 - strvec_push(&midx_verify.args, "--progress");
976 - else
977 - strvec_push(&midx_verify.args, "--no-progress");
978 - if (run_command(&midx_verify))
979 - return -1;
980 -
981 - return 0;
982 - }
983 -
984 - static int odb_source_packed_fsck(struct odb_source *source,
985 - struct odb_fsck_options *opts)
986 - {
987 - struct odb_source_packed *packed = odb_source_packed_downcast(source);
988 - int ret = 0;
989 -
990 - if ((opts->flags & ODB_FSCK_FULL) && verify_packs(packed, opts) < 0)
991 - ret = -1;
992 -
993 - if (verify_reverse_indices(packed, opts) < 0)
994 - ret = -1;
995 -
996 - if (verify_bitmap_files(packed))
997 - ret = -1;
998 -
999 - if (verify_midx(packed, opts) < 0)
1000 - ret = -1;
1001 -
1002 - return ret;
1003 - }
1004 -
1005 888 struct odb_source_packed *odb_source_packed_new(struct object_database *odb,
1006 889 const char *path,
1007 890 bool local)
@@ -1015,7 +898,6 @@ struct odb_source_packed *odb_source_packed_new(struct object_database *odb,
1015 898 packed->base.free = odb_source_packed_free;
1016 899 packed->base.close = odb_source_packed_close;
1017 900 packed->base.prepare = odb_source_packed_prepare;
1018 - packed->base.fsck = odb_source_packed_fsck;
1019 901 packed->base.read_object_info = odb_source_packed_read_object_info;
1020 902 packed->base.read_object_stream = odb_source_packed_read_object_stream;
1021 903 packed->base.for_each_object = odb_source_packed_for_each_object;
modified odb/source.h
@@ -325,17 +325,6 @@ struct odb_source {
325 325 int (*generate_pack)(struct odb_source *source,
326 326 struct odb_pack_generator **out,
327 327 const struct odb_generate_pack_options *opts);
328 -
329 - /*
330 - * This callback is expected to check the integrity of the object source
331 - * and report any errors found via the fsck options. The checks performed
332 - * are backend-specific.
333 - *
334 - * The callback is expected to return 0 on success, a negative error
335 - * code otherwise.
336 - */
337 - int (*fsck)(struct odb_source *source,
338 - struct odb_fsck_options *options);
339 328 };
340 329
341 330 /*
@@ -609,14 +598,4 @@ static inline int odb_source_generate_pack(struct odb_source *source,
609 598 return source->generate_pack(source, out, opts);
610 599 }
611 600
612 - /*
613 - * Check the integrity of the object database source. The checks performed
614 - * are backend-specific. Returns 0 on success, a negative error code otherwise.
615 - */
616 - static inline int odb_source_fsck(struct odb_source *source,
617 - struct odb_fsck_options *opts)
618 - {
619 - return source->fsck(source, opts);
620 - }
621 -
622 601 #endif
modified pack-bitmap.c
@@ -3410,22 +3410,28 @@ static int verify_bitmap_file(const struct git_hash_algo *algop,
3410 3410 return res;
3411 3411 }
3412 3412
3413 - int verify_bitmap_files(struct odb_source_packed *source)
3413 + int verify_bitmap_files(struct repository *r)
3414 3414 {
3415 - struct packfile_list_entry *e;
3416 - struct multi_pack_index *m;
3415 + struct odb_source *source;
3416 + struct packed_git *p;
3417 3417 int res = 0;
3418 3418
3419 - m = get_multi_pack_index(source);
3420 - if (m) {
3421 - char *midx_bitmap_name = midx_bitmap_filename(m);
3422 - res |= verify_bitmap_file(source->base.odb->repo->hash_algo, midx_bitmap_name);
3419 + for (source = r->objects->sources; source; source = source->next) {
3420 + struct odb_source_files *files = odb_source_files_downcast(source);
3421 + struct multi_pack_index *m = get_multi_pack_index(files->packed);
3422 + char *midx_bitmap_name;
3423 +
3424 + if (!m)
3425 + continue;
3426 +
3427 + midx_bitmap_name = midx_bitmap_filename(m);
3428 + res |= verify_bitmap_file(r->hash_algo, midx_bitmap_name);
3423 3429 free(midx_bitmap_name);
3424 3430 }
3425 3431
3426 - for (e = packfile_store_get_packs(source); e; e = e->next) {
3427 - char *pack_bitmap_name = pack_bitmap_filename(e->pack);
3428 - res |= verify_bitmap_file(source->base.odb->repo->hash_algo, pack_bitmap_name);
3432 + repo_for_each_pack(r, p) {
3433 + char *pack_bitmap_name = pack_bitmap_filename(p);
3434 + res |= verify_bitmap_file(r->hash_algo, pack_bitmap_name);
3429 3435 free(pack_bitmap_name);
3430 3436 }
3431 3437
modified pack-bitmap.h
@@ -205,7 +205,7 @@ int bitmap_is_midx(struct bitmap_index *bitmap_git);
205 205
206 206 int bitmap_is_preferred_refname(struct repository *r, const char *refname);
207 207
208 - int verify_bitmap_files(struct odb_source_packed *source);
208 + int verify_bitmap_files(struct repository *r);
209 209
210 210 struct ewah_bitmap *read_bitmap(const unsigned char *map,
211 211 size_t map_size, size_t *map_pos);
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((void *)pathspec->items[i].match);
753 - free((void *)pathspec->items[i].original);
752 + free(pathspec->items[i].match);
753 + free(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 - const char *match;
39 - const char *original;
38 + char *match;
39 + char *original;
40 40 unsigned magic;
41 41 int len, prefix;
42 42 int nowildcard_len;
modified read-cache-ll.h
@@ -269,10 +269,9 @@ void validate_cache_entries(const struct index_state *istate);
269 269 * the given predicate. This function should only be called if
270 270 * repo_has_promisor_remote() returns true.
271 271 */
272 - typedef int (*must_prefetch_predicate)(const struct cache_entry *, void *cb_data);
272 + typedef int (*must_prefetch_predicate)(const struct cache_entry *);
273 273 void prefetch_cache_entries(const struct index_state *istate,
274 - must_prefetch_predicate must_prefetch,
275 - void *cb_data);
274 + must_prefetch_predicate must_prefetch);
276 275
277 276 /* Initialize and use the cache information */
278 277 struct lock_file;
modified read-cache.c
@@ -1748,7 +1748,7 @@ static int read_index_extension(struct index_state *istate,
1748 1748 {
1749 1749 switch (CACHE_EXT(ext)) {
1750 1750 case CACHE_EXT_TREE:
1751 - istate->cache_tree = cache_tree_read(istate->repo, data, sz);
1751 + istate->cache_tree = cache_tree_read(data, sz);
1752 1752 break;
1753 1753 case CACHE_EXT_RESOLVE_UNDO:
1754 1754 istate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo);
@@ -3012,7 +3012,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
3012 3012 !drop_cache_tree && istate->cache_tree) {
3013 3013 strbuf_reset(&sb);
3014 3014
3015 - cache_tree_write(istate->repo, &sb, istate->cache_tree);
3015 + cache_tree_write(&sb, istate->cache_tree);
3016 3016 err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
3017 3017 hashwrite(f, sb.buf, sb.len);
3018 3018 if (err) {
@@ -3733,8 +3733,7 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta
3733 3733 }
3734 3734
3735 3735 void prefetch_cache_entries(const struct index_state *istate,
3736 - must_prefetch_predicate must_prefetch,
3737 - void *cb_data)
3736 + must_prefetch_predicate must_prefetch)
3738 3737 {
3739 3738 int i;
3740 3739 struct oid_array to_fetch = OID_ARRAY_INIT;
@@ -3742,7 +3741,7 @@ void prefetch_cache_entries(const struct index_state *istate,
3742 3741 for (i = 0; i < istate->cache_nr; i++) {
3743 3742 struct cache_entry *ce = istate->cache[i];
3744 3743
3745 - if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce, cb_data))
3744 + if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
3746 3745 continue;
3747 3746 if (!odb_read_object_info_extended(the_repository->objects,
3748 3747 &ce->oid, NULL,
modified repository.c
@@ -386,8 +386,7 @@ void repo_clear(struct repository *repo)
386 386 odb_free(repo->objects);
387 387 repo->objects = NULL;
388 388
389 - if (repo->parsed_objects)
390 - parsed_object_pool_clear(repo->parsed_objects);
389 + parsed_object_pool_clear(repo->parsed_objects);
391 390 FREE_AND_NULL(repo->parsed_objects);
392 391
393 392 repo_settings_clear(repo);
modified rerere.c
@@ -1173,44 +1173,22 @@ static void unlink_rr_item(struct rerere_id *id)
1173 1173 strbuf_release(&buf);
1174 1174 }
1175 1175
1176 - static void rerere_gc_cutoffs(struct repository *r,
1177 - timestamp_t *cutoff_resolve,
1178 - timestamp_t *cutoff_noresolve)
1179 - {
1180 - timestamp_t now = time(NULL);
1181 -
1182 - if (repo_config_get_expiry_in_days(r, "gc.rerereresolved",
1183 - cutoff_resolve, now))
1184 - *cutoff_resolve = now - 60 * 86400;
1185 - if (repo_config_get_expiry_in_days(r, "gc.rerereunresolved",
1186 - cutoff_noresolve, now))
1187 - *cutoff_noresolve = now - 15 * 86400;
1188 - }
1189 -
1190 - static bool rerere_id_is_stale(struct rerere_id *id,
1191 - timestamp_t cutoff_resolve,
1192 - timestamp_t cutoff_noresolve)
1176 + static void prune_one(struct rerere_id *id,
1177 + timestamp_t cutoff_resolve, timestamp_t cutoff_noresolve)
1193 1178 {
1194 1179 timestamp_t then;
1195 1180 timestamp_t cutoff;
1196 1181
1197 1182 then = rerere_last_used_at(id);
1198 - if (then) {
1183 + if (then)
1199 1184 cutoff = cutoff_resolve;
1200 - } else {
1185 + else {
1201 1186 then = rerere_created_at(id);
1202 1187 if (!then)
1203 - return false;
1188 + return;
1204 1189 cutoff = cutoff_noresolve;
1205 1190 }
1206 -
1207 - return then < cutoff;
1208 - }
1209 -
1210 - static void prune_one(struct rerere_id *id,
1211 - timestamp_t cutoff_resolve, timestamp_t cutoff_noresolve)
1212 - {
1213 - if (rerere_id_is_stale(id, cutoff_resolve, cutoff_noresolve))
1191 + if (then < cutoff)
1214 1192 unlink_rr_item(id);
1215 1193 }
1216 1194
@@ -1222,70 +1200,24 @@ static int is_rr_cache_dirname(const char *path)
1222 1200 return !parse_oid_hex(path, &oid, &end) && !*end;
1223 1201 }
1224 1202
1225 - bool rerere_gc_needed(struct repository *r, size_t limit)
1226 - {
1227 - timestamp_t cutoff_resolve, cutoff_noresolve;
1228 - struct strbuf buf = STRBUF_INIT;
1229 - bool needed = false;
1230 - struct dirent *e;
1231 - size_t count = 0;
1232 - DIR *dir;
1233 -
1234 - dir = opendir(repo_git_path_replace(r, &buf, "rr-cache"));
1235 - if (!dir)
1236 - goto out;
1237 -
1238 - rerere_gc_cutoffs(r, &cutoff_resolve, &cutoff_noresolve);
1239 -
1240 - while ((e = readdir_skip_dot_and_dotdot(dir))) {
1241 - struct rerere_id id;
1242 -
1243 - /*
1244 - * We estimate the number of stale entries by only considering
1245 - * those starting with "17". This is the same strategy that we
1246 - * use for estimating the number of loose objects.
1247 - */
1248 - if (!starts_with(e->d_name, "17") ||
1249 - !is_rr_cache_dirname(e->d_name))
1250 - continue;
1251 -
1252 - id.collection = find_rerere_dir(e->d_name);
1253 - for (id.variant = 0;
1254 - id.variant < id.collection->status_nr;
1255 - id.variant++) {
1256 - if (rerere_id_is_stale(&id, cutoff_resolve,
1257 - cutoff_noresolve)) {
1258 - count += 256;
1259 - if (count >= limit) {
1260 - needed = true;
1261 - goto out;
1262 - }
1263 - }
1264 - }
1265 - }
1266 -
1267 - out:
1268 - if (dir)
1269 - closedir(dir);
1270 - free_rerere_dirs();
1271 - strbuf_release(&buf);
1272 - return needed;
1273 - }
1274 -
1275 1203 void rerere_gc(struct repository *r, struct string_list *rr)
1276 1204 {
1277 1205 struct string_list to_remove = STRING_LIST_INIT_DUP;
1278 1206 DIR *dir;
1279 1207 struct dirent *e;
1280 1208 int i;
1281 - timestamp_t cutoff_noresolve;
1282 - timestamp_t cutoff_resolve;
1209 + timestamp_t now = time(NULL);
1210 + timestamp_t cutoff_noresolve = now - 15 * 86400;
1211 + timestamp_t cutoff_resolve = now - 60 * 86400;
1283 1212 struct strbuf buf = STRBUF_INIT;
1284 1213
1285 1214 if (setup_rerere(r, rr, 0) < 0)
1286 1215 return;
1287 1216
1288 - rerere_gc_cutoffs(r, &cutoff_resolve, &cutoff_noresolve);
1217 + repo_config_get_expiry_in_days(the_repository, "gc.rerereresolved",
1218 + &cutoff_resolve, now);
1219 + repo_config_get_expiry_in_days(the_repository, "gc.rerereunresolved",
1220 + &cutoff_noresolve, now);
1289 1221 repo_config(the_repository, git_default_config, NULL);
1290 1222 dir = opendir(repo_git_path_replace(the_repository, &buf, "rr-cache"));
1291 1223 if (!dir)
modified rerere.h
@@ -39,12 +39,6 @@ int rerere_remaining(struct repository *, struct string_list *);
39 39 void rerere_clear(struct repository *, struct string_list *);
40 40 void rerere_gc(struct repository *, struct string_list *);
41 41
42 - /*
43 - * Check whether garbage collection for rerere entries is needed, which is
44 - * the case when there's at least `limit` stale entries that would be pruned.
45 - */
46 - bool rerere_gc_needed(struct repository *r, size_t limit);
47 -
48 42 #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
49 43 N_("update the index with reused conflict resolution if possible"))
50 44
modified sequencer.c
@@ -19,7 +19,6 @@
19 19 #include "commit.h"
20 20 #include "sequencer.h"
21 21 #include "run-command.h"
22 - #include "stash.h"
23 22 #include "hook.h"
24 23 #include "utf8.h"
25 24 #include "cache-tree.h"
@@ -143,13 +142,6 @@ static GIT_PATH_FUNC(rebase_path_author_script, "rebase-merge/author-script")
143 142 * command is processed, this file is deleted.
144 143 */
145 144 static GIT_PATH_FUNC(rebase_path_amend, "rebase-merge/amend")
146 - /*
147 - * The apply ("am") backend keeps its state in the rebase-apply directory;
148 - * the "applying" file within it marks a plain `git am` (as opposed to an
149 - * apply-based rebase).
150 - */
151 - static GIT_PATH_FUNC(apply_dir, "rebase-apply")
152 - static GIT_PATH_FUNC(apply_path_applying, "rebase-apply/applying")
153 145 /*
154 146 * When we stop at a given patch via the "edit" command, this file contains
155 147 * the commit object name of the corresponding patch.
@@ -822,7 +814,7 @@ static int do_recursive_merge(struct repository *r,
822 814
823 815 static struct object_id *get_cache_tree_oid(struct index_state *istate)
824 816 {
825 - if (!cache_tree_fully_valid(istate))
817 + if (!cache_tree_fully_valid(istate->cache_tree))
826 818 if (cache_tree_update(istate, 0)) {
827 819 error(_("unable to update cache tree"));
828 820 return NULL;
@@ -4802,50 +4794,31 @@ void create_autostash_ref(struct repository *r, const char *refname,
4802 4794 create_autostash_internal(r, NULL, refname, message, silent);
4803 4795 }
4804 4796
4805 - static enum stash_apply_result do_stash_apply(const char *stash_oid,
4806 - const char *label_ours,
4807 - const char *label_theirs,
4808 - const char *label_base)
4797 + static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply,
4798 + const char *label_ours, const char *label_theirs,
4799 + const char *label_base,
4800 + const char *stash_msg)
4809 4801 {
4810 4802 struct child_process child = CHILD_PROCESS_INIT;
4803 + int ret = 0;
4811 4804
4812 - child.git_cmd = 1;
4813 - child.no_stdout = 1;
4814 - child.no_stderr = 1;
4815 - strvec_push(&child.args, "stash");
4816 - strvec_push(&child.args, "apply");
4817 - if (label_ours)
4818 - strvec_pushf(&child.args, "--label-ours=%s", label_ours);
4819 - if (label_theirs)
4820 - strvec_pushf(&child.args, "--label-theirs=%s", label_theirs);
4821 - if (label_base)
4822 - strvec_pushf(&child.args, "--label-base=%s", label_base);
4823 - strvec_push(&child.args, stash_oid);
4824 -
4825 - switch (run_command(&child)) {
4826 - case 0:
4827 - return STASH_APPLY_CLEAN;
4828 - case STASH_APPLY_CONFLICT:
4829 - return STASH_APPLY_CONFLICT;
4830 - default:
4831 - return STASH_APPLY_ERROR;
4832 - }
4833 - }
4834 -
4835 - static enum stash_apply_result apply_save_autostash_oid(const char *stash_oid,
4836 - int attempt_apply,
4837 - const char *label_ours,
4838 - const char *label_theirs,
4839 - const char *label_base,
4840 - const char *stash_msg)
4841 - {
4842 - enum stash_apply_result ret = STASH_APPLY_CLEAN;
4843 -
4844 - if (attempt_apply)
4845 - ret = do_stash_apply(stash_oid, label_ours, label_theirs,
4846 - label_base);
4847 -
4848 - if (attempt_apply && ret == STASH_APPLY_CLEAN)
4805 + if (attempt_apply) {
4806 + child.git_cmd = 1;
4807 + child.no_stdout = 1;
4808 + child.no_stderr = 1;
4809 + strvec_push(&child.args, "stash");
4810 + strvec_push(&child.args, "apply");
4811 + if (label_ours)
4812 + strvec_pushf(&child.args, "--label-ours=%s", label_ours);
4813 + if (label_theirs)
4814 + strvec_pushf(&child.args, "--label-theirs=%s", label_theirs);
4815 + if (label_base)
4816 + strvec_pushf(&child.args, "--label-base=%s", label_base);
4817 + strvec_push(&child.args, stash_oid);
4818 + ret = run_command(&child);
4819 + }
4820 +
4821 + if (attempt_apply && !ret)
4849 4822 fprintf(stderr, _("Applied autostash.\n"));
4850 4823 else {
4851 4824 struct child_process store = CHILD_PROCESS_INIT;
@@ -4859,16 +4832,13 @@ static enum stash_apply_result apply_save_autostash_oid(const char *stash_oid,
4859 4832 strvec_push(&store.args, stash_oid);
4860 4833 if (run_command(&store))
4861 4834 ret = error(_("cannot store %s"), stash_oid);
4862 - else if (attempt_apply && ret == STASH_APPLY_CONFLICT)
4835 + else if (attempt_apply)
4863 4836 fprintf(stderr,
4864 4837 _("Your local changes are stashed, however applying them\n"
4865 4838 "resulted in conflicts. You can either resolve the conflicts\n"
4866 4839 "and then discard the stash with \"git stash drop\", or, if you\n"
4867 4840 "do not want to resolve them now, run \"git reset --hard\" and\n"
4868 4841 "apply the local changes later by running \"git stash pop\".\n"));
4869 - else if (attempt_apply)
4870 - ret = error(_("could not apply autostash; "
4871 - "your changes are safe in the stash"));
4872 4842 else
4873 4843 fprintf(stderr,
4874 4844 _("Autostash exists; creating a new stash entry.\n"
@@ -4880,16 +4850,15 @@ static enum stash_apply_result apply_save_autostash_oid(const char *stash_oid,
4880 4850 return ret;
4881 4851 }
4882 4852
4883 - static enum stash_apply_result apply_save_autostash(const char *path,
4884 - int attempt_apply)
4853 + static int apply_save_autostash(const char *path, int attempt_apply)
4885 4854 {
4886 4855 struct strbuf stash_oid = STRBUF_INIT;
4887 - enum stash_apply_result ret = STASH_APPLY_CLEAN;
4856 + int ret = 0;
4888 4857
4889 4858 if (!read_oneliner(&stash_oid, path,
4890 4859 READ_ONELINER_SKIP_IF_EMPTY)) {
4891 4860 strbuf_release(&stash_oid);
4892 - return STASH_APPLY_CLEAN;
4861 + return 0;
4893 4862 }
4894 4863 strbuf_trim(&stash_oid);
4895 4864
@@ -4901,40 +4870,37 @@ static enum stash_apply_result apply_save_autostash(const char *path,
4901 4870 return ret;
4902 4871 }
4903 4872
4904 - enum stash_apply_result save_autostash(const char *path)
4873 + int save_autostash(const char *path)
4905 4874 {
4906 4875 return apply_save_autostash(path, 0);
4907 4876 }
4908 4877
4909 - enum stash_apply_result apply_autostash(const char *path)
4878 + int apply_autostash(const char *path)
4910 4879 {
4911 4880 return apply_save_autostash(path, 1);
4912 4881 }
4913 4882
4914 - enum stash_apply_result apply_autostash_oid(const char *stash_oid)
4883 + int apply_autostash_oid(const char *stash_oid)
4915 4884 {
4916 4885 return apply_save_autostash_oid(stash_oid, 1, NULL, NULL, NULL, NULL);
4917 4886 }
4918 4887
4919 - static enum stash_apply_result apply_save_autostash_ref(struct repository *r,
4920 - const char *refname,
4921 - int attempt_apply,
4922 - const char *label_ours,
4923 - const char *label_theirs,
4924 - const char *label_base,
4925 - const char *stash_msg)
4888 + static int apply_save_autostash_ref(struct repository *r, const char *refname,
4889 + int attempt_apply,
4890 + const char *label_ours, const char *label_theirs,
4891 + const char *label_base,
4892 + const char *stash_msg)
4926 4893 {
4927 4894 struct object_id stash_oid;
4928 4895 char stash_oid_hex[GIT_MAX_HEXSZ + 1];
4929 - int flag;
4930 - enum stash_apply_result ret;
4896 + int flag, ret;
4931 4897
4932 4898 if (!refs_ref_exists(get_main_ref_store(r), refname))
4933 - return STASH_APPLY_CLEAN;
4899 + return 0;
4934 4900
4935 4901 if (!refs_resolve_ref_unsafe(get_main_ref_store(r), refname,
4936 4902 RESOLVE_REF_READING, &stash_oid, &flag))
4937 - return STASH_APPLY_ERROR;
4903 + return -1;
4938 4904 if (flag & REF_ISSYMREF)
4939 4905 return error(_("autostash reference is a symref"));
4940 4906
@@ -4949,19 +4915,15 @@ static enum stash_apply_result apply_save_autostash_ref(struct repository *r,
4949 4915 return ret;
4950 4916 }
4951 4917
4952 - enum stash_apply_result save_autostash_ref(struct repository *r,
4953 - const char *refname)
4918 + int save_autostash_ref(struct repository *r, const char *refname)
4954 4919 {
4955 4920 return apply_save_autostash_ref(r, refname, 0,
4956 4921 NULL, NULL, NULL, NULL);
4957 4922 }
4958 4923
4959 - enum stash_apply_result apply_autostash_ref(struct repository *r,
4960 - const char *refname,
4961 - const char *label_ours,
4962 - const char *label_theirs,
4963 - const char *label_base,
4964 - const char *stash_msg)
4924 + int apply_autostash_ref(struct repository *r, const char *refname,
4925 + const char *label_ours, const char *label_theirs,
4926 + const char *label_base, const char *stash_msg)
4965 4927 {
4966 4928 return apply_save_autostash_ref(r, refname, 1,
4967 4929 label_ours, label_theirs, label_base,
@@ -6994,7 +6956,7 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
6994 6956 !repo_get_oid(r, "REBASE_HEAD", &rebase_head) &&
6995 6957 !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
6996 6958 oideq(&rebase_head, &cherry_pick_head))
6997 - *whence = FROM_REBASE_NOW_EMPTY;
6959 + *whence = FROM_REBASE_PICK;
6998 6960 else
6999 6961 *whence = FROM_CHERRY_PICK_SINGLE;
7000 6962
@@ -7004,56 +6966,6 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
7004 6966 return 0;
7005 6967 }
7006 6968
7007 - enum ongoing_operation sequencer_ongoing_operation(struct repository *r,
7008 - enum commit_whence whence)
7009 - {
7010 - /*
7011 - * The merge, cherry-pick, and (empty) rebase-pick stops are already
7012 - * distinguished by 'whence'.
7013 - */
7014 - switch (whence) {
7015 - case FROM_MERGE:
7016 - return ONGOING_MERGE;
7017 - case FROM_CHERRY_PICK_SINGLE:
7018 - case FROM_CHERRY_PICK_MULTI:
7019 - return ONGOING_CHERRY_PICK;
7020 - case FROM_REBASE_NOW_EMPTY:
7021 - return ONGOING_REBASE_NOW_EMPTY;
7022 - case FROM_COMMIT:
7023 - break;
7024 - }
7025 -
7026 - /*
7027 - * 'whence' is FROM_COMMIT, but we may still be in the middle of an
7028 - * operation that records its result on top of HEAD; detect those
7029 - * from their on-disk state.
7030 - */
7031 -
7032 - /* In the middle of a revert? */
7033 - if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD"))
7034 - return ONGOING_REVERT;
7035 -
7036 - /* In the middle of an `am`? */
7037 - if (file_exists(apply_path_applying()))
7038 - return ONGOING_AM;
7039 -
7040 - /*
7041 - * In the middle of a rebase that stopped for conflict resolution?
7042 - * The apply backend only ever stops for conflicts, so the presence
7043 - * of its state directory is enough. The merge backend writes
7044 - * stopped-sha whenever it hands control back to the user, but omits
7045 - * `amend` unless it stopped with HEAD already pointing at the commit
7046 - * to be amended (a clean edit/reword stop); its absence therefore
7047 - * marks a conflicted stop.
7048 - */
7049 - if (file_exists(apply_dir()) ||
7050 - (file_exists(rebase_path_stopped_sha()) &&
7051 - !file_exists(rebase_path_amend())))
7052 - return ONGOING_REBASE_CONFLICT;
7053 -
7054 - return ONGOING_NONE;
7055 - }
7056 -
7057 6969 int sequencer_get_update_refs_state(const char *wt_dir,
7058 6970 struct string_list *refs)
7059 6971 {
modified sequencer.h
@@ -3,7 +3,6 @@
3 3
4 4 #include "strbuf.h"
5 5 #include "strvec.h"
6 - #include "stash.h"
7 6 #include "wt-status.h"
8 7
9 8 struct commit;
@@ -232,17 +231,13 @@ void commit_post_rewrite(struct repository *r,
232 231 void create_autostash(struct repository *r, const char *path);
233 232 void create_autostash_ref(struct repository *r, const char *refname,
234 233 const char *message, bool silent);
235 - enum stash_apply_result save_autostash(const char *path);
236 - enum stash_apply_result save_autostash_ref(struct repository *r,
237 - const char *refname);
238 - enum stash_apply_result apply_autostash(const char *path);
239 - enum stash_apply_result apply_autostash_oid(const char *stash_oid);
240 - enum stash_apply_result apply_autostash_ref(struct repository *r,
241 - const char *refname,
242 - const char *label_ours,
243 - const char *label_theirs,
244 - const char *label_base,
245 - const char *stash_msg);
234 + int save_autostash(const char *path);
235 + int save_autostash_ref(struct repository *r, const char *refname);
236 + int apply_autostash(const char *path);
237 + int apply_autostash_oid(const char *stash_oid);
238 + int apply_autostash_ref(struct repository *r, const char *refname,
239 + const char *label_ours, const char *label_theirs,
240 + const char *label_base, const char *stash_msg);
246 241
247 242 #define SUMMARY_INITIAL_COMMIT (1 << 0)
248 243 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
@@ -282,30 +277,6 @@ int sequencer_get_last_command(struct repository* r,
282 277 enum replay_action *action);
283 278 int sequencer_determine_whence(struct repository *r, enum commit_whence *whence);
284 279
285 - /*
286 - * An in-progress operation that records its result (often a conflict
287 - * resolution) as a new commit on top of HEAD. Some ways of invoking
288 - * "git commit" -- amending HEAD, or a partial commit -- are almost
289 - * always a mistake during such an operation.
290 - */
291 - enum ongoing_operation {
292 - ONGOING_NONE = 0,
293 - ONGOING_MERGE,
294 - ONGOING_CHERRY_PICK,
295 - ONGOING_REBASE_NOW_EMPTY,
296 - ONGOING_REVERT,
297 - ONGOING_AM,
298 - ONGOING_REBASE_CONFLICT
299 - };
300 -
301 - /*
302 - * Return which in-progress operation, if any, is underway; see enum
303 - * ongoing_operation. 'whence' is the origin already computed for the
304 - * pending commit.
305 - */
306 - enum ongoing_operation sequencer_ongoing_operation(struct repository *r,
307 - enum commit_whence whence);
308 -
309 280 /**
310 281 * Append the set of ref-OID pairs that are currently stored for the 'git
311 282 * rebase --update-refs' feature if such a rebase is currently happening.
modified sparse-index.c
@@ -228,7 +228,7 @@ int convert_to_sparse(struct index_state *istate, int flags)
228 228 if (index_has_unmerged_entries(istate))
229 229 return 0;
230 230
231 - if (!cache_tree_fully_valid(istate)) {
231 + if (!cache_tree_fully_valid(istate->cache_tree)) {
232 232 /* Clear and recompute the cache-tree */
233 233 cache_tree_free(&istate->cache_tree);
234 234
deleted stash.h mode 100644
@@ -1,21 +0,0 @@
1 - #ifndef STASH_H
2 - #define STASH_H
3 -
4 - enum stash_apply_result {
5 - /* The stash was applied cleanly, or there was nothing to apply. */
6 - STASH_APPLY_CLEAN = 0,
7 -
8 - /*
9 - * The stash could not be applied because it resulted in
10 - * conflicts. The stash entry is left in place. The "git stash
11 - * apply", "pop" and "branch" subcommands exit with this status
12 - * in this case, mirroring the convention of "git merge-tree" and
13 - * the merge strategies.
14 - */
15 - STASH_APPLY_CONFLICT = 1,
16 -
17 - /* Something went wrong. */
18 - STASH_APPLY_ERROR = -1,
19 - };
20 -
21 - #endif /* STASH_H */
modified submodule-config.c
@@ -1,3 +1,4 @@
1 + #define USE_THE_REPOSITORY_VARIABLE
1 2 #define DISABLE_SIGN_COMPARE_WARNINGS
2 3
3 4 #include "git-compat-util.h"
@@ -132,9 +133,7 @@ void submodule_cache_free(struct submodule_cache *cache)
132 133 static unsigned int hash_oid_string(const struct object_id *oid,
133 134 const char *string)
134 135 {
135 - if (oid->algo == GIT_HASH_UNKNOWN)
136 - BUG("hashing an object ID with unknown algorithm");
137 - return memhash(oid->hash, hash_algos[oid->algo].rawsz) + strhash(string);
136 + return memhash(oid->hash, the_hash_algo->rawsz) + strhash(string);
138 137 }
139 138
140 139 static void cache_put_path(struct submodule_cache *cache,
@@ -668,20 +667,19 @@ static int parse_config(const char *var, const char *value,
668 667 return ret;
669 668 }
670 669
671 - static int gitmodule_oid_from_commit(struct repository *repo,
672 - const struct object_id *treeish_name,
670 + static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
673 671 struct object_id *gitmodules_oid,
674 672 struct strbuf *rev)
675 673 {
676 674 int ret = 0;
677 675
678 676 if (is_null_oid(treeish_name)) {
679 - oidclr(gitmodules_oid, repo->hash_algo);
677 + oidclr(gitmodules_oid, the_repository->hash_algo);
680 678 return 1;
681 679 }
682 680
683 681 strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
684 - if (repo_get_oid(repo, rev->buf, gitmodules_oid) >= 0)
682 + if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
685 683 ret = 1;
686 684
687 685 return ret;
@@ -691,11 +689,9 @@ static int gitmodule_oid_from_commit(struct repository *repo,
691 689 * (key) with on-demand reading of the appropriate .gitmodules from
692 690 * revisions.
693 691 */
694 - static const struct submodule *config_from(struct repository *repo,
695 - struct submodule_cache *cache,
696 - const struct object_id *treeish_name,
697 - const char *key,
698 - enum lookup_type lookup_type)
692 + static const struct submodule *config_from(struct submodule_cache *cache,
693 + const struct object_id *treeish_name, const char *key,
694 + enum lookup_type lookup_type)
699 695 {
700 696 struct strbuf rev = STRBUF_INIT;
701 697 size_t config_size;
@@ -722,7 +718,7 @@ static const struct submodule *config_from(struct repository *repo,
722 718 return entry->config;
723 719 }
724 720
725 - if (!gitmodule_oid_from_commit(repo, treeish_name, &oid, &rev))
721 + if (!gitmodule_oid_from_commit(treeish_name, &oid, &rev))
726 722 goto out;
727 723
728 724 switch (lookup_type) {
@@ -736,7 +732,7 @@ static const struct submodule *config_from(struct repository *repo,
736 732 if (submodule)
737 733 goto out;
738 734
739 - config = odb_read_object(repo->objects, &oid,
735 + config = odb_read_object(the_repository->objects, &oid,
740 736 &type, &config_size);
741 737 if (!config || type != OBJ_BLOB)
742 738 goto out;
@@ -802,6 +798,9 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
802 798 } else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
803 799 repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
804 800 config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
801 + if (repo != the_repository)
802 + odb_add_submodule_source_by_path(the_repository->objects,
803 + repo->objects->sources->path);
805 804 } else {
806 805 goto out;
807 806 }
@@ -822,7 +821,7 @@ static int gitmodules_cb(const char *var, const char *value,
822 821
823 822 parameter.cache = repo->submodule_cache;
824 823 parameter.treeish_name = NULL;
825 - parameter.gitmodules_oid = null_oid(repo->hash_algo);
824 + parameter.gitmodules_oid = null_oid(the_hash_algo);
826 825 parameter.overwrite = 1;
827 826
828 827 return parse_config(var, value, ctx, &parameter);
@@ -844,22 +843,21 @@ void repo_read_gitmodules(struct repository *repo, int skip_if_read)
844 843 repo->submodule_cache->gitmodules_read = 1;
845 844 }
846 845
847 - void gitmodules_config_oid(struct repository *repo,
848 - const struct object_id *commit_oid)
846 + void gitmodules_config_oid(const struct object_id *commit_oid)
849 847 {
850 848 struct strbuf rev = STRBUF_INIT;
851 849 struct object_id oid;
852 850
853 - submodule_cache_check_init(repo);
851 + submodule_cache_check_init(the_repository);
854 852
855 - if (gitmodule_oid_from_commit(repo, commit_oid, &oid, &rev)) {
853 + if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) {
856 854 git_config_from_blob_oid(gitmodules_cb, rev.buf,
857 - repo, &oid, repo,
855 + the_repository, &oid, the_repository,
858 856 CONFIG_SCOPE_UNKNOWN);
859 857 }
860 858 strbuf_release(&rev);
861 859
862 - repo->submodule_cache->gitmodules_read = 1;
860 + the_repository->submodule_cache->gitmodules_read = 1;
863 861 }
864 862
865 863 const struct submodule *submodule_from_name(struct repository *r,
@@ -867,7 +865,7 @@ const struct submodule *submodule_from_name(struct repository *r,
867 865 const char *name)
868 866 {
869 867 repo_read_gitmodules(r, 1);
870 - return config_from(r, r->submodule_cache, treeish_name, name, lookup_name);
868 + return config_from(r->submodule_cache, treeish_name, name, lookup_name);
871 869 }
872 870
873 871 const struct submodule *submodule_from_path(struct repository *r,
@@ -875,7 +873,7 @@ const struct submodule *submodule_from_path(struct repository *r,
875 873 const char *path)
876 874 {
877 875 repo_read_gitmodules(r, 1);
878 - return config_from(r, r->submodule_cache, treeish_name, path, lookup_path);
876 + return config_from(r->submodule_cache, treeish_name, path, lookup_path);
879 877 }
880 878
881 879 /**
@@ -982,12 +980,11 @@ int print_config_from_gitmodules(struct repository *repo, const char *key)
982 980 return 0;
983 981 }
984 982
985 - int config_set_in_gitmodules_file_gently(struct repository *repo,
986 - const char *key, const char *value)
983 + int config_set_in_gitmodules_file_gently(const char *key, const char *value)
987 984 {
988 985 int ret;
989 986
990 - ret = repo_config_set_in_file_gently(repo, GITMODULES_FILE, key, NULL, value);
987 + ret = repo_config_set_in_file_gently(the_repository, GITMODULES_FILE, key, NULL, value);
991 988 if (ret < 0)
992 989 /* Maybe the user already did that, don't error out here */
993 990 warning(_("Could not update .gitmodules entry %s"), key);
@@ -1020,15 +1017,13 @@ static int gitmodules_fetch_config(const char *var, const char *value,
1020 1017 return 0;
1021 1018 }
1022 1019
1023 - void fetch_config_from_gitmodules(struct repository *repo,
1024 - int *max_children,
1025 - int *recurse_submodules)
1020 + void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
1026 1021 {
1027 1022 struct fetch_config config = {
1028 1023 .max_children = max_children,
1029 1024 .recurse_submodules = recurse_submodules
1030 1025 };
1031 - config_from_gitmodules(gitmodules_fetch_config, repo, &config);
1026 + config_from_gitmodules(gitmodules_fetch_config, the_repository, &config);
1032 1027 }
1033 1028
1034 1029 static int gitmodules_update_clone_config(const char *var, const char *value,
@@ -1041,7 +1036,7 @@ static int gitmodules_update_clone_config(const char *var, const char *value,
1041 1036 return 0;
1042 1037 }
1043 1038
1044 - void update_clone_config_from_gitmodules(struct repository *repo, int *max_jobs)
1039 + void update_clone_config_from_gitmodules(int *max_jobs)
1045 1040 {
1046 - config_from_gitmodules(gitmodules_update_clone_config, repo, max_jobs);
1041 + config_from_gitmodules(gitmodules_update_clone_config, the_repository, max_jobs);
1047 1042 }
modified submodule-config.h
@@ -57,8 +57,7 @@ int option_fetch_parse_recurse_submodules(const struct option *opt,
57 57 int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
58 58 int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
59 59 void repo_read_gitmodules(struct repository *repo, int skip_if_read);
60 - void gitmodules_config_oid(struct repository *repo,
61 - const struct object_id *commit_oid);
60 + void gitmodules_config_oid(const struct object_id *commit_oid);
62 61
63 62 /**
64 63 * Same as submodule_from_path but lookup by name.
@@ -81,8 +80,7 @@ const struct submodule *submodule_from_path(struct repository *r,
81 80 void submodule_free(struct repository *r);
82 81
83 82 int print_config_from_gitmodules(struct repository *repo, const char *key);
84 - int config_set_in_gitmodules_file_gently(struct repository *repo,
85 - const char *key, const char *value);
83 + int config_set_in_gitmodules_file_gently(const char *key, const char *value);
86 84
87 85 /*
88 86 * Returns 0 if the name is syntactically acceptable as a submodule "name"
@@ -102,10 +100,8 @@ int check_submodule_url(const char *url);
102 100 * New helpers to retrieve arbitrary configuration from the '.gitmodules' file
103 101 * should NOT be added.
104 102 */
105 - void fetch_config_from_gitmodules(struct repository *repo,
106 - int *max_children,
107 - int *recurse_submodules);
108 - void update_clone_config_from_gitmodules(struct repository *repo, int *max_jobs);
103 + void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
104 + void update_clone_config_from_gitmodules(int *max_jobs);
109 105
110 106 /*
111 107 * Submodule entry that contains relevant information about a
modified submodule.c
@@ -133,7 +133,7 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
133 133 strbuf_addstr(&entry, "submodule.");
134 134 strbuf_addstr(&entry, submodule->name);
135 135 strbuf_addstr(&entry, ".path");
136 - ret = config_set_in_gitmodules_file_gently(the_repository, entry.buf, newpath);
136 + ret = config_set_in_gitmodules_file_gently(entry.buf, newpath);
137 137 strbuf_release(&entry);
138 138 return ret;
139 139 }
modified t/README
@@ -462,6 +462,13 @@ GIT_TEST_CHECKOUT_WORKERS=<n> overrides the 'checkout.workers' setting
462 462 to <n> and 'checkout.thresholdForParallelism' to 0, forcing the
463 463 execution of the parallel-checkout code.
464 464
465 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=<boolean>, when true, makes
466 + registering submodule ODBs as alternates a fatal action. Support for
467 + this environment variable can be removed once the migration to
468 + explicitly providing repositories when accessing submodule objects is
469 + complete or needs to be abandoned for whatever reason (in which case the
470 + migrated codepaths still retain their performance benefits).
471 +
465 472 GIT_TEST_REQUIRE_PREREQ=<list> allows specifying a space separated list of
466 473 prereqs that are required to succeed. If a prereq in this list is triggered by
467 474 a test and then fails then the whole test run will abort. This can help to make
modified t/helper/test-read-midx.c
@@ -5,42 +5,34 @@
5 5 #include "midx.h"
6 6 #include "repository.h"
7 7 #include "odb.h"
8 - #include "odb/source-packed.h"
9 8 #include "pack-bitmap.h"
10 9 #include "packfile.h"
11 10 #include "setup.h"
12 11 #include "gettext.h"
13 12 #include "pack-revindex.h"
14 13
15 - static struct multi_pack_index *setup_midx(const char *object_dir,
16 - struct odb_source_packed **out)
14 + static struct multi_pack_index *setup_midx(const char *object_dir)
17 15 {
18 - struct odb_source_packed *packed;
16 + struct odb_source_files *files;
19 17 struct odb_source *source;
20 -
21 18 setup_git_directory(the_repository);
22 -
23 19 source = odb_find_source(the_repository->objects, object_dir);
24 - if (source) {
25 - packed = odb_source_files_downcast(source)->packed;
26 - } else {
27 - packed = odb_source_packed_new(the_repository->objects,
28 - object_dir, false);
29 - *out = packed;
30 - }
20 + if (!source)
21 + source = odb_add_to_alternates_memory(the_repository->objects,
22 + object_dir);
23 + files = odb_source_files_downcast(source);
31 24
32 - return load_multi_pack_index(packed);
25 + return load_multi_pack_index(files->packed);
33 26 }
34 27
35 28 static int read_midx_file(const char *object_dir, const char *checksum,
36 29 int show_objects)
37 30 {
38 - struct odb_source_packed *packed = NULL;
39 31 uint32_t i;
40 32 struct multi_pack_index *m, *tip;
41 33 int ret = 0;
42 34
43 - m = tip = setup_midx(object_dir, &packed);
35 + m = tip = setup_midx(object_dir);
44 36
45 37 if (!m)
46 38 return 1;
@@ -99,35 +91,29 @@ static int read_midx_file(const char *object_dir, const char *checksum,
99 91
100 92 out:
101 93 close_midx(tip);
102 - if (packed)
103 - odb_source_free(&packed->base);
104 94
105 95 return ret;
106 96 }
107 97
108 98 static int read_midx_checksum(const char *object_dir)
109 99 {
110 - struct odb_source_packed *packed = NULL;
111 100 struct multi_pack_index *m;
112 101
113 - m = setup_midx(object_dir, &packed);
102 + m = setup_midx(object_dir);
114 103 if (!m)
115 104 return 1;
116 105 printf("%s\n", midx_get_checksum_hex(m));
117 106
118 107 close_midx(m);
119 - if (packed)
120 - odb_source_free(&packed->base);
121 108 return 0;
122 109 }
123 110
124 111 static int read_midx_preferred_pack(const char *object_dir)
125 112 {
126 - struct odb_source_packed *packed = NULL;
127 113 struct multi_pack_index *midx = NULL;
128 114 uint32_t preferred_pack;
129 115
130 - midx = setup_midx(object_dir, &packed);
116 + midx = setup_midx(object_dir);
131 117 if (!midx)
132 118 return 1;
133 119
@@ -138,21 +124,17 @@ static int read_midx_preferred_pack(const char *object_dir)
138 124 }
139 125
140 126 printf("%s\n", midx->pack_names[preferred_pack]);
141 -
142 127 close_midx(midx);
143 - if (packed)
144 - odb_source_free(&packed->base);
145 128 return 0;
146 129 }
147 130
148 131 static int read_midx_bitmapped_packs(const char *object_dir)
149 132 {
150 - struct odb_source_packed *packed = NULL;
151 133 struct multi_pack_index *midx = NULL;
152 134 struct bitmapped_pack pack;
153 135 uint32_t i;
154 136
155 - midx = setup_midx(object_dir, &packed);
137 + midx = setup_midx(object_dir);
156 138 if (!midx)
157 139 return 1;
158 140
@@ -168,8 +150,7 @@ static int read_midx_bitmapped_packs(const char *object_dir)
168 150 }
169 151
170 152 close_midx(midx);
171 - if (packed)
172 - odb_source_free(&packed->base);
153 +
173 154 return 0;
174 155 }
175 156
modified t/helper/test-ref-store.c
@@ -74,6 +74,14 @@ static const char **get_store(const char **argv, struct ref_store **refs)
74 74 } else if (!strcmp(argv[0], "main")) {
75 75 *refs = get_main_ref_store(the_repository);
76 76 } else if (skip_prefix(argv[0], "submodule:", &gitdir)) {
77 + struct strbuf sb = STRBUF_INIT;
78 +
79 + if (!repo_submodule_path_append(the_repository,
80 + &sb, gitdir, "objects/"))
81 + die("computing submodule path failed");
82 + odb_add_to_alternates_memory(the_repository->objects, sb.buf);
83 + strbuf_release(&sb);
84 +
77 85 *refs = repo_get_submodule_ref_store(the_repository, gitdir);
78 86 } else if (skip_prefix(argv[0], "worktree:", &gitdir)) {
79 87 struct worktree **p, **worktrees = get_worktrees(the_repository);
modified t/helper/test-submodule.c
@@ -168,7 +168,7 @@ static int cmd__submodule_config_set(int argc, const char **argv)
168 168 if (!is_writing_gitmodules_ok())
169 169 die("please make sure that the .gitmodules file is in the working tree");
170 170
171 - return config_set_in_gitmodules_file_gently(the_repository, argv[1], argv[2]);
171 + return config_set_in_gitmodules_file_gently(argv[1], argv[2]);
172 172 }
173 173 usage_with_options(usage, options);
174 174 }
@@ -188,7 +188,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)
188 188 if (argc == 2) {
189 189 if (!is_writing_gitmodules_ok())
190 190 die("please make sure that the .gitmodules file is in the working tree");
191 - return config_set_in_gitmodules_file_gently(the_repository, argv[1], NULL);
191 + return config_set_in_gitmodules_file_gently(argv[1], NULL);
192 192 }
193 193 usage_with_options(usage, options);
194 194 }
modified t/lib-httpd.sh
@@ -159,18 +159,6 @@ prepare_httpd() {
159 159 mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
160 160 cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
161 161 cp "$TEST_PATH"/proxy-passwd "$HTTPD_ROOT_PATH"
162 - # Apache can run the following scripts concurrently per request. Make
163 - # sure any state management logic is resilient to race conditions.
164 - #
165 - # For example:
166 - # - use "mkdir dir" to ensure only one request "succeeds" under some
167 - # condition (see http-429.sh).
168 - # - chain (&&) atomic operations like "rm marker" (no -f) with the
169 - # logic that is guarded by the marker instead of relying on a
170 - # separate "test -f" and "rm marker" check
171 - # (see apply-one-time-script.sh).
172 - # - use scratch file names that include the process ID ($$), so
173 - # concurrent requests do not overwrite each other's state.
174 162 install_script incomplete-length-upload-pack-v2-http.sh
175 163 install_script incomplete-body-upload-pack-v2-http.sh
176 164 install_script error-no-report.sh
modified t/lib-httpd/apply-one-time-script.sh
@@ -6,31 +6,21 @@
6 6 #
7 7 # This can be used to simulate the effects of the repository changing in
8 8 # between HTTP request-response pairs.
9 - test -f one-time-script || exec "$GIT_EXEC_PATH/git-http-backend"
10 -
11 - LC_ALL=C
12 - export LC_ALL
9 + if test -f one-time-script
10 + then
11 + LC_ALL=C
12 + export LC_ALL
13 13
14 - out=out.$$
15 - modified=out-modified.$$
16 - "$GIT_EXEC_PATH/git-http-backend" >"$out"
14 + "$GIT_EXEC_PATH/git-http-backend" >out
15 + ./one-time-script out >out_modified
17 16
18 - # Since Apache can execute this script for multiple requests
19 - # concurrently, we chain "rm one-time-script" with the logic
20 - # for generating a modified response. If the "rm" ran separately,
21 - # a concurrent request could pass the "test -f" above and
22 - # erroneously result in multiple modified responses or an empty
23 - # body depending on the race state.
24 - #
25 - # We discard stderr for ./one-time-script since it is possible
26 - # ./one-time-script has been removed already, which is expected
27 - # sometimes. In this case, the unmodified response will be returned.
28 - if ./one-time-script "$out" 2>/dev/null >"$modified" &&
29 - ! cmp -s "$out" "$modified" &&
30 - rm one-time-script 2>/dev/null
31 - then
32 - cat "$modified"
17 + if cmp -s out out_modified
18 + then
19 + cat out
20 + else
21 + cat out_modified
22 + rm one-time-script
23 + fi
33 24 else
34 - cat "$out"
25 + "$GIT_EXEC_PATH/git-http-backend"
35 26 fi
36 - rm -f "$out" "$modified"
modified t/lib-httpd/http-429.sh
@@ -3,7 +3,7 @@
3 3 # Script to return HTTP 429 Too Many Requests responses for testing retry logic.
4 4 # Usage: /http_429/<test-context>/<retry-after-value>/<repo-path>
5 5 #
6 - # The test-context is a unique identifier for each test to isolate state directories.
6 + # The test-context is a unique identifier for each test to isolate state files.
7 7 # The retry-after-value can be:
8 8 # - A number (e.g., "1", "2", "100") - sets Retry-After header to that many seconds
9 9 # - "none" - no Retry-After header
@@ -26,16 +26,14 @@ repo_path="${remaining#*/}" # Get rest (repo path)
26 26 # The repo name is the first component before any "/"
27 27 repo_name="${repo_path%%/*}"
28 28
29 - # Use current directory (HTTPD_ROOT_PATH) to hold state directory
30 - # Create a safe directory name from test_context, retry_after and repo_name
31 - # This ensures all requests for the same test context share the same state directory
29 + # Use current directory (HTTPD_ROOT_PATH) for state file
30 + # Create a safe filename from test_context, retry_after and repo_name
31 + # This ensures all requests for the same test context share the same state file
32 32 safe_name=$(echo "${test_context}-${retry_after}-${repo_name}" | tr '/' '_' | tr -cd 'a-zA-Z0-9_-')
33 - state="http-429-state-${safe_name}"
33 + state_file="http-429-state-${safe_name}"
34 34
35 - # Check if this is the first call (no state directory exists), or if
36 - # the retry-after-value is "permanent", which indicates a 429 must be
37 - # returned for every request (even if the state directory exists).
38 - if test "$retry_after" != permanent && ! mkdir "$state" 2>/dev/null
35 + # Check if this is the first call (no state file exists)
36 + if test -f "$state_file"
39 37 then
40 38 # Already returned 429 once, forward to git-http-backend
41 39 # Set PATH_INFO to just the repo path (without retry-after value)
@@ -54,6 +52,9 @@ then
54 52 exec "$GIT_EXEC_PATH/git-http-backend"
55 53 fi
56 54
55 + # Mark that we've returned 429
56 + touch "$state_file"
57 +
57 58 # Output HTTP 429 response
58 59 printf "Status: 429 Too Many Requests\r\n"
59 60
@@ -66,7 +67,8 @@ case "$retry_after" in
66 67 printf "Retry-After: invalid-format-123abc\r\n"
67 68 ;;
68 69 permanent)
69 - # Always return 429
70 + # Always return 429, don't set state file for success
71 + rm -f "$state_file"
70 72 printf "Retry-After: 1\r\n"
71 73 printf "Content-Type: text/plain\r\n"
72 74 printf "\r\n"
modified t/meson.build
@@ -717,7 +717,6 @@ integration_tests = [
717 717 't5564-http-proxy.sh',
718 718 't5565-push-multiple.sh',
719 719 't5566-push-group.sh',
720 - 't5567-one-time-script.sh',
721 720 't5570-git-daemon.sh',
722 721 't5571-pre-push-hook.sh',
723 722 't5572-pull-submodule.sh',
modified t/t1450-fsck.sh
@@ -844,11 +844,6 @@ test_expect_success 'alternate objects are correctly blamed' '
844 844 echo "../../alt.git/objects" >.git/objects/info/alternates &&
845 845 mkdir alt.git/objects/$(dirname $path) &&
846 846 >alt.git/objects/$(dirname $path)/$(basename $path) &&
847 -
848 - # Without "--full", only the local object source is checked.
849 - git fsck --no-full >out 2>&1 &&
850 - test_must_be_empty out &&
851 -
852 847 test_must_fail git fsck >out 2>&1 &&
853 848 test_grep alt.git out
854 849 '
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 'partial commit is allowed when a rebase pick becomes empty' '
1861 + test_expect_success 'correct error message for partial commit after empty pick' '
1862 1862 test_when_finished "git rebase --abort" &&
1863 1863 (
1864 1864 set_fake_editor &&
@@ -1867,7 +1867,8 @@ test_expect_success 'partial commit is allowed when a rebase pick becomes empty'
1867 1867 test_must_fail git rebase -i A D
1868 1868 ) &&
1869 1869 echo x >file1 &&
1870 - git commit file1
1870 + test_must_fail git commit file1 2>err &&
1871 + test_grep "cannot do a partial commit during a rebase." err
1871 1872 '
1872 1873
1873 1874 test_expect_success 'correct error message for commit --amend after empty pick' '
@@ -1880,128 +1881,7 @@ test_expect_success 'correct error message for commit --amend after empty pick'
1880 1881 ) &&
1881 1882 echo x>file1 &&
1882 1883 test_must_fail git commit -a --amend 2>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 - )
1884 + test_grep "middle of a rebase -- cannot amend." err
2005 1885 '
2006 1886
2007 1887 test_expect_success 'todo has correct onto hash' '
modified t/t3507-cherry-pick-conflict.sh
@@ -79,8 +79,7 @@ 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 &&
83 - test_ref_missing CHERRY_PICK_HEAD
82 + test_cmp expected actual
84 83 "
85 84
86 85 test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
@@ -365,28 +364,6 @@ test_expect_success 'failed revert sets REVERT_HEAD' '
365 364 test_cmp_rev picked REVERT_HEAD
366 365 '
367 366
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 -
390 367 test_expect_success 'successful revert does not set REVERT_HEAD' '
391 368 pristine_detach base &&
392 369 git revert base &&
modified t/t3903-stash.sh
@@ -1808,13 +1808,13 @@ test_expect_success 'stash.index=false overridden by --index' '
1808 1808 test_cmp expect file
1809 1809 '
1810 1810
1811 - test_expect_success 'apply exits 1 on conflicts' '
1811 + test_expect_success 'apply with custom conflict labels' '
1812 1812 git reset --hard initial &&
1813 1813 test_commit label-base conflict-file base-content &&
1814 1814 echo stashed >conflict-file &&
1815 1815 git stash push -m "stashed" &&
1816 1816 test_commit label-upstream conflict-file upstream-content &&
1817 - test_expect_code 1 git -c merge.conflictStyle=diff3 stash apply --label-ours=UP --label-theirs=STASH &&
1817 + test_must_fail git -c merge.conflictStyle=diff3 stash apply --label-ours=UP --label-theirs=STASH &&
1818 1818 test_grep "^<<<<<<< UP" conflict-file &&
1819 1819 test_grep "^||||||| Stash base" conflict-file &&
1820 1820 test_grep "^>>>>>>> STASH" conflict-file
@@ -1826,30 +1826,11 @@ test_expect_success 'apply with empty conflict labels' '
1826 1826 echo stashed >conflict-file &&
1827 1827 git stash push -m "stashed" &&
1828 1828 test_commit empty-label-upstream conflict-file upstream-content &&
1829 - test_expect_code 1 git stash apply --label-ours= --label-theirs= &&
1829 + test_must_fail git stash apply --label-ours= --label-theirs= &&
1830 1830 test_grep "^<<<<<<<$" conflict-file &&
1831 1831 test_grep "^>>>>>>>$" conflict-file
1832 1832 '
1833 1833
1834 - test_expect_success 'pop exits 1 on conflicts and keeps the stash entry' '
1835 - git reset --hard initial &&
1836 - echo stashed >file &&
1837 - git stash push -m pop-stashed &&
1838 - test_commit pop-upstream file upstream-content &&
1839 - test_expect_code 1 git stash pop &&
1840 - git stash list >list &&
1841 - test_grep pop-stashed list
1842 - '
1843 -
1844 - test_expect_success 'stash branch exits with a non-1 status on errors' '
1845 - git reset --hard initial &&
1846 - echo stashed >file &&
1847 - git stash push -m branch-stashed &&
1848 - test_expect_code 128 git stash branch conflicting-branch refs/heads/does-not-exist &&
1849 - git stash list >list &&
1850 - test_grep branch-stashed list
1851 - '
1852 -
1853 1834 test_expect_success 'stash show --include-untracked includes untracked files' '
1854 1835 git reset --hard &&
1855 1836
modified t/t4151-am-abort.sh
@@ -63,28 +63,6 @@ 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 -
88 66 test_expect_success 'am -3 --skip removes otherfile-4' '
89 67 git reset --hard initial &&
90 68 test_must_fail git am -3 0003-*.patch &&
modified t/t5319-multi-pack-index.sh
@@ -573,19 +573,6 @@ test_expect_success 'verify incorrect checksum' '
573 573 $objdir "incorrect checksum"
574 574 '
575 575
576 - test_expect_success 'git fsck --no-full checks multi-pack-index, --connectivity-only does not' '
577 - pos=$(($(wc -c <$objdir/pack/multi-pack-index) - 10)) &&
578 - corrupt_midx_and_verify $pos \
579 - "\377\377\377\377\377\377\377\377\377\377" \
580 - $objdir "incorrect checksum" &&
581 -
582 - test_must_fail git fsck --no-full 2>err &&
583 - test_grep "incorrect checksum" err &&
584 -
585 - git fsck --connectivity-only 2>err &&
586 - test_grep ! "incorrect checksum" err
587 - '
588 -
589 576 test_expect_success 'setup for v1-specific fsck tests' '
590 577 git -c midx.version=1 multi-pack-index write
591 578 '
@@ -711,9 +698,10 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
711 698 corrupt_data $idx64 $(test_oid idxoff) "\02" &&
712 699 # objects64 is not a real repository, but can serve as an alternate
713 700 # anyway so we can write a MIDX into it
714 - git init repo64 &&
701 + git init repo &&
702 + test_when_finished "rm -fr repo" &&
715 703 (
716 - cd repo64 &&
704 + cd repo &&
717 705 ( cd ../objects64 && pwd ) >.git/objects/info/alternates &&
718 706 midx64=$(git multi-pack-index --object-dir=../objects64 write)
719 707 ) &&
@@ -721,7 +709,7 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
721 709 '
722 710
723 711 test_expect_success 'verify multi-pack-index with 64-bit offsets' '
724 - git -C repo64 multi-pack-index verify --object-dir=../objects64
712 + git multi-pack-index verify --object-dir=objects64
725 713 '
726 714
727 715 NUM_OBJECTS=63
@@ -733,7 +721,7 @@ MIDX_BYTE_LARGE_OFFSET=$(($MIDX_OFFSET_LARGE_OFFSETS + 3))
733 721
734 722 test_expect_success 'verify incorrect 64-bit offset' '
735 723 corrupt_midx_and_verify $MIDX_BYTE_LARGE_OFFSET "\07" objects64 \
736 - "incorrect object offset" "git -C repo64 multi-pack-index verify --object-dir=../objects64"
724 + "incorrect object offset"
737 725 '
738 726
739 727 test_expect_success 'setup expire tests' '
modified t/t5325-reverse-index.sh
@@ -204,12 +204,4 @@ test_expect_success 'fsck catches invalid header: hash function' '
204 204 "reverse-index file .* has unsupported hash id"
205 205 '
206 206
207 - test_expect_success 'fsck --no-full checks rev-index, --connectivity-only does not' '
208 - test_must_fail git -C corrupt fsck --no-full 2>err &&
209 - test_grep "has unsupported hash id" err &&
210 -
211 - git -C corrupt fsck --connectivity-only 2>err &&
212 - test_grep ! "has unsupported hash id" err
213 - '
214 -
215 207 test_done
modified t/t5326-multi-pack-bitmaps.sh
@@ -498,15 +498,7 @@ test_expect_success 'git fsck correctly identifies good and bad bitmaps' '
498 498 corrupt_file "$packbitmap" &&
499 499 test_must_fail git fsck 2>err &&
500 500 test_grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err &&
501 - test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err &&
502 -
503 - # The bitmap checks are performed with "--no-full", but not with
504 - # "--connectivity-only".
505 - test_must_fail git fsck --no-full 2>err &&
506 - test_grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err &&
507 - test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err &&
508 - git fsck --connectivity-only 2>err &&
509 - test_grep ! "invalid checksum" err
501 + test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err
510 502 '
511 503
512 504 test_expect_success 'corrupt MIDX with bitmap causes fallback' '
modified t/t5526-fetch-submodules.sh
@@ -3,6 +3,9 @@
3 3
4 4 test_description='Recursive "git fetch" for submodules'
5 5
6 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
7 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
8 +
6 9 . ./test-lib.sh
7 10
8 11 pwd=$(pwd)
modified t/t5531-deep-submodule-push.sh
@@ -5,6 +5,9 @@ test_description='test push with submodules'
5 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 7
8 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10 +
8 11 . ./test-lib.sh
9 12
10 13 test_expect_success setup '
modified t/t5545-push-options.sh
@@ -5,6 +5,9 @@ test_description='pushing to a repository using push options'
5 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 7
8 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10 +
8 11 . ./test-lib.sh
9 12
10 13 mk_repo_pair () {
deleted t/t5567-one-time-script.sh mode 100755
@@ -1,96 +0,0 @@
1 - #!/bin/sh
2 -
3 - test_description='apply-one-time-script CGI helper is safe under concurrent requests'
4 -
5 - . ./test-lib.sh
6 -
7 - HELPER="$TEST_DIRECTORY/lib-httpd/apply-one-time-script.sh"
8 -
9 - test_expect_success PIPE 'helper only serves one rewritten response for concurrent requests' '
10 - mkdir workdir fakebin &&
11 - ENTERED="$PWD/entered" &&
12 - GATE="$PWD/gate" &&
13 - export ENTERED GATE &&
14 - mkfifo "$ENTERED" "$GATE" &&
15 -
16 - # A stub git-http-backend that returns a response based on
17 - # $ROLE. For $ROLE = modify, return the response string
18 - # "packfile", which ends up being modified by the example
19 - # one-time-script below.
20 - #
21 - # Otherwise, run the branch returning a response that
22 - # should be passed through, and block until released
23 - # by "read -r $GATE".
24 - write_script fakebin/git-http-backend <<-\EOF &&
25 - printf "Status: 200 OK\r\n"
26 - printf "Content-Type: application/x-git-result\r\n"
27 - printf "\r\n"
28 - if test "$ROLE" = modify
29 - then
30 - printf "packfile\n"
31 - else
32 - echo entered >"$ENTERED"
33 - read -r released <"$GATE"
34 - printf "refs\n"
35 - fi
36 - EOF
37 -
38 - # An example one-time-script for apply-one-time-script
39 - # to execute. Checks for "packfile" in the response
40 - # that will be returned, and replaces it with a
41 - # modified response. Passes through responses without
42 - # "packfile" in them.
43 - write_script workdir/one-time-script <<-\EOF &&
44 - if grep packfile "$1" >/dev/null
45 - then
46 - sed "/packfile/q" "$1" &&
47 - printf "REPLACED\n"
48 - else
49 - cat "$1"
50 - fi
51 - EOF
52 -
53 - GIT_EXEC_PATH="$PWD/fakebin" &&
54 - export GIT_EXEC_PATH &&
55 -
56 - # Ensure $GATE has a reader so the test does not block indefinitely if
57 - # the helper is buggy and "echo released >&9" below does not unblock
58 - # the unmodified response gate.
59 - exec 9<>"$GATE" &&
60 -
61 - # Launch the passthrough request in the background. Record its pid
62 - # so it can be killed when the test finishes if, for some reason, the
63 - # request stays blocked and would stall a test runner.
64 - { (
65 - cd workdir &&
66 - ROLE=passthrough sh "$HELPER" >../passthrough.out 2>../passthrough.err
67 - ) & } &&
68 - passthrough_pid=$! &&
69 - test_when_finished "kill $passthrough_pid 2>/dev/null || :" &&
70 -
71 - # Wait until the passthrough request is "in-flight" and paused
72 - # mid-response.
73 - read -r entered <"$ENTERED" &&
74 -
75 - # Launch the request for a modified response while the passthrough
76 - # request is concurrently "in-flight" and paused.
77 - (
78 - cd workdir &&
79 - ROLE=modify sh "$HELPER" >../modify.out 2>../modify.err
80 - ) &&
81 -
82 - # Unblock the passthrough request, allowing git-http-backend to
83 - # complete its response.
84 - echo released >&9 &&
85 - { wait "$passthrough_pid" || :; } &&
86 -
87 - test_must_be_empty passthrough.err &&
88 - test_must_be_empty modify.err &&
89 - test_grep "Status: 200 OK" passthrough.out &&
90 - test_grep "Status: 200 OK" modify.out &&
91 - test_grep REPLACED modify.out &&
92 - test_grep ! REPLACED passthrough.out &&
93 - test_grep refs passthrough.out
94 - '
95 -
96 - test_done
modified t/t5572-pull-submodule.sh
@@ -2,6 +2,9 @@
2 2
3 3 test_description='pull can handle submodules'
4 4
5 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
6 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
7 +
5 8 . ./test-lib.sh
6 9 . "$TEST_DIRECTORY"/lib-submodule-update.sh
7 10
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 trace2 &&
1226 + rm -rf "$P" http_child log &&
1227 1227
1228 1228 git init "$P" &&
1229 1229 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
@@ -1238,15 +1238,10 @@ 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" \
1242 1241 git -c protocol.version=2 \
1243 1242 -c fetch.uriprotocols=http,https \
1244 1243 clone "$HTTPD_URL/smart/http_parent" http_child &&
1245 1244
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 -
1250 1245 # Ensure that my-blob and other-blob are in separate packfiles.
1251 1246 for idx in http_child/.git/objects/pack/*.idx
1252 1247 do
modified t/t6022-rev-list-missing.sh
@@ -198,55 +198,6 @@ do
198 198 '
199 199 done
200 200
201 - for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
202 - do
203 - test_expect_success "rev-list --missing-only with missing $obj" '
204 - oid="$(git rev-parse $obj)" &&
205 - path=".git/objects/$(test_oid_to_path $oid)" &&
206 -
207 - mv "$path" "$path.hidden" &&
208 - test_when_finished "mv $path.hidden $path" &&
209 -
210 - git rev-list --missing=print --missing-only --objects \
211 - --no-object-names HEAD >actual &&
212 -
213 - echo $oid >expect &&
214 - test_cmp expect actual
215 - '
216 - done
217 -
218 - test_expect_success "--missing-only requires --missing=print or --missing=print-info" '
219 - test_must_fail git rev-list --missing-only --objects HEAD 2>err &&
220 - test_grep "requires --missing=print" err
221 - '
222 -
223 - test_expect_success "--missing-only is incompatible with --count" '
224 - test_must_fail git rev-list --missing=print --missing-only \
225 - --count --objects HEAD 2>err &&
226 - test_grep "cannot be used together" err
227 - '
228 -
229 - test_expect_success "--missing-only is incompatible with --disk-usage" '
230 - test_must_fail git rev-list --missing=print --missing-only \
231 - --disk-usage --objects HEAD 2>err &&
232 - test_grep "cannot be used together" err
233 - '
234 -
235 - test_expect_success "--missing-only works with --missing=print-info" '
236 - oid="$(git rev-parse HEAD:1.t)" &&
237 - path=".git/objects/$(test_oid_to_path $oid)" &&
238 -
239 - mv "$path" "$path.hidden" &&
240 - test_when_finished "mv $path.hidden $path" &&
241 -
242 - git rev-list --missing=print-info --missing-only --objects \
243 - --no-object-names HEAD >actual &&
244 -
245 - # Filter keeps print-info fields; only the "?" prefix is dropped.
246 - echo "$oid path=1.t type=blob" >expect &&
247 - test_cmp expect actual
248 - '
249 -
250 201 test_expect_success "-z nul-delimited --missing" '
251 202 test_when_finished rm -rf repo &&
252 203
modified t/t6437-submodule-merge.sh
@@ -5,6 +5,9 @@ test_description='merging with submodules'
5 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 7
8 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10 +
8 11 . ./test-lib.sh
9 12
10 13 #
modified t/t7201-co.sh
@@ -236,18 +236,10 @@ test_expect_success 'checkout -m creates a recoverable stash on conflict' '
236 236 test_must_fail git checkout side 2>stderr &&
237 237 test_grep "Your local changes" stderr &&
238 238 git checkout -m side >actual 2>&1 &&
239 - cat >expect <<-EOF &&
240 - Your local changes are stashed, however applying them
241 - resulted in conflicts. You can either resolve the conflicts
242 - and then discard the stash with "git stash drop", or, if you
243 - do not want to resolve them now, run "git reset --hard" and
244 - apply the local changes later by running "git stash pop".
245 -
246 - Switched to branch ${SQ}side${SQ}
247 - The following paths have local changes:
248 - M one
249 - EOF
250 - test_cmp expect actual &&
239 + test_grep "resulted in conflicts" actual &&
240 + test_grep "git stash drop" actual &&
241 + test_grep "git stash pop" actual &&
242 + test_grep "The following paths have local changes" actual &&
251 243 git log -p -1 --format="%gs%n%B" -g --diff-merges=1 refs/stash >actual &&
252 244 sed /^index/d actual >actual.trimmed &&
253 245 cat >expect <<-EOF &&
modified t/t7418-submodule-sparse-gitmodules.sh
@@ -12,6 +12,9 @@ The test setup uses a sparse checkout, however the same scenario can be set up
12 12 also by committing .gitmodules and then just removing it from the filesystem.
13 13 '
14 14
15 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
16 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
17 +
15 18 . ./test-lib.sh
16 19
17 20 test_expect_success 'setup' '
modified t/t7426-submodule-get-default-remote.sh
@@ -60,23 +60,6 @@ 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 -
80 63 test_expect_success 'get-default-remote fails without path argument' '
81 64 (
82 65 cd super &&
modified t/t7814-grep-recurse-submodules.sh
@@ -9,6 +9,9 @@ submodules.
9 9 TEST_CREATE_REPO_NO_TEMPLATE=1
10 10 . ./test-lib.sh
11 11
12 + GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
13 + export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
14 +
12 15 test_expect_success 'setup directory structure and submodule' '
13 16 echo "(1|2)d(3|4)" >a &&
14 17 mkdir b &&
modified t/t7900-maintenance.sh
@@ -1016,70 +1016,37 @@ test_expect_success 'rerere-gc task without --auto always collects garbage' '
1016 1016 test_expect_rerere_gc git maintenance run --task=rerere-gc
1017 1017 '
1018 1018
1019 - test_expect_success 'rerere-gc task with --auto only prunes with stale entries' '
1019 + test_expect_success 'rerere-gc task with --auto only prunes with prunable entries' '
1020 1020 test_when_finished "rm -rf .git/rr-cache" &&
1021 - entry_1=.git/rr-cache/171$(echo $ZERO_OID | cut -c4-) &&
1022 - entry_2=.git/rr-cache/172$(echo $ZERO_OID | cut -c4-) &&
1023 - entry_3=.git/rr-cache/173$(echo $ZERO_OID | cut -c4-) &&
1024 -
1025 - # Without the "rr-cache" directory there is nothing to prune.
1026 1021 ! git maintenance is-needed --auto --task=rerere-gc &&
1027 1022 test_expect_rerere_gc ! git maintenance run --auto --task=rerere-gc &&
1028 -
1029 - # Fresh unresolved entries are not stale.
1030 - for e in $entry_1 $entry_2 $entry_3
1031 - do
1032 - mkdir -p $e &&
1033 - echo preimage >$e/preimage || return 1
1034 - done &&
1023 + mkdir .git/rr-cache &&
1035 1024 ! git maintenance is-needed --auto --task=rerere-gc &&
1036 1025 test_expect_rerere_gc ! git maintenance run --auto --task=rerere-gc &&
1037 -
1038 - # Entries are sampled using the "17" prefix, so we scale up the
1039 - # estimate by 256. A single entry is not sufficient to reach the
1040 - # default limit of 512.
1041 - test-tool chmtime =-$((16 * 86400)) $entry_1/preimage &&
1042 - ! git maintenance is-needed --auto --task=rerere-gc &&
1043 -
1044 - # A second prunable entry will reach the limit though and will thus get
1045 - # pruned.
1046 - test-tool chmtime =-$((16 * 86400)) $entry_2/preimage &&
1026 + : >.git/rr-cache/entry &&
1047 1027 git maintenance is-needed --auto --task=rerere-gc &&
1048 -
1049 - # The prunable entries are gone, the other one remains.
1050 - test_expect_rerere_gc git maintenance run --auto --task=rerere-gc &&
1051 - test_path_is_missing $entry_1 &&
1052 - test_path_is_missing $entry_2 &&
1053 - test_path_is_dir $entry_3
1028 + test_expect_rerere_gc git maintenance run --auto --task=rerere-gc
1054 1029 '
1055 1030
1056 1031 test_expect_success 'rerere-gc task with --auto honors maintenance.rerere-gc.auto' '
1057 1032 test_when_finished "rm -rf .git/rr-cache" &&
1058 - entry=.git/rr-cache/171$(echo $ZERO_OID | cut -c4-) &&
1059 1033
1060 1034 # A negative value should always prune.
1061 1035 git -c maintenance.rerere-gc.auto=-1 maintenance is-needed --auto --task=rerere-gc &&
1062 1036 test_expect_rerere_gc git -c maintenance.rerere-gc.auto=-1 maintenance run --auto --task=rerere-gc &&
1063 1037
1064 - # A positive value prunes only when the estimated number of stale
1065 - # entries is at least as big. A single sampled entry counts for 256
1066 - # estimated entries.
1067 - mkdir -p $entry &&
1068 - echo preimage >$entry/preimage &&
1069 - test-tool chmtime =-$((16 * 86400)) $entry/preimage &&
1070 -
1071 - ! git -c maintenance.rerere-gc.auto=257 maintenance is-needed --auto --task=rerere-gc &&
1072 - test_expect_rerere_gc ! git -c maintenance.rerere-gc.auto=257 maintenance run --auto --task=rerere-gc &&
1073 - test_path_is_dir $entry &&
1074 -
1075 - git -c maintenance.rerere-gc.auto=256 maintenance is-needed --auto --task=rerere-gc &&
1076 - test_expect_rerere_gc git -c maintenance.rerere-gc.auto=256 maintenance run --auto --task=rerere-gc &&
1077 - test_path_is_missing $entry &&
1038 + # A positive value prunes when there is at least one entry.
1039 + ! git -c maintenance.rerere-gc.auto=9000 maintenance is-needed --auto --task=rerere-gc &&
1040 + test_expect_rerere_gc ! git -c maintenance.rerere-gc.auto=9000 maintenance run --auto --task=rerere-gc &&
1041 + mkdir .git/rr-cache &&
1042 + ! git -c maintenance.rerere-gc.auto=9000 maintenance is-needed --auto --task=rerere-gc &&
1043 + test_expect_rerere_gc ! git -c maintenance.rerere-gc.auto=9000 maintenance run --auto --task=rerere-gc &&
1044 + : >.git/rr-cache/entry-1 &&
1045 + git -c maintenance.rerere-gc.auto=9000 maintenance is-needed --auto --task=rerere-gc &&
1046 + test_expect_rerere_gc git -c maintenance.rerere-gc.auto=9000 maintenance run --auto --task=rerere-gc &&
1078 1047
1079 1048 # Zero should never prune.
1080 - mkdir -p $entry &&
1081 - echo preimage >$entry/preimage &&
1082 - test-tool chmtime =-$((16 * 86400)) $entry/preimage &&
1049 + : >.git/rr-cache/entry-1 &&
1083 1050 ! git -c maintenance.rerere-gc.auto=0 maintenance is-needed --auto --task=rerere-gc &&
1084 1051 test_expect_rerere_gc ! git -c maintenance.rerere-gc.auto=0 maintenance run --auto --task=rerere-gc
1085 1052 '
modified t/t9129-git-svn-i18n-commitencoding.sh
@@ -71,7 +71,7 @@ do
71 71 '
72 72 done
73 73
74 - test_expect_success UTF8,!MINGW 'ISO-8859-1 should match UTF-8 in svn' '
74 + test_expect_success UTF8 'ISO-8859-1 should match UTF-8 in svn' '
75 75 (
76 76 cd ISO8859-1 &&
77 77 compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
@@ -80,7 +80,7 @@ test_expect_success UTF8,!MINGW 'ISO-8859-1 should match UTF-8 in svn' '
80 80
81 81 for H in eucJP ISO-2022-JP
82 82 do
83 - test_expect_success UTF8,!MINGW "$H should match UTF-8 in svn" '
83 + test_expect_success UTF8 "$H should match UTF-8 in svn" '
84 84 (
85 85 cd $H &&
86 86 compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
modified t/t9700/test.pl
@@ -118,7 +118,7 @@ unlink $tmpfile;
118 118
119 119 # paths
120 120 my $abs_git_dir = $abs_repo_dir . "/.git";
121 - if (defined $ENV{MSYSTEM} && $ENV{MSYSTEM} ne 'MSYS') {
121 + if ($^O eq 'msys') {
122 122 $abs_git_dir = `cygpath -am "$abs_repo_dir/.git"`;
123 123 $abs_git_dir =~ s/\r?\n?$//;
124 124 }
modified tmp-objdir.c
@@ -321,6 +321,11 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
321 321 return t->env.v;
322 322 }
323 323
324 + void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
325 + {
326 + odb_add_to_alternates_memory(t->repo->objects, t->path.buf);
327 + }
328 +
324 329 struct odb_source *tmp_objdir_replace_primary_odb(struct tmp_objdir *t,
325 330 int will_destroy)
326 331 {
modified tmp-objdir.h
@@ -55,6 +55,12 @@ int tmp_objdir_destroy(struct tmp_objdir *);
55 55 */
56 56 void tmp_objdir_discard_objects(struct tmp_objdir *);
57 57
58 + /*
59 + * Add the temporary object directory as an alternate object store in the
60 + * current process.
61 + */
62 + void tmp_objdir_add_as_alternate(const struct tmp_objdir *);
63 +
58 64 /*
59 65 * Replaces the writable object store in the current process with the temporary
60 66 * object directory and makes the former main object store an alternate.
modified unpack-trees.c
@@ -416,8 +416,7 @@ static void report_collided_checkout(struct index_state *index)
416 416 string_list_clear(&list, 0);
417 417 }
418 418
419 - static int must_checkout(const struct cache_entry *ce,
420 - void *cb_data UNUSED)
419 + static int must_checkout(const struct cache_entry *ce)
421 420 {
422 421 return ce->ce_flags & CE_UPDATE;
423 422 }
@@ -478,7 +477,7 @@ static int check_updates(struct unpack_trees_options *o,
478 477 * Prefetch the objects that are to be checked out in the loop
479 478 * below.
480 479 */
481 - prefetch_cache_entries(index, must_checkout, NULL);
480 + prefetch_cache_entries(index, must_checkout);
482 481
483 482 get_parallel_checkout_configs(&pc_workers, &pc_threshold);
484 483
@@ -488,7 +487,7 @@ static int check_updates(struct unpack_trees_options *o,
488 487 for (i = 0; i < index->cache_nr; i++) {
489 488 struct cache_entry *ce = index->cache[i];
490 489
491 - if (must_checkout(ce, NULL)) {
490 + if (must_checkout(ce)) {
492 491 size_t last_pc_queue_size = pc_queue_size();
493 492
494 493 if (ce->ce_flags & CE_WT_REMOVE)
@@ -2087,7 +2086,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
2087 2086 }
2088 2087
2089 2088 if (!o->skip_cache_tree_update &&
2090 - !cache_tree_fully_valid(&o->internal.result))
2089 + !cache_tree_fully_valid(o->internal.result.cache_tree))
2091 2090 cache_tree_update(&o->internal.result,
2092 2091 WRITE_TREE_SILENT |
2093 2092 WRITE_TREE_REPAIR);
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_NOW_EMPTY /* rebase applied a pick that became empty */
44 + FROM_REBASE_PICK /* commit came from a pick/reword/edit */
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_now_empty(enum commit_whence whence)
53 + static inline int is_from_rebase(enum commit_whence whence)
54 54 {
55 - return whence == FROM_REBASE_NOW_EMPTY;
55 + return whence == FROM_REBASE_PICK;
56 56 }
57 57
58 58 struct wt_status_change_data {