Compare
508ec9837c846e8c1675fb4cd11113e2bc3f4466..b6f5e80fdf32c270ff812c1743e720dedca7d5e2
replay: fail gracefully when a merge input is unreadable
When objects involved in the merge cannot be read, the merge machinery will return early with result.clean = -1, and result.tree left as NULL. pick_regular_commit() tested only "if (!result->clean)", ignoring the case where "clean < 0". That causes the code to try to use result->tree, resulting in a SIGSEGV. Handle clean < 0 explicitly; the merge machinery will already have printed messages such as "Could not read <object>" and "collecting merge info failed for trees...", so we don't need to add much detail beyond the fact that the merge failed. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren <newren@gmail.com> · 2026-08-29 07:00 UTC · committed by Junio C Hamano
67 files changed,
+1476
−359
- Documentation/RelNotes/2.56.0.adoc
- Documentation/git-add.adoc
- Documentation/git-bisect.adoc
- Documentation/git-http-fetch.adoc
- Documentation/git-refs.adoc
- Documentation/technical/partial-clone.adoc
- Makefile
- bisect.c
- builtin/add.c
- builtin/bisect.c
- builtin/fast-import.c
- builtin/fetch-pack.c
- builtin/fsck.c
- builtin/index-pack.c
- builtin/pack-objects.c
- builtin/prune.c
- builtin/rev-list.c
- common-init.c
- compat/posix.h
- compat/writev.c
- config.mak.uname
- contrib/buildsystems/CMakeLists.txt
- diff.c
- fetch-pack.c
- git.c
- http-fetch.c
- http-push.c
- http-walker.c
- http.c
- merge-ll.c
- merge-ll.h
- meson.build
- midx-write.c
- midx.c
- midx.h
- odb.c
- odb.h
- odb/source-files.c
- odb/source-inmemory.c
- odb/source-loose.c
- odb/source-packed.c
- odb/source.h
- packfile.c
- packfile.h
- read-cache-ll.h
- read-cache.c
- replay.c
- repository.c
- repository.h
- rerere.c
- revision.c
- sideband.c
- t/helper/test-read-midx.c
- t/meson.build
- t/t0213-trace2-ancestry.sh
- t/t1060-object-corruption.sh
- t/t2207-add-resolved.sh
- t/t3650-replay-basics.sh
- t/t5550-http-fetch-dumb.sh
- t/t5702-protocol-v2.sh
- t/t6030-bisect-porcelain.sh
- t/t7528-signed-commit-ssh.sh
- t/unit-tests/u-odb-inmemory.c
- wrapper.c
- wrapper.h
- write-or-die.c
- write-or-die.h
modified Documentation/RelNotes/2.56.0.adoc
| @@ -85,6 +85,22 @@ UI, Workflows & Features | |||
| 85 | 85 | syscall fails has also been improved to name both the source and | |
| 86 | 86 | the destination. | |
| 87 | 87 | ||
| 88 | + | * 'git add' has been taught a new '--resolved' option to stage | |
| 89 | + | conflict-resolved paths, while leaving unrelated local changes | |
| 90 | + | unstaged. It scans the unmerged paths for leftover conflict | |
| 91 | + | markers and aborts if any are found. | |
| 92 | + | ||
| 93 | + | * The known limitations of the ref format migration in 'git refs' have | |
| 94 | + | been moved to be displayed as a warning admonition directly under the | |
| 95 | + | description of the 'migrate' subcommand, improving visibility. A | |
| 96 | + | reference to 'git-maintenance' has also been corrected to use the | |
| 97 | + | 'linkgit' macro. | |
| 98 | + | ||
| 99 | + | * The 'git bisect' command has been taught a | |
| 100 | + | '--reset-when-found[=<where>]' option that tells the command to | |
| 101 | + | automatically run 'git bisect reset' to jump back to the original | |
| 102 | + | state or to the found culprit. | |
| 103 | + | ||
| 88 | 104 | ||
| 89 | 105 | Performance, Internal Implementation, Development Support etc. | |
| 90 | 106 | -------------------------------------------------------------- | |
| @@ -334,6 +350,27 @@ Performance, Internal Implementation, Development Support etc. | |||
| 334 | 350 | exit codes (0 for success, 1 for non-ancestor, 128 for errors) and | |
| 335 | 351 | to ensure it cannot be combined with '--all'. | |
| 336 | 352 | ||
| 353 | + | * The 'TRACE2_ANCESTRY' prerequisite in the 't0213' test script has been | |
| 354 | + | refined to avoid failures under user-mode emulation by verifying that | |
| 355 | + | the ancestry collector reports the expected process names rather than | |
| 356 | + | the emulator binary name. | |
| 357 | + | ||
| 358 | + | * Concurrent downloads of packfiles via packfile URIs and dumb HTTP are | |
| 359 | + | safer by avoiding concurrent appends to the staging file. Opening in | |
| 360 | + | read-write mode with separate file offsets prevents corruption and | |
| 361 | + | preserves resumability. 'fetch-pack' now tolerates pre-existing | |
| 362 | + | '.keep' files. | |
| 363 | + | ||
| 364 | + | * The 'ssh-agent' tests in 't7528' have been fixed to work when the | |
| 365 | + | user's login shell is csh-like, by explicitly passing '-s' to | |
| 366 | + | 'ssh-agent' to force Bourne shell syntax. | |
| 367 | + | (merge d5dd17756d kl/t7528-ssh-agent-for-csh-users later to maint). | |
| 368 | + | ||
| 369 | + | * A compatibility wrapper for writev(3p) has been reintroduced, | |
| 370 | + | including fixes for CMake build and 'MAX_IO_SIZE' limits on NonStop. | |
| 371 | + | Calls to write(3p) in send_sideband() and cat_blob() have been | |
| 372 | + | refactored to use writev(3p) wrappers to reduce syscall overhead. | |
| 373 | + | ||
| 337 | 374 | ||
| 338 | 375 | Fixes since v2.55 | |
| 339 | 376 | ----------------- | |
modified Documentation/git-add.adoc
| @@ -11,7 +11,7 @@ SYNOPSIS | |||
| 11 | 11 | git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] | |
| 12 | 12 | [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse] | |
| 13 | 13 | [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize] | |
| 14 | - | [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]] | |
| 14 | + | [--resolved] [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]] | |
| 15 | 15 | [--] [<pathspec>...] | |
| 16 | 16 | ||
| 17 | 17 | DESCRIPTION | |
| @@ -195,6 +195,14 @@ for `git add --no-all <pathspec>...`, i.e. ignored removed files. | |||
| 195 | 195 | while a _CRLF_ cleans to _LF_, a _CRCRLF_ sequence is only partially | |
| 196 | 196 | cleaned to _CRLF_. | |
| 197 | 197 | ||
| 198 | + | `--resolved`:: | |
| 199 | + | Update the index for unmerged paths matching _<pathspec>_ where | |
| 200 | + | no conflict markers remain in the working tree. Unmerged paths | |
| 201 | + | without conflict markers (including binary files and file | |
| 202 | + | deletions) are staged as resolved, while any path with leftover | |
| 203 | + | conflict markers causes the command to refuse to stage any files. | |
| 204 | + | Cannot be combined with `-u` or `-A`. | |
| 205 | + | ||
| 198 | 206 | `--chmod=(+|-)x`:: | |
| 199 | 207 | Override the executable bit of the added files. The executable | |
| 200 | 208 | bit is only changed in the index, the files on disk are left | |
modified Documentation/git-bisect.adoc
| @@ -10,7 +10,7 @@ SYNOPSIS | |||
| 10 | 10 | -------- | |
| 11 | 11 | [synopsis] | |
| 12 | 12 | git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>] | |
| 13 | - | [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...] | |
| 13 | + | [--no-checkout] [--first-parent] [--reset-when-found[=<where>]] [<bad> [<good>...]] [--] [<pathspec>...] | |
| 14 | 14 | git bisect (bad|new|<term-new>) [<rev>] | |
| 15 | 15 | git bisect (good|old|<term-old>) [<rev>...] | |
| 16 | 16 | git bisect terms [--term-(good|old) | --term-(bad|new)] | |
| @@ -20,7 +20,7 @@ git bisect reset [<commit>] | |||
| 20 | 20 | git bisect (visualize|view) | |
| 21 | 21 | git bisect replay <logfile> | |
| 22 | 22 | git bisect log | |
| 23 | - | git bisect run <cmd> [<arg>...] | |
| 23 | + | git bisect run [--reset-when-found[=<where>]] <cmd> [<arg>...] | |
| 24 | 24 | git bisect help | |
| 25 | 25 | ||
| 26 | 26 | DESCRIPTION | |
| @@ -385,6 +385,16 @@ ignored. | |||
| 385 | 385 | This option is particularly useful in avoiding false positives when a merged | |
| 386 | 386 | branch contained broken or non-buildable commits, but the merge itself was OK. | |
| 387 | 387 | ||
| 388 | + | `--reset-when-found[=<where>]`:: | |
| 389 | + | Once the first bad commit is found, report it and clean up the | |
| 390 | + | bisection state. `<where>` may be `original` to return to the commit | |
| 391 | + | checked out before `git bisect start`, or `found` to leave the first | |
| 392 | + | bad commit checked out. If `<where>` is omitted, it defaults to | |
| 393 | + | `original`. | |
| 394 | + | + | |
| 395 | + | This option may be given to `git bisect start` or to `git bisect run`. It | |
| 396 | + | cannot be used for a bisection started with `--no-checkout`. | |
| 397 | + | ||
| 388 | 398 | EXAMPLES | |
| 389 | 399 | -------- | |
| 390 | 400 | ||
modified Documentation/git-http-fetch.adoc
| @@ -48,13 +48,15 @@ commit-id:: | |||
| 48 | 48 | line (which is not expected in | |
| 49 | 49 | this case), 'git http-fetch' fetches the packfile directly at the given | |
| 50 | 50 | URL and uses index-pack to generate corresponding .idx and .keep files. | |
| 51 | - | The hash is used to determine the name of the temporary file and is | |
| 52 | - | arbitrary. The output of index-pack is printed to stdout. Requires | |
| 53 | - | --index-pack-args. | |
| 51 | + | The hash is used to determine the name of the temporary file. It need | |
| 52 | + | not be the pack hash, but it must uniquely identify the pack contents | |
| 53 | + | for resumption. The output of index-pack is printed to stdout. Requires | |
| 54 | + | one or more --index-pack-arg options. | |
| 54 | 55 | ||
| 55 | - | --index-pack-args=<args>:: | |
| 56 | - | For internal use only. The command to run on the contents of the | |
| 57 | - | downloaded pack. Arguments are URL-encoded separated by spaces. | |
| 56 | + | --index-pack-arg=<arg>:: | |
| 57 | + | For internal use only. The first instance specifies the command run on | |
| 58 | + | the contents of the downloaded pack. Subsequent instances specify its | |
| 59 | + | arguments. | |
| 58 | 60 | ||
| 59 | 61 | --recover:: | |
| 60 | 62 | Verify that everything reachable from target is fetched. Used after | |
modified Documentation/git-refs.adoc
| @@ -35,6 +35,21 @@ COMMANDS | |||
| 35 | 35 | ||
| 36 | 36 | `migrate`:: | |
| 37 | 37 | Migrate ref store between different formats. | |
| 38 | + | + | |
| 39 | + | [WARNING] | |
| 40 | + | -- | |
| 41 | + | The ref format migration has several known limitations in its current form: | |
| 42 | + | ||
| 43 | + | * It is not possible to migrate repositories that have worktrees. | |
| 44 | + | ||
| 45 | + | * There is no way to block concurrent writes to the repository during an | |
| 46 | + | ongoing migration. Concurrent writes can lead to an inconsistent migrated | |
| 47 | + | state. Users are expected to block writes on a higher level. If your | |
| 48 | + | repository is registered for scheduled maintenance, it is recommended to | |
| 49 | + | unregister it first with linkgit:git-maintenance[1]. | |
| 50 | + | ||
| 51 | + | These limitations may eventually be lifted. | |
| 52 | + | -- | |
| 38 | 53 | ||
| 39 | 54 | `verify`:: | |
| 40 | 55 | Verify reference database consistency. | |
| @@ -130,21 +145,6 @@ The following options are specific to commands which write references: | |||
| 130 | 145 | Operate on <ref> itself rather than the reference it points to via a | |
| 131 | 146 | symbolic ref. | |
| 132 | 147 | ||
| 133 | - | KNOWN LIMITATIONS | |
| 134 | - | ----------------- | |
| 135 | - | ||
| 136 | - | The ref format migration has several known limitations in its current form: | |
| 137 | - | ||
| 138 | - | * It is not possible to migrate repositories that have worktrees. | |
| 139 | - | ||
| 140 | - | * There is no way to block concurrent writes to the repository during an | |
| 141 | - | ongoing migration. Concurrent writes can lead to an inconsistent migrated | |
| 142 | - | state. Users are expected to block writes on a higher level. If your | |
| 143 | - | repository is registered for scheduled maintenance, it is recommended to | |
| 144 | - | unregister it first with git-maintenance(1). | |
| 145 | - | ||
| 146 | - | These limitations may eventually be lifted. | |
| 147 | - | ||
| 148 | 148 | GIT | |
| 149 | 149 | --- | |
| 150 | 150 | Part of the linkgit:git[1] suite | |
modified Documentation/technical/partial-clone.adoc
| @@ -159,7 +159,7 @@ and prefetch those objects in bulk. | |||
| 159 | 159 | - `repack` in GC has been updated to not touch promisor packfiles at all, | |
| 160 | 160 | and to only repack other objects. | |
| 161 | 161 | ||
| 162 | - | - The per-repository flag "fetch_if_missing" is used to control whether an | |
| 162 | + | - The global variable "fetch_if_missing" is used to control whether an | |
| 163 | 163 | object lookup will attempt to dynamically fetch a missing object or | |
| 164 | 164 | report an error. | |
| 165 | 165 | + | |
modified Makefile
| @@ -2045,6 +2045,10 @@ ifdef NO_PREAD | |||
| 2045 | 2045 | COMPAT_CFLAGS += -DNO_PREAD | |
| 2046 | 2046 | COMPAT_OBJS += compat/pread.o | |
| 2047 | 2047 | endif | |
| 2048 | + | ifdef NO_WRITEV | |
| 2049 | + | COMPAT_CFLAGS += -DNO_WRITEV | |
| 2050 | + | COMPAT_OBJS += compat/writev.o | |
| 2051 | + | endif | |
| 2048 | 2052 | ifdef NO_FAST_WORKING_DIRECTORY | |
| 2049 | 2053 | BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY | |
| 2050 | 2054 | endif | |
modified bisect.c
| @@ -488,6 +488,7 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") | |||
| 488 | 488 | static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") | |
| 489 | 489 | static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") | |
| 490 | 490 | static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") | |
| 491 | + | static GIT_PATH_FUNC(git_path_bisect_reset_when_found, "BISECT_RESET_WHEN_FOUND") | |
| 491 | 492 | ||
| 492 | 493 | static void read_bisect_paths(struct strvec *array) | |
| 493 | 494 | { | |
| @@ -1211,6 +1212,7 @@ int bisect_clean_state(void) | |||
| 1211 | 1212 | unlink_or_warn(git_path_bisect_run()); | |
| 1212 | 1213 | unlink_or_warn(git_path_bisect_terms()); | |
| 1213 | 1214 | unlink_or_warn(git_path_bisect_first_parent()); | |
| 1215 | + | unlink_or_warn(git_path_bisect_reset_when_found()); | |
| 1214 | 1216 | /* | |
| 1215 | 1217 | * Cleanup BISECT_START last to support the --no-checkout option | |
| 1216 | 1218 | * introduced in the commit 4796e823a. | |
modified builtin/add.c
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | #include "strvec.h" | |
| 27 | 27 | #include "submodule.h" | |
| 28 | 28 | #include "add-interactive.h" | |
| 29 | + | #include "merge-ll.h" | |
| 29 | 30 | ||
| 30 | 31 | static const char * const builtin_add_usage[] = { | |
| 31 | 32 | N_("git add [<options>] [--] <pathspec>..."), | |
| @@ -35,6 +36,7 @@ static int patch_interactive, add_interactive, edit_interactive; | |||
| 35 | 36 | static struct interactive_options interactive_opts = INTERACTIVE_OPTIONS_INIT; | |
| 36 | 37 | static int take_worktree_changes; | |
| 37 | 38 | static int add_renormalize; | |
| 39 | + | static int add_resolved; | |
| 38 | 40 | static int pathspec_file_nul; | |
| 39 | 41 | static int include_sparse; | |
| 40 | 42 | static const char *pathspec_from_file; | |
| @@ -265,6 +267,7 @@ static struct option builtin_add_options[] = { | |||
| 265 | 267 | OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files"), 0), | |
| 266 | 268 | OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")), | |
| 267 | 269 | OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")), | |
| 270 | + | OPT_BOOL(0, "resolved", &add_resolved, N_("add conflict-resolved tracked files")), | |
| 268 | 271 | OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")), | |
| 269 | 272 | OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")), | |
| 270 | 273 | OPT_CALLBACK_F(0, "ignore-removal", &addremove_explicit, | |
| @@ -379,6 +382,76 @@ static int add_files(struct repository *repo, struct dir_struct *dir, int flags) | |||
| 379 | 382 | return exit_status; | |
| 380 | 383 | } | |
| 381 | 384 | ||
| 385 | + | static int failed_to_add(int flags, const char *path) | |
| 386 | + | { | |
| 387 | + | if (!(flags & ADD_CACHE_IGNORE_ERRORS)) | |
| 388 | + | die(_("updating file '%s' failed"), path); | |
| 389 | + | return 1; | |
| 390 | + | } | |
| 391 | + | ||
| 392 | + | static int add_resolved_files(struct repository *repo, | |
| 393 | + | const struct pathspec *pathspec, | |
| 394 | + | int flags) | |
| 395 | + | { | |
| 396 | + | struct index_state *istate = repo->index; | |
| 397 | + | struct string_list unmerged_paths = STRING_LIST_INIT_DUP; | |
| 398 | + | struct string_list unresolved_paths = STRING_LIST_INIT_DUP; | |
| 399 | + | int exit_status = 0; | |
| 400 | + | size_t i; | |
| 401 | + | ||
| 402 | + | for (i = 0; i < istate->cache_nr; i++) { | |
| 403 | + | struct cache_entry *ce = istate->cache[i]; | |
| 404 | + | if (!ce_stage(ce)) | |
| 405 | + | continue; | |
| 406 | + | if (pathspec->nr && !ce_path_match(istate, ce, pathspec, NULL)) | |
| 407 | + | continue; | |
| 408 | + | if (!unmerged_paths.nr || | |
| 409 | + | strcmp(unmerged_paths.items[unmerged_paths.nr - 1].string, ce->name)) | |
| 410 | + | string_list_append(&unmerged_paths, ce->name); | |
| 411 | + | } | |
| 412 | + | ||
| 413 | + | if (!unmerged_paths.nr) { | |
| 414 | + | string_list_clear(&unmerged_paths, 0); | |
| 415 | + | return 0; | |
| 416 | + | } | |
| 417 | + | ||
| 418 | + | for (i = 0; i < unmerged_paths.nr; i++) { | |
| 419 | + | const char *path = unmerged_paths.items[i].string; | |
| 420 | + | struct stat st; | |
| 421 | + | ||
| 422 | + | if (!lstat(path, &st) && S_ISREG(st.st_mode)) { | |
| 423 | + | if (has_conflict_markers(istate, path)) | |
| 424 | + | string_list_append(&unresolved_paths, path); | |
| 425 | + | } | |
| 426 | + | } | |
| 427 | + | ||
| 428 | + | if (unresolved_paths.nr) { | |
| 429 | + | struct strbuf sb = STRBUF_INIT; | |
| 430 | + | for (i = 0; i < unresolved_paths.nr; i++) | |
| 431 | + | strbuf_addf(&sb, "\t%s\n", unresolved_paths.items[i].string); | |
| 432 | + | die(_("the following paths still have conflict markers:\n%s"), sb.buf); | |
| 433 | + | } | |
| 434 | + | ||
| 435 | + | for (i = 0; i < unmerged_paths.nr; i++) { | |
| 436 | + | const char *path = unmerged_paths.items[i].string; | |
| 437 | + | struct stat st; | |
| 438 | + | ||
| 439 | + | if (lstat(path, &st)) { | |
| 440 | + | if (errno != ENOENT) | |
| 441 | + | die_errno(_("cannot lstat: '%s'"), path); | |
| 442 | + | if (remove_file_from_index_with_flags(istate, path, flags)) | |
| 443 | + | exit_status = failed_to_add(flags, path); | |
| 444 | + | } else { | |
| 445 | + | if (add_file_to_index(istate, path, flags)) | |
| 446 | + | exit_status = failed_to_add(flags, path); | |
| 447 | + | } | |
| 448 | + | } | |
| 449 | + | ||
| 450 | + | string_list_clear(&unmerged_paths, 0); | |
| 451 | + | string_list_clear(&unresolved_paths, 0); | |
| 452 | + | return exit_status; | |
| 453 | + | } | |
| 454 | + | ||
| 382 | 455 | int cmd_add(int argc, | |
| 383 | 456 | const char **argv, | |
| 384 | 457 | const char *prefix, | |
| @@ -438,8 +511,9 @@ int cmd_add(int argc, | |||
| 438 | 511 | else if (take_worktree_changes && ADDREMOVE_DEFAULT) | |
| 439 | 512 | addremove = 0; /* "-u" was given but not "-A" */ | |
| 440 | 513 | ||
| 441 | - | if (addremove && take_worktree_changes) | |
| 442 | - | die(_("options '%s' and '%s' cannot be used together"), "-A", "-u"); | |
| 514 | + | die_for_incompatible_opt3(take_worktree_changes, "-u/--update", | |
| 515 | + | 0 < addremove_explicit, "-A/--all", | |
| 516 | + | add_resolved, "--resolved"); | |
| 443 | 517 | ||
| 444 | 518 | if (!show_only && ignore_missing) | |
| 445 | 519 | die(_("the option '%s' requires '%s'"), "--ignore-missing", "--dry-run"); | |
| @@ -448,8 +522,11 @@ int cmd_add(int argc, | |||
| 448 | 522 | chmod_arg[1] != 'x' || chmod_arg[2])) | |
| 449 | 523 | die(_("--chmod param '%s' must be either -x or +x"), chmod_arg); | |
| 450 | 524 | ||
| 451 | - | add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize; | |
| 452 | - | require_pathspec = !(take_worktree_changes || (0 < addremove_explicit)); | |
| 525 | + | add_new_files = !take_worktree_changes && !refresh_only && | |
| 526 | + | !add_renormalize && !add_resolved; | |
| 527 | + | require_pathspec = !(take_worktree_changes || | |
| 528 | + | (0 < addremove_explicit) || | |
| 529 | + | add_resolved); | |
| 453 | 530 | ||
| 454 | 531 | repo_hold_locked_index(repo, &lock_file, LOCK_DIE_ON_ERROR); | |
| 455 | 532 | ||
| @@ -481,7 +558,8 @@ int cmd_add(int argc, | |||
| 481 | 558 | return 0; | |
| 482 | 559 | } | |
| 483 | 560 | ||
| 484 | - | if (!take_worktree_changes && addremove_explicit < 0 && pathspec.nr) | |
| 561 | + | if (!take_worktree_changes && !add_resolved && | |
| 562 | + | addremove_explicit < 0 && pathspec.nr) | |
| 485 | 563 | /* Turn "git add pathspec..." to "git add -A pathspec..." */ | |
| 486 | 564 | addremove = 1; | |
| 487 | 565 | ||
| @@ -584,7 +662,9 @@ int cmd_add(int argc, | |||
| 584 | 662 | odb_transaction_begin_or_die(repo->objects, &transaction, 0); | |
| 585 | 663 | ||
| 586 | 664 | ps_matched = xcalloc(pathspec.nr, 1); | |
| 587 | - | if (add_renormalize) | |
| 665 | + | if (add_resolved) | |
| 666 | + | exit_status |= add_resolved_files(repo, &pathspec, flags); | |
| 667 | + | else if (add_renormalize) | |
| 588 | 668 | exit_status |= renormalize_tracked_files(repo, &pathspec, flags); | |
| 589 | 669 | else | |
| 590 | 670 | exit_status |= add_files_to_cache(repo, prefix, | |
modified builtin/bisect.c
| @@ -24,11 +24,12 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") | |||
| 24 | 24 | static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") | |
| 25 | 25 | static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") | |
| 26 | 26 | static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") | |
| 27 | + | static GIT_PATH_FUNC(git_path_bisect_reset_when_found, "BISECT_RESET_WHEN_FOUND") | |
| 27 | 28 | static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN") | |
| 28 | 29 | ||
| 29 | 30 | #define BUILTIN_GIT_BISECT_START_USAGE \ | |
| 30 | 31 | N_("git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]\n" \ | |
| 31 | - | " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]") | |
| 32 | + | " [--no-checkout] [--first-parent] [--reset-when-found[=<where>]] [<bad> [<good>...]] [--] [<pathspec>...]") | |
| 32 | 33 | #define BUILTIN_GIT_BISECT_BAD_USAGE \ | |
| 33 | 34 | N_("git bisect (bad|new|<term-new>) [<rev>]") | |
| 34 | 35 | #define BUILTIN_GIT_BISECT_GOOD_USAGE \ | |
| @@ -48,7 +49,7 @@ static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN") | |||
| 48 | 49 | #define BUILTIN_GIT_BISECT_LOG_USAGE \ | |
| 49 | 50 | "git bisect log" | |
| 50 | 51 | #define BUILTIN_GIT_BISECT_RUN_USAGE \ | |
| 51 | - | N_("git bisect run <cmd> [<arg>...]") | |
| 52 | + | N_("git bisect run [--reset-when-found[=<where>]] <cmd> [<arg>...]") | |
| 52 | 53 | #define BUILTIN_GIT_BISECT_HELP_USAGE \ | |
| 53 | 54 | "git bisect help" | |
| 54 | 55 | ||
| @@ -68,6 +69,12 @@ static const char * const git_bisect_usage[] = { | |||
| 68 | 69 | NULL | |
| 69 | 70 | }; | |
| 70 | 71 | ||
| 72 | + | enum reset_when_found_mode { | |
| 73 | + | RESET_WHEN_FOUND_NONE, | |
| 74 | + | RESET_WHEN_FOUND_TO_ORIGINAL, | |
| 75 | + | RESET_WHEN_FOUND_TO_FOUND, | |
| 76 | + | }; | |
| 77 | + | ||
| 71 | 78 | struct add_bisect_ref_data { | |
| 72 | 79 | struct rev_info *revs; | |
| 73 | 80 | unsigned int object_flags; | |
| @@ -234,7 +241,7 @@ static int write_terms(const char *bad, const char *good) | |||
| 234 | 241 | return res; | |
| 235 | 242 | } | |
| 236 | 243 | ||
| 237 | - | static int bisect_reset(const char *commit) | |
| 244 | + | static int bisect_reset(const char *commit, bool quiet) | |
| 238 | 245 | { | |
| 239 | 246 | struct strbuf branch = STRBUF_INIT; | |
| 240 | 247 | ||
| @@ -255,8 +262,10 @@ static int bisect_reset(const char *commit) | |||
| 255 | 262 | struct child_process cmd = CHILD_PROCESS_INIT; | |
| 256 | 263 | ||
| 257 | 264 | cmd.git_cmd = 1; | |
| 258 | - | strvec_pushl(&cmd.args, "checkout", "--ignore-other-worktrees", | |
| 259 | - | branch.buf, "--", NULL); | |
| 265 | + | strvec_pushl(&cmd.args, "checkout", "--ignore-other-worktrees", NULL); | |
| 266 | + | if (quiet) | |
| 267 | + | strvec_push(&cmd.args, "--quiet"); | |
| 268 | + | strvec_pushl(&cmd.args, branch.buf, "--", NULL); | |
| 260 | 269 | if (run_command(&cmd)) { | |
| 261 | 270 | error(_("could not check out original" | |
| 262 | 271 | " HEAD '%s'. Try 'git bisect" | |
| @@ -267,7 +276,79 @@ static int bisect_reset(const char *commit) | |||
| 267 | 276 | } | |
| 268 | 277 | ||
| 269 | 278 | strbuf_release(&branch); | |
| 270 | - | return bisect_clean_state(); | |
| 279 | + | return 0; | |
| 280 | + | } | |
| 281 | + | ||
| 282 | + | static int parse_reset_when_found(const char *value, | |
| 283 | + | enum reset_when_found_mode *mode) | |
| 284 | + | { | |
| 285 | + | if (!strcmp(value, "original")) | |
| 286 | + | *mode = RESET_WHEN_FOUND_TO_ORIGINAL; | |
| 287 | + | else if (!strcmp(value, "found")) | |
| 288 | + | *mode = RESET_WHEN_FOUND_TO_FOUND; | |
| 289 | + | else | |
| 290 | + | return error(_("invalid value for '--reset-when-found': '%s'"), | |
| 291 | + | value); | |
| 292 | + | ||
| 293 | + | return 0; | |
| 294 | + | } | |
| 295 | + | ||
| 296 | + | static const char *reset_when_found_mode_name(enum reset_when_found_mode mode) | |
| 297 | + | { | |
| 298 | + | switch (mode) { | |
| 299 | + | case RESET_WHEN_FOUND_TO_ORIGINAL: | |
| 300 | + | return "original"; | |
| 301 | + | case RESET_WHEN_FOUND_TO_FOUND: | |
| 302 | + | return "found"; | |
| 303 | + | case RESET_WHEN_FOUND_NONE: | |
| 304 | + | BUG("no name for unset reset-when-found mode"); | |
| 305 | + | } | |
| 306 | + | BUG("unknown reset-when-found mode %d", mode); | |
| 307 | + | } | |
| 308 | + | ||
| 309 | + | static int read_reset_when_found(enum reset_when_found_mode *mode) | |
| 310 | + | { | |
| 311 | + | struct strbuf value = STRBUF_INIT; | |
| 312 | + | int res = 0; | |
| 313 | + | ||
| 314 | + | *mode = RESET_WHEN_FOUND_NONE; | |
| 315 | + | if (is_empty_or_missing_file(git_path_bisect_reset_when_found())) | |
| 316 | + | return 0; | |
| 317 | + | ||
| 318 | + | if (strbuf_read_file(&value, git_path_bisect_reset_when_found(), 0) < 0) { | |
| 319 | + | res = error_errno(_("could not read '%s'"), | |
| 320 | + | git_path_bisect_reset_when_found()); | |
| 321 | + | goto out; | |
| 322 | + | } | |
| 323 | + | strbuf_trim(&value); | |
| 324 | + | if (parse_reset_when_found(value.buf, mode)) | |
| 325 | + | res = -1; | |
| 326 | + | ||
| 327 | + | out: | |
| 328 | + | strbuf_release(&value); | |
| 329 | + | return res; | |
| 330 | + | } | |
| 331 | + | ||
| 332 | + | static int bisect_reset_when_found(enum reset_when_found_mode mode) | |
| 333 | + | { | |
| 334 | + | struct bisect_terms terms = { 0 }; | |
| 335 | + | char *commit = NULL; | |
| 336 | + | int res; | |
| 337 | + | ||
| 338 | + | if (mode == RESET_WHEN_FOUND_TO_FOUND) { | |
| 339 | + | read_bisect_terms(&terms.term_bad, &terms.term_good); | |
| 340 | + | commit = xstrfmt("refs/bisect/%s", terms.term_bad); | |
| 341 | + | } else if (mode == RESET_WHEN_FOUND_NONE) { | |
| 342 | + | BUG("automatic reset requested without a reset mode"); | |
| 343 | + | } | |
| 344 | + | ||
| 345 | + | res = bisect_reset(commit, true); | |
| 346 | + | if (!res) | |
| 347 | + | res = bisect_clean_state(); | |
| 348 | + | ||
| 349 | + | free(commit); | |
| 350 | + | free_terms(&terms); | |
| 351 | + | return res; | |
| 271 | 352 | } | |
| 272 | 353 | ||
| 273 | 354 | static void log_commit(FILE *fp, | |
| @@ -680,7 +761,8 @@ static int bisect_successful(struct bisect_terms *terms) | |||
| 680 | 761 | return res; | |
| 681 | 762 | } | |
| 682 | 763 | ||
| 683 | - | static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix) | |
| 764 | + | static enum bisect_error bisect_next(struct bisect_terms *terms, | |
| 765 | + | const char *prefix) | |
| 684 | 766 | { | |
| 685 | 767 | enum bisect_error res; | |
| 686 | 768 | ||
| @@ -703,7 +785,8 @@ static enum bisect_error bisect_next(struct bisect_terms *terms, const char *pre | |||
| 703 | 785 | return res; | |
| 704 | 786 | } | |
| 705 | 787 | ||
| 706 | - | static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char *prefix) | |
| 788 | + | static enum bisect_error bisect_auto_next(struct bisect_terms *terms, | |
| 789 | + | const char *prefix) | |
| 707 | 790 | { | |
| 708 | 791 | if (bisect_next_check(terms, NULL)) { | |
| 709 | 792 | bisect_print_status(terms); | |
| @@ -727,6 +810,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 727 | 810 | struct strbuf bisect_names = STRBUF_INIT; | |
| 728 | 811 | struct object_id head_oid; | |
| 729 | 812 | struct object_id oid; | |
| 813 | + | enum reset_when_found_mode reset_when_found = RESET_WHEN_FOUND_NONE; | |
| 730 | 814 | const char *head; | |
| 731 | 815 | ||
| 732 | 816 | if (is_bare_repository(the_repository)) | |
| @@ -750,6 +834,13 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 750 | 834 | no_checkout = 1; | |
| 751 | 835 | } else if (!strcmp(arg, "--first-parent")) { | |
| 752 | 836 | first_parent_only = 1; | |
| 837 | + | } else if (!strcmp(arg, "--reset-when-found")) { | |
| 838 | + | reset_when_found = RESET_WHEN_FOUND_TO_ORIGINAL; | |
| 839 | + | } else if (skip_prefix(arg, "--reset-when-found=", &arg)) { | |
| 840 | + | if (parse_reset_when_found(arg, &reset_when_found)) { | |
| 841 | + | res = BISECT_FAILED; | |
| 842 | + | goto finish; | |
| 843 | + | } | |
| 753 | 844 | } else if (!strcmp(arg, "--term-good") || | |
| 754 | 845 | !strcmp(arg, "--term-old")) { | |
| 755 | 846 | i++; | |
| @@ -787,6 +878,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 787 | 878 | break; | |
| 788 | 879 | } | |
| 789 | 880 | } | |
| 881 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE && no_checkout) { | |
| 882 | + | res = error(_("options '%s' and '%s' cannot be used together"), | |
| 883 | + | "--reset-when-found", "--no-checkout"); | |
| 884 | + | goto finish; | |
| 885 | + | } | |
| 790 | 886 | pathspec_pos = i; | |
| 791 | 887 | ||
| 792 | 888 | /* | |
| @@ -866,6 +962,10 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 866 | 962 | if (first_parent_only) | |
| 867 | 963 | write_file(git_path_bisect_first_parent(), "\n"); | |
| 868 | 964 | ||
| 965 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE) | |
| 966 | + | write_file(git_path_bisect_reset_when_found(), "%s\n", | |
| 967 | + | reset_when_found_mode_name(reset_when_found)); | |
| 968 | + | ||
| 869 | 969 | if (no_checkout) { | |
| 870 | 970 | if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) { | |
| 871 | 971 | res = error(_("invalid ref: '%s'"), start_head.buf); | |
| @@ -1096,7 +1196,7 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f | |||
| 1096 | 1196 | if (is_empty_or_missing_file(filename)) | |
| 1097 | 1197 | return error(_("cannot read file '%s' for replaying"), filename); | |
| 1098 | 1198 | ||
| 1099 | - | if (bisect_reset(NULL)) | |
| 1199 | + | if (bisect_clean_state()) | |
| 1100 | 1200 | return BISECT_FAILED; | |
| 1101 | 1201 | ||
| 1102 | 1202 | fp = fopen(filename, "r"); | |
| @@ -1244,13 +1344,36 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1244 | 1344 | { | |
| 1245 | 1345 | int res = BISECT_OK; | |
| 1246 | 1346 | struct strbuf command = STRBUF_INIT; | |
| 1347 | + | const char *reset_when_found_arg; | |
| 1247 | 1348 | const char *new_state; | |
| 1248 | 1349 | int temporary_stdout_fd, saved_stdout; | |
| 1249 | 1350 | int is_first_run = 1; | |
| 1351 | + | enum reset_when_found_mode reset_when_found = RESET_WHEN_FOUND_NONE; | |
| 1250 | 1352 | ||
| 1251 | 1353 | if (bisect_next_check(terms, NULL)) | |
| 1252 | 1354 | return BISECT_FAILED; | |
| 1253 | 1355 | ||
| 1356 | + | if (argc && !strcmp(argv[0], "--reset-when-found")) { | |
| 1357 | + | reset_when_found = RESET_WHEN_FOUND_TO_ORIGINAL; | |
| 1358 | + | } else if (argc && skip_prefix(argv[0], "--reset-when-found=", | |
| 1359 | + | &reset_when_found_arg)) { | |
| 1360 | + | if (parse_reset_when_found(reset_when_found_arg, | |
| 1361 | + | &reset_when_found)) | |
| 1362 | + | return BISECT_FAILED; | |
| 1363 | + | } | |
| 1364 | + | ||
| 1365 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE && | |
| 1366 | + | refs_ref_exists(get_main_ref_store(the_repository), "BISECT_HEAD")) | |
| 1367 | + | return error(_("options '%s' and '%s' cannot be used together"), | |
| 1368 | + | "--reset-when-found", "--no-checkout"); | |
| 1369 | + | ||
| 1370 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE) { | |
| 1371 | + | write_file(git_path_bisect_reset_when_found(), "%s\n", | |
| 1372 | + | reset_when_found_mode_name(reset_when_found)); | |
| 1373 | + | argc--; | |
| 1374 | + | argv++; | |
| 1375 | + | } | |
| 1376 | + | ||
| 1254 | 1377 | if (!argc) { | |
| 1255 | 1378 | error(_("bisect run failed: no command provided.")); | |
| 1256 | 1379 | return BISECT_FAILED; | |
| @@ -1325,7 +1448,6 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1325 | 1448 | res = BISECT_OK; | |
| 1326 | 1449 | } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { | |
| 1327 | 1450 | printf(_("bisect found first '%s' commit\n"), terms->term_bad); | |
| 1328 | - | res = BISECT_OK; | |
| 1329 | 1451 | } else if (res) { | |
| 1330 | 1452 | error(_("bisect run failed: 'git bisect %s'" | |
| 1331 | 1453 | " exited with error code %d"), new_state, res); | |
| @@ -1342,10 +1464,15 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1342 | 1464 | static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED, | |
| 1343 | 1465 | struct repository *repo UNUSED) | |
| 1344 | 1466 | { | |
| 1467 | + | int res; | |
| 1468 | + | ||
| 1345 | 1469 | if (argc > 1) | |
| 1346 | 1470 | return error(_("'%s' requires either no argument or a commit"), | |
| 1347 | 1471 | "git bisect reset"); | |
| 1348 | - | return bisect_reset(argc ? argv[0] : NULL); | |
| 1472 | + | res = bisect_reset(argc ? argv[0] : NULL, false); | |
| 1473 | + | if (res) | |
| 1474 | + | return res; | |
| 1475 | + | return bisect_clean_state(); | |
| 1349 | 1476 | } | |
| 1350 | 1477 | ||
| 1351 | 1478 | static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED, | |
| @@ -1487,7 +1614,8 @@ int cmd_bisect(int argc, | |||
| 1487 | 1614 | !one_of(argv[0], terms.term_good, terms.term_bad, NULL)) | |
| 1488 | 1615 | usage_msg_optf(_("unknown command: '%s'"), git_bisect_usage, | |
| 1489 | 1616 | options, argv[0]); | |
| 1490 | - | res = bisect_state(&terms, argc, argv); | |
| 1617 | + | else | |
| 1618 | + | res = bisect_state(&terms, argc, argv); | |
| 1491 | 1619 | free_terms(&terms); | |
| 1492 | 1620 | } else { | |
| 1493 | 1621 | argc--; | |
| @@ -1495,5 +1623,15 @@ int cmd_bisect(int argc, | |||
| 1495 | 1623 | res = fn(argc, argv, prefix, repo); | |
| 1496 | 1624 | } | |
| 1497 | 1625 | ||
| 1626 | + | if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { | |
| 1627 | + | enum reset_when_found_mode mode; | |
| 1628 | + | ||
| 1629 | + | if (read_reset_when_found(&mode)) | |
| 1630 | + | res = BISECT_FAILED; | |
| 1631 | + | else if (mode != RESET_WHEN_FOUND_NONE && | |
| 1632 | + | bisect_reset_when_found(mode)) | |
| 1633 | + | res = BISECT_FAILED; | |
| 1634 | + | } | |
| 1635 | + | ||
| 1498 | 1636 | return is_bisect_success(res) ? 0 : -res; | |
| 1499 | 1637 | } | |
modified builtin/fast-import.c
| @@ -3333,6 +3333,7 @@ static void cat_blob_write(const char *buf, unsigned long size) | |||
| 3333 | 3333 | static void cat_blob(struct object_entry *oe, struct object_id *oid) | |
| 3334 | 3334 | { | |
| 3335 | 3335 | struct strbuf line = STRBUF_INIT; | |
| 3336 | + | struct iovec iov[3]; | |
| 3336 | 3337 | unsigned long size; | |
| 3337 | 3338 | enum object_type type = 0; | |
| 3338 | 3339 | char *buf; | |
| @@ -3366,10 +3367,21 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid) | |||
| 3366 | 3367 | strbuf_reset(&line); | |
| 3367 | 3368 | strbuf_addf(&line, "%s %s %"PRIuMAX"\n", oid_to_hex(oid), | |
| 3368 | 3369 | type_name(type), (uintmax_t)size); | |
| 3369 | - | cat_blob_write(line.buf, line.len); | |
| 3370 | + | ||
| 3371 | + | /* | |
| 3372 | + | * Write the header, the payload and the trailing newline with a | |
| 3373 | + | * single writev(3p) call instead of three separate write(3p) calls. | |
| 3374 | + | */ | |
| 3375 | + | iov[0].iov_base = line.buf; | |
| 3376 | + | iov[0].iov_len = line.len; | |
| 3377 | + | iov[1].iov_base = buf; | |
| 3378 | + | iov[1].iov_len = size; | |
| 3379 | + | iov[2].iov_base = (void *) "\n"; | |
| 3380 | + | iov[2].iov_len = 1; | |
| 3381 | + | ||
| 3382 | + | if (writev_in_full(cat_blob_fd, iov, ARRAY_SIZE(iov)) < 0) | |
| 3383 | + | die_errno(_("write to frontend failed")); | |
| 3370 | 3384 | strbuf_release(&line); | |
| 3371 | - | cat_blob_write(buf, size); | |
| 3372 | - | cat_blob_write("\n", 1); | |
| 3373 | 3385 | if (oe && oe->pack_id == pack_id) { | |
| 3374 | 3386 | last_blob.offset = oe->idx.offset; | |
| 3375 | 3387 | strbuf_attach(&last_blob.data, buf, size, size + 1); | |
modified builtin/fetch-pack.c
| @@ -49,7 +49,7 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc, | |||
| 49 | 49 | int cmd_fetch_pack(int argc, | |
| 50 | 50 | const char **argv, | |
| 51 | 51 | const char *prefix UNUSED, | |
| 52 | - | struct repository *repo) | |
| 52 | + | struct repository *repo UNUSED) | |
| 53 | 53 | { | |
| 54 | 54 | int i, ret; | |
| 55 | 55 | struct ref *fetched_refs = NULL, *remote_refs = NULL; | |
| @@ -67,6 +67,8 @@ int cmd_fetch_pack(int argc, | |||
| 67 | 67 | struct packet_reader reader; | |
| 68 | 68 | enum protocol_version version; | |
| 69 | 69 | ||
| 70 | + | fetch_if_missing = 0; | |
| 71 | + | ||
| 70 | 72 | packet_trace_identity("fetch-pack"); | |
| 71 | 73 | ||
| 72 | 74 | memset(&args, 0, sizeof(args)); | |
| @@ -75,8 +77,6 @@ int cmd_fetch_pack(int argc, | |||
| 75 | 77 | ||
| 76 | 78 | show_usage_if_asked(argc, argv, fetch_pack_usage); | |
| 77 | 79 | ||
| 78 | - | repo->fetch_if_missing = 0; | |
| 79 | - | ||
| 80 | 80 | for (i = 1; i < argc && *argv[i] == '-'; i++) { | |
| 81 | 81 | const char *arg = argv[i]; | |
| 82 | 82 | ||
modified builtin/fsck.c
| @@ -1017,15 +1017,15 @@ int cmd_fsck(int argc, | |||
| 1017 | 1017 | .ref = NULL | |
| 1018 | 1018 | }; | |
| 1019 | 1019 | ||
| 1020 | + | /* fsck knows how to handle missing promisor objects */ | |
| 1021 | + | fetch_if_missing = 0; | |
| 1022 | + | ||
| 1020 | 1023 | errors_found = 0; | |
| 1021 | 1024 | disable_replace_refs(); | |
| 1022 | 1025 | save_commit_buffer = 0; | |
| 1023 | 1026 | ||
| 1024 | 1027 | argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0); | |
| 1025 | 1028 | ||
| 1026 | - | /* fsck knows how to handle missing promisor objects */ | |
| 1027 | - | repo->fetch_if_missing = 0; | |
| 1028 | - | ||
| 1029 | 1029 | fsck_options_init(&fsck_walk_options, repo, FSCK_OPTIONS_DEFAULT); | |
| 1030 | 1030 | fsck_walk_options.walk = mark_object; | |
| 1031 | 1031 | ||
modified builtin/index-pack.c
| @@ -1886,7 +1886,7 @@ static void repack_local_links(void) | |||
| 1886 | 1886 | int cmd_index_pack(int argc, | |
| 1887 | 1887 | const char **argv, | |
| 1888 | 1888 | const char *prefix, | |
| 1889 | - | struct repository *repo) | |
| 1889 | + | struct repository *repo UNUSED) | |
| 1890 | 1890 | { | |
| 1891 | 1891 | int i, fix_thin_pack = 0, verify = 0, stat_only = 0, rev_index; | |
| 1892 | 1892 | const char *curr_index; | |
| @@ -1903,15 +1903,15 @@ int cmd_index_pack(int argc, | |||
| 1903 | 1903 | int report_end_of_input = 0; | |
| 1904 | 1904 | int hash_algo = 0; | |
| 1905 | 1905 | ||
| 1906 | - | show_usage_if_asked(argc, argv, index_pack_usage); | |
| 1907 | - | ||
| 1908 | 1906 | /* | |
| 1909 | 1907 | * index-pack never needs to fetch missing objects except when | |
| 1910 | 1908 | * REF_DELTA bases are missing (which are explicitly handled). It only | |
| 1911 | 1909 | * accesses the repo to do hash collision checks and to check which | |
| 1912 | 1910 | * REF_DELTA bases need to be fetched. | |
| 1913 | 1911 | */ | |
| 1914 | - | (repo ? repo : the_repository)->fetch_if_missing = 0; | |
| 1912 | + | fetch_if_missing = 0; | |
| 1913 | + | ||
| 1914 | + | show_usage_if_asked(argc, argv, index_pack_usage); | |
| 1915 | 1915 | ||
| 1916 | 1916 | disable_replace_refs(); | |
| 1917 | 1917 | ||
modified builtin/pack-objects.c
| @@ -1759,7 +1759,7 @@ static int want_object_in_pack_mtime(const struct object_id *oid, | |||
| 1759 | 1759 | struct odb_source *source = the_repository->objects->sources->next; | |
| 1760 | 1760 | for (; source; source = source->next) { | |
| 1761 | 1761 | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 1762 | - | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0)) | |
| 1762 | + | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL)) | |
| 1763 | 1763 | return 0; | |
| 1764 | 1764 | } | |
| 1765 | 1765 | } | |
| @@ -1786,7 +1786,7 @@ static int want_object_in_pack_mtime(const struct object_id *oid, | |||
| 1786 | 1786 | struct multi_pack_index *m = get_multi_pack_index(files->packed); | |
| 1787 | 1787 | struct pack_entry e; | |
| 1788 | 1788 | ||
| 1789 | - | if (m && fill_midx_entry(m, oid, &e)) { | |
| 1789 | + | if (m && fill_midx_entry(m, oid, &e, NULL)) { | |
| 1790 | 1790 | want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime); | |
| 1791 | 1791 | if (want != -1) | |
| 1792 | 1792 | return want; | |
| @@ -4087,10 +4087,9 @@ static void stdin_packs_read_input(struct rev_info *revs, | |||
| 4087 | 4087 | ||
| 4088 | 4088 | static void add_unreachable_loose_objects(struct rev_info *revs); | |
| 4089 | 4089 | ||
| 4090 | - | static void read_stdin_packs(struct repository *repo, | |
| 4091 | - | enum stdin_packs_mode mode, int rev_list_unpacked) | |
| 4090 | + | static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked) | |
| 4092 | 4091 | { | |
| 4093 | - | int prev_fetch_if_missing = repo->fetch_if_missing; | |
| 4092 | + | int prev_fetch_if_missing = fetch_if_missing; | |
| 4094 | 4093 | struct rev_info revs; | |
| 4095 | 4094 | ||
| 4096 | 4095 | /* | |
| @@ -4098,9 +4097,9 @@ static void read_stdin_packs(struct repository *repo, | |||
| 4098 | 4097 | * walk is best-effort though we don't want to perform backfill fetches | |
| 4099 | 4098 | * for them. | |
| 4100 | 4099 | */ | |
| 4101 | - | repo->fetch_if_missing = 0; | |
| 4100 | + | fetch_if_missing = 0; | |
| 4102 | 4101 | ||
| 4103 | - | repo_init_revisions(repo, &revs, NULL); | |
| 4102 | + | repo_init_revisions(the_repository, &revs, NULL); | |
| 4104 | 4103 | /* | |
| 4105 | 4104 | * Use a revision walk to fill in the namehash of objects in the include | |
| 4106 | 4105 | * packs. To save time, we'll avoid traversing through objects that are | |
| @@ -4146,7 +4145,7 @@ static void read_stdin_packs(struct repository *repo, | |||
| 4146 | 4145 | trace2_data_intmax("pack-objects", the_repository, "stdin_packs_hints", | |
| 4147 | 4146 | stdin_packs_hints_nr); | |
| 4148 | 4147 | ||
| 4149 | - | repo->fetch_if_missing = prev_fetch_if_missing; | |
| 4148 | + | fetch_if_missing = prev_fetch_if_missing; | |
| 4150 | 4149 | } | |
| 4151 | 4150 | ||
| 4152 | 4151 | static void add_cruft_object_entry(const struct object_id *oid, enum object_type type, | |
| @@ -4172,7 +4171,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type | |||
| 4172 | 4171 | ||
| 4173 | 4172 | for (; !found && source; source = source->next) { | |
| 4174 | 4173 | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 4175 | - | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0)) | |
| 4174 | + | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL)) | |
| 4176 | 4175 | found = 1; | |
| 4177 | 4176 | } | |
| 4178 | 4177 | ||
| @@ -4456,11 +4455,9 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name, | |||
| 4456 | 4455 | show_object(obj, name, data); | |
| 4457 | 4456 | } | |
| 4458 | 4457 | ||
| 4459 | - | static int option_parse_missing_action(const struct option *opt, | |
| 4458 | + | static int option_parse_missing_action(const struct option *opt UNUSED, | |
| 4460 | 4459 | const char *arg, int unset) | |
| 4461 | 4460 | { | |
| 4462 | - | struct repository *repo = opt->value; | |
| 4463 | - | ||
| 4464 | 4461 | assert(arg); | |
| 4465 | 4462 | assert(!unset); | |
| 4466 | 4463 | ||
| @@ -4472,14 +4469,14 @@ static int option_parse_missing_action(const struct option *opt, | |||
| 4472 | 4469 | ||
| 4473 | 4470 | if (!strcmp(arg, "allow-any")) { | |
| 4474 | 4471 | arg_missing_action = MA_ALLOW_ANY; | |
| 4475 | - | repo->fetch_if_missing = 0; | |
| 4472 | + | fetch_if_missing = 0; | |
| 4476 | 4473 | fn_show_object = show_object__ma_allow_any; | |
| 4477 | 4474 | return 0; | |
| 4478 | 4475 | } | |
| 4479 | 4476 | ||
| 4480 | 4477 | if (!strcmp(arg, "allow-promisor")) { | |
| 4481 | 4478 | arg_missing_action = MA_ALLOW_PROMISOR; | |
| 4482 | - | repo->fetch_if_missing = 0; | |
| 4479 | + | fetch_if_missing = 0; | |
| 4483 | 4480 | fn_show_object = show_object__ma_allow_promisor; | |
| 4484 | 4481 | return 0; | |
| 4485 | 4482 | } | |
| @@ -4640,7 +4637,7 @@ static int force_object_loose(struct odb_source *source, | |||
| 4640 | 4637 | ||
| 4641 | 4638 | for (struct odb_source *s = source->odb->sources; s; s = s->next) { | |
| 4642 | 4639 | struct odb_source_files *files = odb_source_files_downcast(s); | |
| 4643 | - | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0)) | |
| 4640 | + | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL)) | |
| 4644 | 4641 | return 0; | |
| 4645 | 4642 | } | |
| 4646 | 4643 | ||
| @@ -5121,7 +5118,7 @@ static int parse_stdin_packs_mode(const struct option *opt, const char *arg, | |||
| 5121 | 5118 | int cmd_pack_objects(int argc, | |
| 5122 | 5119 | const char **argv, | |
| 5123 | 5120 | const char *prefix, | |
| 5124 | - | struct repository *repo) | |
| 5121 | + | struct repository *repo UNUSED) | |
| 5125 | 5122 | { | |
| 5126 | 5123 | int use_internal_rev_list = 0; | |
| 5127 | 5124 | int all_progress_implied = 0; | |
| @@ -5228,7 +5225,7 @@ int cmd_pack_objects(int argc, | |||
| 5228 | 5225 | N_("write a bitmap index if possible"), | |
| 5229 | 5226 | WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN), | |
| 5230 | 5227 | OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), | |
| 5231 | - | OPT_CALLBACK_F(0, "missing", repo, N_("action"), | |
| 5228 | + | OPT_CALLBACK_F(0, "missing", NULL, N_("action"), | |
| 5232 | 5229 | N_("handling for missing objects"), PARSE_OPT_NONEG, | |
| 5233 | 5230 | option_parse_missing_action), | |
| 5234 | 5231 | OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects, | |
| @@ -5348,7 +5345,7 @@ int cmd_pack_objects(int argc, | |||
| 5348 | 5345 | exclude_promisor_objects_best_effort, | |
| 5349 | 5346 | "--exclude-promisor-objects-best-effort"); | |
| 5350 | 5347 | if (exclude_promisor_objects) { | |
| 5351 | - | repo->fetch_if_missing = 0; | |
| 5348 | + | fetch_if_missing = 0; | |
| 5352 | 5349 | ||
| 5353 | 5350 | /* --stdin-packs handles promisor objects separately. */ | |
| 5354 | 5351 | if (!stdin_packs) { | |
| @@ -5357,9 +5354,8 @@ int cmd_pack_objects(int argc, | |||
| 5357 | 5354 | } | |
| 5358 | 5355 | } else if (exclude_promisor_objects_best_effort) { | |
| 5359 | 5356 | use_internal_rev_list = 1; | |
| 5360 | - | arg_missing_action = MA_ALLOW_ANY; | |
| 5361 | - | repo->fetch_if_missing = 0; | |
| 5362 | - | fn_show_object = show_object__ma_allow_any; | |
| 5357 | + | fetch_if_missing = 0; | |
| 5358 | + | option_parse_missing_action(NULL, "allow-any", 0); | |
| 5363 | 5359 | /* revs configured below */ | |
| 5364 | 5360 | } | |
| 5365 | 5361 | if (unpack_unreachable || keep_unreachable || pack_loose_unreachable) | |
| @@ -5475,7 +5471,7 @@ int cmd_pack_objects(int argc, | |||
| 5475 | 5471 | progress_state = start_progress(the_repository, | |
| 5476 | 5472 | _("Enumerating objects"), 0); | |
| 5477 | 5473 | if (stdin_packs) { | |
| 5478 | - | read_stdin_packs(repo, stdin_packs, rev_list_unpacked); | |
| 5474 | + | read_stdin_packs(stdin_packs, rev_list_unpacked); | |
| 5479 | 5475 | } else if (cruft) { | |
| 5480 | 5476 | read_cruft_objects(); | |
| 5481 | 5477 | } else if (!use_internal_rev_list) { | |
modified builtin/prune.c
| @@ -194,7 +194,7 @@ int cmd_prune(int argc, | |||
| 194 | 194 | if (show_progress == -1) | |
| 195 | 195 | show_progress = isatty(2); | |
| 196 | 196 | if (exclude_promisor_objects) { | |
| 197 | - | repo->fetch_if_missing = 0; | |
| 197 | + | fetch_if_missing = 0; | |
| 198 | 198 | revs.exclude_promisor_objects = 1; | |
| 199 | 199 | } | |
| 200 | 200 | ||
modified builtin/rev-list.c
| @@ -500,8 +500,7 @@ static void print_disk_usage(off_t size) | |||
| 500 | 500 | strbuf_release(&sb); | |
| 501 | 501 | } | |
| 502 | 502 | ||
| 503 | - | static inline int parse_missing_action_value(struct repository *repo, | |
| 504 | - | const char *value) | |
| 503 | + | static inline int parse_missing_action_value(const char *value) | |
| 505 | 504 | { | |
| 506 | 505 | if (!strcmp(value, "error")) { | |
| 507 | 506 | arg_missing_action = MA_ERROR; | |
| @@ -510,25 +509,25 @@ static inline int parse_missing_action_value(struct repository *repo, | |||
| 510 | 509 | ||
| 511 | 510 | if (!strcmp(value, "allow-any")) { | |
| 512 | 511 | arg_missing_action = MA_ALLOW_ANY; | |
| 513 | - | repo->fetch_if_missing = 0; | |
| 512 | + | fetch_if_missing = 0; | |
| 514 | 513 | return 1; | |
| 515 | 514 | } | |
| 516 | 515 | ||
| 517 | 516 | if (!strcmp(value, "print")) { | |
| 518 | 517 | arg_missing_action = MA_PRINT; | |
| 519 | - | repo->fetch_if_missing = 0; | |
| 518 | + | fetch_if_missing = 0; | |
| 520 | 519 | return 1; | |
| 521 | 520 | } | |
| 522 | 521 | ||
| 523 | 522 | if (!strcmp(value, "print-info")) { | |
| 524 | 523 | arg_missing_action = MA_PRINT_INFO; | |
| 525 | - | repo->fetch_if_missing = 0; | |
| 524 | + | fetch_if_missing = 0; | |
| 526 | 525 | return 1; | |
| 527 | 526 | } | |
| 528 | 527 | ||
| 529 | 528 | if (!strcmp(value, "allow-promisor")) { | |
| 530 | 529 | arg_missing_action = MA_ALLOW_PROMISOR; | |
| 531 | - | repo->fetch_if_missing = 0; | |
| 530 | + | fetch_if_missing = 0; | |
| 532 | 531 | return 1; | |
| 533 | 532 | } | |
| 534 | 533 | ||
| @@ -693,7 +692,7 @@ static void prepare_maximal_independent(struct rev_info *revs) | |||
| 693 | 692 | int cmd_rev_list(int argc, | |
| 694 | 693 | const char **argv, | |
| 695 | 694 | const char *prefix, | |
| 696 | - | struct repository *repo) | |
| 695 | + | struct repository *repo UNUSED) | |
| 697 | 696 | { | |
| 698 | 697 | struct rev_info revs; | |
| 699 | 698 | struct rev_list_info info; | |
| @@ -746,10 +745,10 @@ int cmd_rev_list(int argc, | |||
| 746 | 745 | for (i = 1; i < argc; i++) { | |
| 747 | 746 | const char *arg = argv[i]; | |
| 748 | 747 | if (!strcmp(arg, "--exclude-promisor-objects")) { | |
| 749 | - | repo->fetch_if_missing = 0; | |
| 748 | + | fetch_if_missing = 0; | |
| 750 | 749 | revs.exclude_promisor_objects = 1; | |
| 751 | 750 | } else if (skip_prefix(arg, "--missing=", &arg)) { | |
| 752 | - | parse_missing_action_value(repo, arg); | |
| 751 | + | parse_missing_action_value(arg); | |
| 753 | 752 | } else if (!strcmp(arg, "-z")) { | |
| 754 | 753 | line_term = '\0'; | |
| 755 | 754 | info_term = '\0'; | |
modified common-init.c
| @@ -47,7 +47,7 @@ static void setup_environment(void) | |||
| 47 | 47 | update_ref_namespace(NAMESPACE_REPLACE, git_replace_ref_base); | |
| 48 | 48 | ||
| 49 | 49 | if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0)) | |
| 50 | - | the_repository->fetch_if_missing = 0; | |
| 50 | + | fetch_if_missing = 0; | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | 53 | void init_git(const char **argv) | |
modified compat/posix.h
| @@ -148,6 +148,9 @@ | |||
| 148 | 148 | #include <sys/socket.h> | |
| 149 | 149 | #include <sys/ioctl.h> | |
| 150 | 150 | #include <sys/statvfs.h> | |
| 151 | + | #ifndef NO_WRITEV | |
| 152 | + | #include <sys/uio.h> | |
| 153 | + | #endif | |
| 151 | 154 | #include <termios.h> | |
| 152 | 155 | #ifndef NO_SYS_SELECT_H | |
| 153 | 156 | #include <sys/select.h> | |
| @@ -334,6 +337,17 @@ int git_lstat(const char *, struct stat *); | |||
| 334 | 337 | ssize_t git_pread(int fd, void *buf, size_t count, off_t offset); | |
| 335 | 338 | #endif | |
| 336 | 339 | ||
| 340 | + | #ifdef NO_WRITEV | |
| 341 | + | #define writev git_writev | |
| 342 | + | #define iovec git_iovec | |
| 343 | + | struct git_iovec { | |
| 344 | + | void *iov_base; | |
| 345 | + | size_t iov_len; | |
| 346 | + | }; | |
| 347 | + | ||
| 348 | + | ssize_t git_writev(int fd, const struct iovec *iov, int iovcnt); | |
| 349 | + | #endif | |
| 350 | + | ||
| 337 | 351 | #ifdef NO_SETENV | |
| 338 | 352 | #define setenv gitsetenv | |
| 339 | 353 | int gitsetenv(const char *, const char *, int); | |
added compat/writev.c mode 100644
| @@ -0,0 +1,41 @@ | |||
| 1 | + | #include "../git-compat-util.h" | |
| 2 | + | #include "../wrapper.h" | |
| 3 | + | ||
| 4 | + | ssize_t git_writev(int fd, const struct iovec *iov, int iovcnt) | |
| 5 | + | { | |
| 6 | + | size_t sum = 0; | |
| 7 | + | ||
| 8 | + | if (iovcnt <= 0) { | |
| 9 | + | errno = EINVAL; | |
| 10 | + | return -1; | |
| 11 | + | } | |
| 12 | + | ||
| 13 | + | /* | |
| 14 | + | * According to writev(3p), the syscall shall error with EINVAL in case | |
| 15 | + | * the sum of `iov_len` overflows `ssize_t`. | |
| 16 | + | */ | |
| 17 | + | for (int i = 0; i < iovcnt; i++) { | |
| 18 | + | if (iov[i].iov_len > maximum_signed_value_of_type(ssize_t) || | |
| 19 | + | unsigned_add_overflows(iov[i].iov_len, sum) || | |
| 20 | + | iov[i].iov_len + sum > maximum_signed_value_of_type(ssize_t)) { | |
| 21 | + | errno = EINVAL; | |
| 22 | + | return -1; | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | sum += iov[i].iov_len; | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | /* | |
| 29 | + | * We only ever write the first non-empty vector so that we can | |
| 30 | + | * guarantee the call to be non-interleaving as guaranteed by POSIX. | |
| 31 | + | * This works just fine as callers have to loop around writev anyway. | |
| 32 | + | */ | |
| 33 | + | for (int i = 0; i < iovcnt; i++) { | |
| 34 | + | if (!iov[i].iov_len) | |
| 35 | + | continue; | |
| 36 | + | return xwrite(fd, iov[i].iov_base, iov[i].iov_len); | |
| 37 | + | } | |
| 38 | + | ||
| 39 | + | /* When all iovec members were zero we ought to return 0 according to POSIX. */ | |
| 40 | + | return 0; | |
| 41 | + | } | |
modified config.mak.uname
| @@ -483,6 +483,7 @@ ifeq ($(uname_S),Windows) | |||
| 483 | 483 | SANE_TOOL_PATH ?= $(msvc_bin_dir_msys) | |
| 484 | 484 | HAVE_ALLOCA_H = YesPlease | |
| 485 | 485 | NO_PREAD = YesPlease | |
| 486 | + | NO_WRITEV = YesPlease | |
| 486 | 487 | NEEDS_CRYPTO_WITH_SSL = YesPlease | |
| 487 | 488 | NO_LIBGEN_H = YesPlease | |
| 488 | 489 | NO_POLL = YesPlease | |
| @@ -697,6 +698,7 @@ ifeq ($(uname_S),MINGW) | |||
| 697 | 698 | pathsep = ; | |
| 698 | 699 | HAVE_ALLOCA_H = YesPlease | |
| 699 | 700 | NO_PREAD = YesPlease | |
| 701 | + | NO_WRITEV = YesPlease | |
| 700 | 702 | NEEDS_CRYPTO_WITH_SSL = YesPlease | |
| 701 | 703 | NO_LIBGEN_H = YesPlease | |
| 702 | 704 | NO_POLL = YesPlease | |
modified contrib/buildsystems/CMakeLists.txt
| @@ -378,7 +378,7 @@ endif() | |||
| 378 | 378 | #function checks | |
| 379 | 379 | set(function_checks | |
| 380 | 380 | strcasestr memmem strlcpy strtoimax strtoumax strtoull | |
| 381 | - | setenv mkdtemp poll pread memmem) | |
| 381 | + | setenv mkdtemp poll pread memmem writev) | |
| 382 | 382 | ||
| 383 | 383 | #unsetenv,hstrerror are incompatible with windows build | |
| 384 | 384 | if(NOT WIN32) | |
| @@ -423,6 +423,10 @@ if(NOT HAVE_MEMMEM) | |||
| 423 | 423 | list(APPEND compat_SOURCES compat/memmem.c) | |
| 424 | 424 | endif() | |
| 425 | 425 | ||
| 426 | + | if(NOT HAVE_WRITEV) | |
| 427 | + | list(APPEND compat_SOURCES compat/writev.c) | |
| 428 | + | endif() | |
| 429 | + | ||
| 426 | 430 | if(NOT WIN32) | |
| 427 | 431 | if(NOT HAVE_UNSETENV) | |
| 428 | 432 | list(APPEND compat_SOURCES compat/unsetenv.c) | |
modified diff.c
| @@ -3519,29 +3519,6 @@ struct checkdiff_t { | |||
| 3519 | 3519 | int last_line_kind; | |
| 3520 | 3520 | }; | |
| 3521 | 3521 | ||
| 3522 | - | static int is_conflict_marker(const char *line, int marker_size, unsigned long len) | |
| 3523 | - | { | |
| 3524 | - | char firstchar; | |
| 3525 | - | int cnt; | |
| 3526 | - | ||
| 3527 | - | if (len < marker_size + 1) | |
| 3528 | - | return 0; | |
| 3529 | - | firstchar = line[0]; | |
| 3530 | - | switch (firstchar) { | |
| 3531 | - | case '=': case '>': case '<': case '|': | |
| 3532 | - | break; | |
| 3533 | - | default: | |
| 3534 | - | return 0; | |
| 3535 | - | } | |
| 3536 | - | for (cnt = 1; cnt < marker_size; cnt++) | |
| 3537 | - | if (line[cnt] != firstchar) | |
| 3538 | - | return 0; | |
| 3539 | - | /* line[1] through line[marker_size-1] are same as firstchar */ | |
| 3540 | - | if (len < marker_size + 1 || !isspace(line[marker_size])) | |
| 3541 | - | return 0; | |
| 3542 | - | return 1; | |
| 3543 | - | } | |
| 3544 | - | ||
| 3545 | 3522 | static void checkdiff_consume_hunk(void *priv, | |
| 3546 | 3523 | long ob UNUSED, long on UNUSED, | |
| 3547 | 3524 | long nb, long nn UNUSED, | |
| @@ -3571,7 +3548,7 @@ static int checkdiff_consume(void *priv, char *line, unsigned long len) | |||
| 3571 | 3548 | if (line[0] == '+') { | |
| 3572 | 3549 | unsigned bad; | |
| 3573 | 3550 | data->lineno++; | |
| 3574 | - | if (is_conflict_marker(line + 1, marker_size, len - 1)) { | |
| 3551 | + | if (is_conflict_marker_line(line + 1, len - 1, marker_size)) { | |
| 3575 | 3552 | data->status |= 1; | |
| 3576 | 3553 | fprintf(data->o->file, | |
| 3577 | 3554 | "%s%s:%d: leftover conflict marker\n", | |
modified fetch-pack.c
| @@ -1854,9 +1854,10 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, | |||
| 1854 | 1854 | } | |
| 1855 | 1855 | ||
| 1856 | 1856 | for (i = 0; i < packfile_uris.nr; i++) { | |
| 1857 | + | bool created_keep; | |
| 1857 | 1858 | int j; | |
| 1858 | 1859 | struct child_process cmd = CHILD_PROCESS_INIT; | |
| 1859 | - | char packname[GIT_MAX_HEXSZ + 1]; | |
| 1860 | + | char packhash[GIT_MAX_HEXSZ + 1]; | |
| 1860 | 1861 | const char *uri = packfile_uris.items[i].string + | |
| 1861 | 1862 | the_hash_algo->hexsz + 1; | |
| 1862 | 1863 | ||
| @@ -1874,16 +1875,17 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, | |||
| 1874 | 1875 | if (start_command(&cmd)) | |
| 1875 | 1876 | die("fetch-pack: unable to spawn http-fetch"); | |
| 1876 | 1877 | ||
| 1877 | - | if (read_in_full(cmd.out, packname, 5) < 0 || | |
| 1878 | - | memcmp(packname, "keep\t", 5)) | |
| 1879 | - | die("fetch-pack: expected keep then TAB at start of http-fetch output"); | |
| 1878 | + | if (read_in_full(cmd.out, packhash, 5) != 5 || | |
| 1879 | + | (memcmp(packhash, "keep\t", 5) && | |
| 1880 | + | memcmp(packhash, "pack\t", 5))) | |
| 1881 | + | die("fetch-pack: expected pack or keep then TAB at start of http-fetch output"); | |
| 1882 | + | created_keep = !memcmp(packhash, "keep\t", 5); | |
| 1880 | 1883 | ||
| 1881 | - | if (read_in_full(cmd.out, packname, | |
| 1882 | - | the_hash_algo->hexsz + 1) < 0 || | |
| 1883 | - | packname[the_hash_algo->hexsz] != '\n') | |
| 1884 | - | die("fetch-pack: expected hash then LF at end of http-fetch output"); | |
| 1885 | - | ||
| 1886 | - | packname[the_hash_algo->hexsz] = '\0'; | |
| 1884 | + | if (read_in_full(cmd.out, packhash, | |
| 1885 | + | the_hash_algo->hexsz + 1) != the_hash_algo->hexsz + 1 || | |
| 1886 | + | packhash[the_hash_algo->hexsz] != '\n') | |
| 1887 | + | die("fetch-pack: expected hash then LF in http-fetch output"); | |
| 1888 | + | packhash[the_hash_algo->hexsz] = '\0'; | |
| 1887 | 1889 | ||
| 1888 | 1890 | parse_gitmodules_oids(cmd.out, &fsck_options.gitmodules_found); | |
| 1889 | 1891 | ||
| @@ -1892,16 +1894,17 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, | |||
| 1892 | 1894 | if (finish_command(&cmd)) | |
| 1893 | 1895 | die("fetch-pack: unable to finish http-fetch"); | |
| 1894 | 1896 | ||
| 1895 | - | if (memcmp(packfile_uris.items[i].string, packname, | |
| 1897 | + | if (memcmp(packfile_uris.items[i].string, packhash, | |
| 1896 | 1898 | the_hash_algo->hexsz)) | |
| 1897 | 1899 | die("fetch-pack: pack downloaded from %s does not match expected hash %.*s", | |
| 1898 | 1900 | uri, (int) the_hash_algo->hexsz, | |
| 1899 | 1901 | packfile_uris.items[i].string); | |
| 1900 | 1902 | ||
| 1901 | - | string_list_append_nodup(pack_lockfiles, | |
| 1902 | - | xstrfmt("%s/pack/pack-%s.keep", | |
| 1903 | - | repo_get_object_directory(the_repository), | |
| 1904 | - | packname)); | |
| 1903 | + | if (created_keep) | |
| 1904 | + | string_list_append_nodup(pack_lockfiles, | |
| 1905 | + | xstrfmt("%s/pack/pack-%s.keep", | |
| 1906 | + | repo_get_object_directory(the_repository), | |
| 1907 | + | packhash)); | |
| 1905 | 1908 | } | |
| 1906 | 1909 | string_list_clear(&packfile_uris, 0); | |
| 1907 | 1910 | strvec_clear(&index_pack_args); | |
modified git.c
| @@ -202,7 +202,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
| 202 | 202 | if (envchanged) | |
| 203 | 203 | *envchanged = 1; | |
| 204 | 204 | } else if (!strcmp(cmd, "--no-lazy-fetch")) { | |
| 205 | - | the_repository->fetch_if_missing = 0; | |
| 205 | + | fetch_if_missing = 0; | |
| 206 | 206 | setenv(NO_LAZY_FETCH_ENVIRONMENT, "1", 1); | |
| 207 | 207 | if (envchanged) | |
| 208 | 208 | *envchanged = 1; | |
modified http-fetch.c
| @@ -70,7 +70,8 @@ static void fetch_single_packfile(struct object_id *packfile_hash, | |||
| 70 | 70 | ||
| 71 | 71 | if (start_active_slot(preq->slot)) { | |
| 72 | 72 | run_active_slot(preq->slot); | |
| 73 | - | if (results.curl_result != CURLE_OK) { | |
| 73 | + | if (results.curl_result != CURLE_OK && | |
| 74 | + | results.http_code != 416) { | |
| 74 | 75 | struct url_info url; | |
| 75 | 76 | char *nurl = url_normalize(preq->url, &url); | |
| 76 | 77 | if (!nurl || !git_env_bool("GIT_TRACE_REDACT", 1)) { | |
| @@ -155,7 +156,7 @@ int cmd_main(int argc, const char **argv) | |||
| 155 | 156 | ||
| 156 | 157 | if (packfile) { | |
| 157 | 158 | if (!index_pack_args.nr) | |
| 158 | - | die(_("the option '%s' requires '%s'"), "--packfile", "--index-pack-args"); | |
| 159 | + | die(_("the option '%s' requires '%s'"), "--packfile", "--index-pack-arg"); | |
| 159 | 160 | ||
| 160 | 161 | fetch_single_packfile(&packfile_hash, argv[arg], | |
| 161 | 162 | index_pack_args.v); | |
| @@ -164,7 +165,7 @@ int cmd_main(int argc, const char **argv) | |||
| 164 | 165 | } | |
| 165 | 166 | ||
| 166 | 167 | if (index_pack_args.nr) | |
| 167 | - | die(_("the option '%s' requires '%s'"), "--index-pack-args", "--packfile"); | |
| 168 | + | die(_("the option '%s' requires '%s'"), "--index-pack-arg", "--packfile"); | |
| 168 | 169 | ||
| 169 | 170 | if (commits_on_stdin) { | |
| 170 | 171 | commits = walker_targets_stdin(&commit_id, &write_ref); | |
modified http-push.c
| @@ -595,7 +595,8 @@ static void finish_request(struct transfer_request *request) | |||
| 595 | 595 | ||
| 596 | 596 | } else if (request->state == RUN_FETCH_PACKED) { | |
| 597 | 597 | int fail = 1; | |
| 598 | - | if (request->curl_result != CURLE_OK) { | |
| 598 | + | if (request->curl_result != CURLE_OK && | |
| 599 | + | request->http_code != 416) { | |
| 599 | 600 | fprintf(stderr, "Unable to get pack file %s\n%s", | |
| 600 | 601 | request->url, curl_errorstr); | |
| 601 | 602 | } else { | |
modified http-walker.c
| @@ -451,7 +451,8 @@ static int http_fetch_pack(struct walker *walker, struct alt_base *repo, | |||
| 451 | 451 | ||
| 452 | 452 | if (start_active_slot(preq->slot)) { | |
| 453 | 453 | run_active_slot(preq->slot); | |
| 454 | - | if (results.curl_result != CURLE_OK) { | |
| 454 | + | if (results.curl_result != CURLE_OK && | |
| 455 | + | results.http_code != 416) { | |
| 455 | 456 | error("Unable to get pack file %s\n%s", preq->url, | |
| 456 | 457 | curl_errorstr); | |
| 457 | 458 | goto abort; | |
modified http.c
| @@ -2688,10 +2688,13 @@ int finish_http_pack_request(struct http_pack_request *preq) | |||
| 2688 | 2688 | int tmpfile_fd; | |
| 2689 | 2689 | int ret = 0; | |
| 2690 | 2690 | ||
| 2691 | + | /* Another downloader may unlink the staging path while we index it. */ | |
| 2692 | + | tmpfile_fd = xdup(fileno(preq->packfile)); | |
| 2691 | 2693 | fclose(preq->packfile); | |
| 2692 | 2694 | preq->packfile = NULL; | |
| 2693 | - | ||
| 2694 | - | tmpfile_fd = xopen(preq->tmpfile.buf, O_RDONLY); | |
| 2695 | + | if (lseek(tmpfile_fd, 0, SEEK_SET) < 0) | |
| 2696 | + | die_errno("unable to seek local file %s for pack", | |
| 2697 | + | preq->tmpfile.buf); | |
| 2695 | 2698 | ||
| 2696 | 2699 | ip.git_cmd = 1; | |
| 2697 | 2700 | ip.in = tmpfile_fd; | |
| @@ -2704,13 +2707,8 @@ int finish_http_pack_request(struct http_pack_request *preq) | |||
| 2704 | 2707 | else | |
| 2705 | 2708 | ip.no_stdout = 1; | |
| 2706 | 2709 | ||
| 2707 | - | if (run_command(&ip)) { | |
| 2710 | + | if (run_command(&ip)) | |
| 2708 | 2711 | ret = -1; | |
| 2709 | - | goto cleanup; | |
| 2710 | - | } | |
| 2711 | - | ||
| 2712 | - | cleanup: | |
| 2713 | - | close(tmpfile_fd); | |
| 2714 | 2712 | unlink(preq->tmpfile.buf); | |
| 2715 | 2713 | return ret; | |
| 2716 | 2714 | } | |
| @@ -2738,22 +2736,45 @@ struct http_pack_request *new_http_pack_request( | |||
| 2738 | 2736 | struct http_pack_request *new_direct_http_pack_request( | |
| 2739 | 2737 | const unsigned char *packed_git_hash, char *url) | |
| 2740 | 2738 | { | |
| 2741 | - | off_t prev_posn = 0; | |
| 2739 | + | off_t prev_posn; | |
| 2742 | 2740 | struct http_pack_request *preq; | |
| 2741 | + | int fd; | |
| 2743 | 2742 | ||
| 2744 | 2743 | CALLOC_ARRAY(preq, 1); | |
| 2745 | 2744 | strbuf_init(&preq->tmpfile, 0); | |
| 2746 | - | ||
| 2747 | 2745 | preq->url = url; | |
| 2748 | 2746 | ||
| 2749 | 2747 | odb_pack_name(the_repository, &preq->tmpfile, packed_git_hash, "pack"); | |
| 2750 | 2748 | strbuf_addstr(&preq->tmpfile, ".temp"); | |
| 2751 | - | preq->packfile = fopen(preq->tmpfile.buf, "a"); | |
| 2752 | - | if (!preq->packfile) { | |
| 2753 | - | error("Unable to open local file %s for pack", | |
| 2754 | - | preq->tmpfile.buf); | |
| 2749 | + | /* | |
| 2750 | + | * MinGW's non-append O_RDWR open grants FILE_SHARE_DELETE only for an | |
| 2751 | + | * existing file; reopen a newly created file so others may unlink it. | |
| 2752 | + | */ | |
| 2753 | + | for (;;) { | |
| 2754 | + | fd = open(preq->tmpfile.buf, O_RDWR); | |
| 2755 | + | if (fd >= 0 || errno != ENOENT) | |
| 2756 | + | break; | |
| 2757 | + | fd = open(preq->tmpfile.buf, O_RDWR | O_CREAT | O_EXCL, 0666); | |
| 2758 | + | if (fd >= 0) { | |
| 2759 | + | close(fd); | |
| 2760 | + | continue; | |
| 2761 | + | } | |
| 2762 | + | if (errno != EEXIST) | |
| 2763 | + | break; | |
| 2764 | + | } | |
| 2765 | + | if (fd < 0) { | |
| 2766 | + | error_errno("unable to open local file %s for pack", | |
| 2767 | + | preq->tmpfile.buf); | |
| 2755 | 2768 | goto abort; | |
| 2756 | 2769 | } | |
| 2770 | + | prev_posn = lseek(fd, 0, SEEK_END); | |
| 2771 | + | if (prev_posn < 0) { | |
| 2772 | + | error_errno("unable to seek local file %s for pack", | |
| 2773 | + | preq->tmpfile.buf); | |
| 2774 | + | close(fd); | |
| 2775 | + | goto abort; | |
| 2776 | + | } | |
| 2777 | + | preq->packfile = xfdopen(fd, "w"); | |
| 2757 | 2778 | ||
| 2758 | 2779 | preq->slot = get_active_slot(); | |
| 2759 | 2780 | preq->headers = object_request_headers(); | |
| @@ -2762,12 +2783,7 @@ struct http_pack_request *new_direct_http_pack_request( | |||
| 2762 | 2783 | curl_easy_setopt(preq->slot->curl, CURLOPT_URL, preq->url); | |
| 2763 | 2784 | curl_easy_setopt(preq->slot->curl, CURLOPT_HTTPHEADER, preq->headers); | |
| 2764 | 2785 | ||
| 2765 | - | /* | |
| 2766 | - | * If there is data present from a previous transfer attempt, | |
| 2767 | - | * resume where it left off | |
| 2768 | - | */ | |
| 2769 | - | prev_posn = ftello(preq->packfile); | |
| 2770 | - | if (prev_posn>0) { | |
| 2786 | + | if (prev_posn > 0) { | |
| 2771 | 2787 | if (http_is_verbose) | |
| 2772 | 2788 | fprintf(stderr, | |
| 2773 | 2789 | "Resuming fetch of pack %s at byte %"PRIuMAX"\n", | |
modified merge-ll.c
| @@ -468,3 +468,59 @@ int ll_merge_marker_size(struct index_state *istate, const char *path) | |||
| 468 | 468 | } | |
| 469 | 469 | return marker_size; | |
| 470 | 470 | } | |
| 471 | + | ||
| 472 | + | int is_conflict_marker_line(const char *line, unsigned long len, int marker_size) | |
| 473 | + | { | |
| 474 | + | char firstchar; | |
| 475 | + | int cnt; | |
| 476 | + | ||
| 477 | + | if (len < marker_size + 1) | |
| 478 | + | return 0; | |
| 479 | + | ||
| 480 | + | firstchar = line[0]; | |
| 481 | + | switch (firstchar) { | |
| 482 | + | case '=': case '>': case '<': case '|': | |
| 483 | + | break; | |
| 484 | + | default: | |
| 485 | + | return 0; | |
| 486 | + | } | |
| 487 | + | ||
| 488 | + | for (cnt = 1; cnt < marker_size; cnt++) { | |
| 489 | + | if (line[cnt] != firstchar) | |
| 490 | + | return 0; | |
| 491 | + | } | |
| 492 | + | ||
| 493 | + | if (((firstchar == '<') || (firstchar == '>')) && | |
| 494 | + | line[marker_size] != ' ') | |
| 495 | + | return 0; | |
| 496 | + | ||
| 497 | + | if (!isspace((unsigned char)line[marker_size])) | |
| 498 | + | return 0; | |
| 499 | + | ||
| 500 | + | return firstchar; | |
| 501 | + | } | |
| 502 | + | ||
| 503 | + | int has_conflict_markers(struct index_state *istate, const char *path) | |
| 504 | + | { | |
| 505 | + | FILE *f; | |
| 506 | + | struct strbuf sb = STRBUF_INIT; | |
| 507 | + | int marker_size = ll_merge_marker_size(istate, path); | |
| 508 | + | int has_markers = 0; | |
| 509 | + | ||
| 510 | + | f = fopen(path, "r"); | |
| 511 | + | if (!f) | |
| 512 | + | return 0; | |
| 513 | + | ||
| 514 | + | while (strbuf_getwholeline(&sb, f, '\n') != EOF) { | |
| 515 | + | if (is_conflict_marker_line(sb.buf, sb.len, marker_size)) { | |
| 516 | + | has_markers = 1; | |
| 517 | + | break; | |
| 518 | + | } | |
| 519 | + | if (buffer_is_binary(sb.buf, | |
| 520 | + | ULONG_MAX <= sb.len ? ULONG_MAX : sb.len)) | |
| 521 | + | break; | |
| 522 | + | } | |
| 523 | + | fclose(f); | |
| 524 | + | strbuf_release(&sb); | |
| 525 | + | return has_markers; | |
| 526 | + | } | |
modified merge-ll.h
| @@ -109,6 +109,8 @@ enum ll_merge_result ll_merge(mmbuffer_t *result_buf, | |||
| 109 | 109 | const struct ll_merge_options *opts); | |
| 110 | 110 | ||
| 111 | 111 | int ll_merge_marker_size(struct index_state *istate, const char *path); | |
| 112 | + | int is_conflict_marker_line(const char *line, unsigned long len, int marker_size); | |
| 113 | + | int has_conflict_markers(struct index_state *istate, const char *path); | |
| 112 | 114 | void reset_merge_attributes(void); | |
| 113 | 115 | ||
| 114 | 116 | #endif | |
modified meson.build
| @@ -1464,6 +1464,7 @@ checkfuncs = { | |||
| 1464 | 1464 | 'initgroups' : [], | |
| 1465 | 1465 | 'strtoumax' : ['strtoumax.c', 'strtoimax.c'], | |
| 1466 | 1466 | 'pread' : ['pread.c'], | |
| 1467 | + | 'writev' : ['writev.c'], | |
| 1467 | 1468 | } | |
| 1468 | 1469 | ||
| 1469 | 1470 | if host_machine.system() == 'windows' | |
modified midx-write.c
| @@ -865,7 +865,7 @@ static void find_commits_for_midx_bitmap(struct commit_stack *commits, | |||
| 865 | 865 | * complain later that we don't have reachability closure (and fail | |
| 866 | 866 | * appropriately). | |
| 867 | 867 | */ | |
| 868 | - | ctx->repo->fetch_if_missing = 0; | |
| 868 | + | fetch_if_missing = 0; | |
| 869 | 869 | revs.exclude_promisor_objects = 1; | |
| 870 | 870 | ||
| 871 | 871 | if (prepare_revision_walk(&revs)) | |
modified midx.c
| @@ -591,7 +591,8 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos) | |||
| 591 | 591 | ||
| 592 | 592 | int fill_midx_entry(struct multi_pack_index *m, | |
| 593 | 593 | const struct object_id *oid, | |
| 594 | - | struct pack_entry *e) | |
| 594 | + | struct pack_entry *e, | |
| 595 | + | struct packed_git **bad_pack) | |
| 595 | 596 | { | |
| 596 | 597 | uint32_t pos; | |
| 597 | 598 | uint32_t pack_int_id; | |
| @@ -618,8 +619,11 @@ int fill_midx_entry(struct multi_pack_index *m, | |||
| 618 | 619 | return 0; | |
| 619 | 620 | ||
| 620 | 621 | if (oidset_size(&p->bad_objects) && | |
| 621 | - | oidset_contains(&p->bad_objects, oid)) | |
| 622 | + | oidset_contains(&p->bad_objects, oid)) { | |
| 623 | + | if (bad_pack && !*bad_pack) | |
| 624 | + | *bad_pack = p; | |
| 622 | 625 | return 0; | |
| 626 | + | } | |
| 623 | 627 | ||
| 624 | 628 | e->offset = nth_midxed_offset(m, pos); | |
| 625 | 629 | e->p = p; | |
| @@ -1028,7 +1032,7 @@ int verify_midx_file(struct odb_source_packed *source, unsigned flags) | |||
| 1028 | 1032 | ||
| 1029 | 1033 | nth_midxed_object_oid(&oid, m, pairs[i].pos); | |
| 1030 | 1034 | ||
| 1031 | - | if (!fill_midx_entry(m, &oid, &e)) { | |
| 1035 | + | if (!fill_midx_entry(m, &oid, &e, NULL)) { | |
| 1032 | 1036 | midx_report(_("failed to load pack entry for oid[%d] = %s"), | |
| 1033 | 1037 | pairs[i].pos, oid_to_hex(&oid)); | |
| 1034 | 1038 | continue; | |
modified midx.h
| @@ -117,7 +117,8 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos); | |||
| 117 | 117 | struct object_id *nth_midxed_object_oid(struct object_id *oid, | |
| 118 | 118 | struct multi_pack_index *m, | |
| 119 | 119 | uint32_t n); | |
| 120 | - | int fill_midx_entry(struct multi_pack_index *m, const struct object_id *oid, struct pack_entry *e); | |
| 120 | + | int fill_midx_entry(struct multi_pack_index *m, const struct object_id *oid, | |
| 121 | + | struct pack_entry *e, struct packed_git **bad_pack); | |
| 121 | 122 | int midx_contains_pack(struct multi_pack_index *m, | |
| 122 | 123 | const char *idx_or_pack_name); | |
| 123 | 124 | int midx_layer_contains_pack(struct multi_pack_index *m, | |
modified odb.c
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | #include "object-name.h" | |
| 16 | 16 | #include "odb.h" | |
| 17 | 17 | #include "odb/source-inmemory.h" | |
| 18 | - | #include "packfile.h" | |
| 19 | 18 | #include "path.h" | |
| 20 | 19 | #include "promisor-remote.h" | |
| 21 | 20 | #include "quote.h" | |
| @@ -528,6 +527,8 @@ void disable_obj_read_lock(void) | |||
| 528 | 527 | pthread_mutex_destroy(&obj_read_mutex); | |
| 529 | 528 | } | |
| 530 | 529 | ||
| 530 | + | int fetch_if_missing = 1; | |
| 531 | + | ||
| 531 | 532 | static int register_all_submodule_sources(struct object_database *odb) | |
| 532 | 533 | { | |
| 533 | 534 | int ret = odb->submodule_source_paths.nr; | |
| @@ -545,12 +546,15 @@ static int register_all_submodule_sources(struct object_database *odb) | |||
| 545 | 546 | return ret; | |
| 546 | 547 | } | |
| 547 | 548 | ||
| 548 | - | static int do_oid_object_info_extended(struct object_database *odb, | |
| 549 | - | const struct object_id *oid, | |
| 550 | - | struct object_info *oi, unsigned flags) | |
| 549 | + | static enum odb_read_status do_oid_object_info_extended(struct object_database *odb, | |
| 550 | + | const struct object_id *oid, | |
| 551 | + | struct object_info *oi, unsigned flags) | |
| 551 | 552 | { | |
| 553 | + | struct strbuf corrupt_err = STRBUF_INIT; | |
| 552 | 554 | const struct object_id *real = oid; | |
| 555 | + | enum odb_read_status ret; | |
| 553 | 556 | int already_retried = 0; | |
| 557 | + | bool corrupt = false; | |
| 554 | 558 | ||
| 555 | 559 | if (flags & OBJECT_INFO_LOOKUP_REPLACE) | |
| 556 | 560 | real = lookup_replace_object(odb->repo, oid); | |
| @@ -558,7 +562,7 @@ static int do_oid_object_info_extended(struct object_database *odb, | |||
| 558 | 562 | if (is_null_oid(real)) | |
| 559 | 563 | return -1; | |
| 560 | 564 | ||
| 561 | - | if (!odb_source_read_object_info(odb->inmemory_objects, oid, oi, flags)) | |
| 565 | + | if (!odb_source_read_object_info(odb->inmemory_objects, oid, oi, flags, NULL)) | |
| 562 | 566 | return 0; | |
| 563 | 567 | ||
| 564 | 568 | odb_prepare_alternates(odb); | |
| @@ -566,9 +570,14 @@ static int do_oid_object_info_extended(struct object_database *odb, | |||
| 566 | 570 | while (1) { | |
| 567 | 571 | struct odb_source *source; | |
| 568 | 572 | ||
| 569 | - | for (source = odb->sources; source; source = source->next) | |
| 570 | - | if (!odb_source_read_object_info(source, real, oi, flags)) | |
| 571 | - | return 0; | |
| 573 | + | for (source = odb->sources; source; source = source->next) { | |
| 574 | + | ret = odb_source_read_object_info(source, real, oi, flags, | |
| 575 | + | corrupt_err.len ? NULL : &corrupt_err); | |
| 576 | + | if (!ret) | |
| 577 | + | goto out; | |
| 578 | + | if (ret != ODB_READ_NOT_FOUND) | |
| 579 | + | corrupt = true; | |
| 580 | + | } | |
| 572 | 581 | ||
| 573 | 582 | /* | |
| 574 | 583 | * When the object hasn't been found we try a second read and | |
| @@ -576,10 +585,15 @@ static int do_oid_object_info_extended(struct object_database *odb, | |||
| 576 | 585 | * caches or reload on-disk state. | |
| 577 | 586 | */ | |
| 578 | 587 | if (!(flags & OBJECT_INFO_QUICK)) { | |
| 579 | - | for (source = odb->sources; source; source = source->next) | |
| 580 | - | if (!odb_source_read_object_info(source, real, oi, | |
| 581 | - | flags | OBJECT_INFO_SECOND_READ)) | |
| 582 | - | return 0; | |
| 588 | + | for (source = odb->sources; source; source = source->next) { | |
| 589 | + | ret = odb_source_read_object_info(source, real, oi, | |
| 590 | + | flags | OBJECT_INFO_SECOND_READ, | |
| 591 | + | corrupt_err.len ? NULL : &corrupt_err); | |
| 592 | + | if (!ret) | |
| 593 | + | goto out; | |
| 594 | + | if (ret != ODB_READ_NOT_FOUND) | |
| 595 | + | corrupt = true; | |
| 596 | + | } | |
| 583 | 597 | } | |
| 584 | 598 | ||
| 585 | 599 | /* | |
| @@ -593,7 +607,7 @@ static int do_oid_object_info_extended(struct object_database *odb, | |||
| 593 | 607 | continue; | |
| 594 | 608 | ||
| 595 | 609 | /* Check if it is a missing object */ | |
| 596 | - | if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) && | |
| 610 | + | if (fetch_if_missing && repo_has_promisor_remote(odb->repo) && | |
| 597 | 611 | !already_retried && | |
| 598 | 612 | !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) { | |
| 599 | 613 | promisor_remote_get_direct(odb->repo, real, 1); | |
| @@ -602,16 +616,23 @@ static int do_oid_object_info_extended(struct object_database *odb, | |||
| 602 | 616 | } | |
| 603 | 617 | ||
| 604 | 618 | if (flags & OBJECT_INFO_DIE_IF_CORRUPT) { | |
| 605 | - | const struct packed_git *p; | |
| 606 | 619 | if ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid)) | |
| 607 | 620 | die(_("replacement %s not found for %s"), | |
| 608 | 621 | oid_to_hex(real), oid_to_hex(oid)); | |
| 609 | - | if ((p = has_packed_and_bad(odb->repo, real))) | |
| 610 | - | die(_("packed object %s (stored in %s) is corrupt"), | |
| 611 | - | oid_to_hex(real), p->pack_name); | |
| 622 | + | if (corrupt) { | |
| 623 | + | if (corrupt_err.len) | |
| 624 | + | die("%s", corrupt_err.buf); | |
| 625 | + | die(_("object %s is corrupt"), oid_to_hex(real)); | |
| 626 | + | } | |
| 612 | 627 | } | |
| 613 | - | return -1; | |
| 628 | + | ||
| 629 | + | ret = corrupt ? ODB_READ_ERROR : ODB_READ_NOT_FOUND; | |
| 630 | + | goto out; | |
| 614 | 631 | } | |
| 632 | + | ||
| 633 | + | out: | |
| 634 | + | strbuf_release(&corrupt_err); | |
| 635 | + | return ret; | |
| 615 | 636 | } | |
| 616 | 637 | ||
| 617 | 638 | static int oid_object_info_convert(struct repository *r, | |
| @@ -694,12 +715,12 @@ static int oid_object_info_convert(struct repository *r, | |||
| 694 | 715 | return ret; | |
| 695 | 716 | } | |
| 696 | 717 | ||
| 697 | - | int odb_read_object_info_extended(struct object_database *odb, | |
| 698 | - | const struct object_id *oid, | |
| 699 | - | struct object_info *oi, | |
| 700 | - | enum object_info_flags flags) | |
| 718 | + | enum odb_read_status odb_read_object_info_extended(struct object_database *odb, | |
| 719 | + | const struct object_id *oid, | |
| 720 | + | struct object_info *oi, | |
| 721 | + | enum object_info_flags flags) | |
| 701 | 722 | { | |
| 702 | - | int ret; | |
| 723 | + | enum odb_read_status ret; | |
| 703 | 724 | ||
| 704 | 725 | if (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo)) | |
| 705 | 726 | return oid_object_info_convert(odb->repo, oid, oi, flags); | |
modified odb.h
| @@ -15,6 +15,14 @@ struct repository; | |||
| 15 | 15 | struct strbuf; | |
| 16 | 16 | struct strvec; | |
| 17 | 17 | ||
| 18 | + | /* | |
| 19 | + | * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing | |
| 20 | + | * blobs. This has a difference only if extensions.partialClone is set. | |
| 21 | + | * | |
| 22 | + | * Its default value is 1. | |
| 23 | + | */ | |
| 24 | + | extern int fetch_if_missing; | |
| 25 | + | ||
| 18 | 26 | /* | |
| 19 | 27 | * Compute the exact path an alternate is at and returns it. In case of | |
| 20 | 28 | * error NULL is returned and the human readable error is added to `err` | |
| @@ -427,14 +435,23 @@ enum object_info_flags { | |||
| 427 | 435 | OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK), | |
| 428 | 436 | }; | |
| 429 | 437 | ||
| 438 | + | enum odb_read_status { | |
| 439 | + | /* The read was successful. */ | |
| 440 | + | ODB_READ_OK = 0, | |
| 441 | + | /* The read resulted in a generic error. */ | |
| 442 | + | ODB_READ_ERROR = -1, | |
| 443 | + | /* The object could not be found. */ | |
| 444 | + | ODB_READ_NOT_FOUND = -2, | |
| 445 | + | }; | |
| 446 | + | ||
| 430 | 447 | /* | |
| 431 | 448 | * Read object info from the object database and populate the `object_info` | |
| 432 | 449 | * structure. Returns 0 on success, a negative error code otherwise. | |
| 433 | 450 | */ | |
| 434 | - | int odb_read_object_info_extended(struct object_database *odb, | |
| 435 | - | const struct object_id *oid, | |
| 436 | - | struct object_info *oi, | |
| 437 | - | enum object_info_flags flags); | |
| 451 | + | enum odb_read_status odb_read_object_info_extended(struct object_database *odb, | |
| 452 | + | const struct object_id *oid, | |
| 453 | + | struct object_info *oi, | |
| 454 | + | enum object_info_flags flags); | |
| 438 | 455 | ||
| 439 | 456 | /* | |
| 440 | 457 | * Read a subset of object info for the given object ID. Returns an `enum | |
modified odb/source-files.c
| @@ -59,18 +59,35 @@ static void odb_source_files_prepare(struct odb_source *source, | |||
| 59 | 59 | odb_source_prepare(&files->packed->base, flags); | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 62 | - | static int odb_source_files_read_object_info(struct odb_source *source, | |
| 63 | - | const struct object_id *oid, | |
| 64 | - | struct object_info *oi, | |
| 65 | - | enum object_info_flags flags) | |
| 62 | + | static enum odb_read_status odb_source_files_read_object_info(struct odb_source *source, | |
| 63 | + | const struct object_id *oid, | |
| 64 | + | struct object_info *oi, | |
| 65 | + | enum object_info_flags flags, | |
| 66 | + | struct strbuf *errmsg) | |
| 66 | 67 | { | |
| 67 | 68 | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 69 | + | enum odb_read_status ret_packed, ret_loose; | |
| 68 | 70 | ||
| 69 | - | if (!odb_source_read_object_info(&files->packed->base, oid, oi, flags) || | |
| 70 | - | !odb_source_read_object_info(&files->loose->base, oid, oi, flags)) | |
| 71 | + | ret_packed = odb_source_read_object_info(&files->packed->base, oid, oi, | |
| 72 | + | flags, errmsg); | |
| 73 | + | if (!ret_packed) | |
| 71 | 74 | return 0; | |
| 72 | 75 | ||
| 73 | - | return -1; | |
| 76 | + | ret_loose = odb_source_read_object_info(&files->loose->base, oid, oi, flags, | |
| 77 | + | ret_packed == ODB_READ_NOT_FOUND ? errmsg : NULL); | |
| 78 | + | if (!ret_loose) | |
| 79 | + | return 0; | |
| 80 | + | ||
| 81 | + | /* | |
| 82 | + | * Reading the packed object may have failed even though the object | |
| 83 | + | * exists, for example because it is corrupt. Report this failure to | |
| 84 | + | * the caller in case neither of the sources was able to read the | |
| 85 | + | * object, and prefer the error of the packed source in case both | |
| 86 | + | * reads have failed. | |
| 87 | + | */ | |
| 88 | + | if (ret_packed != ODB_READ_NOT_FOUND) | |
| 89 | + | return ret_packed; | |
| 90 | + | return ret_loose; | |
| 74 | 91 | } | |
| 75 | 92 | ||
| 76 | 93 | static int odb_source_files_read_object_stream(struct odb_read_stream **out, | |
modified odb/source-inmemory.c
| @@ -56,17 +56,18 @@ static void populate_object_info(struct odb_source_inmemory *source, | |||
| 56 | 56 | oi->source_infop->source = &source->base; | |
| 57 | 57 | } | |
| 58 | 58 | ||
| 59 | - | static int odb_source_inmemory_read_object_info(struct odb_source *source, | |
| 60 | - | const struct object_id *oid, | |
| 61 | - | struct object_info *oi, | |
| 62 | - | enum object_info_flags flags UNUSED) | |
| 59 | + | static enum odb_read_status odb_source_inmemory_read_object_info(struct odb_source *source, | |
| 60 | + | const struct object_id *oid, | |
| 61 | + | struct object_info *oi, | |
| 62 | + | enum object_info_flags flags UNUSED, | |
| 63 | + | struct strbuf *errmsg UNUSED) | |
| 63 | 64 | { | |
| 64 | 65 | struct odb_source_inmemory *inmemory = odb_source_inmemory_downcast(source); | |
| 65 | 66 | const struct inmemory_object *object; | |
| 66 | 67 | ||
| 67 | 68 | object = find_cached_object(inmemory, oid); | |
| 68 | 69 | if (!object) | |
| 69 | - | return -1; | |
| 70 | + | return ODB_READ_NOT_FOUND; | |
| 70 | 71 | ||
| 71 | 72 | populate_object_info(inmemory, oi, object); | |
| 72 | 73 | return 0; | |
modified odb/source-loose.c
| @@ -67,7 +67,8 @@ static int read_object_info_from_path(struct odb_source_loose *loose, | |||
| 67 | 67 | const char *path, | |
| 68 | 68 | const struct object_id *oid, | |
| 69 | 69 | struct object_info *oi, | |
| 70 | - | enum object_info_flags flags) | |
| 70 | + | enum object_info_flags flags, | |
| 71 | + | struct strbuf *errmsg) | |
| 71 | 72 | { | |
| 72 | 73 | int ret; | |
| 73 | 74 | int fd; | |
| @@ -91,11 +92,16 @@ static int read_object_info_from_path(struct odb_source_loose *loose, | |||
| 91 | 92 | struct stat st; | |
| 92 | 93 | ||
| 93 | 94 | if ((!oi || (!oi->disk_sizep && !oi->mtimep)) && (flags & OBJECT_INFO_QUICK)) { | |
| 94 | - | ret = quick_has_loose(loose, oid) ? 0 : -1; | |
| 95 | + | ret = quick_has_loose(loose, oid) ? 0 : ODB_READ_NOT_FOUND; | |
| 95 | 96 | goto out; | |
| 96 | 97 | } | |
| 97 | 98 | ||
| 98 | 99 | if (lstat(path, &st) < 0) { | |
| 100 | + | if (errno == ENOENT) { | |
| 101 | + | ret = ODB_READ_NOT_FOUND; | |
| 102 | + | goto out; | |
| 103 | + | } | |
| 104 | + | ||
| 99 | 105 | ret = -1; | |
| 100 | 106 | goto out; | |
| 101 | 107 | } | |
| @@ -113,9 +119,12 @@ static int read_object_info_from_path(struct odb_source_loose *loose, | |||
| 113 | 119 | ||
| 114 | 120 | fd = git_open(path); | |
| 115 | 121 | if (fd < 0) { | |
| 116 | - | if (errno != ENOENT) | |
| 117 | - | error_errno(_("unable to open loose object %s"), oid_to_hex(oid)); | |
| 118 | - | ret = -1; | |
| 122 | + | if (errno == ENOENT) { | |
| 123 | + | ret = ODB_READ_NOT_FOUND; | |
| 124 | + | goto out; | |
| 125 | + | } | |
| 126 | + | ||
| 127 | + | ret = error_errno(_("unable to open loose object %s"), oid_to_hex(oid)); | |
| 119 | 128 | goto out; | |
| 120 | 129 | } | |
| 121 | 130 | ||
| @@ -155,7 +164,7 @@ static int read_object_info_from_path(struct odb_source_loose *loose, | |||
| 155 | 164 | ||
| 156 | 165 | if (parse_loose_header(hdr, oi) < 0) { | |
| 157 | 166 | ret = error(_("unable to parse %s header"), oid_to_hex(oid)); | |
| 158 | - | goto corrupt; | |
| 167 | + | goto out; | |
| 159 | 168 | } | |
| 160 | 169 | ||
| 161 | 170 | if (*oi->typep < 0) | |
| @@ -165,7 +174,7 @@ static int read_object_info_from_path(struct odb_source_loose *loose, | |||
| 165 | 174 | *oi->contentp = unpack_loose_rest(&stream, hdr, *oi->sizep, oid); | |
| 166 | 175 | if (!*oi->contentp) { | |
| 167 | 176 | ret = -1; | |
| 168 | - | goto corrupt; | |
| 177 | + | goto out; | |
| 169 | 178 | } | |
| 170 | 179 | } | |
| 171 | 180 | ||
| @@ -173,21 +182,19 @@ static int read_object_info_from_path(struct odb_source_loose *loose, | |||
| 173 | 182 | case ULHR_BAD: | |
| 174 | 183 | ret = error(_("unable to unpack %s header"), | |
| 175 | 184 | oid_to_hex(oid)); | |
| 176 | - | goto corrupt; | |
| 185 | + | goto out; | |
| 177 | 186 | case ULHR_TOO_LONG: | |
| 178 | 187 | ret = error(_("header for %s too long, exceeds %d bytes"), | |
| 179 | 188 | oid_to_hex(oid), MAX_HEADER_LEN); | |
| 180 | - | goto corrupt; | |
| 189 | + | goto out; | |
| 181 | 190 | } | |
| 182 | 191 | ||
| 183 | 192 | ret = 0; | |
| 184 | 193 | ||
| 185 | - | corrupt: | |
| 186 | - | if (ret && (flags & OBJECT_INFO_DIE_IF_CORRUPT)) | |
| 187 | - | die(_("loose object %s (stored in %s) is corrupt"), | |
| 188 | - | oid_to_hex(oid), path); | |
| 189 | - | ||
| 190 | 194 | out: | |
| 195 | + | if (ret && ret != ODB_READ_NOT_FOUND && errmsg) | |
| 196 | + | strbuf_addf(errmsg, _("loose object %s (stored in %s) is corrupt"), | |
| 197 | + | oid_to_hex(oid), path); | |
| 191 | 198 | if (stream_to_end) | |
| 192 | 199 | git_inflate_end(stream_to_end); | |
| 193 | 200 | if (map) | |
| @@ -206,10 +213,11 @@ out: | |||
| 206 | 213 | return ret; | |
| 207 | 214 | } | |
| 208 | 215 | ||
| 209 | - | static int odb_source_loose_read_object_info(struct odb_source *source, | |
| 210 | - | const struct object_id *oid, | |
| 211 | - | struct object_info *oi, | |
| 212 | - | enum object_info_flags flags) | |
| 216 | + | static enum odb_read_status odb_source_loose_read_object_info(struct odb_source *source, | |
| 217 | + | const struct object_id *oid, | |
| 218 | + | struct object_info *oi, | |
| 219 | + | enum object_info_flags flags, | |
| 220 | + | struct strbuf *errmsg) | |
| 213 | 221 | { | |
| 214 | 222 | struct odb_source_loose *loose = odb_source_loose_downcast(source); | |
| 215 | 223 | static struct strbuf buf = STRBUF_INIT; | |
| @@ -221,10 +229,10 @@ static int odb_source_loose_read_object_info(struct odb_source *source, | |||
| 221 | 229 | * second time. | |
| 222 | 230 | */ | |
| 223 | 231 | if (flags & OBJECT_INFO_SECOND_READ) | |
| 224 | - | return -1; | |
| 232 | + | return ODB_READ_NOT_FOUND; | |
| 225 | 233 | ||
| 226 | 234 | odb_loose_path(loose, &buf, oid); | |
| 227 | - | return read_object_info_from_path(loose, buf.buf, oid, oi, flags); | |
| 235 | + | return read_object_info_from_path(loose, buf.buf, oid, oi, flags, errmsg); | |
| 228 | 236 | } | |
| 229 | 237 | ||
| 230 | 238 | /* | |
| @@ -421,7 +429,7 @@ static int for_each_object_wrapper_cb(const struct object_id *oid, | |||
| 421 | 429 | if (data->request) { | |
| 422 | 430 | struct object_info oi = *data->request; | |
| 423 | 431 | ||
| 424 | - | if (read_object_info_from_path(data->loose, path, oid, &oi, 0) < 0) | |
| 432 | + | if (read_object_info_from_path(data->loose, path, oid, &oi, 0, NULL) < 0) | |
| 425 | 433 | return -1; | |
| 426 | 434 | ||
| 427 | 435 | return data->cb(oid, &oi, data->cb_data); | |
| @@ -439,7 +447,7 @@ static int for_each_prefixed_object_wrapper_cb(const struct object_id *oid, | |||
| 439 | 447 | struct object_info oi = *data->request; | |
| 440 | 448 | ||
| 441 | 449 | if (odb_source_read_object_info(&data->loose->base, | |
| 442 | - | oid, &oi, 0) < 0) | |
| 450 | + | oid, &oi, 0, NULL) < 0) | |
| 443 | 451 | return -1; | |
| 444 | 452 | ||
| 445 | 453 | return data->cb(oid, &oi, data->cb_data); | |
modified odb/source-packed.c
| @@ -2,7 +2,9 @@ | |||
| 2 | 2 | #include "abspath.h" | |
| 3 | 3 | #include "chdir-notify.h" | |
| 4 | 4 | #include "dir.h" | |
| 5 | + | #include "gettext.h" | |
| 5 | 6 | #include "git-zlib.h" | |
| 7 | + | #include "hex.h" | |
| 6 | 8 | #include "list-objects-filter-options.h" | |
| 7 | 9 | #include "mergesort.h" | |
| 8 | 10 | #include "midx.h" | |
| @@ -10,21 +12,23 @@ | |||
| 10 | 12 | #include "odb/streaming.h" | |
| 11 | 13 | #include "packfile.h" | |
| 12 | 14 | #include "pack-bitmap.h" | |
| 15 | + | #include "strbuf.h" | |
| 13 | 16 | ||
| 14 | 17 | static int find_pack_entry(struct odb_source_packed *store, | |
| 15 | 18 | const struct object_id *oid, | |
| 16 | - | struct pack_entry *e) | |
| 19 | + | struct pack_entry *e, | |
| 20 | + | struct packed_git **bad_pack) | |
| 17 | 21 | { | |
| 18 | 22 | struct packfile_list_entry *l; | |
| 19 | 23 | ||
| 20 | 24 | odb_source_prepare(&store->base, 0); | |
| 21 | - | if (store->midx && fill_midx_entry(store->midx, oid, e)) | |
| 25 | + | if (store->midx && fill_midx_entry(store->midx, oid, e, bad_pack)) | |
| 22 | 26 | return 1; | |
| 23 | 27 | ||
| 24 | 28 | for (l = store->packs.head; l; l = l->next) { | |
| 25 | 29 | struct packed_git *p = l->pack; | |
| 26 | 30 | ||
| 27 | - | if (!p->multi_pack_index && packfile_fill_entry(p, oid, e)) { | |
| 31 | + | if (!p->multi_pack_index && packfile_fill_entry(p, oid, e, bad_pack)) { | |
| 28 | 32 | if (!store->skip_mru_updates) | |
| 29 | 33 | packfile_list_prepend(&store->packs, p); | |
| 30 | 34 | return 1; | |
| @@ -34,12 +38,14 @@ static int find_pack_entry(struct odb_source_packed *store, | |||
| 34 | 38 | return 0; | |
| 35 | 39 | } | |
| 36 | 40 | ||
| 37 | - | static int odb_source_packed_read_object_info(struct odb_source *source, | |
| 38 | - | const struct object_id *oid, | |
| 39 | - | struct object_info *oi, | |
| 40 | - | enum object_info_flags flags) | |
| 41 | + | static enum odb_read_status odb_source_packed_read_object_info(struct odb_source *source, | |
| 42 | + | const struct object_id *oid, | |
| 43 | + | struct object_info *oi, | |
| 44 | + | enum object_info_flags flags, | |
| 45 | + | struct strbuf *errmsg) | |
| 41 | 46 | { | |
| 42 | 47 | struct odb_source_packed *packed = odb_source_packed_downcast(source); | |
| 48 | + | struct packed_git *bad_pack = NULL; | |
| 43 | 49 | struct pack_entry e; | |
| 44 | 50 | int ret; | |
| 45 | 51 | ||
| @@ -51,23 +57,45 @@ static int odb_source_packed_read_object_info(struct odb_source *source, | |||
| 51 | 57 | if (flags & OBJECT_INFO_SECOND_READ) | |
| 52 | 58 | odb_source_prepare(source, ODB_PREPARE_FLUSH_CACHES); | |
| 53 | 59 | ||
| 54 | - | if (!find_pack_entry(packed, oid, &e)) | |
| 55 | - | return 1; | |
| 60 | + | if (!find_pack_entry(packed, oid, &e, &bad_pack)) { | |
| 61 | + | /* | |
| 62 | + | * The lookup may have failed because the object is known to be | |
| 63 | + | * corrupt in one of the packfiles. Report the object as | |
| 64 | + | * corrupt instead of missing in that case. | |
| 65 | + | */ | |
| 66 | + | if (bad_pack) { | |
| 67 | + | ret = -1; | |
| 68 | + | goto out; | |
| 69 | + | } | |
| 70 | + | ||
| 71 | + | ret = ODB_READ_NOT_FOUND; | |
| 72 | + | goto out; | |
| 73 | + | } | |
| 56 | 74 | ||
| 57 | 75 | /* | |
| 58 | 76 | * We know that the caller doesn't actually need the | |
| 59 | 77 | * information below, so return early. | |
| 60 | 78 | */ | |
| 61 | - | if (!oi) | |
| 62 | - | return 0; | |
| 79 | + | if (!oi) { | |
| 80 | + | ret = 0; | |
| 81 | + | goto out; | |
| 82 | + | } | |
| 63 | 83 | ||
| 64 | 84 | ret = packed_object_info(packed, e.p, e.offset, oi); | |
| 65 | 85 | if (ret < 0) { | |
| 86 | + | bad_pack = e.p; | |
| 66 | 87 | mark_bad_packed_object(e.p, oid); | |
| 67 | - | return -1; | |
| 88 | + | goto out; | |
| 68 | 89 | } | |
| 69 | 90 | ||
| 70 | - | return 0; | |
| 91 | + | ret = 0; | |
| 92 | + | ||
| 93 | + | out: | |
| 94 | + | if (ret < 0 && bad_pack && errmsg) | |
| 95 | + | strbuf_addf(errmsg, _("packed object %s (stored in %s) is corrupt"), | |
| 96 | + | oid_to_hex(oid), bad_pack->pack_name); | |
| 97 | + | ||
| 98 | + | return ret; | |
| 71 | 99 | } | |
| 72 | 100 | ||
| 73 | 101 | static int odb_source_packed_read_object_stream(struct odb_read_stream **out, | |
| @@ -77,7 +105,7 @@ static int odb_source_packed_read_object_stream(struct odb_read_stream **out, | |||
| 77 | 105 | struct odb_source_packed *packed = odb_source_packed_downcast(source); | |
| 78 | 106 | struct pack_entry e; | |
| 79 | 107 | ||
| 80 | - | if (!find_pack_entry(packed, oid, &e)) | |
| 108 | + | if (!find_pack_entry(packed, oid, &e, NULL)) | |
| 81 | 109 | return -1; | |
| 82 | 110 | ||
| 83 | 111 | return packfile_read_object_stream(out, oid, e.p, e.offset); | |
| @@ -583,7 +611,7 @@ static int odb_source_packed_freshen_object(struct odb_source *source, | |||
| 583 | 611 | timesp = × | |
| 584 | 612 | } | |
| 585 | 613 | ||
| 586 | - | if (!find_pack_entry(packed, oid, &e)) | |
| 614 | + | if (!find_pack_entry(packed, oid, &e, NULL)) | |
| 587 | 615 | return 0; | |
| 588 | 616 | if (e.p->is_cruft) | |
| 589 | 617 | return 0; | |
modified odb/source.h
| @@ -27,6 +27,7 @@ enum odb_source_type { | |||
| 27 | 27 | ||
| 28 | 28 | struct object_id; | |
| 29 | 29 | struct odb_read_stream; | |
| 30 | + | struct strbuf; | |
| 30 | 31 | struct strvec; | |
| 31 | 32 | ||
| 32 | 33 | /* | |
| @@ -110,13 +111,17 @@ struct odb_source { | |||
| 110 | 111 | * second read in case they know that the first read would have | |
| 111 | 112 | * already surfaced the object without reloading any on-disk state. | |
| 112 | 113 | * | |
| 113 | - | * The callback is expected to return a negative error code in case | |
| 114 | - | * reading the object has failed, 0 otherwise. | |
| 114 | + | * The callback is expected to return an `enum odb_read_status`. Please | |
| 115 | + | * refer to the individual values that can be returned. In case reading | |
| 116 | + | * the object has failed with a generic error and `errmsg` is non-NULL, | |
| 117 | + | * the callback is expected to populate it with a human-readable | |
| 118 | + | * message that describes the failure. | |
| 115 | 119 | */ | |
| 116 | - | int (*read_object_info)(struct odb_source *source, | |
| 117 | - | const struct object_id *oid, | |
| 118 | - | struct object_info *oi, | |
| 119 | - | enum object_info_flags flags); | |
| 120 | + | enum odb_read_status (*read_object_info)(struct odb_source *source, | |
| 121 | + | const struct object_id *oid, | |
| 122 | + | struct object_info *oi, | |
| 123 | + | enum object_info_flags flags, | |
| 124 | + | struct strbuf *errmsg); | |
| 120 | 125 | ||
| 121 | 126 | /* | |
| 122 | 127 | * This callback is expected to create a new read stream that can be | |
| @@ -340,14 +345,19 @@ static inline void odb_source_prepare(struct odb_source *source, | |||
| 340 | 345 | ||
| 341 | 346 | /* | |
| 342 | 347 | * Read an object from the object database source identified by its object ID. | |
| 343 | - | * Returns 0 on success, a negative error code otherwise. | |
| 348 | + | * Please refer to `enum odb_read_status` for the individual error codes. | |
| 349 | + | * | |
| 350 | + | * In case reading the object has failed with a generic error and `errmsg` is | |
| 351 | + | * non-NULL it will be populated with a human-readable message that describes | |
| 352 | + | * the failure. | |
| 344 | 353 | */ | |
| 345 | - | static inline int odb_source_read_object_info(struct odb_source *source, | |
| 346 | - | const struct object_id *oid, | |
| 347 | - | struct object_info *oi, | |
| 348 | - | enum object_info_flags flags) | |
| 354 | + | static inline enum odb_read_status odb_source_read_object_info(struct odb_source *source, | |
| 355 | + | const struct object_id *oid, | |
| 356 | + | struct object_info *oi, | |
| 357 | + | enum object_info_flags flags, | |
| 358 | + | struct strbuf *errmsg) | |
| 349 | 359 | { | |
| 350 | - | return source->read_object_info(source, oid, oi, flags); | |
| 360 | + | return source->read_object_info(source, oid, oi, flags, errmsg); | |
| 351 | 361 | } | |
| 352 | 362 | ||
| 353 | 363 | /* | |
modified packfile.c
| @@ -985,23 +985,6 @@ void mark_bad_packed_object(struct packed_git *p, const struct object_id *oid) | |||
| 985 | 985 | oidset_insert(&p->bad_objects, oid); | |
| 986 | 986 | } | |
| 987 | 987 | ||
| 988 | - | const struct packed_git *has_packed_and_bad(struct repository *r, | |
| 989 | - | const struct object_id *oid) | |
| 990 | - | { | |
| 991 | - | struct odb_source *source; | |
| 992 | - | ||
| 993 | - | for (source = r->objects->sources; source; source = source->next) { | |
| 994 | - | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 995 | - | struct packfile_list_entry *e; | |
| 996 | - | ||
| 997 | - | for (e = files->packed->packs.head; e; e = e->next) | |
| 998 | - | if (oidset_contains(&e->pack->bad_objects, oid)) | |
| 999 | - | return e->pack; | |
| 1000 | - | } | |
| 1001 | - | ||
| 1002 | - | return NULL; | |
| 1003 | - | } | |
| 1004 | - | ||
| 1005 | 988 | off_t get_delta_base(struct packed_git *p, | |
| 1006 | 989 | struct pack_window **w_curs, | |
| 1007 | 990 | off_t *curpos, | |
| @@ -1859,13 +1842,17 @@ int is_pack_valid(struct packed_git *p) | |||
| 1859 | 1842 | ||
| 1860 | 1843 | int packfile_fill_entry(struct packed_git *p, | |
| 1861 | 1844 | const struct object_id *oid, | |
| 1862 | - | struct pack_entry *e) | |
| 1845 | + | struct pack_entry *e, | |
| 1846 | + | struct packed_git **bad_pack) | |
| 1863 | 1847 | { | |
| 1864 | 1848 | off_t offset; | |
| 1865 | 1849 | ||
| 1866 | 1850 | if (oidset_size(&p->bad_objects) && | |
| 1867 | - | oidset_contains(&p->bad_objects, oid)) | |
| 1851 | + | oidset_contains(&p->bad_objects, oid)) { | |
| 1852 | + | if (bad_pack && !*bad_pack) | |
| 1853 | + | *bad_pack = p; | |
| 1868 | 1854 | return 0; | |
| 1855 | + | } | |
| 1869 | 1856 | ||
| 1870 | 1857 | offset = find_pack_entry_one(oid, p); | |
| 1871 | 1858 | if (!offset) | |
| @@ -1941,7 +1928,7 @@ int has_object_pack(struct repository *r, const struct object_id *oid) | |||
| 1941 | 1928 | odb_prepare_alternates(r->objects); | |
| 1942 | 1929 | for (source = r->objects->sources; source; source = source->next) { | |
| 1943 | 1930 | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 1944 | - | if (!odb_source_read_object_info(&files->packed->base, oid, NULL, 0)) | |
| 1931 | + | if (!odb_source_read_object_info(&files->packed->base, oid, NULL, 0, NULL)) | |
| 1945 | 1932 | return 1; | |
| 1946 | 1933 | } | |
| 1947 | 1934 | ||
| @@ -1962,7 +1949,7 @@ int has_object_kept_pack(struct repository *r, const struct object_id *oid, | |||
| 1962 | 1949 | ||
| 1963 | 1950 | for (; *cache; cache++) { | |
| 1964 | 1951 | struct packed_git *p = *cache; | |
| 1965 | - | if (packfile_fill_entry(p, oid, &e)) | |
| 1952 | + | if (packfile_fill_entry(p, oid, &e, NULL)) | |
| 1966 | 1953 | return 1; | |
| 1967 | 1954 | } | |
| 1968 | 1955 | } | |
modified packfile.h
| @@ -294,7 +294,8 @@ off_t find_pack_entry_one(const struct object_id *oid, struct packed_git *); | |||
| 294 | 294 | ||
| 295 | 295 | int packfile_fill_entry(struct packed_git *p, | |
| 296 | 296 | const struct object_id *oid, | |
| 297 | - | struct pack_entry *e); | |
| 297 | + | struct pack_entry *e, | |
| 298 | + | struct packed_git **bad_pack); | |
| 298 | 299 | ||
| 299 | 300 | int is_pack_valid(struct packed_git *); | |
| 300 | 301 | void *unpack_entry(struct repository *r, struct packed_git *, off_t, | |
| @@ -328,7 +329,6 @@ int packed_object_info_with_index_pos(struct odb_source_packed *source, | |||
| 328 | 329 | uint32_t *maybe_index_pos, struct object_info *oi); | |
| 329 | 330 | ||
| 330 | 331 | void mark_bad_packed_object(struct packed_git *, const struct object_id *); | |
| 331 | - | const struct packed_git *has_packed_and_bad(struct repository *, const struct object_id *); | |
| 332 | 332 | ||
| 333 | 333 | int has_object_pack(struct repository *r, const struct object_id *oid); | |
| 334 | 334 | int has_object_kept_pack(struct repository *r, const struct object_id *oid, | |
modified read-cache-ll.h
| @@ -391,11 +391,14 @@ int remove_index_entry_at(struct index_state *, int pos); | |||
| 391 | 391 | ||
| 392 | 392 | void remove_marked_cache_entries(struct index_state *istate, int invalidate); | |
| 393 | 393 | int remove_file_from_index(struct index_state *, const char *path); | |
| 394 | + | int remove_file_from_index_with_flags(struct index_state *, const char *, int); | |
| 395 | + | ||
| 394 | 396 | #define ADD_CACHE_VERBOSE 1 | |
| 395 | 397 | #define ADD_CACHE_PRETEND 2 | |
| 396 | 398 | #define ADD_CACHE_IGNORE_ERRORS 4 | |
| 397 | 399 | #define ADD_CACHE_IGNORE_REMOVAL 8 | |
| 398 | 400 | #define ADD_CACHE_INTENT 16 | |
| 401 | + | ||
| 399 | 402 | /* | |
| 400 | 403 | * These two are used to add the contents of the file at path | |
| 401 | 404 | * to the index, marking the working tree up-to-date by storing | |
modified read-cache.c
| @@ -636,6 +636,20 @@ int remove_file_from_index(struct index_state *istate, const char *path) | |||
| 636 | 636 | return 0; | |
| 637 | 637 | } | |
| 638 | 638 | ||
| 639 | + | int remove_file_from_index_with_flags(struct index_state *istate, | |
| 640 | + | const char *path, | |
| 641 | + | int flags) | |
| 642 | + | { | |
| 643 | + | int verbose = flags & (ADD_CACHE_VERBOSE | ADD_CACHE_PRETEND); | |
| 644 | + | int pretend = flags & ADD_CACHE_PRETEND; | |
| 645 | + | ||
| 646 | + | if (verbose) | |
| 647 | + | printf(_("remove '%s'\n"), path); | |
| 648 | + | if (pretend) | |
| 649 | + | return 0; | |
| 650 | + | return remove_file_from_index(istate, path); | |
| 651 | + | } | |
| 652 | + | ||
| 639 | 653 | static int compare_name(struct cache_entry *ce, const char *path, int namelen) | |
| 640 | 654 | { | |
| 641 | 655 | return namelen != ce_namelen(ce) || memcmp(path, ce->name, namelen); | |
| @@ -3909,32 +3923,33 @@ static int fix_unmerged_status(struct diff_filepair *p, | |||
| 3909 | 3923 | } | |
| 3910 | 3924 | ||
| 3911 | 3925 | static int skip_submodule(const char *path, | |
| 3912 | - | struct repository *repo, | |
| 3913 | - | struct pathspec *pathspec, | |
| 3914 | - | int ignored_too) | |
| 3915 | - | { | |
| 3916 | - | struct stat st; | |
| 3917 | - | const struct submodule *sub; | |
| 3918 | - | int pathspec_matches = 0; | |
| 3919 | - | int ps_i; | |
| 3920 | - | char *norm_pathspec = NULL; | |
| 3921 | - | ||
| 3922 | - | /* Only consider if path is a directory */ | |
| 3923 | - | if (lstat(path, &st) || !S_ISDIR(st.st_mode)) | |
| 3926 | + | struct repository *repo, | |
| 3927 | + | struct pathspec *pathspec, | |
| 3928 | + | int ignored_too) | |
| 3929 | + | { | |
| 3930 | + | struct stat st; | |
| 3931 | + | const struct submodule *sub; | |
| 3932 | + | int pathspec_matches = 0; | |
| 3933 | + | int ps_i; | |
| 3934 | + | char *norm_pathspec = NULL; | |
| 3935 | + | ||
| 3936 | + | /* Only consider if path is a directory */ | |
| 3937 | + | if (lstat(path, &st) || !S_ISDIR(st.st_mode)) | |
| 3924 | 3938 | return 0; | |
| 3925 | 3939 | ||
| 3926 | - | /* Check if it's a submodule with ignore=all */ | |
| 3927 | - | sub = submodule_from_path(repo, null_oid(the_hash_algo), path); | |
| 3928 | - | if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, "all")) | |
| 3940 | + | /* Check if it's a submodule with ignore=all */ | |
| 3941 | + | sub = submodule_from_path(repo, null_oid(the_hash_algo), path); | |
| 3942 | + | if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, "all")) | |
| 3929 | 3943 | return 0; | |
| 3930 | 3944 | ||
| 3931 | - | trace_printf("ignore=all: %s\n", path); | |
| 3932 | - | trace_printf("pathspec %s\n", (pathspec && pathspec->nr) | |
| 3933 | - | ? "has pathspec" | |
| 3934 | - | : "no pathspec"); | |
| 3945 | + | trace_printf("ignore=all: %s\n", path); | |
| 3946 | + | trace_printf("pathspec %s\n", | |
| 3947 | + | ((pathspec && pathspec->nr) | |
| 3948 | + | ? "has pathspec" | |
| 3949 | + | : "no pathspec")); | |
| 3935 | 3950 | ||
| 3936 | - | /* Check if submodule path is explicitly mentioned in pathspec */ | |
| 3937 | - | if (pathspec) { | |
| 3951 | + | /* Check if submodule path is explicitly mentioned in pathspec */ | |
| 3952 | + | if (pathspec) { | |
| 3938 | 3953 | for (ps_i = 0; ps_i < pathspec->nr; ps_i++) { | |
| 3939 | 3954 | const char *m = pathspec->items[ps_i].match; | |
| 3940 | 3955 | if (!m) | |
| @@ -3948,28 +3963,29 @@ static int skip_submodule(const char *path, | |||
| 3948 | 3963 | } | |
| 3949 | 3964 | FREE_AND_NULL(norm_pathspec); | |
| 3950 | 3965 | } | |
| 3951 | - | } | |
| 3966 | + | } | |
| 3952 | 3967 | ||
| 3953 | - | /* If explicitly matched and forced, allow adding */ | |
| 3954 | - | if (pathspec_matches) { | |
| 3968 | + | /* If explicitly matched and forced, allow adding */ | |
| 3969 | + | if (pathspec_matches) { | |
| 3955 | 3970 | if (ignored_too && ignored_too > 0) { | |
| 3956 | 3971 | trace_printf("Add submodule due to --force: %s\n", path); | |
| 3957 | 3972 | return 0; | |
| 3958 | 3973 | } else { | |
| 3959 | 3974 | advise_if_enabled(ADVICE_ADD_IGNORED_FILE, | |
| 3960 | - | _("Skipping submodule due to ignore=all: %s\n" | |
| 3961 | - | "Use --force if you really want to add the submodule."), path); | |
| 3975 | + | _("Skipping submodule due to ignore=all: %s\n" | |
| 3976 | + | "Use --force if you really want to " | |
| 3977 | + | "add the submodule."), path); | |
| 3962 | 3978 | return 1; | |
| 3963 | 3979 | } | |
| 3964 | - | } | |
| 3980 | + | } | |
| 3965 | 3981 | ||
| 3966 | - | /* No explicit pathspec match -> skip silently */ | |
| 3967 | - | trace_printf("Pathspec to submodule does not match explicitly: %s\n", path); | |
| 3968 | - | return 1; | |
| 3982 | + | /* No explicit pathspec match -> skip silently */ | |
| 3983 | + | trace_printf("Pathspec to submodule does not match explicitly: %s\n", path); | |
| 3984 | + | return 1; | |
| 3969 | 3985 | } | |
| 3970 | 3986 | ||
| 3971 | 3987 | static void update_callback(struct diff_queue_struct *q, | |
| 3972 | - | struct diff_options *opt UNUSED, void *cbdata) | |
| 3988 | + | struct diff_options *opt UNUSED, void *cbdata) | |
| 3973 | 3989 | { | |
| 3974 | 3990 | int i; | |
| 3975 | 3991 | struct update_callback_data *data = cbdata; | |
| @@ -3979,7 +3995,7 @@ static void update_callback(struct diff_queue_struct *q, | |||
| 3979 | 3995 | const char *path = p->one->path; | |
| 3980 | 3996 | ||
| 3981 | 3997 | if (!data->include_sparse && | |
| 3982 | - | !path_in_sparse_checkout(path, data->index)) | |
| 3998 | + | !path_in_sparse_checkout(path, data->index)) | |
| 3983 | 3999 | continue; | |
| 3984 | 4000 | ||
| 3985 | 4001 | switch (fix_unmerged_status(p, data)) { | |
| @@ -3988,8 +4004,8 @@ static void update_callback(struct diff_queue_struct *q, | |||
| 3988 | 4004 | case DIFF_STATUS_MODIFIED: | |
| 3989 | 4005 | case DIFF_STATUS_TYPE_CHANGED: | |
| 3990 | 4006 | if (skip_submodule(path, data->repo, | |
| 3991 | - | data->pathspec, | |
| 3992 | - | data->ignored_too)) | |
| 4007 | + | data->pathspec, | |
| 4008 | + | data->ignored_too)) | |
| 3993 | 4009 | continue; | |
| 3994 | 4010 | ||
| 3995 | 4011 | if (add_file_to_index(data->index, path, data->flags)) { | |
| @@ -4001,10 +4017,7 @@ static void update_callback(struct diff_queue_struct *q, | |||
| 4001 | 4017 | case DIFF_STATUS_DELETED: | |
| 4002 | 4018 | if (data->flags & ADD_CACHE_IGNORE_REMOVAL) | |
| 4003 | 4019 | break; | |
| 4004 | - | if (!(data->flags & ADD_CACHE_PRETEND)) | |
| 4005 | - | remove_file_from_index(data->index, path); | |
| 4006 | - | if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE)) | |
| 4007 | - | printf(_("remove '%s'\n"), path); | |
| 4020 | + | remove_file_from_index_with_flags(data->index, path, data->flags); | |
| 4008 | 4021 | break; | |
| 4009 | 4022 | } | |
| 4010 | 4023 | } | |
modified replay.c
| @@ -327,6 +327,13 @@ static struct commit *pick_regular_commit(struct repository *repo, | |||
| 327 | 327 | merge_opt->ancestor = NULL; | |
| 328 | 328 | merge_opt->branch2 = NULL; | |
| 329 | 329 | ||
| 330 | + | if (result->clean < 0) { | |
| 331 | + | error(_("merge of %s onto %s failed"), | |
| 332 | + | oid_to_hex(&pickme->object.oid), | |
| 333 | + | oid_to_hex(&replayed_base->object.oid)); | |
| 334 | + | return NULL; | |
| 335 | + | } | |
| 336 | + | ||
| 330 | 337 | if (!result->clean) | |
| 331 | 338 | return NULL; | |
| 332 | 339 | ||
modified repository.c
| @@ -74,7 +74,6 @@ void initialize_repository(struct repository *repo) | |||
| 74 | 74 | index_state_init(repo->index, repo); | |
| 75 | 75 | repo->check_deprecated_config = true; | |
| 76 | 76 | repo->bare_cfg = -1; | |
| 77 | - | repo->fetch_if_missing = 1; | |
| 78 | 77 | repo_config_values_init(&repo->config_values_private_); | |
| 79 | 78 | ||
| 80 | 79 | /* | |
modified repository.h
| @@ -184,12 +184,6 @@ struct repository { | |||
| 184 | 184 | /* True if commit-graph has been disabled within this process. */ | |
| 185 | 185 | int commit_graph_disabled; | |
| 186 | 186 | ||
| 187 | - | /* | |
| 188 | - | * Controls whether the repository should lazily fetch missing | |
| 189 | - | * objects from promisor remotes. Defaults to 1. | |
| 190 | - | */ | |
| 191 | - | int fetch_if_missing; | |
| 192 | - | ||
| 193 | 187 | /* | |
| 194 | 188 | * Lazily-populated cache mapping hook event names to configured hooks. | |
| 195 | 189 | * NULL until first hook use. | |
modified rerere.c
| @@ -331,33 +331,6 @@ static int rerere_file_getline(struct strbuf *sb, struct rerere_io *io_) | |||
| 331 | 331 | return strbuf_getwholeline(sb, io->input, '\n'); | |
| 332 | 332 | } | |
| 333 | 333 | ||
| 334 | - | /* | |
| 335 | - | * Require the exact number of conflict marker letters, no more, no | |
| 336 | - | * less, followed by SP or any whitespace | |
| 337 | - | * (including LF). | |
| 338 | - | */ | |
| 339 | - | static int is_cmarker(char *buf, int marker_char, int marker_size) | |
| 340 | - | { | |
| 341 | - | int want_sp; | |
| 342 | - | ||
| 343 | - | /* | |
| 344 | - | * The beginning of our version and the end of their version | |
| 345 | - | * always are labeled like "<<<<< ours" or ">>>>> theirs", | |
| 346 | - | * hence we set want_sp for them. Note that the version from | |
| 347 | - | * the common ancestor in diff3-style output is not always | |
| 348 | - | * labelled (e.g. "||||| common" is often seen but "|||||" | |
| 349 | - | * alone is also valid), so we do not set want_sp. | |
| 350 | - | */ | |
| 351 | - | want_sp = (marker_char == '<') || (marker_char == '>'); | |
| 352 | - | ||
| 353 | - | while (marker_size--) | |
| 354 | - | if (*buf++ != marker_char) | |
| 355 | - | return 0; | |
| 356 | - | if (want_sp && *buf != ' ') | |
| 357 | - | return 0; | |
| 358 | - | return isspace(*buf); | |
| 359 | - | } | |
| 360 | - | ||
| 361 | 334 | static void rerere_strbuf_putconflict(struct strbuf *buf, int ch, size_t size) | |
| 362 | 335 | { | |
| 363 | 336 | strbuf_addchars(buf, ch, size); | |
| @@ -375,7 +348,8 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io, | |||
| 375 | 348 | int has_conflicts = -1; | |
| 376 | 349 | ||
| 377 | 350 | while (!io->getline(&buf, io)) { | |
| 378 | - | if (is_cmarker(buf.buf, '<', marker_size)) { | |
| 351 | + | int marker = is_conflict_marker_line(buf.buf, buf.len, marker_size); | |
| 352 | + | if (marker == '<') { | |
| 379 | 353 | if (handle_conflict(&conflict, io, marker_size, NULL) < 0) | |
| 380 | 354 | break; | |
| 381 | 355 | if (hunk == RR_SIDE_1) | |
| @@ -383,15 +357,15 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io, | |||
| 383 | 357 | else | |
| 384 | 358 | strbuf_addbuf(&two, &conflict); | |
| 385 | 359 | strbuf_release(&conflict); | |
| 386 | - | } else if (is_cmarker(buf.buf, '|', marker_size)) { | |
| 360 | + | } else if (marker == '|') { | |
| 387 | 361 | if (hunk != RR_SIDE_1) | |
| 388 | 362 | break; | |
| 389 | 363 | hunk = RR_ORIGINAL; | |
| 390 | - | } else if (is_cmarker(buf.buf, '=', marker_size)) { | |
| 364 | + | } else if (marker == '=') { | |
| 391 | 365 | if (hunk != RR_SIDE_1 && hunk != RR_ORIGINAL) | |
| 392 | 366 | break; | |
| 393 | 367 | hunk = RR_SIDE_2; | |
| 394 | - | } else if (is_cmarker(buf.buf, '>', marker_size)) { | |
| 368 | + | } else if (marker == '>') { | |
| 395 | 369 | if (hunk != RR_SIDE_2) | |
| 396 | 370 | break; | |
| 397 | 371 | if (strbuf_cmp(&one, &two) > 0) | |
| @@ -442,7 +416,7 @@ static int handle_path(unsigned char *hash, struct rerere_io *io, int marker_siz | |||
| 442 | 416 | git_hash_init(&ctx, the_hash_algo); | |
| 443 | 417 | ||
| 444 | 418 | while (!io->getline(&buf, io)) { | |
| 445 | - | if (is_cmarker(buf.buf, '<', marker_size)) { | |
| 419 | + | if (is_conflict_marker_line(buf.buf, buf.len, marker_size) == '<') { | |
| 446 | 420 | has_conflicts = handle_conflict(&out, io, marker_size, | |
| 447 | 421 | hash ? &ctx : NULL); | |
| 448 | 422 | if (has_conflicts < 0) | |
modified revision.c
| @@ -2732,7 +2732,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg | |||
| 2732 | 2732 | revs->ignore_missing = 1; | |
| 2733 | 2733 | } else if (opt && opt->allow_exclude_promisor_objects && | |
| 2734 | 2734 | !strcmp(arg, "--exclude-promisor-objects")) { | |
| 2735 | - | if (revs->repo->fetch_if_missing) | |
| 2735 | + | if (fetch_if_missing) | |
| 2736 | 2736 | BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0"); | |
| 2737 | 2737 | revs->exclude_promisor_objects = 1; | |
| 2738 | 2738 | } else { | |
modified sideband.c
| @@ -445,6 +445,7 @@ void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_ma | |||
| 445 | 445 | const char *p = data; | |
| 446 | 446 | ||
| 447 | 447 | while (sz) { | |
| 448 | + | struct iovec iov[2]; | |
| 448 | 449 | unsigned n; | |
| 449 | 450 | char hdr[5]; | |
| 450 | 451 | ||
| @@ -454,12 +455,19 @@ void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_ma | |||
| 454 | 455 | if (0 <= band) { | |
| 455 | 456 | xsnprintf(hdr, sizeof(hdr), "%04x", n + 5); | |
| 456 | 457 | hdr[4] = band; | |
| 457 | - | write_or_die(fd, hdr, 5); | |
| 458 | + | iov[0].iov_base = hdr; | |
| 459 | + | iov[0].iov_len = 5; | |
| 458 | 460 | } else { | |
| 459 | 461 | xsnprintf(hdr, sizeof(hdr), "%04x", n + 4); | |
| 460 | - | write_or_die(fd, hdr, 4); | |
| 462 | + | iov[0].iov_base = hdr; | |
| 463 | + | iov[0].iov_len = 4; | |
| 461 | 464 | } | |
| 462 | - | write_or_die(fd, p, n); | |
| 465 | + | ||
| 466 | + | iov[1].iov_base = (void *) p; | |
| 467 | + | iov[1].iov_len = n; | |
| 468 | + | ||
| 469 | + | writev_or_die(fd, iov, ARRAY_SIZE(iov)); | |
| 470 | + | ||
| 463 | 471 | p += n; | |
| 464 | 472 | sz -= n; | |
| 465 | 473 | } | |
modified t/helper/test-read-midx.c
| @@ -82,7 +82,7 @@ static int read_midx_file(const char *object_dir, const char *checksum, | |||
| 82 | 82 | for (i = 0; i < m->num_objects; i++) { | |
| 83 | 83 | nth_midxed_object_oid(&oid, m, | |
| 84 | 84 | i + m->num_objects_in_base); | |
| 85 | - | fill_midx_entry(m, &oid, &e); | |
| 85 | + | fill_midx_entry(m, &oid, &e, NULL); | |
| 86 | 86 | ||
| 87 | 87 | printf("%s %"PRIu64"\t%s\n", | |
| 88 | 88 | oid_to_hex(&oid), e.offset, e.p->pack_name); | |
modified t/meson.build
| @@ -305,6 +305,7 @@ integration_tests = [ | |||
| 305 | 305 | 't2204-add-ignored.sh', | |
| 306 | 306 | 't2205-add-worktree-config.sh', | |
| 307 | 307 | 't2206-add-submodule-ignored.sh', | |
| 308 | + | 't2207-add-resolved.sh', | |
| 308 | 309 | 't2300-cd-to-toplevel.sh', | |
| 309 | 310 | 't2400-worktree-add.sh', | |
| 310 | 311 | 't2401-worktree-prune.sh', | |
modified t/t0213-trace2-ancestry.sh
| @@ -31,12 +31,15 @@ PATH="$TTDIR:$PATH" && export PATH | |||
| 31 | 31 | # no cmd_ancestry event is emitted. We detect this at runtime and | |
| 32 | 32 | # skip the format-specific tests accordingly. | |
| 33 | 33 | ||
| 34 | - | # Determine if cmd_ancestry is supported on this platform. | |
| 34 | + | # Enable these tests only when cmd_ancestry reports real process names. | |
| 35 | + | # The procinfo stub emits no event; under user-mode emulation (e.g. | |
| 36 | + | # qemu-user) /proc reports the emulator, not the guest. Spawn test-tool | |
| 37 | + | # from test-tool and require "test-tool" in the child's ancestry. | |
| 35 | 38 | test_expect_success 'detect cmd_ancestry support' ' | |
| 36 | 39 | test_when_finished "rm -f trace.detect" && | |
| 37 | 40 | GIT_TRACE2_BRIEF=1 GIT_TRACE2="$(pwd)/trace.detect" \ | |
| 38 | - | test-tool trace2 001return 0 && | |
| 39 | - | if grep -q "^cmd_ancestry" trace.detect | |
| 41 | + | test-tool trace2 004child test-tool trace2 001return 0 && | |
| 42 | + | if grep -q "^cmd_ancestry.*test-tool" trace.detect | |
| 40 | 43 | then | |
| 41 | 44 | test_set_prereq TRACE2_ANCESTRY | |
| 42 | 45 | fi | |
modified t/t1060-object-corruption.sh
| @@ -145,4 +145,22 @@ test_expect_success 'partial clone of corrupted repository' ' | |||
| 145 | 145 | test_must_fail git -C corrupt-partial checkout --force | |
| 146 | 146 | ' | |
| 147 | 147 | ||
| 148 | + | test_expect_success 'corrupted loose commit can be read from alternate' ' | |
| 149 | + | git init repo-a && | |
| 150 | + | tree=$(git -C repo-a write-tree) && | |
| 151 | + | commit=$(git -C repo-a commit-tree $tree </dev/null) && | |
| 152 | + | ||
| 153 | + | cp -r repo-a repo-b && | |
| 154 | + | ( | |
| 155 | + | cd repo-b && | |
| 156 | + | echo ../../../repo-a/.git/objects >.git/objects/info/alternates && | |
| 157 | + | corrupt_byte "$commit" 1 | |
| 158 | + | ) && | |
| 159 | + | ||
| 160 | + | git -C repo-a cat-file -p "$commit" >expect && | |
| 161 | + | git -C repo-b cat-file -p "$commit" >actual 2>err && | |
| 162 | + | test_cmp expect actual && | |
| 163 | + | test_grep "inflate: data stream error" err | |
| 164 | + | ' | |
| 165 | + | ||
| 148 | 166 | test_done | |
added t/t2207-add-resolved.sh mode 100755
| @@ -0,0 +1,108 @@ | |||
| 1 | + | #!/bin/sh | |
| 2 | + | ||
| 3 | + | test_description='git add --resolved | |
| 4 | + | ||
| 5 | + | Test that "git add --resolved" stages conflict-resolved paths and | |
| 6 | + | refuses to stage when conflict markers remain.' | |
| 7 | + | ||
| 8 | + | . ./test-lib.sh | |
| 9 | + | ||
| 10 | + | test_expect_success 'setup repo' ' | |
| 11 | + | echo base >file1.txt && | |
| 12 | + | echo base >file2.txt && | |
| 13 | + | echo base >file3.txt && | |
| 14 | + | echo base >file4.txt && | |
| 15 | + | git add file1.txt file2.txt file3.txt file4.txt && | |
| 16 | + | git commit -m initial && | |
| 17 | + | ||
| 18 | + | git branch topic && | |
| 19 | + | echo "ours 1" >file1.txt && | |
| 20 | + | echo "ours 2" >file2.txt && | |
| 21 | + | echo "ours 3" >file3.txt && | |
| 22 | + | git commit -a -m ours && | |
| 23 | + | ||
| 24 | + | git checkout topic && | |
| 25 | + | echo "theirs 1" >file1.txt && | |
| 26 | + | echo "theirs 2" >file2.txt && | |
| 27 | + | echo "theirs 3" >file3.txt && | |
| 28 | + | git commit -a -m theirs && | |
| 29 | + | ||
| 30 | + | git checkout @{-1} | |
| 31 | + | ' | |
| 32 | + | ||
| 33 | + | test_expect_success 'git add --resolved refuses files with conflict markers' ' | |
| 34 | + | test_when_finished "git reset --hard HEAD" && | |
| 35 | + | test_must_fail git merge topic && | |
| 36 | + | echo "resolved 1" >file1.txt && | |
| 37 | + | test_must_fail git add --resolved 2>err && | |
| 38 | + | test_grep "the following paths still have conflict markers:" err && | |
| 39 | + | test_grep "file2.txt" err && | |
| 40 | + | test_grep "file3.txt" err && | |
| 41 | + | # Index should remain unmerged for all files | |
| 42 | + | git ls-files -u file1.txt >unmerged && | |
| 43 | + | test_line_count = 3 unmerged | |
| 44 | + | ' | |
| 45 | + | ||
| 46 | + | test_expect_success 'git add --resolved succeeds when all conflict markers are removed' ' | |
| 47 | + | test_when_finished "git reset --hard HEAD" && | |
| 48 | + | test_must_fail git merge topic && | |
| 49 | + | echo "resolved 1" >file1.txt && | |
| 50 | + | echo "resolved 2" >file2.txt && | |
| 51 | + | echo "resolved 3" >file3.txt && | |
| 52 | + | git add --resolved && | |
| 53 | + | git ls-files -u >unmerged && | |
| 54 | + | test_must_be_empty unmerged && | |
| 55 | + | git ls-files -s file1.txt file2.txt file3.txt >staged && | |
| 56 | + | test_line_count = 3 staged | |
| 57 | + | ' | |
| 58 | + | ||
| 59 | + | test_expect_success 'git add --resolved ignores unconflicted modified files' ' | |
| 60 | + | test_when_finished "git reset --hard HEAD" && | |
| 61 | + | echo "unconflicted local change" >>file4.txt && | |
| 62 | + | test_must_fail git merge topic && | |
| 63 | + | echo "resolved 1" >file1.txt && | |
| 64 | + | echo "resolved 2" >file2.txt && | |
| 65 | + | echo "resolved 3" >file3.txt && | |
| 66 | + | git add --resolved && | |
| 67 | + | # file1, file2, file3 should be staged as resolved | |
| 68 | + | git ls-files -u >unmerged && | |
| 69 | + | test_must_be_empty unmerged && | |
| 70 | + | # file4 should remain unstaged in working tree | |
| 71 | + | git diff file4.txt >diff_out && | |
| 72 | + | test_grep "unconflicted local change" diff_out && | |
| 73 | + | git diff --cached file4.txt >cached_out && | |
| 74 | + | test_must_be_empty cached_out | |
| 75 | + | ' | |
| 76 | + | ||
| 77 | + | test_expect_success 'git add --resolved handles file removals' ' | |
| 78 | + | test_when_finished "git reset --hard HEAD" && | |
| 79 | + | test_must_fail git merge topic && | |
| 80 | + | echo "resolved 1" >file1.txt && | |
| 81 | + | rm file2.txt && | |
| 82 | + | echo "resolved 3" >file3.txt && | |
| 83 | + | git add --resolved && | |
| 84 | + | git ls-files -s file2.txt >out && | |
| 85 | + | test_must_be_empty out | |
| 86 | + | ' | |
| 87 | + | ||
| 88 | + | test_expect_success 'git add --resolved honors pathspec' ' | |
| 89 | + | test_when_finished "git reset --hard HEAD" && | |
| 90 | + | test_must_fail git merge topic && | |
| 91 | + | echo "resolved 1" >file1.txt && | |
| 92 | + | # file2.txt and file3.txt still have conflict markers, | |
| 93 | + | # but pathspec targets only file1.txt | |
| 94 | + | git add --resolved file1.txt && | |
| 95 | + | git ls-files -u file1.txt >unmerged1 && | |
| 96 | + | test_must_be_empty unmerged1 && | |
| 97 | + | git ls-files -u file2.txt >unmerged2 && | |
| 98 | + | test_line_count = 3 unmerged2 | |
| 99 | + | ' | |
| 100 | + | ||
| 101 | + | test_expect_success 'git add --resolved incompatibility with -u and -A' ' | |
| 102 | + | test_must_fail git add --resolved -u 2>err1 && | |
| 103 | + | test_grep "cannot be used together" err1 && | |
| 104 | + | test_must_fail git add --resolved -A 2>err2 && | |
| 105 | + | test_grep "cannot be used together" err2 | |
| 106 | + | ' | |
| 107 | + | ||
| 108 | + | test_done | |
modified t/t3650-replay-basics.sh
| @@ -565,4 +565,38 @@ test_expect_success '--onto with --ref rejects multiple revision ranges' ' | |||
| 565 | 565 | test_grep "cannot be used with multiple revision ranges" err | |
| 566 | 566 | ' | |
| 567 | 567 | ||
| 568 | + | test_expect_success 'replay fails without segfault when objects are missing' ' | |
| 569 | + | test_when_finished "rm -fr unreadable" && | |
| 570 | + | git init unreadable && | |
| 571 | + | ( | |
| 572 | + | cd unreadable && | |
| 573 | + | ||
| 574 | + | test_write_lines l1 l2 l3 l4 l5 l6 l7 l8 >f && | |
| 575 | + | git add f && | |
| 576 | + | git commit -m base && | |
| 577 | + | git branch base && | |
| 578 | + | ||
| 579 | + | test_write_lines l1 l2 l3 l4 l5 l6 l7 CHANGED >f && | |
| 580 | + | git commit -am side && | |
| 581 | + | git branch side && | |
| 582 | + | ||
| 583 | + | git switch -c onto base && | |
| 584 | + | test_write_lines CHANGED l2 l3 l4 l5 l6 l7 l8 >f && | |
| 585 | + | git commit -am onto && | |
| 586 | + | ||
| 587 | + | # The replay works while every object is readable. | |
| 588 | + | git replay --onto onto base..side && | |
| 589 | + | ||
| 590 | + | # Removing the onto tree makes parse_tree() fail during the | |
| 591 | + | # incore merge, driving clean < 0 with a NULL result tree. | |
| 592 | + | onto_tree=$(git rev-parse onto^{tree}) && | |
| 593 | + | obj=$(test_oid_to_path "$onto_tree") && | |
| 594 | + | mv .git/objects/${obj} saved-tree && | |
| 595 | + | ||
| 596 | + | # Ensure replay gracefully handles the missing object | |
| 597 | + | test_must_fail git replay --onto onto base..side 2>err && | |
| 598 | + | test_grep -e "Could not read" -e "collecting merge info failed" err | |
| 599 | + | ) | |
| 600 | + | ' | |
| 601 | + | ||
| 568 | 602 | test_done | |
modified t/t5550-http-fetch-dumb.sh
| @@ -293,6 +293,210 @@ test_expect_success 'http-fetch --packfile' ' | |||
| 293 | 293 | git -C packfileclient cat-file -e "$HASH" | |
| 294 | 294 | ' | |
| 295 | 295 | ||
| 296 | + | test_expect_success 'http-fetch --packfile accepts an already complete partial' ' | |
| 297 | + | git init packfileclient-complete && | |
| 298 | + | p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && | |
| 299 | + | ls objects/pack/pack-*.pack) && | |
| 300 | + | packhash=$(basename "$p" .pack) && | |
| 301 | + | packhash=${packhash#pack-} && | |
| 302 | + | tmpfile="packfileclient-complete/.git/objects/pack/pack-$packhash.pack.temp" && | |
| 303 | + | cp "$HTTPD_DOCUMENT_ROOT_PATH/repo_pack.git/$p" "$tmpfile" && | |
| 304 | + | chmod u+w "$tmpfile" && | |
| 305 | + | GIT_TRACE_CURL="$TRASH_DIRECTORY/complete.trace" \ | |
| 306 | + | git -C packfileclient-complete http-fetch --packfile="$packhash" \ | |
| 307 | + | --index-pack-arg=index-pack \ | |
| 308 | + | --index-pack-arg=--stdin --index-pack-arg=--keep \ | |
| 309 | + | "$HTTPD_URL/dumb/repo_pack.git/$p" >out && | |
| 310 | + | test_grep "416 Requested Range Not Satisfiable" complete.trace && | |
| 311 | + | test_path_is_missing "$tmpfile" && | |
| 312 | + | git -C packfileclient-complete cat-file -e "$HASH" | |
| 313 | + | ' | |
| 314 | + | ||
| 315 | + | test_expect_success 'http-fetch --packfile resumes a partial download' ' | |
| 316 | + | git init packfileclient-resume && | |
| 317 | + | p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && | |
| 318 | + | ls objects/pack/pack-*.pack) && | |
| 319 | + | tmpfile="packfileclient-resume/.git/objects/pack/pack-$ARBITRARY.pack.temp" && | |
| 320 | + | test_copy_bytes 64 <"$HTTPD_DOCUMENT_ROOT_PATH/repo_pack.git/$p" >"$tmpfile" && | |
| 321 | + | GIT_TRACE_CURL="$TRASH_DIRECTORY/resume.trace" \ | |
| 322 | + | git -C packfileclient-resume http-fetch --packfile="$ARBITRARY" \ | |
| 323 | + | --index-pack-arg=index-pack --index-pack-arg=--stdin \ | |
| 324 | + | --index-pack-arg=--keep \ | |
| 325 | + | "$HTTPD_URL/dumb/repo_pack.git/$p" >out && | |
| 326 | + | test_grep "Range: bytes=64-" resume.trace && | |
| 327 | + | test_path_is_missing "$tmpfile" && | |
| 328 | + | git -C packfileclient-resume cat-file -e "$HASH" | |
| 329 | + | ' | |
| 330 | + | ||
| 331 | + | test_expect_success 'http-fetch --packfile permits unlink while indexing' ' | |
| 332 | + | git init packfileclient-unlink && | |
| 333 | + | p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && | |
| 334 | + | ls objects/pack/pack-*.pack) && | |
| 335 | + | tmpfile="packfileclient-unlink/.git/objects/pack/pack-$ARBITRARY.pack.temp" && | |
| 336 | + | write_script git-unlink-index-pack <<-\EOF && | |
| 337 | + | test -f "$GIT_TEST_PACK_TEMP" || exit 1 | |
| 338 | + | rm "$GIT_TEST_PACK_TEMP" || exit 1 | |
| 339 | + | exec git index-pack "$@" | |
| 340 | + | EOF | |
| 341 | + | test_when_finished "rm -f git-unlink-index-pack" && | |
| 342 | + | PATH="$TRASH_DIRECTORY:$PATH" \ | |
| 343 | + | GIT_TEST_PACK_TEMP="$TRASH_DIRECTORY/$tmpfile" \ | |
| 344 | + | git -C packfileclient-unlink http-fetch --packfile="$ARBITRARY" \ | |
| 345 | + | --index-pack-arg=unlink-index-pack \ | |
| 346 | + | --index-pack-arg=--stdin --index-pack-arg=--keep \ | |
| 347 | + | "$HTTPD_URL/dumb/repo_pack.git/$p" >out && | |
| 348 | + | test_path_is_missing "$tmpfile" && | |
| 349 | + | git -C packfileclient-unlink cat-file -e "$HASH" | |
| 350 | + | ' | |
| 351 | + | ||
| 352 | + | test_expect_success PERL,PIPE 'concurrent http-fetch --packfile cannot corrupt an overlapping download' ' | |
| 353 | + | git init packfileclient-overlap && | |
| 354 | + | blob=$(test-tool genrandom pack-overlap 2m | | |
| 355 | + | git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git \ | |
| 356 | + | hash-object -w --stdin) && | |
| 357 | + | packhash=$(printf "%s\n" "$blob" | | |
| 358 | + | git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git \ | |
| 359 | + | pack-objects "$TRASH_DIRECTORY/overlap-pack") && | |
| 360 | + | pack="$TRASH_DIRECTORY/overlap-pack-$packhash.pack" && | |
| 361 | + | tmpfile="packfileclient-overlap/.git/objects/pack/pack-$packhash.pack.temp" && | |
| 362 | + | mkfifo server-ready first-ready && | |
| 363 | + | exec 7<>server-ready && | |
| 364 | + | exec 8<>first-ready && | |
| 365 | + | write_script slow-pack-server "$PERL_PATH" <<-\EOF && | |
| 366 | + | use strict; | |
| 367 | + | use warnings; | |
| 368 | + | use IO::Socket::INET; | |
| 369 | + | ||
| 370 | + | my ($packfile, $server_ready, $first_ready) = @ARGV; | |
| 371 | + | my $completed = 0; | |
| 372 | + | END { | |
| 373 | + | if (!$completed) { | |
| 374 | + | signal_ready($server_ready, "failed"); | |
| 375 | + | signal_ready($first_ready, "failed"); | |
| 376 | + | } | |
| 377 | + | } | |
| 378 | + | ||
| 379 | + | $SIG{ALRM} = sub { die "timed out serving concurrent pack requests\n" }; | |
| 380 | + | alarm 60; | |
| 381 | + | ||
| 382 | + | open(my $in, "<:raw", $packfile) or die "open $packfile: $!"; | |
| 383 | + | my $pack = do { local $/; <$in> }; | |
| 384 | + | close($in) or die "close $packfile: $!"; | |
| 385 | + | my $server = IO::Socket::INET->new(LocalAddr => "127.0.0.1", | |
| 386 | + | LocalPort => 0, Proto => "tcp", Listen => 2, ReuseAddr => 1) | |
| 387 | + | or die "listen: $!"; | |
| 388 | + | ||
| 389 | + | sub signal_ready { | |
| 390 | + | my ($file, $value) = @_; | |
| 391 | + | open(my $out, ">", $file) or die "open $file: $!"; | |
| 392 | + | print $out "$value\n" or die "write $file: $!"; | |
| 393 | + | close($out) or die "close $file: $!"; | |
| 394 | + | } | |
| 395 | + | ||
| 396 | + | sub write_all { | |
| 397 | + | my ($out, $data) = @_; | |
| 398 | + | my $offset = 0; | |
| 399 | + | while ($offset < length($data)) { | |
| 400 | + | my $written = syswrite($out, $data, | |
| 401 | + | length($data) - $offset, $offset); | |
| 402 | + | defined($written) && $written or die "write response: $!"; | |
| 403 | + | $offset += $written; | |
| 404 | + | } | |
| 405 | + | } | |
| 406 | + | ||
| 407 | + | sub start_response { | |
| 408 | + | my $out = $server->accept() or die "accept: $!"; | |
| 409 | + | <$out> or die "read request: $!"; | |
| 410 | + | my $start = 0; | |
| 411 | + | while (<$out>) { | |
| 412 | + | last if /^\r?\n$/; | |
| 413 | + | $start = $1 if /^Range: bytes=(\d+)-/i; | |
| 414 | + | } | |
| 415 | + | $start < length($pack) or die "invalid range $start"; | |
| 416 | + | my $length = length($pack) - $start; | |
| 417 | + | my $middle = int($length / 2); | |
| 418 | + | my $status = $start ? "206 Partial Content" : "200 OK"; | |
| 419 | + | my $headers = "HTTP/1.1 $status\r\n" . | |
| 420 | + | "Content-Length: $length\r\n" . | |
| 421 | + | ($start ? "Content-Range: bytes $start-" . | |
| 422 | + | (length($pack) - 1) . "/" . length($pack) . "\r\n" : "") . | |
| 423 | + | "Connection: close\r\n\r\n"; | |
| 424 | + | write_all($out, $headers); | |
| 425 | + | write_all($out, substr($pack, $start, $middle)); | |
| 426 | + | return ($out, $start + $middle); | |
| 427 | + | } | |
| 428 | + | ||
| 429 | + | signal_ready($server_ready, $server->sockport()); | |
| 430 | + | my ($first, $first_pos) = start_response(); | |
| 431 | + | signal_ready($first_ready, "ready"); | |
| 432 | + | my ($second, $second_pos) = start_response(); | |
| 433 | + | write_all($first, substr($pack, $first_pos)); | |
| 434 | + | write_all($second, substr($pack, $second_pos)); | |
| 435 | + | close($first) or die "close first response: $!"; | |
| 436 | + | close($second) or die "close second response: $!"; | |
| 437 | + | $completed = 1; | |
| 438 | + | alarm 0; | |
| 439 | + | EOF | |
| 440 | + | { | |
| 441 | + | "$TRASH_DIRECTORY/slow-pack-server" "$pack" \ | |
| 442 | + | "$TRASH_DIRECTORY/server-ready" \ | |
| 443 | + | "$TRASH_DIRECTORY/first-ready" >server.log 2>&1 & | |
| 444 | + | server_pid=$! | |
| 445 | + | } && | |
| 446 | + | test_when_finished " | |
| 447 | + | kill $server_pid 2>/dev/null || : | |
| 448 | + | wait $server_pid 2>/dev/null || : | |
| 449 | + | exec 7>&- | |
| 450 | + | exec 8>&- | |
| 451 | + | rm -f server-ready first-ready slow-pack-server | |
| 452 | + | " && | |
| 453 | + | read port <&7 && | |
| 454 | + | url="http://127.0.0.1:$port/pack" && | |
| 455 | + | { | |
| 456 | + | ( | |
| 457 | + | if ! GIT_TRACE_CURL="$TRASH_DIRECTORY/overlap-first.trace" \ | |
| 458 | + | GIT_TRACE_CURL_NO_DATA=1 \ | |
| 459 | + | git -C packfileclient-overlap http-fetch --packfile="$packhash" \ | |
| 460 | + | --index-pack-arg=index-pack \ | |
| 461 | + | --index-pack-arg=--stdin --index-pack-arg=--keep \ | |
| 462 | + | "$url" >first.out | |
| 463 | + | then | |
| 464 | + | echo failed >"$TRASH_DIRECTORY/first-ready" && | |
| 465 | + | exit 1 | |
| 466 | + | fi | |
| 467 | + | ) & | |
| 468 | + | first_pid=$! | |
| 469 | + | } && | |
| 470 | + | test_when_finished " | |
| 471 | + | kill $first_pid 2>/dev/null || : | |
| 472 | + | wait $first_pid 2>/dev/null || : | |
| 473 | + | " && | |
| 474 | + | read ready <&8 && | |
| 475 | + | test "$ready" = ready && | |
| 476 | + | test_path_is_file "$tmpfile" && | |
| 477 | + | { | |
| 478 | + | GIT_TRACE_CURL="$TRASH_DIRECTORY/overlap-second.trace" \ | |
| 479 | + | GIT_TRACE_CURL_NO_DATA=1 \ | |
| 480 | + | git -C packfileclient-overlap http-fetch --packfile="$packhash" \ | |
| 481 | + | --index-pack-arg=index-pack \ | |
| 482 | + | --index-pack-arg=--stdin --index-pack-arg=--keep \ | |
| 483 | + | "$url" >second.out & | |
| 484 | + | second_pid=$! | |
| 485 | + | } && | |
| 486 | + | test_when_finished " | |
| 487 | + | kill $second_pid 2>/dev/null || : | |
| 488 | + | wait $second_pid 2>/dev/null || : | |
| 489 | + | " && | |
| 490 | + | wait "$second_pid" && | |
| 491 | + | wait "$first_pid" && | |
| 492 | + | wait "$server_pid" && | |
| 493 | + | printf "keep\t%s\npack\t%s\n" "$packhash" "$packhash" | sort >expect && | |
| 494 | + | sort first.out second.out >actual && | |
| 495 | + | test_cmp expect actual && | |
| 496 | + | test_path_is_missing "$tmpfile" && | |
| 497 | + | git -C packfileclient-overlap cat-file -e "$blob" | |
| 498 | + | ' | |
| 499 | + | ||
| 296 | 500 | test_expect_success 'fetch notices corrupt pack' ' | |
| 297 | 501 | cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git && | |
| 298 | 502 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git && | |
modified t/t5702-protocol-v2.sh
| @@ -1291,6 +1291,37 @@ test_expect_success 'packfile URIs with fetch instead of clone' ' | |||
| 1291 | 1291 | fetch "$HTTPD_URL/smart/http_parent" | |
| 1292 | 1292 | ' | |
| 1293 | 1293 | ||
| 1294 | + | test_expect_success 'packfile URI preserves an existing keep file' ' | |
| 1295 | + | P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && | |
| 1296 | + | rm -rf "$P" http_child keep.expect && | |
| 1297 | + | ||
| 1298 | + | git init "$P" && | |
| 1299 | + | git -C "$P" config uploadpack.allowsidebandall true && | |
| 1300 | + | ||
| 1301 | + | echo my-blob >"$P/my-blob" && | |
| 1302 | + | git -C "$P" add my-blob && | |
| 1303 | + | git -C "$P" commit -m x && | |
| 1304 | + | configure_exclusion "$P" my-blob >h && | |
| 1305 | + | ||
| 1306 | + | git init http_child && | |
| 1307 | + | packhash=$(cat packh) && | |
| 1308 | + | keep="http_child/.git/objects/pack/pack-$packhash.keep" && | |
| 1309 | + | echo pre-existing >"$keep" && | |
| 1310 | + | cp "$keep" keep.expect && | |
| 1311 | + | ||
| 1312 | + | GIT_TEST_SIDEBAND_ALL=1 \ | |
| 1313 | + | git -C http_child -c protocol.version=2 \ | |
| 1314 | + | -c fetch.uriprotocols=http,https \ | |
| 1315 | + | fetch "$HTTPD_URL/smart/http_parent" && | |
| 1316 | + | ||
| 1317 | + | test_path_is_file \ | |
| 1318 | + | "http_child/.git/objects/pack/pack-$packhash.pack" && | |
| 1319 | + | test_path_is_file \ | |
| 1320 | + | "http_child/.git/objects/pack/pack-$packhash.idx" && | |
| 1321 | + | test_cmp keep.expect "$keep" && | |
| 1322 | + | git -C http_child cat-file -e "$(cat h)" | |
| 1323 | + | ' | |
| 1324 | + | ||
| 1294 | 1325 | test_expect_success 'fetching with valid packfile URI but invalid hash fails' ' | |
| 1295 | 1326 | P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && | |
| 1296 | 1327 | rm -rf "$P" http_child log && | |
modified t/t6030-bisect-porcelain.sh
| @@ -43,6 +43,42 @@ test_bisect_usage () { | |||
| 43 | 43 | test_cmp expect actual | |
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | + | test_bisect_state_file () { | |
| 47 | + | local file && | |
| 48 | + | file=$(git rev-parse --git-path "$1") && | |
| 49 | + | test_path_is_file "$file" | |
| 50 | + | } | |
| 51 | + | ||
| 52 | + | test_bisect_state_missing () { | |
| 53 | + | local file && | |
| 54 | + | file=$(git rev-parse --git-path "$1") && | |
| 55 | + | test_path_is_missing "$file" | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | bisect_start_and_finish () { | |
| 59 | + | git bisect start "$1" $HASH4 $HASH2 && | |
| 60 | + | git bisect bad | |
| 61 | + | } | |
| 62 | + | ||
| 63 | + | bisect_run_reset_when_found () { | |
| 64 | + | write_script test_script.sh <<-\EOF && | |
| 65 | + | ! grep Another hello >/dev/null | |
| 66 | + | EOF | |
| 67 | + | git bisect start $HASH4 $HASH2 && | |
| 68 | + | git bisect run "$1" ./test_script.sh >my_bisect_log.txt && | |
| 69 | + | test_grep "$HASH3 is the first .bad. commit" my_bisect_log.txt && | |
| 70 | + | test_bisect_state_missing BISECT_RUN | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | test_reset_when_found_fails () { | |
| 74 | + | local pattern="$1" && | |
| 75 | + | local state_file="$2" && | |
| 76 | + | shift 2 && | |
| 77 | + | test_must_fail "$@" 2>err && | |
| 78 | + | test_grep -- "$pattern" err && | |
| 79 | + | test_bisect_state_missing "$state_file" | |
| 80 | + | } | |
| 81 | + | ||
| 46 | 82 | test_expect_success 'bisect usage' " | |
| 47 | 83 | test_bisect_usage 1 git bisect reset extra1 extra2 <<-\EOF && | |
| 48 | 84 | error: 'git bisect reset' requires either no argument or a commit | |
| @@ -453,6 +489,91 @@ test_expect_success '"git bisect run" simple case' ' | |||
| 453 | 489 | git bisect reset | |
| 454 | 490 | ' | |
| 455 | 491 | ||
| 492 | + | test_expect_success '"git bisect start --reset-when-found" defaults to original' ' | |
| 493 | + | test_when_finished "git bisect reset && git checkout main" && | |
| 494 | + | git checkout main && | |
| 495 | + | bisect_start_and_finish --reset-when-found && | |
| 496 | + | actual=$(git rev-parse HEAD) && | |
| 497 | + | test "$HASH4" = "$actual" && | |
| 498 | + | actual=$(git branch --show-current) && | |
| 499 | + | test main = "$actual" && | |
| 500 | + | test_bisect_state_missing BISECT_START && | |
| 501 | + | ||
| 502 | + | bisect_start_and_finish --reset-when-found=original && | |
| 503 | + | actual=$(git rev-parse HEAD) && | |
| 504 | + | test "$HASH4" = "$actual" && | |
| 505 | + | actual=$(git branch --show-current) && | |
| 506 | + | test main = "$actual" && | |
| 507 | + | test_bisect_state_missing BISECT_START | |
| 508 | + | ' | |
| 509 | + | ||
| 510 | + | test_expect_success '"git bisect start --reset-when-found=found" leaves first bad checked out' ' | |
| 511 | + | test_when_finished "git bisect reset && git checkout main" && | |
| 512 | + | bisect_start_and_finish --reset-when-found=found && | |
| 513 | + | actual=$(git rev-parse HEAD) && | |
| 514 | + | test "$HASH3" = "$actual" && | |
| 515 | + | test_bisect_state_missing BISECT_START | |
| 516 | + | ' | |
| 517 | + | ||
| 518 | + | test_expect_success '"git bisect run --reset-when-found" defaults to original' ' | |
| 519 | + | test_when_finished "git bisect reset && git checkout main" && | |
| 520 | + | bisect_run_reset_when_found --reset-when-found && | |
| 521 | + | actual=$(git rev-parse HEAD) && | |
| 522 | + | test "$HASH4" = "$actual" && | |
| 523 | + | actual=$(git branch --show-current) && | |
| 524 | + | test main = "$actual" && | |
| 525 | + | test_bisect_state_missing BISECT_START | |
| 526 | + | ' | |
| 527 | + | ||
| 528 | + | test_expect_success '"git bisect run --reset-when-found=found" leaves first bad checked out' ' | |
| 529 | + | test_when_finished "git bisect reset && git checkout main" && | |
| 530 | + | bisect_run_reset_when_found --reset-when-found=found && | |
| 531 | + | actual=$(git rev-parse HEAD) && | |
| 532 | + | test "$HASH3" = "$actual" && | |
| 533 | + | test_bisect_state_missing BISECT_START | |
| 534 | + | ' | |
| 535 | + | ||
| 536 | + | test_expect_success '--reset-when-found rejects an unknown reset target' ' | |
| 537 | + | test_when_finished "git bisect reset && git checkout main" && | |
| 538 | + | test_reset_when_found_fails \ | |
| 539 | + | "invalid value for.*--reset-when-found.*unknown" BISECT_START \ | |
| 540 | + | git bisect start --reset-when-found=unknown $HASH4 $HASH2 && | |
| 541 | + | ||
| 542 | + | git bisect start $HASH4 $HASH2 && | |
| 543 | + | test_reset_when_found_fails \ | |
| 544 | + | "invalid value for.*--reset-when-found.*unknown" \ | |
| 545 | + | BISECT_RESET_WHEN_FOUND \ | |
| 546 | + | git bisect run --reset-when-found=unknown true | |
| 547 | + | ' | |
| 548 | + | ||
| 549 | + | test_expect_success '--reset-when-found cannot be used with --no-checkout' ' | |
| 550 | + | test_when_finished "git bisect reset" && | |
| 551 | + | test_reset_when_found_fails \ | |
| 552 | + | "options .*--reset-when-found.* and .*--no-checkout.* cannot be used together" BISECT_START \ | |
| 553 | + | git bisect start --reset-when-found=original --no-checkout $HASH4 $HASH2 && | |
| 554 | + | ||
| 555 | + | git bisect start --no-checkout $HASH4 $HASH2 && | |
| 556 | + | test_reset_when_found_fails \ | |
| 557 | + | "options .*--reset-when-found.* and .*--no-checkout.* cannot be used together" BISECT_RESET_WHEN_FOUND \ | |
| 558 | + | git bisect run --reset-when-found=found true | |
| 559 | + | ' | |
| 560 | + | ||
| 561 | + | test_expect_success 'without --reset-when-found the bisection state is kept' ' | |
| 562 | + | test_when_finished "git bisect reset" && | |
| 563 | + | git bisect start $HASH4 $HASH2 && | |
| 564 | + | git bisect bad && | |
| 565 | + | test_bisect_state_file BISECT_START | |
| 566 | + | ' | |
| 567 | + | ||
| 568 | + | test_expect_success '--reset-when-found does not leak into a later bisection' ' | |
| 569 | + | test_when_finished "git bisect reset && git checkout main" && | |
| 570 | + | bisect_start_and_finish --reset-when-found && | |
| 571 | + | ||
| 572 | + | git bisect start $HASH4 $HASH2 && | |
| 573 | + | git bisect bad && | |
| 574 | + | test_bisect_state_file BISECT_START | |
| 575 | + | ' | |
| 576 | + | ||
| 456 | 577 | # We want to automatically find the commit that | |
| 457 | 578 | # added "Ciao" into hello. | |
| 458 | 579 | test_expect_success '"git bisect run" with more complex "git bisect start"' ' | |
modified t/t7528-signed-commit-ssh.sh
| @@ -82,7 +82,7 @@ test_expect_success GPGSSH 'create signed commits' ' | |||
| 82 | 82 | test_expect_success GPGSSH 'sign commits using literal public keys with ssh-agent' ' | |
| 83 | 83 | test_when_finished "test_unconfig commit.gpgsign" && | |
| 84 | 84 | test_config gpg.format ssh && | |
| 85 | - | eval $(ssh-agent -T || ssh-agent) && | |
| 85 | + | eval $(ssh-agent -T -s || ssh-agent -s) && | |
| 86 | 86 | test_when_finished "kill ${SSH_AGENT_PID}" && | |
| 87 | 87 | test_when_finished "test_unconfig user.signingkey" && | |
| 88 | 88 | mkdir tmpdir && | |
modified t/unit-tests/u-odb-inmemory.c
| @@ -29,7 +29,7 @@ static void cl_assert_object_info(struct odb_source_inmemory *source, | |||
| 29 | 29 | .contentp = &actual_content, | |
| 30 | 30 | }; | |
| 31 | 31 | ||
| 32 | - | cl_must_pass(odb_source_read_object_info(&source->base, oid, &oi, 0)); | |
| 32 | + | cl_must_pass(odb_source_read_object_info(&source->base, oid, &oi, 0, NULL)); | |
| 33 | 33 | cl_assert_equal_u(actual_size, strlen(expected_content)); | |
| 34 | 34 | cl_assert_equal_u(actual_type, expected_type); | |
| 35 | 35 | cl_assert_equal_s((char *) actual_content, expected_content); | |
| @@ -72,7 +72,8 @@ void test_odb_inmemory__read_missing_object(void) | |||
| 72 | 72 | const char *end; | |
| 73 | 73 | ||
| 74 | 74 | cl_must_pass(parse_oid_hex_algop(RANDOM_OID, &oid, &end, repo.hash_algo)); | |
| 75 | - | cl_must_fail(odb_source_read_object_info(&source->base, &oid, NULL, 0)); | |
| 75 | + | cl_assert_equal_i(odb_source_read_object_info(&source->base, &oid, NULL, 0, NULL), | |
| 76 | + | ODB_READ_NOT_FOUND); | |
| 76 | 77 | ||
| 77 | 78 | odb_source_free(&source->base); | |
| 78 | 79 | } | |
modified wrapper.c
| @@ -323,6 +323,84 @@ ssize_t write_in_full(int fd, const void *buf, size_t count) | |||
| 323 | 323 | return total; | |
| 324 | 324 | } | |
| 325 | 325 | ||
| 326 | + | ssize_t xwritev(int fd, struct iovec *iov, int iovcnt) | |
| 327 | + | { | |
| 328 | + | size_t allowed = MAX_IO_SIZE; | |
| 329 | + | int i; | |
| 330 | + | ||
| 331 | + | /* | |
| 332 | + | * Some platforms define a comparatively small `MAX_IO_SIZE` that | |
| 333 | + | * limits how many bytes can be written with a single call to | |
| 334 | + | * write(3p) or writev(3p); exceeding that limit causes the syscall to | |
| 335 | + | * fail with EINVAL. Just like xwrite() chomps overly large requests | |
| 336 | + | * for write(3p), pretend that the underlying writev(3p) performed a | |
| 337 | + | * short write by only passing along the leading iovec entries that | |
| 338 | + | * fit into that limit. | |
| 339 | + | */ | |
| 340 | + | for (i = 0; i < iovcnt; i++) { | |
| 341 | + | if (iov[i].iov_len > allowed) { | |
| 342 | + | /* | |
| 343 | + | * If the first buffer is larger than MAX_IO_SIZE, | |
| 344 | + | * let xwrite() deal with it. | |
| 345 | + | */ | |
| 346 | + | if (!i) | |
| 347 | + | return xwrite(fd, iov->iov_base, iov->iov_len); | |
| 348 | + | break; | |
| 349 | + | } | |
| 350 | + | allowed -= iov[i].iov_len; | |
| 351 | + | } | |
| 352 | + | ||
| 353 | + | while (1) { | |
| 354 | + | ssize_t bytes_written = writev(fd, iov, i); | |
| 355 | + | if (bytes_written < 0) { | |
| 356 | + | if (errno == EINTR) | |
| 357 | + | continue; | |
| 358 | + | if (handle_nonblock(fd, POLLOUT, errno)) | |
| 359 | + | continue; | |
| 360 | + | } | |
| 361 | + | ||
| 362 | + | return bytes_written; | |
| 363 | + | } | |
| 364 | + | } | |
| 365 | + | ||
| 366 | + | ssize_t writev_in_full(int fd, struct iovec *iov, int iovcnt) | |
| 367 | + | { | |
| 368 | + | ssize_t total_written = 0; | |
| 369 | + | ||
| 370 | + | while (iovcnt) { | |
| 371 | + | ssize_t bytes_written = xwritev(fd, iov, iovcnt); | |
| 372 | + | if (bytes_written < 0) | |
| 373 | + | return -1; | |
| 374 | + | if (!bytes_written) { | |
| 375 | + | errno = ENOSPC; | |
| 376 | + | return -1; | |
| 377 | + | } | |
| 378 | + | ||
| 379 | + | total_written += bytes_written; | |
| 380 | + | ||
| 381 | + | /* | |
| 382 | + | * We first need to discard any iovec entities that have been | |
| 383 | + | * fully written. | |
| 384 | + | */ | |
| 385 | + | while (iovcnt && (size_t)bytes_written >= iov->iov_len) { | |
| 386 | + | bytes_written -= iov->iov_len; | |
| 387 | + | iov++; | |
| 388 | + | iovcnt--; | |
| 389 | + | } | |
| 390 | + | ||
| 391 | + | /* | |
| 392 | + | * Finally, we need to adjust the last iovec in case we have | |
| 393 | + | * performed a partial write. | |
| 394 | + | */ | |
| 395 | + | if (iovcnt && bytes_written) { | |
| 396 | + | iov->iov_base = (char *) iov->iov_base + bytes_written; | |
| 397 | + | iov->iov_len -= bytes_written; | |
| 398 | + | } | |
| 399 | + | } | |
| 400 | + | ||
| 401 | + | return total_written; | |
| 402 | + | } | |
| 403 | + | ||
| 326 | 404 | ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset) | |
| 327 | 405 | { | |
| 328 | 406 | char *p = buf; | |
modified wrapper.h
| @@ -16,6 +16,7 @@ void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_ | |||
| 16 | 16 | int xopen(const char *path, int flags, ...); | |
| 17 | 17 | ssize_t xread(int fd, void *buf, size_t len); | |
| 18 | 18 | ssize_t xwrite(int fd, const void *buf, size_t len); | |
| 19 | + | ssize_t xwritev(int fd, struct iovec *iov, int iovcnt); | |
| 19 | 20 | ssize_t xpread(int fd, void *buf, size_t len, off_t offset); | |
| 20 | 21 | int xdup(int fd); | |
| 21 | 22 | FILE *xfopen(const char *path, const char *mode); | |
| @@ -47,6 +48,15 @@ ssize_t read_in_full(int fd, void *buf, size_t count); | |||
| 47 | 48 | ssize_t write_in_full(int fd, const void *buf, size_t count); | |
| 48 | 49 | ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset); | |
| 49 | 50 | ||
| 51 | + | /* | |
| 52 | + | * Try to write all iovecs. Returns -1 in case an error occurred with a proper | |
| 53 | + | * errno set, the number of bytes written otherwise. | |
| 54 | + | * | |
| 55 | + | * Note that the iovec will be modified as a result of this call to adjust for | |
| 56 | + | * partial writes! | |
| 57 | + | */ | |
| 58 | + | ssize_t writev_in_full(int fd, struct iovec *iov, int iovcnt); | |
| 59 | + | ||
| 50 | 60 | static inline ssize_t write_str_in_full(int fd, const char *str) | |
| 51 | 61 | { | |
| 52 | 62 | return write_in_full(fd, str, strlen(str)); | |
modified write-or-die.c
| @@ -96,6 +96,14 @@ void write_or_die(int fd, const void *buf, size_t count) | |||
| 96 | 96 | } | |
| 97 | 97 | } | |
| 98 | 98 | ||
| 99 | + | void writev_or_die(int fd, struct iovec *iov, int iovlen) | |
| 100 | + | { | |
| 101 | + | if (writev_in_full(fd, iov, iovlen) < 0) { | |
| 102 | + | check_pipe(errno); | |
| 103 | + | die_errno("writev error"); | |
| 104 | + | } | |
| 105 | + | } | |
| 106 | + | ||
| 99 | 107 | void fwrite_or_die(FILE *f, const void *buf, size_t count) | |
| 100 | 108 | { | |
| 101 | 109 | if (fwrite(buf, 1, count, f) != count) | |
modified write-or-die.h
| @@ -7,6 +7,7 @@ void fprintf_or_die(FILE *, const char *fmt, ...); | |||
| 7 | 7 | void fwrite_or_die(FILE *f, const void *buf, size_t count); | |
| 8 | 8 | void fflush_or_die(FILE *f); | |
| 9 | 9 | void write_or_die(int fd, const void *buf, size_t count); | |
| 10 | + | void writev_or_die(int fd, struct iovec *iov, int iovlen); | |
| 10 | 11 | ||
| 11 | 12 | /* | |
| 12 | 13 | * These values are used to help identify parts of a repository to fsync. | |