]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/misc-null-check-fixes'
authorJunio C Hamano <gitster@pobox.com>
Tue, 2 May 2023 17:13:34 +0000 (10:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 May 2023 17:13:34 +0000 (10:13 -0700)
Code clean-up.

* jk/misc-null-check-fixes:
  fetch_bundle_uri(): drop pointless NULL check
  notes: clean up confusing NULL checks in init_notes()

268 files changed:
Documentation/Makefile
Documentation/RelNotes/2.30.9.txt [new file with mode: 0644]
Documentation/RelNotes/2.31.8.txt [new file with mode: 0644]
Documentation/RelNotes/2.32.7.txt [new file with mode: 0644]
Documentation/RelNotes/2.33.8.txt [new file with mode: 0644]
Documentation/RelNotes/2.34.8.txt [new file with mode: 0644]
Documentation/RelNotes/2.35.8.txt [new file with mode: 0644]
Documentation/RelNotes/2.36.6.txt [new file with mode: 0644]
Documentation/RelNotes/2.37.7.txt [new file with mode: 0644]
Documentation/RelNotes/2.38.5.txt [new file with mode: 0644]
Documentation/RelNotes/2.39.3.txt
Documentation/RelNotes/2.40.1.txt [new file with mode: 0644]
Documentation/RelNotes/2.41.0.txt
Documentation/config/feature.txt
Documentation/config/gc.txt
Documentation/config/pack.txt
Documentation/git-checkout.txt
Documentation/git-gc.txt
Documentation/gitformat-pack.txt
Documentation/githooks.txt
Makefile
add-patch.c
apply.c
archive-tar.c
archive-zip.c
archive.c
archive.h
bisect.c
blame.c
branch.c
builtin/add.c
builtin/am.c
builtin/bisect.c
builtin/blame.c
builtin/branch.c
builtin/bugreport.c
builtin/cat-file.c
builtin/check-attr.c
builtin/checkout.c
builtin/clone.c
builtin/commit-graph.c
builtin/commit-tree.c
builtin/commit.c
builtin/config.c
builtin/credential-cache--daemon.c
builtin/describe.c
builtin/diagnose.c
builtin/difftool.c
builtin/fast-export.c
builtin/fast-import.c
builtin/fetch-pack.c
builtin/fetch.c
builtin/fsck.c
builtin/fsmonitor--daemon.c
builtin/gc.c
builtin/grep.c
builtin/hash-object.c
builtin/help.c
builtin/index-pack.c
builtin/init-db.c
builtin/log.c
builtin/ls-files.c
builtin/ls-tree.c
builtin/merge-base.c
builtin/merge-recursive.c
builtin/merge-tree.c
builtin/merge.c
builtin/mktag.c
builtin/mv.c
builtin/name-rev.c
builtin/notes.c
builtin/pack-objects.c
builtin/prune.c
builtin/pull.c
builtin/push.c
builtin/range-diff.c
builtin/read-tree.c
builtin/rebase.c
builtin/receive-pack.c
builtin/repack.c
builtin/replace.c
builtin/reset.c
builtin/rev-list.c
builtin/rev-parse.c
builtin/rm.c
builtin/show-branch.c
builtin/show-ref.c
builtin/sparse-checkout.c
builtin/stash.c
builtin/submodule--helper.c
builtin/tag.c
builtin/unpack-file.c
builtin/unpack-objects.c
builtin/update-index.c
builtin/update-ref.c
builtin/var.c
builtin/verify-commit.c
builtin/verify-tag.c
builtin/worktree.c
bulk-checkin.c
bundle.c
cache-tree.c
cache.h
chdir-notify.c
checkout.c
ci/run-build-and-tests.sh
color.c
column.c
combine-diff.c
commit-graph.c
commit.c
common-main.c
compat/fsmonitor/fsm-listen-win32.c
compat/mingw.c
compat/pread.c
compat/simple-ipc/ipc-unix-socket.c
compat/simple-ipc/ipc-win32.c
compat/win32/trace2_win32_process_info.c
config.c
connect.c
connect.h
contrib/completion/git-prompt.sh
convert.c
daemon.c
date.c
delta-islands.c
diff-lib.c
diff-no-index.c
diff.c
dir.c
editor.c
editor.h [new file with mode: 0644]
environment.c
exec-cmd.c
fetch-pack.c
fmt-merge-msg.c
fsck.c
fsmonitor.c
fsmonitor.h
gettext.c
gettext.h
git-compat-util.h
git-send-email.perl
git-zlib.c [moved from zlib.c with 99% similarity]
git-zlib.h [new file with mode: 0644]
git.c
gpg-interface.c
grep.c
http-backend.c
http-fetch.c
http-push.c
http-walker.c
http.c
http.h
list-objects-filter.c
list-objects.c
ll-merge.c
log-tree.c
mailmap.c
mailmap.h
merge-ort.c
merge-recursive.c
midx.c
name-hash.c
notes-merge.c
notes.c
object-file.c
object-file.h [new file with mode: 0644]
object-name.c
object-name.h [new file with mode: 0644]
object-store.h
object.c
object.h
pack-bitmap-write.c
pack-bitmap.c
pack-check.c
pack-mtimes.c
pack-revindex.c
pack-revindex.h
pack-write.c
packfile.c
pager.c
pager.h [new file with mode: 0644]
parse-options-cb.c
path.c
pkt-line.c
preload-index.c
pretty.c
progress.c
promisor-remote.c
protocol.c
protocol.h
quote.c
quote.h
range-diff.c
read-cache.c
rebase-interactive.c
ref-filter.c
refs.c
refs/files-backend.c
refs/packed-backend.c
refs/ref-cache.h
remote-curl.c
remote.c
repo-settings.c
repository.c
repository.h
rerere.c
reset.c
resolve-undo.h
revision.c
run-command.c
scalar.c
send-pack.c
sequencer.c
server-info.c
setup.c
shallow.c
sideband.c
split-index.c
split-index.h
strbuf.c
strbuf.h
streaming.c
submodule-config.c
submodule.c
t/README
t/helper/test-chmtime.c
t/helper/test-date.c
t/helper/test-fast-rebase.c
t/helper/test-lazy-init-name-hash.c
t/helper/test-match-trees.c
t/helper/test-mergesort.c
t/helper/test-oidmap.c
t/helper/test-path-utils.c
t/helper/test-reach.c
t/helper/test-submodule-config.c
t/perf/p5312-pack-bitmaps-revs.sh
t/t1300-config.sh
t/t4115-apply-symlink.sh
t/t5300-pack-object.sh
t/t5304-prune.sh
t/t5319-multi-pack-index.sh
t/t5325-reverse-index.sh
t/t5331-pack-objects-stdin.sh [new file with mode: 0755]
t/t5512-ls-remote.sh
t/t6500-gc.sh
t/t6501-freshen-objects.sh
t/t7510-signed-commit.sh
t/t7700-repack.sh
t/t7703-repack-geometric.sh
t/t9001-send-email.sh
t/t9300-fast-import.sh
tag.c
templates/hooks--sendemail-validate.sample [new file with mode: 0755]
tmp-objdir.c
trace.c
trace2.c
transport-helper.c
transport.c
tree-walk.c
tree.c
unpack-trees.c
unpack-trees.h
upload-pack.c
walker.c
wrapper.c
wt-status.c

index 3133ea31829ec3c1107e6075362d499f1f4a657c..b629176d7d2d6776e0a66fbda466915219f32bc2 100644 (file)
@@ -144,13 +144,16 @@ man5dir = $(mandir)/man5
 man7dir = $(mandir)/man7
 # DESTDIR =
 
+GIT_DATE := $(shell git show --quiet --pretty='%as')
+
 ASCIIDOC = asciidoc
 ASCIIDOC_EXTRA =
 ASCIIDOC_HTML = xhtml11
 ASCIIDOC_DOCBOOK = docbook
 ASCIIDOC_CONF = -f asciidoc.conf
 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
-               -amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)'
+               -amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)' \
+               -arevdate='$(GIT_DATE)'
 ASCIIDOC_DEPS = asciidoc.conf GIT-ASCIIDOCFLAGS
 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
diff --git a/Documentation/RelNotes/2.30.9.txt b/Documentation/RelNotes/2.30.9.txt
new file mode 100644 (file)
index 0000000..708d626
--- /dev/null
@@ -0,0 +1,43 @@
+Git v2.30.9 Release Notes
+=========================
+
+This release addresses the security issues CVE-2023-25652,
+CVE-2023-25815, and CVE-2023-29007.
+
+
+Fixes since v2.30.8
+-------------------
+
+ * CVE-2023-25652:
+
+   By feeding specially crafted input to `git apply --reject`, a
+   path outside the working tree can be overwritten with partially
+   controlled contents (corresponding to the rejected hunk(s) from
+   the given patch).
+
+ * CVE-2023-25815:
+
+   When Git is compiled with runtime prefix support and runs without
+   translated messages, it still used the gettext machinery to
+   display messages, which subsequently potentially looked for
+   translated messages in unexpected places. This allowed for
+   malicious placement of crafted messages.
+
+ * CVE-2023-29007:
+
+   When renaming or deleting a section from a configuration file,
+   certain malicious configuration values may be misinterpreted as
+   the beginning of a new configuration section, leading to arbitrary
+   configuration injection.
+
+Credit for finding CVE-2023-25652 goes to Ry0taK, and the fix was
+developed by Taylor Blau, Junio C Hamano and Johannes Schindelin,
+with the help of Linus Torvalds.
+
+Credit for finding CVE-2023-25815 goes to Maxime Escourbiac and
+Yassine BENGANA of Michelin, and the fix was developed by Johannes
+Schindelin.
+
+Credit for finding CVE-2023-29007 goes to André Baptista and Vítor Pinho
+of Ethiack, and the fix was developed by Taylor Blau, and Johannes
+Schindelin, with help from Jeff King, and Patrick Steinhardt.
diff --git a/Documentation/RelNotes/2.31.8.txt b/Documentation/RelNotes/2.31.8.txt
new file mode 100644 (file)
index 0000000..0aa3080
--- /dev/null
@@ -0,0 +1,6 @@
+Git v2.31.8 Release Notes
+=========================
+
+This release merges the fixes that appear in v2.30.9 to address the
+security issues CVE-2023-25652, CVE-2023-25815, and CVE-2023-29007;
+see the release notes for that version for details.
diff --git a/Documentation/RelNotes/2.32.7.txt b/Documentation/RelNotes/2.32.7.txt
new file mode 100644 (file)
index 0000000..7bb3538
--- /dev/null
@@ -0,0 +1,7 @@
+Git v2.32.7 Release Notes
+=========================
+
+This release merges the fixes that appear in v2.30.9 and v2.31.8 to
+address the security issues CVE-2023-25652, CVE-2023-25815, and
+CVE-2023-29007; see the release notes for these versions for
+details.
diff --git a/Documentation/RelNotes/2.33.8.txt b/Documentation/RelNotes/2.33.8.txt
new file mode 100644 (file)
index 0000000..d8cf4c7
--- /dev/null
@@ -0,0 +1,7 @@
+Git v2.33.8 Release Notes
+=========================
+
+This release merges the fixes that appear in v2.30.9, v2.31.8 and
+v2.32.7 to address the security issues CVE-2023-25652,
+CVE-2023-25815, and CVE-2023-29007; see the release notes for these
+versions for details.
diff --git a/Documentation/RelNotes/2.34.8.txt b/Documentation/RelNotes/2.34.8.txt
new file mode 100644 (file)
index 0000000..2b5bd7d
--- /dev/null
@@ -0,0 +1,7 @@
+Git v2.34.8 Release Notes
+=========================
+
+This release merges the fixes that appear in v2.30.9, v2.31.8,
+v2.32.7 and v2.33.8 to address the security issues CVE-2023-25652,
+CVE-2023-25815, and CVE-2023-29007; see the release notes for these
+versions for details.
diff --git a/Documentation/RelNotes/2.35.8.txt b/Documentation/RelNotes/2.35.8.txt
new file mode 100644 (file)
index 0000000..3c9c094
--- /dev/null
@@ -0,0 +1,7 @@
+Git v2.35.8 Release Notes
+=========================
+
+This release merges the fixes that appear in v2.30.9, v2.31.8,
+v2.32.7, v2.33.8 and v2.34.8 to address the security issues
+CVE-2023-25652, CVE-2023-25815, and CVE-2023-29007; see the release
+notes for these versions for details.
diff --git a/Documentation/RelNotes/2.36.6.txt b/Documentation/RelNotes/2.36.6.txt
new file mode 100644 (file)
index 0000000..e1edebc
--- /dev/null
@@ -0,0 +1,7 @@
+Git v2.36.6 Release Notes
+=========================
+
+This release merges the fixes that appear in v2.30.9, v2.31.8,
+v2.32.7, v2.33.8, v2.34.8 and v2.35.8 to address the security issues
+CVE-2023-25652, CVS-2023-25815, and CVE-2023-29007; see the release
+notes for these versions for details.
diff --git a/Documentation/RelNotes/2.37.7.txt b/Documentation/RelNotes/2.37.7.txt
new file mode 100644 (file)
index 0000000..4b8165f
--- /dev/null
@@ -0,0 +1,7 @@
+Git v2.37.7 Release Notes
+=========================
+
+This release merges up the fix that appears in v2.30.9, v2.31.8,
+v2.32.7, v2.33.8, v2.34.8, v2.35.8 and v2.36.6 to address the
+security issues CVE-2023-25652, CVE-2023-25815, and CVE-2023-29007;
+see the release notes for these versions for details.
diff --git a/Documentation/RelNotes/2.38.5.txt b/Documentation/RelNotes/2.38.5.txt
new file mode 100644 (file)
index 0000000..2d1f3b1
--- /dev/null
@@ -0,0 +1,8 @@
+Git v2.38.5 Release Notes
+=========================
+
+This release merges up the fix that appears in v2.30.9, v2.31.8,
+v2.32.7, v2.33.8, v2.34.8, v2.35.8, v2.36.6 and v2.37.7 to address
+the security issues CVE-2023-25652, CVE-2023-25815, and
+CVE-2023-29007; see the release notes for these versions for
+details.
index dddff53627765dc2b795949fbfc51e5b2c26fe2b..66351b65c219a9a53c19c78cf2d76c05a2f104a7 100644 (file)
@@ -1,9 +1,15 @@
 Git v2.39.3 Release Notes
 =========================
 
-This release is primarily to merge fixes accumulated on the 'master'
-front to prepare for 2.40 release that are still relevant to 2.39.x
-maintenance track.
+This release merges up the fix that appears in v2.30.9, v2.31.8,
+v2.32.7, v2.33.8, v2.34.8, v2.35.8, v2.36.6, v2.37.7 and v2.38.5 to
+address the security issues CVE-2023-25652, CVE-2023-25815, and
+CVE-2023-29007; see the release notes for these versions for
+details.
+
+This release also merges fixes that have accumulated on the 'master'
+front to prepare for the 2.40 release that are still relevant to
+2.39.x maintenance track.
 
 Fixes since v2.39.2
 -------------------
diff --git a/Documentation/RelNotes/2.40.1.txt b/Documentation/RelNotes/2.40.1.txt
new file mode 100644 (file)
index 0000000..e72f6b1
--- /dev/null
@@ -0,0 +1,8 @@
+Git v2.40.1 Release Notes
+=========================
+
+This release merges up the fix that appears in v2.30.9, v2.31.8,
+v2.32.7, v2.33.8, v2.34.8, v2.35.8, v2.36.6, v2.37.7, v2.38.5
+and v2.39.3 to address the security issues CVE-2023-25652,
+CVE-2023-25815, and CVE-2023-29007; see the release notes for these
+versions for details.
index abbaff30957d383595e635564ed3ad4b9414074b..b7373711487f59a1ccd302d5939e6aa6ed7145d4 100644 (file)
@@ -69,6 +69,16 @@ UI, Workflows & Features
    learns "--omit-empty" to hide refs that whose formatting result
    becomes an empty string from the output.
 
+ * The sendemail-validate validate hook learned to pass the total
+   number of input files and where in the sequence each invocation is
+   via environment variables.
+
+ * When "gc" needs to retain unreachable objects, packing them into
+   cruft packs (instead of exploding them into loose object files) has
+   been offered as a more efficient option for some time.  Now the use
+   of cruft packs has been made the default and no longer considered
+   an experimental feature.
+
 
 Performance, Internal Implementation, Development Support etc.
 
@@ -109,6 +119,11 @@ Performance, Internal Implementation, Development Support etc.
 
  * "git write-tree" learns to work better with sparse-index.
 
+ * The on-disk reverse index that allows mapping from the pack offset
+   to the object name for the object stored at the offset has been
+   enabled by default.
+
+ * "git fsck" learned to validate the on-disk pack reverse index files.
 
 
 Fixes since v2.40
@@ -240,6 +255,20 @@ Fixes since v2.40
    paths outside the current directory.
    (merge 92b1dd1b9e rs/archive-from-subdirectory-fixes later to maint).
 
+ * The code to parse capability list for v0 on-wire protocol fell into
+   an infinite loop when a capability appears multiple times, which
+   has been corrected.
+
+ * Geometric repacking ("git repack --geometric=<n>") in a repository
+   that borrows from an alternate object database had various corner
+   case bugs, which have been corrected.
+   (merge d85cd18777 ps/fix-geom-repack-with-alternates later to maint).
+
+ * The "%GT" placeholder for the "--format" option of "git log" and
+   friends caused BUG() to trigger on a commit signed with an unknown
+   key, which has been corrected.
+   (merge 7891e46585 jk/gpg-trust-level-fix later to maint).
+
  * Other code cleanup, docfix, build fix, etc.
    (merge f7111175df as/doc-markup-fix later to maint).
    (merge 90ff7c9898 fc/test-aggregation-clean-up later to maint).
index e52bc6b858470c60f09f52d4f9d2b9f17135483c..17b4d39f894c12a32da93f69006b59b2434f0775 100644 (file)
@@ -14,9 +14,6 @@ feature.experimental::
 +
 * `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
 skipping more commits at a time, reducing the number of round trips.
-+
-* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
-garbage collection, preventing loose object explosions.
 
 feature.manyFiles::
        Enable config options that optimize for repos with many files in the
index 38fea076a26d0f1f7bf137723baba945675901fc..7f95c866e1dee036adaeb94f68a5286bad669652 100644 (file)
@@ -43,11 +43,11 @@ gc.autoDetach::
        if the system supports it. Default is true.
 
 gc.bigPackThreshold::
-       If non-zero, all packs larger than this limit are kept when
-       `git gc` is run. This is very similar to `--keep-largest-pack`
-       except that all packs that meet the threshold are kept, not
-       just the largest pack. Defaults to zero. Common unit suffixes of
-       'k', 'm', or 'g' are supported.
+       If non-zero, all non-cruft packs larger than this limit are kept
+       when `git gc` is run. This is very similar to
+       `--keep-largest-pack` except that all non-cruft packs that meet
+       the threshold are kept, not just the largest pack. Defaults to
+       zero. Common unit suffixes of 'k', 'm', or 'g' are supported.
 +
 Note that if the number of kept packs is more than gc.autoPackLimit,
 this configuration variable is ignored, all packs except the base pack
@@ -84,7 +84,7 @@ gc.packRefs::
 gc.cruftPacks::
        Store unreachable objects in a cruft pack (see
        linkgit:git-repack[1]) instead of as loose objects. The default
-       is `false`.
+       is `true`.
 
 gc.pruneExpire::
        When 'git gc' is run, it will call 'prune --expire 2.weeks.ago'
index 53093d99969cc090e4727a570eb667a6fba445d4..d4c7c9d4e4e5d217d72cc90a02dbcb86e39971ca 100644 (file)
@@ -171,9 +171,15 @@ pack.writeBitmapLookupTable::
        beneficial in repositories that have relatively large bitmap
        indexes. Defaults to false.
 
+pack.readReverseIndex::
+       When true, git will read any .rev file(s) that may be available
+       (see: linkgit:gitformat-pack[5]). When false, the reverse index
+       will be generated from scratch and stored in memory. Defaults to
+       true.
+
 pack.writeReverseIndex::
        When true, git will write a corresponding .rev file (see:
        linkgit:gitformat-pack[5])
        for each new packfile that it writes in all places except for
        linkgit:git-fast-import[1] and in the bulk checkin mechanism.
-       Defaults to false.
+       Defaults to true.
index 6bb32ab4602aa9b55c935a0d3bb64d56682c7bed..4af0904f4729b463d3b63bf3479f5e4b313773fd 100644 (file)
@@ -483,14 +483,11 @@ $ git checkout -b foo  # or "git switch -c foo"  <1>
 $ git branch foo                                 <2>
 $ git tag foo                                    <3>
 ------------
-
 <1> creates a new branch `foo`, which refers to commit `f`, and then
     updates `HEAD` to refer to branch `foo`. In other words, we'll no longer
     be in detached `HEAD` state after this command.
-
 <2> similarly creates a new branch `foo`, which refers to commit `f`,
     but leaves `HEAD` detached.
-
 <3> creates a new tag `foo`, which refers to commit `f`,
     leaving `HEAD` detached.
 
@@ -519,84 +516,89 @@ to checkout these paths out of the index.
 EXAMPLES
 --------
 
-. The following sequence checks out the `master` branch, reverts
-  the `Makefile` to two revisions back, deletes `hello.c` by
-  mistake, and gets it back from the index.
-+
+=== 1. Paths
+
+The following sequence checks out the `master` branch, reverts
+the `Makefile` to two revisions back, deletes `hello.c` by
+mistake, and gets it back from the index.
+
 ------------
 $ git checkout master             <1>
 $ git checkout master~2 Makefile  <2>
 $ rm -f hello.c
 $ git checkout hello.c            <3>
 ------------
-+
 <1> switch branch
 <2> take a file out of another commit
 <3> restore `hello.c` from the index
-+
+
 If you want to check out _all_ C source files out of the index,
 you can say
-+
+
 ------------
 $ git checkout -- '*.c'
 ------------
-+
+
 Note the quotes around `*.c`.  The file `hello.c` will also be
 checked out, even though it is no longer in the working tree,
 because the file globbing is used to match entries in the index
 (not in the working tree by the shell).
-+
+
 If you have an unfortunate branch that is named `hello.c`, this
 step would be confused as an instruction to switch to that branch.
 You should instead write:
-+
+
 ------------
 $ git checkout -- hello.c
 ------------
 
-. After working in the wrong branch, switching to the correct
-  branch would be done using:
-+
+=== 2. Merge
+
+After working in the wrong branch, switching to the correct
+branch would be done using:
+
 ------------
 $ git checkout mytopic
 ------------
-+
+
 However, your "wrong" branch and correct `mytopic` branch may
 differ in files that you have modified locally, in which case
 the above checkout would fail like this:
-+
+
 ------------
 $ git checkout mytopic
 error: You have local changes to 'frotz'; not switching branches.
 ------------
-+
+
 You can give the `-m` flag to the command, which would try a
 three-way merge:
-+
+
 ------------
 $ git checkout -m mytopic
 Auto-merging frotz
 ------------
-+
+
 After this three-way merge, the local modifications are _not_
 registered in your index file, so `git diff` would show you what
 changes you made since the tip of the new branch.
 
-. When a merge conflict happens during switching branches with
-  the `-m` option, you would see something like this:
-+
+=== 3. Merge conflict
+
+When a merge conflict happens during switching branches with
+the `-m` option, you would see something like this:
+
 ------------
 $ git checkout -m mytopic
 Auto-merging frotz
 ERROR: Merge conflict in frotz
 fatal: merge program failed
 ------------
-+
+
 At this point, `git diff` shows the changes cleanly merged as in
 the previous example, as well as the changes in the conflicted
 files.  Edit and resolve the conflict and mark it resolved with
 `git add` as usual:
-+
+
 ------------
 $ edit frotz
 $ git add frotz
index a65c9aa62d64112dfd03335af82a680e54d00c58..90806fd26aa4ac0d1fef93d25384af3799818896 100644 (file)
@@ -54,9 +54,10 @@ other housekeeping tasks (e.g. rerere, working trees, reflog...) will
 be performed as well.
 
 
---cruft::
+--[no-]cruft::
        When expiring unreachable objects, pack them separately into a
-       cruft pack instead of storing them as loose objects.
+       cruft pack instead of storing them as loose objects. `--cruft`
+       is on by default.
 
 --prune=<date>::
        Prune loose objects older than date (default is 2 weeks ago,
@@ -77,9 +78,10 @@ be performed as well.
        instance running on this repository.
 
 --keep-largest-pack::
-       All packs except the largest pack and those marked with a
-       `.keep` files are consolidated into a single pack. When this
-       option is used, `gc.bigPackThreshold` is ignored.
+       All packs except the largest non-cruft pack, any packs marked
+       with a `.keep` file, and any cruft pack(s) are consolidated into
+       a single pack. When this option is used, `gc.bigPackThreshold`
+       is ignored.
 
 AGGRESSIVE
 ----------
index e06af02f211e7a7a8488d1470d7f76dd58e5989c..0c1be2dbe85caf3300a314c374dd12d54b7434a7 100644 (file)
@@ -611,8 +611,8 @@ result of repeatedly resetting the objects' mtimes to the present time.
 
 If you are GC-ing repositories in a mixed version environment, consider omitting
 the `--cruft` option when using linkgit:git-repack[1] and linkgit:git-gc[1], and
-leaving the `gc.cruftPacks` configuration unset until all writers understand
-cruft packs.
+setting the `gc.cruftPacks` configuration to "false" until all writers
+understand cruft packs.
 
 === Alternatives
 
index 62908602e7bee3ff4bd6c0aaeca39f5ac3bc7741..c8e55b2613f520a1ad7006f403611097257a850f 100644 (file)
@@ -600,6 +600,28 @@ the name of the file that holds the e-mail to be sent.  Exiting with a
 non-zero status causes `git send-email` to abort before sending any
 e-mails.
 
+The following environment variables are set when executing the hook.
+
+`GIT_SENDEMAIL_FILE_COUNTER`::
+       A 1-based counter incremented by one for every file holding an e-mail
+       to be sent (excluding any FIFOs). This counter does not follow the
+       patch series counter scheme. It will always start at 1 and will end at
+       GIT_SENDEMAIL_FILE_TOTAL.
+
+`GIT_SENDEMAIL_FILE_TOTAL`::
+       The total number of files that will be sent (excluding any FIFOs). This
+       counter does not follow the patch series counter scheme. It will always
+       be equal to the number of files being sent, whether there is a cover
+       letter or not.
+
+These variables may for instance be used to validate patch series.
+
+The sample `sendemail-validate` hook that comes with Git checks that all sent
+patches (excluding the cover letter) can be applied on top of the upstream
+repository default branch without conflicts. Some placeholders are left for
+additional validation steps to be performed after all patches of a given series
+have been applied.
+
 fsmonitor-watchman
 ~~~~~~~~~~~~~~~~~~
 
index 60ab1a8b4f4f2f72b6d6232d1d0130a57eb4a082..e440728c2461b9367e01db5a817ae48479afcf65 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1032,6 +1032,7 @@ LIB_OBJS += fsmonitor.o
 LIB_OBJS += fsmonitor-ipc.o
 LIB_OBJS += fsmonitor-settings.o
 LIB_OBJS += gettext.o
+LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
@@ -1192,7 +1193,6 @@ LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
 LIB_OBJS += xdiff-interface.o
-LIB_OBJS += zlib.o
 
 BUILTIN_OBJS += builtin/add.o
 BUILTIN_OBJS += builtin/am.o
index 1e1ee2df59674ebf5340ae77b8e00a3de30f1947..8d770d203ff78f487b9497cf0603436cb56d4e74 100644 (file)
@@ -1,8 +1,11 @@
 #include "cache.h"
 #include "add-interactive.h"
+#include "advice.h"
 #include "alloc.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/apply.c b/apply.c
index 9b7288bc9270754447b1750142c58946ba9b04c6..3636bc14c2dfd482fcc146b3c560d908caccd919 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -22,6 +22,8 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
@@ -4586,7 +4588,7 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
        FILE *rej;
        char namebuf[PATH_MAX];
        struct fragment *frag;
-       int cnt = 0;
+       int fd, cnt = 0;
        struct strbuf sb = STRBUF_INIT;
 
        for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
@@ -4626,7 +4628,17 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
        memcpy(namebuf, patch->new_name, cnt);
        memcpy(namebuf + cnt, ".rej", 5);
 
-       rej = fopen(namebuf, "w");
+       fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
+       if (fd < 0) {
+               if (errno != EEXIST)
+                       return error_errno(_("cannot open %s"), namebuf);
+               if (unlink(namebuf))
+                       return error_errno(_("cannot unlink '%s'"), namebuf);
+               fd = open(namebuf, O_CREAT | O_EXCL | O_WRONLY, 0666);
+               if (fd < 0)
+                       return error_errno(_("cannot open %s"), namebuf);
+       }
+       rej = fdopen(fd, "w");
        if (!rej)
                return error_errno(_("cannot open %s"), namebuf);
 
index 497dad0b3af4adac513ee70d5eb72f9cc1517179..4cd81d8161e738c582d47709a90bc2f55d838f50 100644 (file)
@@ -5,6 +5,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "tar.h"
 #include "archive.h"
index e6f5c10a14f20a105de81224aae0144610f5a312..ef538a90df4ff3815f8b23bcebb5b2947306ae40 100644 (file)
@@ -5,6 +5,7 @@
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "streaming.h"
 #include "utf8.h"
index d2d1b4eb42e713ed36715478af9b582c98510296..8570cf37ff76450db090600a5dfd893ea552f652 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
index 7178e2a9a2d06c5c3eaaa8884464e6f4cc26fbde..3a4bdfbd078109680dd54143d03ee2567a0cba31 100644 (file)
--- a/archive.h
+++ b/archive.h
@@ -1,8 +1,9 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
-#include "cache.h"
+#include "object-name.h"
 #include "pathspec.h"
+#include "string-list.h"
 
 struct repository;
 struct pretty_print_context;
index 0a5f2ed35467e47f80a7c1968b5c7de3035ed64a..8d5f8e58851ea650224c8de043891ea0de4a77cd 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
 #include "diff.h"
@@ -17,6 +17,7 @@
 #include "strvec.h"
 #include "commit-slab.h"
 #include "commit-reach.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "dir.h"
 
diff --git a/blame.c b/blame.c
index 2c427bcdbfdddecc7835b2628caca279a7925b99..58dd58b6c975025e6fb400dc99ee28be50c2f475 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -3,12 +3,14 @@
 #include "object-store.h"
 #include "cache-tree.h"
 #include "mergesort.h"
+#include "convert.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
 #include "hex.h"
 #include "setup.h"
 #include "tag.h"
+#include "trace2.h"
 #include "blame.h"
 #include "alloc.h"
 #include "commit-slab.h"
index 99a0e7889e42226ce8230e8d0472268bcfec7fe5..7df982693af14f79a97b5c456a4416c3bd133a51 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -1,10 +1,11 @@
 #include "git-compat-util.h"
-#include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "branch.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
index f12054d9be113b5fa63bd0df1445ae59343d4cd5..76cc026a68a992a750b24a9ac23d05f4899dacc2 100644 (file)
@@ -5,9 +5,11 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
+#include "editor.h"
 #include "dir.h"
 #include "gettext.h"
 #include "pathspec.h"
index cd1e20f24e542360fbc7bcb7b6ada156d13bf89d..5c83f2e003fb01ab6409a23e3a79ab15e4aed6f2 100644 (file)
@@ -6,8 +6,10 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
@@ -26,6 +28,7 @@
 #include "diffcore.h"
 #include "unpack-trees.h"
 #include "branch.h"
+#include "object-name.h"
 #include "sequencer.h"
 #include "revision.h"
 #include "merge-recursive.h"
@@ -37,6 +40,7 @@
 #include "apply.h"
 #include "string-list.h"
 #include "packfile.h"
+#include "pager.h"
 #include "repository.h"
 #include "pretty.h"
 #include "wrapper.h"
index 26f07357a03ead1e0bba6946c4f3afb68ed60eeb..4b2143d4557a8de9007b4885866c1d4ca9668cc8 100644 (file)
@@ -3,12 +3,14 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
 #include "refs.h"
 #include "dir.h"
 #include "strvec.h"
 #include "run-command.h"
+#include "oid-array.h"
 #include "prompt.h"
 #include "quote.h"
 #include "revision.h"
index a8d2114adc90f84de3610019d3599192f0be4f4d..2df6039a6e0e139227c937023b8d8565e5ceb611 100644 (file)
@@ -28,7 +28,9 @@
 #include "line-log.h"
 #include "dir.h"
 #include "progress.h"
+#include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "blame.h"
 #include "refs.h"
 #include "setup.h"
index bb7e1ac206373311c217b66002c93ba0c1ae4db2..501c47657c9dfaff84d4fdef4414f6e01d960f9e 100644 (file)
@@ -8,11 +8,13 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "refs.h"
 #include "commit.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "branch.h"
index 52955e1d389bbd92628a0329a17998a0b8513cfd..daf6c236577626fffd8dd61c63489d9e6e706635 100644 (file)
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "abspath.h"
+#include "editor.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "strbuf.h"
@@ -8,6 +9,7 @@
 #include "hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
+#include "object-file.h"
 #include "setup.h"
 #include "wrapper.h"
 
index 04d4bb6c77772fa185c40573fa5b231501709112..0bafc14e6c03ac1c034e64878b884ebcb15128af 100644 (file)
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "builtin.h"
 #include "diff.h"
 #include "environment.h"
@@ -19,6 +20,8 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
index 1dbe9d6ca887811134b77df04c8bc6ff453d3625..037bf1aaa2ab3b8202902a3dec30ff1b2b519321 100644 (file)
@@ -5,6 +5,7 @@
 #include "attr.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "quote.h"
 #include "setup.h"
 #include "parse-options.h"
index 38a8cd6a965210b3959043c3e228a3d84ba93ab1..6f5d82ed3d3b8944676739b99325c7ad28e9b425 100644 (file)
@@ -15,7 +15,9 @@
 #include "hook.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "mem-pool.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "refs.h"
@@ -26,6 +28,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
index eeec8067ec30315dbe85f5a5f44298358bfc7e86..186845ef0b54c9965a12bcd05330cec3890d810c 100644 (file)
@@ -11,6 +11,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
@@ -20,6 +21,7 @@
 #include "fetch-pack.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tree.h"
 #include "tree-walk.h"
@@ -40,6 +42,7 @@
 #include "hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
+#include "wrapper.h"
 
 /*
  * Overall FIXMEs:
index 901142697612feb7354e87049d44048411fbcd13..a3d00fa232b51a0ed6581a2638ca65bf50db3023 100644 (file)
@@ -12,6 +12,7 @@
 #include "progress.h"
 #include "replace-object.h"
 #include "tag.h"
+#include "trace2.h"
 
 #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
        N_("git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress]")
index 15be167f87a47915530996248cb95fcedaf30b95..d1d251c3ded2798ecb6667034bb7e21477be847d 100644 (file)
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
index 9d8e1ea91a327248799cf137ef3c0aaf0fc65ed1..e67c4be2211eed8f6c8d61f510adc2fc87d9b007 100644 (file)
@@ -7,11 +7,13 @@
 
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "lockfile.h"
 #include "cache-tree.h"
 #include "color.h"
 #include "dir.h"
+#include "editor.h"
 #include "environment.h"
 #include "builtin.h"
 #include "diff.h"
@@ -26,6 +28,7 @@
 #include "log-tree.h"
 #include "strbuf.h"
 #include "utf8.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "rerere.h"
index fe79fb60c4377bce46fa56f44e7534cf7b96e0d8..9401f1e5e3b21d44386f623e0037f8385041d2a4 100644 (file)
@@ -3,6 +3,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
index 62c09a271d6eb4578ef0360910575c5611f61ffd..4e571d9951b540637526fb9a2eaea4226c6e16fa 100644 (file)
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 
 #ifndef NO_UNIX_SOCKETS
index c6b388e6494df94831c2b7c6cd99afae36ee63bc..55b4baaa223d9aa2ba32ee61539d39f28445a839 100644 (file)
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "revision.h"
 #include "diff.h"
index 0f8b64994c427a241e3d66726775d86a37c51f10..4f22eb2b55d06968896d12ae9257d470d5d3a8fb 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "diagnose.h"
 
index 5ba524fa639cdd30dd6f6fa846519370fecc2510..f09d24d37f9e81727afbec6aa05ab6e1720064c1 100644 (file)
@@ -25,6 +25,7 @@
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "dir.h"
 #include "entry.h"
index 8224bf4bc1d58b581d361cafcac5a584c1bbf850..9a95f6a1a82affafc02895cce56ed9a790c6666c 100644 (file)
@@ -10,6 +10,7 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "commit.h"
 #include "object.h"
index 1fb95275d70669006f1f43271880b23e776c6a98..bbd9b2b3e715db7e84011cc41542e2fe6dd4d4f0 100644 (file)
@@ -19,6 +19,8 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
 #include "commit-reach.h"
index 5f341b794dc0184c936a4dd9aad4d93dca2cd9dc..3ba0fe5a39614b3785f80ad75cd0f3a494547f37 100644 (file)
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "remote.h"
index 85bd2801036a8401a096043e26db1aeadc44d325..ab623f41b4d60cd2dab4a7b92c3bd01007b4bdea 100644 (file)
@@ -2,6 +2,7 @@
  * "git fetch"
  */
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "environment.h"
@@ -9,8 +10,10 @@
 #include "repository.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oidset.h"
+#include "oid-array.h"
 #include "commit.h"
 #include "builtin.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "utf8.h"
 #include "packfile.h"
+#include "pager.h"
 #include "list-objects-filter-options.h"
 #include "commit-reach.h"
 #include "branch.h"
 #include "promisor-remote.h"
 #include "commit-graph.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "bundle-uri.h"
 
index 095b39d39803492fd8142269d0b26cefb580b37e..2cd461b84c11db2b34b61ca01a9246bb70ac39a6 100644 (file)
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "worktree.h"
+#include "pack-revindex.h"
 
 #define REACHABLE 0x0001
 #define SEEN      0x0002
@@ -53,6 +56,7 @@ static int name_objects;
 #define ERROR_REFS 010
 #define ERROR_COMMIT_GRAPH 020
 #define ERROR_MULTI_PACK_INDEX 040
+#define ERROR_PACK_REV_INDEX 0100
 
 static const char *describe_object(const struct object_id *oid)
 {
@@ -856,6 +860,38 @@ static int mark_packed_for_connectivity(const struct object_id *oid,
        return 0;
 }
 
+static int check_pack_rev_indexes(struct repository *r, int show_progress)
+{
+       struct progress *progress = NULL;
+       uint32_t pack_count = 0;
+       int res = 0;
+
+       if (show_progress) {
+               for (struct packed_git *p = get_all_packs(the_repository); p; p = p->next)
+                       pack_count++;
+               progress = start_delayed_progress("Verifying reverse pack-indexes", pack_count);
+               pack_count = 0;
+       }
+
+       for (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {
+               int load_error = load_pack_revindex_from_disk(p);
+
+               if (load_error < 0) {
+                       error(_("unable to load rev-index for pack '%s'"), p->pack_name);
+                       res = ERROR_PACK_REV_INDEX;
+               } else if (!load_error &&
+                          !load_pack_revindex(the_repository, p) &&
+                          verify_pack_revindex(p)) {
+                       error(_("invalid rev-index for pack '%s'"), p->pack_name);
+                       res = ERROR_PACK_REV_INDEX;
+               }
+               display_progress(progress, ++pack_count);
+       }
+       stop_progress(&progress);
+
+       return res;
+}
+
 static char const * const fsck_usage[] = {
        N_("git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]\n"
           "         [--[no-]full] [--strict] [--verbose] [--lost-found]\n"
@@ -1019,6 +1055,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
                free_worktrees(worktrees);
        }
 
+       errors_found |= check_pack_rev_indexes(the_repository, show_progress);
+
        check_connectivity();
 
        if (the_repository->settings.core_commit_graph) {
index 42af6a2cc7e7df7f96906227da62f580c261d0b7..f6dd9a784c195e6ff5368b1b86c1eaa0c6c4b4c0 100644 (file)
@@ -14,6 +14,7 @@
 #include "simple-ipc.h"
 #include "khash.h"
 #include "pkt-line.h"
+#include "trace2.h"
 
 static const char * const builtin_fsmonitor__daemon_usage[] = {
        N_("git fsmonitor--daemon start [<options>]"),
index edd98d35a5a460a06bd812e455be201a0309d334..c9f855733515b7eb13cbf1863fb4fb1eacd3fcd9 100644 (file)
@@ -25,6 +25,7 @@
 #include "commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-objects.h"
@@ -37,6 +38,7 @@
 #include "gettext.h"
 #include "hook.h"
 #include "setup.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 #define FAILED_RUN "failed to run %s"
@@ -48,7 +50,7 @@ static const char * const builtin_gc_usage[] = {
 
 static int pack_refs = 1;
 static int prune_reflogs = 1;
-static int cruft_packs = -1;
+static int cruft_packs = 1;
 static int aggressive_depth = 50;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
@@ -219,7 +221,7 @@ static struct packed_git *find_base_packs(struct string_list *packs,
        struct packed_git *p, *base = NULL;
 
        for (p = get_all_packs(the_repository); p; p = p->next) {
-               if (!p->pack_local)
+               if (!p->pack_local || p->is_cruft)
                        continue;
                if (limit) {
                        if (p->pack_size >= limit)
@@ -608,10 +610,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
        if (prune_expire && parse_expiry_date(prune_expire, &dummy))
                die(_("failed to parse prune expiry value %s"), prune_expire);
 
-       prepare_repo_settings(the_repository);
-       if (cruft_packs < 0)
-               cruft_packs = the_repository->settings.gc_cruft_packs;
-
        if (aggressive) {
                strvec_push(&repack, "-f");
                if (aggressive_depth > 0)
index a1b68d90bdb630327f08273b4f3658db86e2eb6a..b86c754defbc59654a6e455b2115487ba01f084f 100644 (file)
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "pager.h"
 #include "write-or-die.h"
 
 static const char *grep_prefix;
index a15fe4fd3f4f96b9f82535c224956eb957e93b49..a3801211666410eb703fa11bd24a4ba03ff3e6ea 100644 (file)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "quote.h"
index 87333a02ec40adb4e2b2b613b840c36f066f4e52..128aa83099a8a9cb8d1b31b9823464d3b12cb5ec 100644 (file)
@@ -6,6 +6,7 @@
 #include "builtin.h"
 #include "exec-cmd.h"
 #include "gettext.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "config-list.h"
index b17e79cd40f797d53ee3dbe12440af0ed4787228..bb67e16655994ceee8116a6325ead1daf1d8e860 100644 (file)
 #include "streaming.h"
 #include "thread-utils.h"
 #include "packfile.h"
+#include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "setup.h"
@@ -1753,12 +1756,13 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
        fsck_options.walk = mark_link;
 
        reset_pack_idx_option(&opts);
+       opts.flags |= WRITE_REV;
        git_config(git_index_pack_config, &opts);
        if (prefix && chdir(prefix))
                die(_("Cannot come back to cwd"));
 
-       if (git_env_bool(GIT_TEST_WRITE_REV_INDEX, 0))
-               rev_index = 1;
+       if (git_env_bool(GIT_TEST_NO_WRITE_REV_INDEX, 0))
+               rev_index = 0;
        else
                rev_index = !!(opts.flags & (WRITE_REV_VERIFY | WRITE_REV));
 
index ba6e0b20fa524e2f4fdb5d43dd977ed2046a36f1..6183f3fb3ffabba2485374da44ca4d5a1e732f13 100644 (file)
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "setup.h"
 #include "worktree.h"
index 7d195789633978c03c18e2c331d75f1b56f924e8..4f162ff4d0cbb4dbc90330dfacbb714ca543a1e8 100644 (file)
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "color.h"
 #include "commit.h"
 #include "diff.h"
@@ -20,6 +23,7 @@
 #include "revision.h"
 #include "log-tree.h"
 #include "builtin.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "reflog-walk.h"
 #include "patch-ids.h"
index ed35fa8d8e84b57bbc7bc2b3e62a2b4d437c992f..625f48f0d6178f9078f887a2941e4d8c2a9efe30 100644 (file)
@@ -8,10 +8,12 @@
 #include "cache.h"
 #include "repository.h"
 #include "config.h"
+#include "convert.h"
 #include "quote.h"
 #include "dir.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "tree.h"
 #include "cache-tree.h"
index f32e6be21983cff504ac46cc727bc076cae4026c..077977a46100327e9d611e8badb9d0c9190de33f 100644 (file)
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
index 3f22273b40076df9432f5b435b92461badda064d..854019a32dcc63c9e2504f7aa9e96e7cd7a86762 100644 (file)
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "diff.h"
 #include "revision.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "repository.h"
 #include "commit-reach.h"
index 91ed55f3ab79b0aff7c0870b0e9d3eeaaa3f63cb..708a8ffabeaf8dc9adefb97436a1845076b4a6e9 100644 (file)
@@ -1,9 +1,11 @@
 #include "cache.h"
 #include "builtin.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "tag.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
index 803e380856edf087ca06bb42bef1813d2c6b11ba..6b9f006ec190d734ce8ee5a2aee1652aebf15ae8 100644 (file)
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "commit-reach.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "repository.h"
index a99be9610e9bc1950deb0afd9c47395ccc6a3ab1..8da3e46abb0fdc692faac47e0b0deb9e13fe4194 100644 (file)
@@ -9,11 +9,14 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "builtin.h"
 #include "lockfile.h"
index b3f6d7ea389788610c6ae9351f31ed040b2eb264..44fa56eff38c298f5444ff1c7dc5fdfdbd1adc7d 100644 (file)
@@ -4,6 +4,7 @@
 #include "parse-options.h"
 #include "tag.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "fsck.h"
 #include "config.h"
index b7c5ffbd8c796f5848523ac8fbe450ce425be13d..32935af48e66bddf032a8e47e0bceb5aa1f706d3 100644 (file)
@@ -6,10 +6,12 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "pathspec.h"
 #include "lockfile.h"
 #include "dir.h"
index 831d360a78a6a706cd1e6b4cc5b9d3eced21bea6..593f0506a105c50d934f0ca405bed2006b0bffe5 100644 (file)
@@ -8,6 +8,8 @@
 #include "commit.h"
 #include "tag.h"
 #include "refs.h"
+#include "object-name.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
index 4ff44f1e3d09bf277546a63281b6e2c300c29173..d5788352b6ee7c69663ddf822134b55a36bf95b0 100644 (file)
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "blob.h"
index 77d88f85b04c6d8febb6ed3c79d817e68a991ac2..a5b466839bad1b4529b9aafc822fc6d3e516448e 100644 (file)
@@ -33,6 +33,7 @@
 #include "strvec.h"
 #include "list.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "dir.h"
@@ -3359,16 +3360,16 @@ static void read_packs_list_from_stdin(void)
        }
 
        string_list_sort(&include_packs);
+       string_list_remove_duplicates(&include_packs, 0);
        string_list_sort(&exclude_packs);
+       string_list_remove_duplicates(&exclude_packs, 0);
 
        for (p = get_all_packs(the_repository); p; p = p->next) {
                const char *pack_name = pack_basename(p);
 
-               item = string_list_lookup(&include_packs, pack_name);
-               if (!item)
-                       item = string_list_lookup(&exclude_packs, pack_name);
-
-               if (item)
+               if ((item = string_list_lookup(&include_packs, pack_name)))
+                       item->util = p;
+               if ((item = string_list_lookup(&exclude_packs, pack_name)))
                        item->util = p;
        }
 
@@ -4293,9 +4294,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        }
 
        reset_pack_idx_option(&pack_idx_opts);
+       pack_idx_opts.flags |= WRITE_REV;
        git_config(git_pack_config, NULL);
-       if (git_env_bool(GIT_TEST_WRITE_REV_INDEX, 0))
-               pack_idx_opts.flags |= WRITE_REV;
+       if (git_env_bool(GIT_TEST_NO_WRITE_REV_INDEX, 0))
+               pack_idx_opts.flags &= ~WRITE_REV;
 
        progress = isatty(2);
        argc = parse_options(argc, argv, prefix, pack_objects_options,
index 5c0952f5c647c255c2b29e41c4f349a4ecbfc9ff..5dc9b20720006700584069a3b6aa1211088ff5d7 100644 (file)
@@ -11,6 +11,8 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
 
index 5405d09f22fbf5b2c5b036650d175ba3e7d1eaae..967368ebc65e6eb36562b4d4c690694cea71eeb0 100644 (file)
@@ -7,10 +7,12 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "exec-cmd.h"
 #include "run-command.h"
index fa550b8f80ad4e3d8da1f15fbf98ba8ac6858d03..6001e4ae0a4723af3a23c6334936bc094b7a8895 100644 (file)
@@ -2,6 +2,7 @@
  * "git push"
  */
 #include "cache.h"
+#include "advice.h"
 #include "branch.h"
 #include "config.h"
 #include "environment.h"
@@ -16,6 +17,7 @@
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
+#include "trace2.h"
 #include "color.h"
 
 static const char * const push_usage[] = {
index b72af527f08bc1275d4e1ccf4c56870c3c0dc822..04339a92ea5d1a62df2aa63b73619c2a6c2167ae 100644 (file)
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "range-diff.h"
 #include "config.h"
index 600d4f748fcff432f05bbeb318d7007f5b551c7f..d61cbad96de6a40136ccdbedd8aa2be5fadb5fca 100644 (file)
@@ -11,6 +11,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "object.h"
+#include "object-name.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "cache-tree.h"
index 1ceac603c724aabd482b15680b2df195d3039622..ace1d5e8d11afee64ce0e400867b97b627282f2f 100644 (file)
@@ -21,6 +21,8 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
 #include "diff.h"
@@ -32,6 +34,7 @@
 #include "sequencer.h"
 #include "rebase-interactive.h"
 #include "reset.h"
+#include "trace2.h"
 #include "hook.h"
 #include "wrapper.h"
 
index 9109552533d838755a0db62b8de9bd8a671cad12..d22180435c5b797f1543e52f7c5840c611f04178 100644 (file)
 #include "tmp-objdir.h"
 #include "oidset.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "shallow.h"
 #include "parse-options.h"
@@ -2093,7 +2096,7 @@ static struct command *read_head_info(struct packet_reader *reader,
                        const char *feature_list = reader->line + linelen + 1;
                        const char *hash = NULL;
                        const char *client_sid;
-                       int len = 0;
+                       size_t len = 0;
                        if (parse_feature_request(feature_list, "report-status"))
                                report_status = 1;
                        if (parse_feature_request(feature_list, "report-status-v2"))
index df4d8e0f0bafc912f4b5cb410aaf74abf6819ec4..bb7bf60e7ce99d48296e34db33048baa1cde3c1e 100644 (file)
@@ -325,7 +325,8 @@ static int geometry_cmp(const void *va, const void *vb)
 }
 
 static void init_pack_geometry(struct pack_geometry **geometry_p,
-                              struct string_list *existing_kept_packs)
+                              struct string_list *existing_kept_packs,
+                              const struct pack_objects_args *args)
 {
        struct packed_git *p;
        struct pack_geometry *geometry;
@@ -335,6 +336,14 @@ static void init_pack_geometry(struct pack_geometry **geometry_p,
        geometry = *geometry_p;
 
        for (p = get_all_packs(the_repository); p; p = p->next) {
+               if (args->local && !p->pack_local)
+                       /*
+                        * When asked to only repack local packfiles we skip
+                        * over any packfiles that are borrowed from alternate
+                        * object directories.
+                        */
+                       continue;
+
                if (!pack_kept_objects) {
                        /*
                         * Any pack that has its pack_keep bit set will appear
@@ -448,8 +457,10 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
        geometry->split = split;
 }
 
-static struct packed_git *get_largest_active_pack(struct pack_geometry *geometry)
+static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)
 {
+       uint32_t i;
+
        if (!geometry) {
                /*
                 * No geometry means either an all-into-one repack (in which
@@ -464,7 +475,21 @@ static struct packed_git *get_largest_active_pack(struct pack_geometry *geometry
        }
        if (geometry->split == geometry->pack_nr)
                return NULL;
-       return geometry->pack[geometry->pack_nr - 1];
+
+       /*
+        * The preferred pack is the largest pack above the split line. In
+        * other words, it is the largest pack that does not get rolled up in
+        * the geometric repack.
+        */
+       for (i = geometry->pack_nr; i > geometry->split; i--)
+               /*
+                * A pack that is not local would never be included in a
+                * multi-pack index. We thus skip over any non-local packs.
+                */
+               if (geometry->pack[i - 1]->pack_local)
+                       return geometry->pack[i - 1];
+
+       return NULL;
 }
 
 static void clear_pack_geometry(struct pack_geometry *geometry)
@@ -558,6 +583,17 @@ static void midx_included_packs(struct string_list *include,
                for (i = geometry->split; i < geometry->pack_nr; i++) {
                        struct packed_git *p = geometry->pack[i];
 
+                       /*
+                        * The multi-pack index never refers to packfiles part
+                        * of an alternate object database, so we skip these.
+                        * While git-multi-pack-index(1) would silently ignore
+                        * them anyway, this allows us to skip executing the
+                        * command completely when we have only non-local
+                        * packfiles.
+                        */
+                       if (!p->pack_local)
+                               continue;
+
                        strbuf_addstr(&buf, pack_basename(p));
                        strbuf_strip_suffix(&buf, ".pack");
                        strbuf_addstr(&buf, ".idx");
@@ -591,7 +627,7 @@ static int write_midx_included_packs(struct string_list *include,
 {
        struct child_process cmd = CHILD_PROCESS_INIT;
        struct string_list_item *item;
-       struct packed_git *largest = get_largest_active_pack(geometry);
+       struct packed_git *preferred = get_preferred_pack(geometry);
        FILE *in;
        int ret;
 
@@ -612,9 +648,9 @@ static int write_midx_included_packs(struct string_list *include,
        if (write_bitmaps)
                strvec_push(&cmd.args, "--bitmap");
 
-       if (largest)
+       if (preferred)
                strvec_pushf(&cmd.args, "--preferred-pack=%s",
-                            pack_basename(largest));
+                            pack_basename(preferred));
 
        if (refs_snapshot)
                strvec_pushf(&cmd.args, "--refs-snapshot=%s", refs_snapshot);
@@ -774,7 +810,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                N_("same as -a, pack unreachable cruft objects separately"),
                                   PACK_CRUFT),
                OPT_STRING(0, "cruft-expiration", &cruft_expiration, N_("approxidate"),
-                               N_("with -C, expire objects older than this")),
+                               N_("with --cruft, expire objects older than this")),
                OPT_BOOL('d', NULL, &delete_redundant,
                                N_("remove redundant packs, and run git-prune-packed")),
                OPT_BOOL('f', NULL, &po_args.no_reuse_delta,
@@ -853,6 +889,18 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)
                die(_(incremental_bitmap_conflict_error));
 
+       if (write_bitmaps && po_args.local && has_alt_odb(the_repository)) {
+               /*
+                * When asked to do a local repack, but we have
+                * packfiles that are inherited from an alternate, then
+                * we cannot guarantee that the multi-pack-index would
+                * have full coverage of all objects. We thus disable
+                * writing bitmaps in that case.
+                */
+               warning(_("disabling bitmap writing, as some objects are not being packed"));
+               write_bitmaps = 0;
+       }
+
        if (write_midx && write_bitmaps) {
                struct strbuf path = STRBUF_INIT;
 
@@ -875,7 +923,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        if (geometric_factor) {
                if (pack_everything)
                        die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
-               init_pack_geometry(&geometry, &existing_kept_packs);
+               init_pack_geometry(&geometry, &existing_kept_packs, &po_args);
                split_pack_geometry(geometry, geometric_factor);
        }
 
index d2adc8ab613401db7dcd8bf05aff5830ded984c7..981f1894436dd3c3d2df15c0926e2a808557703d 100644 (file)
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "repository.h"
index 0ed329236c88e3f92692d5c3b6d2c69064bdb242..f99f32d5802fc537441982e45ec6539cc0241e94 100644 (file)
@@ -9,6 +9,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
 #include "diffcore.h"
 #include "tree.h"
 #include "branch.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "unpack-trees.h"
 #include "cache-tree.h"
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace.h"
+#include "trace2.h"
 #include "dir.h"
 #include "add-interactive.h"
 
index a3dbbb6338ebe5ac297b807c87f0d06effd48a86..6dc8be492a2c424623de0dddc0006a1b0a242f7e 100644 (file)
@@ -10,6 +10,8 @@
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
 #include "object.h"
+#include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
index 1af2089f9bd04810cb057b94371f67e45523ad0b..852e49e3403119707118973f6285e26c0893c355 100644 (file)
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "quote.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "diff.h"
 #include "revision.h"
index 6be92817429a880130b8d3604c43d75115b9b5e3..d36072252e72ab5d4aa90243b81df15e17bda08f 100644 (file)
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "gettext.h"
 #include "tree-walk.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "setup.h"
index 463a8d11c317cd5d47facf1cbe9386c474decf8e..20030b75e39ffd8cae40b6a743f7e23f364364d8 100644 (file)
@@ -8,6 +8,7 @@
 #include "builtin.h"
 #include "color.h"
 #include "strvec.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "dir.h"
 #include "commit-slab.h"
index 138d30a005e2de9067cc2f280ea5bf205a7b11be..a2243b42195b1b89c49a26f0c80b2bc09de142da 100644 (file)
@@ -4,6 +4,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
index 5e917ead7bc304956faa789a60b8a6663d1d6123..40d420f06cb0c58e57b957f322dd0485b7669023 100644 (file)
@@ -4,6 +4,8 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
 #include "repository.h"
index 735d27039e1865369018f127666a009928e8fda4..a7e17ffe3844a5b5567450c61a830e18de4b1361 100644 (file)
@@ -5,6 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "lockfile.h"
index 569068e6a2c90cda1006143eae8bdba41fa951a3..6bf8d666ce91203024b69192ab427df40912904c 100644 (file)
@@ -24,6 +24,8 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
 #include "branch.h"
index ab5f5c74f437288797383ccd2aab199435f28266..1850a6a6fdcf82f18ad3f1f1aefd5d22fc527e3f 100644 (file)
@@ -7,12 +7,15 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "run-command.h"
index 00179180c7dfd0d57a4ade4bee842d6af9636900..b35a4b9dfee83e9050771bf0f6d51555f1b32dcd 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "wrapper.h"
 
index 585e81b1069007625409c5e1bd2a4d304c306ca6..2c52c3a741fbd49d7782f6388e2ebe38f54cb8fb 100644 (file)
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "object-store.h"
 #include "object.h"
index 03cda5e60d2bd17c6de251c815d9c2bdd319429b..33b00cef15190467fb79e93cf5e50a251e856030 100644 (file)
@@ -15,6 +15,7 @@
 #include "cache-tree.h"
 #include "tree-walk.h"
 #include "builtin.h"
+#include "object-file.h"
 #include "refs.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
index 3ffd75b3e78ca96a4d8266b89588d29e9cffaa99..6ca85420c3b82f0eb92321679540d0c3a2fa1802 100644 (file)
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "refs.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "strvec.h"
index acb988d2d56fec4645c7d905023027f203c43911..214999898079454affe0882be5b4e7a24a7a569b 100644 (file)
@@ -5,7 +5,9 @@
  */
 #include "builtin.h"
 #include "config.h"
+#include "editor.h"
 #include "ident.h"
+#include "pager.h"
 #include "refs.h"
 
 static const char var_usage[] = "git var (-l | <variable>)";
index 4d10aa98b109c04aa554647fea42144dd1596505..5d99b82a64f65efcc673ee8da144748f5e62fc82 100644 (file)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
index 28d0da684542deaa68f71326300c4bae0f83ab9f..c6019a0ad8cf79f92df9e1e443df373516f67db9 100644 (file)
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
index 39e9e5c9ce8239df42cfcf566d6e51d829db3a3d..a61bc32189d1be96ccdb147bb7f0283ead6a7303 100644 (file)
@@ -7,6 +7,8 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
 #include "branch.h"
index 6362b6aabc7f4f363e0e628869cb2213040b4ed1..d843279715c3369ed92f853bd91c0e846af55049 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "bulk-checkin.h"
 #include "environment.h"
@@ -15,7 +15,9 @@
 #include "string-list.h"
 #include "tmp-objdir.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
+#include "wrapper.h"
 
 static int odb_transaction_nesting;
 
index 6471489975a52bf3e498d49d02a36728bbe2fb5e..a5505368de5a9190e0ee6238b6f905cfca5f0efe 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
 #include "environment.h"
index ff14b527da38acc6968d88df65a1e1ebfd854b5b..ebfe649b330760eb5f13f172c4d5a9f4ed29da41 100644 (file)
@@ -7,10 +7,13 @@
 #include "tree-walk.h"
 #include "cache-tree.h"
 #include "bulk-checkin.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "sparse-index.h"
+#include "trace.h"
+#include "trace2.h"
 
 #ifndef DEBUG_CACHE_TREE
 #define DEBUG_CACHE_TREE 0
diff --git a/cache.h b/cache.h
index 82d7b112b4e71cc2d707f637178841a327217584..71e2fe74c4fd6b45c49e987207777ab6020d6f83 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -4,46 +4,11 @@
 #include "git-compat-util.h"
 #include "strbuf.h"
 #include "hashmap.h"
-#include "list.h"
-#include "advice.h"
 #include "gettext.h"
-#include "convert.h"
-#include "trace.h"
-#include "trace2.h"
 #include "string-list.h"
-#include "pack-revindex.h"
-#include "hash.h"
-#include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "oid-array.h"
-#include "repository.h"
 #include "statinfo.h"
-#include "mem-pool.h"
-
-typedef struct git_zstream {
-       z_stream z;
-       unsigned long avail_in;
-       unsigned long avail_out;
-       unsigned long total_in;
-       unsigned long total_out;
-       unsigned char *next_in;
-       unsigned char *next_out;
-} git_zstream;
-
-void git_inflate_init(git_zstream *);
-void git_inflate_init_gzip_only(git_zstream *);
-void git_inflate_end(git_zstream *);
-int git_inflate(git_zstream *, int flush);
-
-void git_deflate_init(git_zstream *, int level);
-void git_deflate_init_gzip(git_zstream *, int level);
-void git_deflate_init_raw(git_zstream *, int level);
-void git_deflate_end(git_zstream *);
-int git_deflate_abort(git_zstream *);
-int git_deflate_end_gently(git_zstream *);
-int git_deflate(git_zstream *, int flush);
-unsigned long git_deflate_bound(git_zstream *, unsigned long);
 
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
 #define DTYPE(de)      ((de)->d_type)
@@ -59,18 +24,6 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);
 #define DTYPE(de)      DT_UNKNOWN
 #endif
 
-/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
-#define S_IFINVALID     0030000
-
-/*
- * A "directory link" is a link to another git directory.
- *
- * The value 0160000 is not normally a valid mode, and
- * also just happens to be S_IFDIR + S_IFLNK
- */
-#define S_IFGITLINK    0160000
-#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
-
 /*
  * Some mode bits are also used internally for computations.
  *
@@ -86,27 +39,6 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);
 #define S_DIFFTREE_IFXMIN_NEQ  0x80000000
 
 
-/*
- * Intensive research over the course of many years has shown that
- * port 9418 is totally unused by anything else. Or
- *
- *     Your search - "port 9418" - did not match any documents.
- *
- * as www.google.com puts it.
- *
- * This port has been properly assigned for git use by IANA:
- * git (Assigned-9418) [I06-050728-0001].
- *
- *     git  9418/tcp   git pack transfer service
- *     git  9418/udp   git pack transfer service
- *
- * with Linus Torvalds <torvalds@osdl.org> as the point of
- * contact. September 2005.
- *
- * See http://www.iana.org/assignments/port-numbers
- */
-#define DEFAULT_GIT_PORT 9418
-
 /*
  * Basic data structures for the directory cache
  */
@@ -186,11 +118,8 @@ struct cache_entry {
 #error "CE_EXTENDED_FLAGS out of range"
 #endif
 
-#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
-
 /* Forward structure decls */
 struct pathspec;
-struct child_process;
 struct tree;
 
 /*
@@ -228,17 +157,6 @@ static inline unsigned create_ce_flags(unsigned stage)
 #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
 #define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
 
-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
-static inline unsigned int create_ce_mode(unsigned int mode)
-{
-       if (S_ISLNK(mode))
-               return S_IFLNK;
-       if (S_ISSPARSEDIR(mode))
-               return S_IFDIR;
-       if (S_ISDIR(mode) || S_ISGITLINK(mode))
-               return S_IFGITLINK;
-       return S_IFREG | ce_permissions(mode);
-}
 static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
                                             unsigned int mode)
 {
@@ -265,16 +183,6 @@ static inline int ce_to_dtype(const struct cache_entry *ce)
        else
                return DT_UNKNOWN;
 }
-static inline unsigned int canon_mode(unsigned int mode)
-{
-       if (S_ISREG(mode))
-               return S_IFREG | ce_permissions(mode);
-       if (S_ISLNK(mode))
-               return S_IFLNK;
-       if (S_ISDIR(mode))
-               return S_IFDIR;
-       return S_IFGITLINK;
-}
 
 static inline int ce_path_match(struct index_state *istate,
                                const struct cache_entry *ce,
@@ -445,13 +353,6 @@ void prefetch_cache_entries(const struct index_state *istate,
 extern struct index_state the_index;
 #endif
 
-static inline enum object_type object_type(unsigned int mode)
-{
-       return S_ISDIR(mode) ? OBJ_TREE :
-               S_ISGITLINK(mode) ? OBJ_COMMIT :
-               OBJ_BLOB;
-}
-
 #define INIT_DB_QUIET 0x0001
 #define INIT_DB_EXIST_OK 0x0002
 
@@ -626,13 +527,6 @@ int has_racy_timestamp(struct index_state *istate);
 int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 
-#define HASH_WRITE_OBJECT 1
-#define HASH_FORMAT_CHECK 2
-#define HASH_RENORMALIZE  4
-#define HASH_SILENT 8
-int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
-int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
-
 /*
  * Record to sd the data from st that we use to check whether a file
  * might have changed.
@@ -684,8 +578,6 @@ void set_alternate_index_output(const char *);
 extern int verify_index_checksum;
 extern int verify_ce_order;
 
-extern int quote_path_fully;
-
 #define MTIME_CHANGED  0x0001
 #define CTIME_CHANGED  0x0002
 #define OWNER_CHANGED  0x0004
@@ -694,213 +586,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Return an abbreviated sha1 unique within this repository's object database.
- * The result will be at least `len` characters long, and will be NUL
- * terminated.
- *
- * The non-`_r` version returns a static buffer which remains valid until 4
- * more calls to repo_find_unique_abbrev are made.
- *
- * The `_r` variant writes to a buffer supplied by the caller, which must be at
- * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
- * written (excluding the NUL terminator).
- *
- * Note that while this version avoids the static buffer, it is not fully
- * reentrant, as it calls into other non-reentrant git code.
- */
-const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
-
-/*
- * Create the directory containing the named path, using care to be
- * somewhat safe against races. Return one of the scld_error values to
- * indicate success/failure. On error, set errno to describe the
- * problem.
- *
- * SCLD_VANISHED indicates that one of the ancestor directories of the
- * path existed at one point during the function call and then
- * suddenly vanished, probably because another process pruned the
- * directory while we were working.  To be robust against this kind of
- * race, callers might want to try invoking the function again when it
- * returns SCLD_VANISHED.
- *
- * safe_create_leading_directories() temporarily changes path while it
- * is working but restores it before returning.
- * safe_create_leading_directories_const() doesn't modify path, even
- * temporarily. Both these variants adjust the permissions of the
- * created directories to honor core.sharedRepository, so they are best
- * suited for files inside the git dir. For working tree files, use
- * safe_create_leading_directories_no_share() instead, as it ignores
- * the core.sharedRepository setting.
- */
-enum scld_error {
-       SCLD_OK = 0,
-       SCLD_FAILED = -1,
-       SCLD_PERMS = -2,
-       SCLD_EXISTS = -3,
-       SCLD_VANISHED = -4
-};
-enum scld_error safe_create_leading_directories(char *path);
-enum scld_error safe_create_leading_directories_const(const char *path);
-enum scld_error safe_create_leading_directories_no_share(char *path);
-
-int mkdir_in_gitdir(const char *path);
-
-int git_open_cloexec(const char *name, int flags);
-#define git_open(name) git_open_cloexec(name, O_RDONLY)
-
-/**
- * unpack_loose_header() initializes the data stream needed to unpack
- * a loose object header.
- *
- * Returns:
- *
- * - ULHR_OK on success
- * - ULHR_BAD on error
- * - ULHR_TOO_LONG if the header was too long
- *
- * It will only parse up to MAX_HEADER_LEN bytes unless an optional
- * "hdrbuf" argument is non-NULL. This is intended for use with
- * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
- * reporting. The full header will be extracted to "hdrbuf" for use
- * with parse_loose_header(), ULHR_TOO_LONG will still be returned
- * from this function to indicate that the header was too long.
- */
-enum unpack_loose_header_result {
-       ULHR_OK,
-       ULHR_BAD,
-       ULHR_TOO_LONG,
-};
-enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
-                                                   unsigned char *map,
-                                                   unsigned long mapsize,
-                                                   void *buffer,
-                                                   unsigned long bufsiz,
-                                                   struct strbuf *hdrbuf);
-
-/**
- * parse_loose_header() parses the starting "<type> <len>\0" of an
- * object. If it doesn't follow that format -1 is returned. To check
- * the validity of the <type> populate the "typep" in the "struct
- * object_info". It will be OBJ_BAD if the object type is unknown. The
- * parsed <len> can be retrieved via "oi->sizep", and from there
- * passed to unpack_loose_rest().
- */
-struct object_info;
-int parse_loose_header(const char *hdr, struct object_info *oi);
-
-/**
- * With in-core object data in "buf", rehash it to make sure the
- * object name actually matches "oid" to detect object corruption.
- *
- * A negative value indicates an error, usually that the OID is not
- * what we expected, but it might also indicate another error.
- */
-int check_object_signature(struct repository *r, const struct object_id *oid,
-                          void *map, unsigned long size,
-                          enum object_type type);
-
-/**
- * A streaming version of check_object_signature().
- * Try reading the object named with "oid" using
- * the streaming interface and rehash it to do the same.
- */
-int stream_object_signature(struct repository *r, const struct object_id *oid);
-
-int finalize_object_file(const char *tmpfile, const char *filename);
-
-/* Helper to check and "touch" a file */
-int check_and_freshen_file(const char *fn, int freshen);
-
-/* Convert to/from hex/sha1 representation */
-#define MINIMUM_ABBREV minimum_abbrev
-#define DEFAULT_ABBREV default_abbrev
-
-/* used when the code does not know or care what the default abbrev is */
-#define FALLBACK_DEFAULT_ABBREV 7
-
-struct object_context {
-       unsigned short mode;
-       /*
-        * symlink_path is only used by get_tree_entry_follow_symlinks,
-        * and only for symlinks that point outside the repository.
-        */
-       struct strbuf symlink_path;
-       /*
-        * If GET_OID_RECORD_PATH is set, this will record path (if any)
-        * found when resolving the name. The caller is responsible for
-        * releasing the memory.
-        */
-       char *path;
-};
-
-int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
-__attribute__((format (printf, 2, 3)))
-int get_oidf(struct object_id *oid, const char *fmt, ...);
-int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
-void maybe_die_on_misspelt_object_name(struct repository *repo,
-                                      const char *name,
-                                      const char *prefix);
-enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
-                                        unsigned flags, struct object_id *oid,
-                                        struct object_context *oc);
-
-typedef int each_abbrev_fn(const struct object_id *oid, void *);
-int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
-
-int set_disambiguate_hint_config(const char *var, const char *value);
-
-/*
- * This reads short-hand syntax that not only evaluates to a commit
- * object name, but also can act as if the end user spelled the name
- * of the branch from the command line.
- *
- * - "@{-N}" finds the name of the Nth previous branch we were on, and
- *   places the name of the branch in the given buf and returns the
- *   number of characters parsed if successful.
- *
- * - "<branch>@{upstream}" finds the name of the other ref that
- *   <branch> is configured to merge with (missing <branch> defaults
- *   to the current branch), and places the name of the branch in the
- *   given buf and returns the number of characters parsed if
- *   successful.
- *
- * If the input is not of the accepted format, it returns a negative
- * number to signal an error.
- *
- * If the input was ok but there are not N branch switches in the
- * reflog, it returns 0.
- */
-#define INTERPRET_BRANCH_LOCAL (1<<0)
-#define INTERPRET_BRANCH_REMOTE (1<<1)
-#define INTERPRET_BRANCH_HEAD (1<<2)
-struct interpret_branch_name_options {
-       /*
-        * If "allowed" is non-zero, it is a treated as a bitfield of allowable
-        * expansions: local branches ("refs/heads/"), remote branches
-        * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
-        * allowed, even ones to refs outside of those namespaces.
-        */
-       unsigned allowed;
-
-       /*
-        * If ^{upstream} or ^{push} (or equivalent) is requested, and the
-        * branch in question does not have such a reference, return -1 instead
-        * of die()-ing.
-        */
-       unsigned nonfatal_dangling_mark : 1;
-};
-int repo_interpret_branch_name(struct repository *r,
-                              const char *str, int len,
-                              struct strbuf *buf,
-                              const struct interpret_branch_name_options *options);
-
 int base_name_compare(const char *name1, size_t len1, int mode1,
                      const char *name2, size_t len2, int mode2);
 int df_name_compare(const char *name1, size_t len1, int mode1,
@@ -908,21 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-void *read_object_with_reference(struct repository *r,
-                                const struct object_id *oid,
-                                enum object_type required_type,
-                                unsigned long *size,
-                                struct object_id *oid_ret);
-
-struct object *repo_peel_to_type(struct repository *r,
-                                const char *name, int namelen,
-                                struct object *o, enum object_type);
-
-const char *git_editor(void);
-const char *git_sequence_editor(void);
-const char *git_pager(int stdout_is_tty);
-int is_terminal_dumb(void);
-
 struct cache_def {
        struct strbuf path;
        int flags;
@@ -959,36 +629,15 @@ struct pack_entry {
        struct packed_git *p;
 };
 
-/*
- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
- * blobs. This has a difference only if extensions.partialClone is set.
- *
- * Its default value is 1.
- */
-extern int fetch_if_missing;
-
 /* Dumb servers support */
 int update_server_info(int);
 
-extern const char *git_mailmap_file;
-extern const char *git_mailmap_blob;
-
 #define COPY_READ_ERROR (-2)
 #define COPY_WRITE_ERROR (-3)
 int copy_fd(int ifd, int ofd);
 int copy_file(const char *dst, const char *src, int mode);
 int copy_file_with_time(const char *dst, const char *src, int mode);
 
-/* pager.c */
-void setup_pager(void);
-int pager_in_use(void);
-extern int pager_use_color;
-int term_columns(void);
-void term_clear_line(void);
-int decimal_width(uintmax_t);
-int check_pager_config(const char *cmd);
-void prepare_pager_args(struct child_process *, const char *pager);
-
 /* base85 */
 int decode_85(char *dst, const char *line, int linelen);
 void encode_85(char *buf, const unsigned char *data, int bytes);
index 929ec01b3a24435f56380f9497064ecc405c375f..0d7bc0460747b2973f913b746c4b9ef0ba6b9028 100644 (file)
@@ -1,8 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "list.h"
+#include "path.h"
 #include "strbuf.h"
+#include "trace.h"
 
 struct chdir_notify_entry {
        const char *name;
index 1247b8822481a6face3fc47a45ec2ce1bf298c06..04238b27133901e4792de0c45ceb17cb48489c21 100644 (file)
@@ -1,8 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
 #include "config.h"
+#include "strbuf.h"
 
 struct tracking_name_data {
        /* const */ char *src_ref;
index b098e10f52aed2f9d8928958fd393cbd574ddf8b..a18b13a41dd462edd3643b3fc9cd59404c2de6c3 100755 (executable)
@@ -27,7 +27,7 @@ linux-TEST-vars)
        export GIT_TEST_MULTI_PACK_INDEX=1
        export GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=1
        export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
-       export GIT_TEST_WRITE_REV_INDEX=1
+       export GIT_TEST_NO_WRITE_REV_INDEX=1
        export GIT_TEST_CHECKOUT_WORKERS=2
        ;;
 linux-clang)
diff --git a/color.c b/color.c
index 672dcbb73a6a982a4a4c8086b6f6585fde4377a6..6031998d3ea0bc729b048b908fd5344d2e764329 100644 (file)
--- a/color.c
+++ b/color.c
@@ -1,8 +1,10 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
+#include "pager.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
index fbf88639aaed931602b203f012468cdeefda284f..ff2f0abf39930c85a515283625a98152d85bc492 100644 (file)
--- a/column.c
+++ b/column.c
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "utf8.h"
index 44ef6a1a812b02153f0d35137489930440357573..f7e9fb574735d36e57b704c6455eae175fb42103 100644 (file)
@@ -1,11 +1,13 @@
 #include "cache.h"
 #include "object-store.h"
 #include "commit.h"
+#include "convert.h"
 #include "blob.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "quote.h"
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
@@ -14,6 +16,7 @@
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
+#include "wrapper.h"
 
 static int compare_paths(const struct combine_diff_path *one,
                          const struct diff_filespec *two)
index b1e737c01b1df701af6f0c0b8b814ea91ab9424b..43558b4d9b0230a6d8c759691ddfa55801faf328 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
@@ -11,7 +11,9 @@
 #include "revision.h"
 #include "hash-lookup.h"
 #include "commit-graph.h"
+#include "object-file.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "alloc.h"
 #include "hashmap.h"
 #include "replace-object.h"
index 6d844da9a6b4f7c86f77e5945803c5a6bd211155..878b4473e4ce14dc664839f97dc3d7ed85d0b437 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "commit-graph.h"
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pkt-line.h"
 #include "utf8.h"
index b83cb5cf066732be125e8a5912d56405fed741d3..f319317353584348ec476111b7560d0b55c5d825 100644 (file)
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "attr.h"
 #include "setup.h"
+#include "trace2.h"
 
 /*
  * Many parts of Git have subprograms communicate via pipe, expect the
index 7b07b74ba5bd0d20f504f1d5b1e3e5d6dd3e4c21..677b1bbdecac2e82b03c3755af4dfa0de562f73d 100644 (file)
@@ -4,6 +4,7 @@
 #include "fsm-listen.h"
 #include "fsmonitor--daemon.h"
 #include "gettext.h"
+#include "trace2.h"
 
 /*
  * The documentation of ReadDirectoryChangesW() states that the maximum
index 94c5a1daa40cde53093b62f0c2c3c67da12ffd9e..abbc3faf32f428bc75edaa311ef8cb3d6cd8ab7a 100644 (file)
@@ -12,6 +12,7 @@
 #include "win32/lazyload.h"
 #include "../config.h"
 #include "../environment.h"
+#include "../trace2.h"
 #include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
index 978cac4ec91e6bb2f81539d85422bb37e4941a51..484e6d4c716ef6b6c3e5b24ff5a1879db3039d5d 100644 (file)
@@ -1,4 +1,5 @@
 #include "../git-compat-util.h"
+#include "../wrapper.h"
 
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
 {
index 152db60a311c2784ab5c90a346769a2785ca8cac..b2f4f22ce44f51f6f8f18e0d7ca6a2ed22de183b 100644 (file)
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace2.h"
 #include "unix-socket.h"
 #include "unix-stream-server.h"
 
index 997f6144344d883584b2991f2684ff383a7c9e55..6adce3c650eba5b8ae4879b5c32b79c3849c3d95 100644 (file)
@@ -5,6 +5,8 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace.h"
+#include "trace2.h"
 #include "accctrl.h"
 #include "aclapi.h"
 
index a53fd924340f7d6da04e5197363fe831b9d19bf3..e3e895c78a2206b07e8cd5040926491228b49563 100644 (file)
@@ -1,5 +1,6 @@
 #include "../../cache.h"
 #include "../../json-writer.h"
+#include "../../trace2.h"
 #include "lazyload.h"
 #include <Psapi.h>
 #include <tlHelp32.h>
index 493f47df8ae6a56ff1abf37090df20e2ee665b3e..43b0d3fb573330f01c2d48378a9fc2ea3f426fe3 100644 (file)
--- a/config.c
+++ b/config.c
@@ -7,27 +7,33 @@
  */
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "date.h"
 #include "branch.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
 #include "repository.h"
 #include "lockfile.h"
+#include "mailmap.h"
 #include "exec-cmd.h"
 #include "strbuf.h"
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
+#include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "utf8.h"
 #include "dir.h"
 #include "color.h"
 #include "replace-object.h"
 #include "refs.h"
 #include "setup.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "wrapper.h"
 #include "write-or-die.h"
@@ -3652,9 +3658,10 @@ void git_config_set_multivar(const char *key, const char *value,
                                        flags);
 }
 
-static int section_name_match (const char *buf, const char *name)
+static size_t section_name_match (const char *buf, const char *name)
 {
-       int i = 0, j = 0, dot = 0;
+       size_t i = 0, j = 0;
+       int dot = 0;
        if (buf[i] != '[')
                return 0;
        for (i = 1; buf[i] && buf[i] != ']'; i++) {
@@ -3707,6 +3714,8 @@ static int section_name_is_ok(const char *name)
        return 1;
 }
 
+#define GIT_CONFIG_MAX_LINE_LEN (512 * 1024)
+
 /* if new_name == NULL, the section is removed instead */
 static int git_config_copy_or_rename_section_in_file(const char *config_filename,
                                      const char *old_name,
@@ -3716,11 +3725,12 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
        char *filename_buf = NULL;
        struct lock_file lock = LOCK_INIT;
        int out_fd;
-       char buf[1024];
+       struct strbuf buf = STRBUF_INIT;
        FILE *config_file = NULL;
        struct stat st;
        struct strbuf copystr = STRBUF_INIT;
        struct config_store_data store;
+       uint32_t line_nr = 0;
 
        memset(&store, 0, sizeof(store));
 
@@ -3757,16 +3767,25 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
                goto out;
        }
 
-       while (fgets(buf, sizeof(buf), config_file)) {
-               unsigned i;
-               int length;
+       while (!strbuf_getwholeline(&buf, config_file, '\n')) {
+               size_t i, length;
                int is_section = 0;
-               char *output = buf;
-               for (i = 0; buf[i] && isspace(buf[i]); i++)
+               char *output = buf.buf;
+
+               line_nr++;
+
+               if (buf.len >= GIT_CONFIG_MAX_LINE_LEN) {
+                       ret = error(_("refusing to work with overly long line "
+                                     "in '%s' on line %"PRIuMAX),
+                                   config_filename, (uintmax_t)line_nr);
+                       goto out;
+               }
+
+               for (i = 0; buf.buf[i] && isspace(buf.buf[i]); i++)
                        ; /* do nothing */
-               if (buf[i] == '[') {
+               if (buf.buf[i] == '[') {
                        /* it's a section */
-                       int offset;
+                       size_t offset;
                        is_section = 1;
 
                        /*
@@ -3783,7 +3802,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
                                strbuf_reset(&copystr);
                        }
 
-                       offset = section_name_match(&buf[i], old_name);
+                       offset = section_name_match(&buf.buf[i], old_name);
                        if (offset > 0) {
                                ret++;
                                if (!new_name) {
@@ -3858,6 +3877,7 @@ out:
 out_no_rollback:
        free(filename_buf);
        config_store_data_clear(&store);
+       strbuf_release(&buf);
        return ret;
 }
 
index c0c8a38178cec786ff4dfc721e0b9e389a3c5888..3a0186280c439a12fa6564ff9965cf284fb214d3 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,4 @@
 #include "git-compat-util.h"
-#include "cache.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
@@ -14,6 +13,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "transport.h"
+#include "trace2.h"
 #include "strbuf.h"
 #include "version.h"
 #include "protocol.h"
@@ -22,7 +22,7 @@
 
 static char *server_capabilities_v1;
 static struct strvec server_capabilities_v2 = STRVEC_INIT;
-static const char *next_server_feature_value(const char *feature, int *len, int *offset);
+static const char *next_server_feature_value(const char *feature, size_t *len, size_t *offset);
 
 static int check_ref(const char *name, unsigned int flags)
 {
@@ -205,10 +205,10 @@ reject:
 static void annotate_refs_with_symref_info(struct ref *ref)
 {
        struct string_list symref = STRING_LIST_INIT_DUP;
-       int offset = 0;
+       size_t offset = 0;
 
        while (1) {
-               int len;
+               size_t len;
                const char *val;
 
                val = next_server_feature_value("symref", &len, &offset);
@@ -231,7 +231,7 @@ static void annotate_refs_with_symref_info(struct ref *ref)
 static void process_capabilities(struct packet_reader *reader, int *linelen)
 {
        const char *feat_val;
-       int feat_len;
+       size_t feat_len;
        const char *line = reader->line;
        int nul_location = strlen(line);
        if (nul_location == *linelen)
@@ -263,7 +263,8 @@ static int process_dummy_ref(const struct packet_reader *reader)
                return 0;
        name++;
 
-       return oideq(null_oid(), &oid) && !strcmp(name, "capabilities^{}");
+       return oideq(reader->hash_algo->null_oid, &oid) &&
+               !strcmp(name, "capabilities^{}");
 }
 
 static void check_no_capabilities(const char *line, int len)
@@ -595,9 +596,10 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
        return list;
 }
 
-const char *parse_feature_value(const char *feature_list, const char *feature, int *lenp, int *offset)
+const char *parse_feature_value(const char *feature_list, const char *feature, size_t *lenp, size_t *offset)
 {
-       int len;
+       const char *orig_start = feature_list;
+       size_t len;
 
        if (!feature_list)
                return NULL;
@@ -616,19 +618,19 @@ const char *parse_feature_value(const char *feature_list, const char *feature, i
                                if (lenp)
                                        *lenp = 0;
                                if (offset)
-                                       *offset = found + len - feature_list;
+                                       *offset = found + len - orig_start;
                                return value;
                        }
                        /* feature with a value (e.g., "agent=git/1.2.3") */
                        else if (*value == '=') {
-                               int end;
+                               size_t end;
 
                                value++;
                                end = strcspn(value, " \t\n");
                                if (lenp)
                                        *lenp = end;
                                if (offset)
-                                       *offset = value + end - feature_list;
+                                       *offset = value + end - orig_start;
                                return value;
                        }
                        /*
@@ -643,8 +645,8 @@ const char *parse_feature_value(const char *feature_list, const char *feature, i
 
 int server_supports_hash(const char *desired, int *feature_supported)
 {
-       int offset = 0;
-       int len;
+       size_t offset = 0;
+       size_t len;
        const char *hash;
 
        hash = next_server_feature_value("object-format", &len, &offset);
@@ -668,12 +670,12 @@ int parse_feature_request(const char *feature_list, const char *feature)
        return !!parse_feature_value(feature_list, feature, NULL, NULL);
 }
 
-static const char *next_server_feature_value(const char *feature, int *len, int *offset)
+static const char *next_server_feature_value(const char *feature, size_t *len, size_t *offset)
 {
        return parse_feature_value(server_capabilities_v1, feature, len, offset);
 }
 
-const char *server_feature_value(const char *feature, int *len)
+const char *server_feature_value(const char *feature, size_t *len)
 {
        return parse_feature_value(server_capabilities_v1, feature, len, NULL);
 }
index f41a0b4c1fb766523d6bee7964989063a6ceeaa2..1645126c17f889659d84174210a43939ef67507f 100644 (file)
--- a/connect.h
+++ b/connect.h
@@ -12,14 +12,14 @@ int finish_connect(struct child_process *conn);
 int git_connection_is_socket(struct child_process *conn);
 int server_supports(const char *feature);
 int parse_feature_request(const char *features, const char *feature);
-const char *server_feature_value(const char *feature, int *len_ret);
+const char *server_feature_value(const char *feature, size_t *len_ret);
 int url_is_local_not_ssh(const char *url);
 
 struct packet_reader;
 enum protocol_version discover_version(struct packet_reader *reader);
 
 int server_supports_hash(const char *desired, int *feature_supported);
-const char *parse_feature_value(const char *feature_list, const char *feature, int *lenp, int *offset);
+const char *parse_feature_value(const char *feature_list, const char *feature, size_t *lenp, size_t *offset);
 int server_supports_v2(const char *c);
 void ensure_server_supports_v2(const char *c);
 int server_feature_v2(const char *c, const char **v);
index 76ee4ab1e54965f6bf02afb5b562eb327d66ebac..2c030050aea1c67472570a9d86d69d55e31e7714 100644 (file)
@@ -298,7 +298,7 @@ __git_ps1_colorize_gitstring ()
 # variable, in that order.
 __git_eread ()
 {
-       test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
+       test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1"
 }
 
 # see if a cherry-pick or revert is in progress, if the user has committed a
index da06e2f51cb0ff83b989106c32e94b5921de496c..5a2ea5308d6b1467b1ac1925507b1dacc5d809e4 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1,5 +1,7 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
+#include "convert.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
@@ -9,6 +11,7 @@
 #include "sigchain.h"
 #include "pkt-line.h"
 #include "sub-process.h"
+#include "trace.h"
 #include "utf8.h"
 #include "ll-merge.h"
 #include "wrapper.h"
index db8a31a6ea2145a4c3c2a44caaa82d0ed9e9c278..75c3c064574140bba35174619da87e5914c1884f 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "pkt-line.h"
+#include "protocol.h"
 #include "run-command.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/date.c b/date.c
index 7c8650f79967a32d16f4e2a133b43ef0358eacb0..e867ebf6b78fb7e91b1ba0d411cdd015ec69aecf 100644 (file)
--- a/date.c
+++ b/date.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "date.h"
 #include "gettext.h"
+#include "pager.h"
 
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
index 40f2ccfb55049d434935d83e7494fdb281fe3ec4..c824a5f6a42e56c04a46c8189d4fc1675fd172ea 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "attr.h"
 #include "object.h"
index 4169dd8cb1329a55c7f47674ed694293185f0b2a..d292405a262495974eb7de0e8b6e590df024d1c8 100644 (file)
@@ -8,11 +8,13 @@
 #include "diffcore.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "refs.h"
 #include "submodule.h"
+#include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
 #include "commit-reach.h"
index 934a24bee5851ac0d3da1492d3deba6189402faf..4296940f907530ef420a9bc6ba085f2dd1f693a9 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2008 by Junio C Hamano
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "color.h"
 #include "commit.h"
diff --git a/diff.c b/diff.c
index 78b0fdd8caa2664337e25572abc2e698197357cc..067846b13c1a45ad351dfdf18f65d2e72edd5f33 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "tempfile.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "graph.h"
+#include "oid-array.h"
 #include "packfile.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
 #include "wrapper.h"
diff --git a/dir.c b/dir.c
index 18fd14c46b2f61ea300b2f26e864a0c929ad8c88..aa840995c40bebc029b609dde82b235f1a6e5b9a 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -9,9 +9,11 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "attr.h"
 #include "refs.h"
@@ -23,6 +25,7 @@
 #include "fsmonitor.h"
 #include "setup.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 /*
index d632d7906608732a1059d197d7f06a62e1f55ed2..b34e10606d23942ceb8f397299ac79332ac71154 100644 (file)
--- a/editor.c
+++ b/editor.c
@@ -1,12 +1,16 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
+#include "pager.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "sigchain.h"
+#include "wrapper.h"
 
 #ifndef DEFAULT_EDITOR
 #define DEFAULT_EDITOR "vi"
@@ -129,3 +133,31 @@ int launch_sequence_editor(const char *path, struct strbuf *buffer,
 {
        return launch_specified_editor(git_sequence_editor(), path, buffer, env);
 }
+
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+                             const char *const *env)
+{
+       char *path2 = NULL;
+       int fd, res = 0;
+
+       if (!is_absolute_path(path))
+               path = path2 = xstrdup(git_path("%s", path));
+
+       fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+       if (fd < 0)
+               res = error_errno(_("could not open '%s' for writing"), path);
+       else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
+               res = error_errno(_("could not write to '%s'"), path);
+               close(fd);
+       } else if (close(fd) < 0)
+               res = error_errno(_("could not close '%s'"), path);
+       else {
+               strbuf_reset(buffer);
+               if (launch_editor(path, buffer, env) < 0)
+                       res = error_errno(_("could not edit '%s'"), path);
+               unlink(path);
+       }
+
+       free(path2);
+       return res;
+}
diff --git a/editor.h b/editor.h
new file mode 100644 (file)
index 0000000..8016bb5
--- /dev/null
+++ b/editor.h
@@ -0,0 +1,34 @@
+#ifndef EDITOR_H
+#define EDITOR_H
+
+struct strbuf;
+
+const char *git_editor(void);
+const char *git_sequence_editor(void);
+int is_terminal_dumb(void);
+
+/**
+ * Launch the user preferred editor to edit a file and fill the buffer
+ * with the file's contents upon the user completing their editing. The
+ * third argument can be used to set the environment which the editor is
+ * run in. If the buffer is NULL the editor is launched as usual but the
+ * file's contents are not read into the buffer upon completion.
+ */
+int launch_editor(const char *path, struct strbuf *buffer,
+                 const char *const *env);
+
+int launch_sequence_editor(const char *path, struct strbuf *buffer,
+                          const char *const *env);
+
+/*
+ * In contrast to `launch_editor()`, this function writes out the contents
+ * of the specified file first, then clears the `buffer`, then launches
+ * the editor and reads back in the file contents into the `buffer`.
+ * Finally, it deletes the temporary file.
+ *
+ * If `path` is relative, it refers to a file in the `.git` directory.
+ */
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+                             const char *const *env);
+
+#endif
index 63c697e7e97cca35e52df3847bb017713f6940ef..8a96997539ab4edd2216aa3be1747aa947297300 100644 (file)
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "branch.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "repository.h"
 #include "fmt-merge-msg.h"
 #include "commit.h"
 #include "strvec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "tmp-objdir.h"
 #include "chdir-notify.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
@@ -56,7 +59,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 96 * 1024 * 1024;
 unsigned long big_file_threshold = 512 * 1024 * 1024;
-int pager_use_color = 1;
 const char *editor_program;
 const char *askpass_program;
 const char *excludes_file;
index fae0d4b244a9d37cafb8f984311b0259bf702898..6f618463896b6e840dd2620bdbd36877192854df 100644 (file)
@@ -5,6 +5,8 @@
 #include "gettext.h"
 #include "quote.h"
 #include "strvec.h"
+#include "trace.h"
+#include "trace2.h"
 
 #if defined(RUNTIME_PREFIX)
 
index 368f2ed25a1c40f6ab55f0b1098a8722ce930c18..6fa6e8af9a3f27c471c229a2f014d797af065bb6 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
@@ -17,6 +17,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "connect.h"
+#include "trace2.h"
 #include "transport.h"
 #include "version.h"
 #include "oid-array.h"
@@ -1099,7 +1100,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
        struct ref *ref = copy_ref_list(orig_ref);
        struct object_id oid;
        const char *agent_feature;
-       int agent_len;
+       size_t agent_len;
        struct fetch_negotiator negotiator_alloc;
        struct fetch_negotiator *negotiator;
 
@@ -1117,7 +1118,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
                agent_supported = 1;
                if (agent_len)
                        print_verbose(args, _("Server version is %.*s"),
-                                     agent_len, agent_feature);
+                                     (int)agent_len, agent_feature);
        }
 
        if (!server_supports("session-id"))
index 1886c92ddb9cd0cda98fcc945d6fa3eecf6d4931..5af0d4715ba22f2f1629880ec530a0752398e716 100644 (file)
@@ -1,8 +1,9 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "diff.h"
 #include "diff-merges.h"
diff --git a/fsck.c b/fsck.c
index 8ef1b0223467292aa89042a27ab99a98d90e66cb..adbe8bf59e7a2a1a41448f1deb8088e7f9ddd8dc 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "hex.h"
 #include "object-store.h"
index c956a347a27a8a907deaba3030f8a725f030e3f3..28c083d4d8417404bcf4efca872ac1106cf4a925 100644 (file)
@@ -7,6 +7,7 @@
 #include "fsmonitor-ipc.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 
 #define INDEX_EXTENSION_VERSION1       (1)
 #define INDEX_EXTENSION_VERSION2       (2)
index 778707b131ba01f8a800ab4f3253b1b841709d1d..c67e0ebc09bd52bc9cb0b65d054b1d9ef83003e1 100644 (file)
@@ -4,6 +4,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "fsmonitor-settings.h"
+#include "trace.h"
 
 extern struct trace_key trace_fsmonitor;
 
index 5f348708300e81addb7238a6c84be5e37a0ebcba..f27e94407b4c2848eecfbd827ee85525ff8c04ed 100644 (file)
--- a/gettext.c
+++ b/gettext.c
@@ -102,6 +102,8 @@ static void init_gettext_charset(const char *domain)
                setlocale(LC_CTYPE, "C");
 }
 
+int git_gettext_enabled = 0;
+
 void git_setup_gettext(void)
 {
        const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
@@ -121,6 +123,8 @@ void git_setup_gettext(void)
        init_gettext_charset("git");
        textdomain("git");
 
+       git_gettext_enabled = 1;
+
        free(p);
 }
 
index d209911ebb80c164fb93073d054fd1ff7acb8da3..484cafa5628850930f8536c6c4e79fb26847153d 100644 (file)
--- a/gettext.h
+++ b/gettext.h
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
 #ifndef NO_GETTEXT
+extern int git_gettext_enabled;
 void git_setup_gettext(void);
 int gettext_width(const char *s);
 #else
+#define git_gettext_enabled (0)
 static inline void git_setup_gettext(void)
 {
 }
@@ -45,12 +47,16 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
        if (!*msgid)
                return "";
+       if (!git_gettext_enabled)
+               return msgid;
        return gettext(msgid);
 }
 
 static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
 const char *Q_(const char *msgid, const char *plu, unsigned long n)
 {
+       if (!git_gettext_enabled)
+               return n == 1 ? msgid : plu;
        return ngettext(msgid, plu, n);
 }
 
index 4a200a9fb41123e1d945ae9a397f09d7c0456367..5b2b99c17c564c5a5904442416e5d7d13f7b0568 100644 (file)
@@ -878,12 +878,6 @@ int git_lstat(const char *, struct stat *);
 #define pread git_pread
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
 #endif
-/*
- * Forward decl that will remind us if its twin in cache.h changes.
- * This function is used in compat/pread.c.  But we can't include
- * cache.h there.
- */
-ssize_t read_in_full(int fd, void *buf, size_t count);
 
 #ifdef NO_SETENV
 #define setenv gitsetenv
index fd8cd0d46fde6cca528b8e0259c778fa4ddad9c3..66c91711092be7f8cc32a2b81945b48bbe657bd0 100755 (executable)
@@ -795,11 +795,26 @@ if (@rev_list_opts) {
 @files = handle_backup_files(@files);
 
 if ($validate) {
+       # FIFOs can only be read once, exclude them from validation.
+       my @real_files = ();
        foreach my $f (@files) {
                unless (-p $f) {
-                       validate_patch($f, $target_xfer_encoding);
+                       push(@real_files, $f);
                }
        }
+
+       # Run the loop once again to avoid gaps in the counter due to FIFO
+       # arguments provided by the user.
+       my $num = 1;
+       my $num_files = scalar @real_files;
+       $ENV{GIT_SENDEMAIL_FILE_TOTAL} = "$num_files";
+       foreach my $r (@real_files) {
+               $ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num";
+               validate_patch($r, $target_xfer_encoding);
+               $num += 1;
+       }
+       delete $ENV{GIT_SENDEMAIL_FILE_COUNTER};
+       delete $ENV{GIT_SENDEMAIL_FILE_TOTAL};
 }
 
 if (@files) {
similarity index 99%
rename from zlib.c
rename to git-zlib.c
index d594cba3fc9d82d94b9277e886f2bee265e552f6..d43bbeb6daa4c195048f7012e0bccff8c5b4b5f1 100644 (file)
--- a/zlib.c
@@ -2,7 +2,8 @@
  * zlib wrappers to make sure we don't silently miss errors
  * at init time.
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "git-zlib.h"
 
 static const char *zerr_to_string(int status)
 {
diff --git a/git-zlib.h b/git-zlib.h
new file mode 100644 (file)
index 0000000..d8a670a
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef GIT_ZLIB_H
+#define GIT_ZLIB_H
+
+typedef struct git_zstream {
+       z_stream z;
+       unsigned long avail_in;
+       unsigned long avail_out;
+       unsigned long total_in;
+       unsigned long total_out;
+       unsigned char *next_in;
+       unsigned char *next_out;
+} git_zstream;
+
+void git_inflate_init(git_zstream *);
+void git_inflate_init_gzip_only(git_zstream *);
+void git_inflate_end(git_zstream *);
+int git_inflate(git_zstream *, int flush);
+
+void git_deflate_init(git_zstream *, int level);
+void git_deflate_init_gzip(git_zstream *, int level);
+void git_deflate_init_raw(git_zstream *, int level);
+void git_deflate_end(git_zstream *);
+int git_deflate_abort(git_zstream *);
+int git_deflate_end_gently(git_zstream *);
+int git_deflate(git_zstream *, int flush);
+unsigned long git_deflate_bound(git_zstream *, unsigned long);
+
+#endif /* GIT_ZLIB_H */
diff --git a/git.c b/git.c
index de681f4f7cd7683a81550126318b9a2467dc6c58..45899be82658d725ac87c8d2328483089bcefd1c 100644 (file)
--- a/git.c
+++ b/git.c
@@ -4,11 +4,14 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
+#include "pager.h"
 #include "run-command.h"
 #include "alias.h"
 #include "replace-object.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 
 #define RUN_SETUP              (1<<0)
 #define RUN_SETUP_GENTLY       (1<<1)
index aceeb083367bd5c147e809ac8f0f4c2e155622e6..f3ac5acdd9a27a735e356bb596b01db977a3bb28 100644 (file)
@@ -650,7 +650,7 @@ int check_signature(struct signature_check *sigc,
        gpg_interface_lazy_init();
 
        sigc->result = 'N';
-       sigc->trust_level = -1;
+       sigc->trust_level = TRUST_UNDEFINED;
 
        fmt = get_format_by_sig(signature);
        if (!fmt)
diff --git a/grep.c b/grep.c
index b86462a12a9e38bf6693da5a5dbe7e8f0fa798f3..073559f2cd0b3929c2bd00c286e92d69b3e0b3b0 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -11,6 +11,7 @@
 #include "commit.h"
 #include "quote.h"
 #include "help.h"
+#include "wrapper.h"
 
 static int grep_source_load(struct grep_source *gs);
 static int grep_source_is_binary(struct grep_source *gs,
index 89aad1b42c7f1e14868fb28d963c20979fe452ad..ac146d85c54efddf1f7cf01b61aa13ec3b3470e3 100644 (file)
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
index c874d3402dd920e97704b22650e7873a2b3e3bb5..fffda592670e667e81eb92af218f9a4d95d7614d 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "exec-cmd.h"
 #include "gettext.h"
index 88b70f2c44f8291814693dbaae079445ba54bd61..76ab5dbb093c81d4a443abda970723766552ace7 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
index e5dadae377009a642ebf446694a463b57c2b96e1..bba306b2d5e18b94aaa41e8fdce30321034feaea 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "repository.h"
 #include "commit.h"
 #include "hex.h"
diff --git a/http.c b/http.c
index d5d82c5230f84194442634a84a894d5af74036cc..bb58bb3e6a3a47163b911d8276f5c185eada003b 100644 (file)
--- a/http.c
+++ b/http.c
 #include "version.h"
 #include "pkt-line.h"
 #include "gettext.h"
+#include "trace.h"
 #include "transport.h"
 #include "packfile.h"
 #include "protocol.h"
 #include "string-list.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
diff --git a/http.h b/http.h
index 77c042706c6597e347d1b8cc05d3f5972e2de117..3a409bccd4e6197874a97629c36b050ca923b944 100644 (file)
--- a/http.h
+++ b/http.h
@@ -1,7 +1,9 @@
 #ifndef HTTP_H
 #define HTTP_H
 
-#include "cache.h"
+struct packed_git;
+
+#include "git-zlib.h"
 
 #include <curl/curl.h>
 #include <curl/easy.h>
index 298ca08711e31a95cd594381c2d45e50079a373f..5d270ce59877e297298258e89762a75146518edd 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "gettext.h"
@@ -15,6 +15,7 @@
 #include "list-objects-filter-options.h"
 #include "oidmap.h"
 #include "oidset.h"
+#include "object-name.h"
 #include "object-store.h"
 
 /* Remember to update object flag allocation in object.h */
index df18d103063dccb4661f7d809106cc2b1c006a35..eecca721ac0826ef09071e6c3119a231d693771a 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "gettext.h"
index 8be38d3bd4176410cbb1c7d838f0982baab5d726..28bc94c45d63015bd6eb7f971d4e78bf55a4deba 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "cache.h"
 #include "config.h"
+#include "convert.h"
 #include "attr.h"
 #include "xdiff-interface.h"
 #include "run-command.h"
index dbb088473e08e784ef5bc32a5f029ca627684b93..143b86fecf9cc94d540055003271e3af694a9332 100644 (file)
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "diff.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "tmp-objdir.h"
index 74fd9db448fd6c6523eea2e29f8aacae05f17709..5dc5223c430949030d0ceb5aa8a29c6d7e6c02aa 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "setup.h"
 
index 7e99fccb46c92e012fa32fafb6ed27c217fdcc4d..0f8fd2c586feaccd4bb4df772b8e8393148ccf6c 100644 (file)
--- a/mailmap.h
+++ b/mailmap.h
@@ -3,6 +3,9 @@
 
 struct string_list;
 
+extern const char *git_mailmap_file;
+extern const char *git_mailmap_blob;
+
 int read_mailmap(struct string_list *map);
 void clear_mailmap(struct string_list *map);
 
index 5bf64354d168e3577b43ceca2ee25f8cc957f1de..34ec2675a25910cbc69bb04117c2c2e7cbf737f7 100644 (file)
 #include "hex.h"
 #include "entry.h"
 #include "ll-merge.h"
+#include "mem-pool.h"
+#include "object-name.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "promisor-remote.h"
 #include "revision.h"
 #include "strmap.h"
 #include "submodule-config.h"
 #include "submodule.h"
+#include "trace2.h"
 #include "tree.h"
 #include "unpack-trees.h"
 #include "xdiff-interface.h"
@@ -4718,14 +4722,14 @@ void merge_switch_to_result(struct merge_options *opt,
 void merge_finalize(struct merge_options *opt,
                    struct merge_result *result)
 {
-       struct merge_options_internal *opti = result->priv;
-
        if (opt->renormalize)
                git_attr_set_direction(GIT_ATTR_CHECKIN);
        assert(opt->priv == NULL);
 
-       clear_or_reinit_internal_opts(opti, 0);
-       FREE_AND_NULL(opti);
+       if (result->priv) {
+               clear_or_reinit_internal_opts(result->priv, 0);
+               FREE_AND_NULL(result->priv);
+       }
 }
 
 /*** Function Grouping: helper functions for merge_incore_*() ***/
index ed5534eb57d4ffa874369bad189237d90a2f7cf5..9875bdb11cb34c174af5d6cca53866652ad162df 100644 (file)
@@ -22,6 +22,8 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "revision.h"
diff --git a/midx.c b/midx.c
index 9af3e5de8899cda69ab885c74bfd0e2b72f53bdb..281a1406a8403f7c163e61dece9d54e67aa220a1 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "midx.h"
@@ -1330,17 +1331,17 @@ static int write_midx_internal(const char *object_dir,
        }
 
        if (preferred_pack_name) {
-               int found = 0;
+               ctx.preferred_pack_idx = -1;
+
                for (i = 0; i < ctx.nr; i++) {
                        if (!cmp_idx_or_pack_name(preferred_pack_name,
                                                  ctx.info[i].pack_name)) {
                                ctx.preferred_pack_idx = i;
-                               found = 1;
                                break;
                        }
                }
 
-               if (!found)
+               if (ctx.preferred_pack_idx == -1)
                        warning(_("unknown preferred pack: '%s'"),
                                preferred_pack_name);
        } else if (ctx.nr &&
index 2c2861efd1cf3b3cc0b56fb40f531ac467213b46..fb13716e4303ebc7c96caa49934ca67f61ae772e 100644 (file)
@@ -9,6 +9,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "thread-utils.h"
+#include "trace.h"
 #include "trace2.h"
 #include "sparse-index.h"
 
index c40107c3aa027218f0acd10f69a162049c88fca2..233e49e31950ac95d38418e41f5d6cae19e79e3c 100644 (file)
@@ -1,7 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "diff.h"
@@ -13,6 +16,7 @@
 #include "notes.h"
 #include "notes-merge.h"
 #include "strbuf.h"
+#include "trace.h"
 #include "notes-utils.h"
 #include "commit-reach.h"
 #include "wrapper.h"
diff --git a/notes.c b/notes.c
index cadb435056db2fe8a73e7f95d226e67030bc03e9..ce32d96ae515ac36350a1092b156b04fd0ca4cce 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -1,8 +1,9 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
index 76b22ca75cd2a3d65133ed49d285474f7e98d760..af18e38527dccdcae706f91061b726abd59078e1 100644 (file)
@@ -10,6 +10,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
@@ -35,6 +36,7 @@
 #include "mergesort.h"
 #include "quote.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "setup.h"
@@ -951,6 +953,12 @@ void prepare_alt_odb(struct repository *r)
        r->objects->loaded_alternates = 1;
 }
 
+int has_alt_odb(struct repository *r)
+{
+       prepare_alt_odb(r);
+       return !!r->objects->odb->next;
+}
+
 /* Returns 1 if we have successfully freshened the file, 0 otherwise. */
 static int freshen_file(const char *fn)
 {
diff --git a/object-file.h b/object-file.h
new file mode 100644 (file)
index 0000000..e0cfc3a
--- /dev/null
@@ -0,0 +1,129 @@
+#ifndef OBJECT_FILE_H
+#define OBJECT_FILE_H
+
+#include "git-zlib.h"
+#include "object.h"
+
+/*
+ * Set this to 0 to prevent oid_object_info_extended() from fetching missing
+ * blobs. This has a difference only if extensions.partialClone is set.
+ *
+ * Its default value is 1.
+ */
+extern int fetch_if_missing;
+
+#define HASH_WRITE_OBJECT 1
+#define HASH_FORMAT_CHECK 2
+#define HASH_RENORMALIZE  4
+#define HASH_SILENT 8
+int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
+int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
+
+/*
+ * Create the directory containing the named path, using care to be
+ * somewhat safe against races. Return one of the scld_error values to
+ * indicate success/failure. On error, set errno to describe the
+ * problem.
+ *
+ * SCLD_VANISHED indicates that one of the ancestor directories of the
+ * path existed at one point during the function call and then
+ * suddenly vanished, probably because another process pruned the
+ * directory while we were working.  To be robust against this kind of
+ * race, callers might want to try invoking the function again when it
+ * returns SCLD_VANISHED.
+ *
+ * safe_create_leading_directories() temporarily changes path while it
+ * is working but restores it before returning.
+ * safe_create_leading_directories_const() doesn't modify path, even
+ * temporarily. Both these variants adjust the permissions of the
+ * created directories to honor core.sharedRepository, so they are best
+ * suited for files inside the git dir. For working tree files, use
+ * safe_create_leading_directories_no_share() instead, as it ignores
+ * the core.sharedRepository setting.
+ */
+enum scld_error {
+       SCLD_OK = 0,
+       SCLD_FAILED = -1,
+       SCLD_PERMS = -2,
+       SCLD_EXISTS = -3,
+       SCLD_VANISHED = -4
+};
+enum scld_error safe_create_leading_directories(char *path);
+enum scld_error safe_create_leading_directories_const(const char *path);
+enum scld_error safe_create_leading_directories_no_share(char *path);
+
+int mkdir_in_gitdir(const char *path);
+
+int git_open_cloexec(const char *name, int flags);
+#define git_open(name) git_open_cloexec(name, O_RDONLY)
+
+/**
+ * unpack_loose_header() initializes the data stream needed to unpack
+ * a loose object header.
+ *
+ * Returns:
+ *
+ * - ULHR_OK on success
+ * - ULHR_BAD on error
+ * - ULHR_TOO_LONG if the header was too long
+ *
+ * It will only parse up to MAX_HEADER_LEN bytes unless an optional
+ * "hdrbuf" argument is non-NULL. This is intended for use with
+ * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
+ * reporting. The full header will be extracted to "hdrbuf" for use
+ * with parse_loose_header(), ULHR_TOO_LONG will still be returned
+ * from this function to indicate that the header was too long.
+ */
+enum unpack_loose_header_result {
+       ULHR_OK,
+       ULHR_BAD,
+       ULHR_TOO_LONG,
+};
+enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
+                                                   unsigned char *map,
+                                                   unsigned long mapsize,
+                                                   void *buffer,
+                                                   unsigned long bufsiz,
+                                                   struct strbuf *hdrbuf);
+
+/**
+ * parse_loose_header() parses the starting "<type> <len>\0" of an
+ * object. If it doesn't follow that format -1 is returned. To check
+ * the validity of the <type> populate the "typep" in the "struct
+ * object_info". It will be OBJ_BAD if the object type is unknown. The
+ * parsed <len> can be retrieved via "oi->sizep", and from there
+ * passed to unpack_loose_rest().
+ */
+struct object_info;
+int parse_loose_header(const char *hdr, struct object_info *oi);
+
+/**
+ * With in-core object data in "buf", rehash it to make sure the
+ * object name actually matches "oid" to detect object corruption.
+ *
+ * A negative value indicates an error, usually that the OID is not
+ * what we expected, but it might also indicate another error.
+ */
+int check_object_signature(struct repository *r, const struct object_id *oid,
+                          void *map, unsigned long size,
+                          enum object_type type);
+
+/**
+ * A streaming version of check_object_signature().
+ * Try reading the object named with "oid" using
+ * the streaming interface and rehash it to do the same.
+ */
+int stream_object_signature(struct repository *r, const struct object_id *oid);
+
+int finalize_object_file(const char *tmpfile, const char *filename);
+
+/* Helper to check and "touch" a file */
+int check_and_freshen_file(const char *fn, int freshen);
+
+void *read_object_with_reference(struct repository *r,
+                                const struct object_id *oid,
+                                enum object_type required_type,
+                                unsigned long *size,
+                                struct object_id *oid_ret);
+
+#endif /* OBJECT_FILE_H */
index f1edc0035b0534e2d992c02d911bfff344a27fe8..538e8a8f62e8e1dbacd66a3869e2eb6c3165c908 100644 (file)
@@ -1,4 +1,6 @@
 #include "cache.h"
+#include "object-name.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/object-name.h b/object-name.h
new file mode 100644 (file)
index 0000000..1d63698
--- /dev/null
@@ -0,0 +1,121 @@
+#ifndef OBJECT_NAME_H
+#define OBJECT_NAME_H
+
+#include "object.h"
+#include "strbuf.h"
+
+struct object_id;
+struct repository;
+
+struct object_context {
+       unsigned short mode;
+       /*
+        * symlink_path is only used by get_tree_entry_follow_symlinks,
+        * and only for symlinks that point outside the repository.
+        */
+       struct strbuf symlink_path;
+       /*
+        * If GET_OID_RECORD_PATH is set, this will record path (if any)
+        * found when resolving the name. The caller is responsible for
+        * releasing the memory.
+        */
+       char *path;
+};
+
+/*
+ * Return an abbreviated sha1 unique within this repository's object database.
+ * The result will be at least `len` characters long, and will be NUL
+ * terminated.
+ *
+ * The non-`_r` version returns a static buffer which remains valid until 4
+ * more calls to repo_find_unique_abbrev are made.
+ *
+ * The `_r` variant writes to a buffer supplied by the caller, which must be at
+ * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
+ * written (excluding the NUL terminator).
+ *
+ * Note that while this version avoids the static buffer, it is not fully
+ * reentrant, as it calls into other non-reentrant git code.
+ */
+const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
+int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
+
+int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
+__attribute__((format (printf, 2, 3)))
+int get_oidf(struct object_id *oid, const char *fmt, ...);
+int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
+void maybe_die_on_misspelt_object_name(struct repository *repo,
+                                      const char *name,
+                                      const char *prefix);
+enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
+                                        unsigned flags, struct object_id *oid,
+                                        struct object_context *oc);
+
+
+typedef int each_abbrev_fn(const struct object_id *oid, void *);
+int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
+
+int set_disambiguate_hint_config(const char *var, const char *value);
+
+/*
+ * This reads short-hand syntax that not only evaluates to a commit
+ * object name, but also can act as if the end user spelled the name
+ * of the branch from the command line.
+ *
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
+ *   places the name of the branch in the given buf and returns the
+ *   number of characters parsed if successful.
+ *
+ * - "<branch>@{upstream}" finds the name of the other ref that
+ *   <branch> is configured to merge with (missing <branch> defaults
+ *   to the current branch), and places the name of the branch in the
+ *   given buf and returns the number of characters parsed if
+ *   successful.
+ *
+ * If the input is not of the accepted format, it returns a negative
+ * number to signal an error.
+ *
+ * If the input was ok but there are not N branch switches in the
+ * reflog, it returns 0.
+ */
+#define INTERPRET_BRANCH_LOCAL (1<<0)
+#define INTERPRET_BRANCH_REMOTE (1<<1)
+#define INTERPRET_BRANCH_HEAD (1<<2)
+struct interpret_branch_name_options {
+       /*
+        * If "allowed" is non-zero, it is a treated as a bitfield of allowable
+        * expansions: local branches ("refs/heads/"), remote branches
+        * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
+        * allowed, even ones to refs outside of those namespaces.
+        */
+       unsigned allowed;
+
+       /*
+        * If ^{upstream} or ^{push} (or equivalent) is requested, and the
+        * branch in question does not have such a reference, return -1 instead
+        * of die()-ing.
+        */
+       unsigned nonfatal_dangling_mark : 1;
+};
+int repo_interpret_branch_name(struct repository *r,
+                              const char *str, int len,
+                              struct strbuf *buf,
+                              const struct interpret_branch_name_options *options);
+
+struct object *repo_peel_to_type(struct repository *r,
+                                const char *name, int namelen,
+                                struct object *o, enum object_type);
+
+/* Convert to/from hex/sha1 representation */
+#define MINIMUM_ABBREV minimum_abbrev
+#define DEFAULT_ABBREV default_abbrev
+
+/* used when the code does not know or care what the default abbrev is */
+#define FALLBACK_DEFAULT_ABBREV 7
+
+#endif /* OBJECT_NAME_H */
index f9d225783ae6c1730e7e947c81b39f86ebb3c85b..4ac91e375dd3aad4474de628fac34cb73b0a0686 100644 (file)
@@ -56,6 +56,7 @@ KHASH_INIT(odb_path_map, const char * /* key: odb_path */,
        struct object_directory *, 1, fspathhash, fspatheq)
 
 void prepare_alt_odb(struct repository *r);
+int has_alt_odb(struct repository *r);
 char *compute_alternate_path(const char *path, struct strbuf *err);
 struct object_directory *find_odb(struct repository *r, const char *obj_dir);
 typedef int alt_odb_fn(struct object_directory *, void *);
index 45c9721b8c81929a13854d46d0354374370fd02f..6d4ef1524defed90be95ee17372e37ed099cd27e 100644 (file)
--- a/object.c
+++ b/object.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "object.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
index fc45b158da095d750d9dc55b93282aabe997e7f1..96e52e24fb1b777592373e955e07002f5c64ee1d 100644 (file)
--- a/object.h
+++ b/object.h
@@ -101,6 +101,50 @@ enum object_type {
        OBJ_MAX
 };
 
+/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
+#define S_IFINVALID     0030000
+
+/*
+ * A "directory link" is a link to another git directory.
+ *
+ * The value 0160000 is not normally a valid mode, and
+ * also just happens to be S_IFDIR + S_IFLNK
+ */
+#define S_IFGITLINK    0160000
+#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
+
+#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
+
+static inline enum object_type object_type(unsigned int mode)
+{
+       return S_ISDIR(mode) ? OBJ_TREE :
+               S_ISGITLINK(mode) ? OBJ_COMMIT :
+               OBJ_BLOB;
+}
+
+#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
+static inline unsigned int create_ce_mode(unsigned int mode)
+{
+       if (S_ISLNK(mode))
+               return S_IFLNK;
+       if (S_ISSPARSEDIR(mode))
+               return S_IFDIR;
+       if (S_ISDIR(mode) || S_ISGITLINK(mode))
+               return S_IFGITLINK;
+       return S_IFREG | ce_permissions(mode);
+}
+
+static inline unsigned int canon_mode(unsigned int mode)
+{
+       if (S_ISREG(mode))
+               return S_IFREG | ce_permissions(mode);
+       if (S_ISLNK(mode))
+               return S_IFLNK;
+       if (S_ISDIR(mode))
+               return S_IFDIR;
+       return S_IFGITLINK;
+}
+
 /*
  * The object type is stored in 3 bits.
  */
index 7f5f489beb026545593613857a9d987b42ea34c2..faf67c94d37e15914f248779f50207ffeb805b72 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
index b2e7d06d604ece888ea3ca0d7139f189d8134d2f..e0fad723bf380f4d39a9ae123b51f146f77874d4 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "commit.h"
 #include "gettext.h"
@@ -15,6 +15,8 @@
 #include "pack-objects.h"
 #include "packfile.h"
 #include "repository.h"
+#include "trace2.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
@@ -379,7 +381,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
                goto cleanup;
        }
 
-       if (load_midx_revindex(bitmap_git->midx) < 0) {
+       if (load_midx_revindex(bitmap_git->midx)) {
                warning(_("multi-pack bitmap is missing required reverse index"));
                goto cleanup;
        }
@@ -463,7 +465,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
        return 0;
 }
 
-static int load_reverse_index(struct bitmap_index *bitmap_git)
+static int load_reverse_index(struct repository *r, struct bitmap_index *bitmap_git)
 {
        if (bitmap_is_midx(bitmap_git)) {
                uint32_t i;
@@ -477,23 +479,23 @@ static int load_reverse_index(struct bitmap_index *bitmap_git)
                 * since we will need to make use of them in pack-objects.
                 */
                for (i = 0; i < bitmap_git->midx->num_packs; i++) {
-                       ret = load_pack_revindex(bitmap_git->midx->packs[i]);
+                       ret = load_pack_revindex(r, bitmap_git->midx->packs[i]);
                        if (ret)
                                return ret;
                }
                return 0;
        }
-       return load_pack_revindex(bitmap_git->pack);
+       return load_pack_revindex(r, bitmap_git->pack);
 }
 
-static int load_bitmap(struct bitmap_index *bitmap_git)
+static int load_bitmap(struct repository *r, struct bitmap_index *bitmap_git)
 {
        assert(bitmap_git->map);
 
        bitmap_git->bitmaps = kh_init_oid_map();
        bitmap_git->ext_index.positions = kh_init_oid_pos();
 
-       if (load_reverse_index(bitmap_git))
+       if (load_reverse_index(r, bitmap_git))
                goto failed;
 
        if (!(bitmap_git->commits = read_bitmap_1(bitmap_git)) ||
@@ -580,7 +582,7 @@ struct bitmap_index *prepare_bitmap_git(struct repository *r)
 {
        struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
 
-       if (!open_bitmap(r, bitmap_git) && !load_bitmap(bitmap_git))
+       if (!open_bitmap(r, bitmap_git) && !load_bitmap(r, bitmap_git))
                return bitmap_git;
 
        free_bitmap_index(bitmap_git);
@@ -589,9 +591,10 @@ struct bitmap_index *prepare_bitmap_git(struct repository *r)
 
 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx)
 {
+       struct repository *r = the_repository;
        struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
 
-       if (!open_midx_bitmap_1(bitmap_git, midx) && !load_bitmap(bitmap_git))
+       if (!open_midx_bitmap_1(bitmap_git, midx) && !load_bitmap(r, bitmap_git))
                return bitmap_git;
 
        free_bitmap_index(bitmap_git);
@@ -1592,7 +1595,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
         * from disk. this is the point of no return; after this the rev_list
         * becomes invalidated and we must perform the revwalk through bitmaps
         */
-       if (load_bitmap(bitmap_git) < 0)
+       if (load_bitmap(revs->repo, bitmap_git) < 0)
                goto cleanup;
 
        object_array_clear(&revs->pending);
@@ -1742,6 +1745,7 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
                                       uint32_t *entries,
                                       struct bitmap **reuse_out)
 {
+       struct repository *r = the_repository;
        struct packed_git *pack;
        struct bitmap *result = bitmap_git->result;
        struct bitmap *reuse;
@@ -1752,7 +1756,7 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
 
        assert(result);
 
-       load_reverse_index(bitmap_git);
+       load_reverse_index(r, bitmap_git);
 
        if (bitmap_is_midx(bitmap_git))
                pack = bitmap_git->midx->packs[midx_preferred_pack(bitmap_git)];
@@ -2132,12 +2136,13 @@ int rebuild_bitmap(const uint32_t *reposition,
 uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
                                struct packing_data *mapping)
 {
+       struct repository *r = the_repository;
        uint32_t i, num_objects;
        uint32_t *reposition;
 
        if (!bitmap_is_midx(bitmap_git))
-               load_reverse_index(bitmap_git);
-       else if (load_midx_revindex(bitmap_git->midx) < 0)
+               load_reverse_index(r, bitmap_git);
+       else if (load_midx_revindex(bitmap_git->midx))
                BUG("rebuild_existing_bitmaps: missing required rev-cache "
                    "extension");
 
index 6974e40a95826e39b3f102d1653b391c9e87cde5..049f2f0bfc03f2c08a4e24fa6be767f01fe8145d 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
@@ -6,6 +6,7 @@
 #include "pack-revindex.h"
 #include "progress.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 struct idx_entry {
index afed63219060ecb57cc1fdb285bfe0b90eac725c..020a37f8fe3a837de959ceade8dca86849253593 100644 (file)
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 
index 03c7e81f9da61602f22185d20bcb5121ba7fc97b..1f51b712e879e401e9b308d993a2b810460f01e3 100644 (file)
@@ -1,10 +1,13 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "trace2.h"
 #include "config.h"
 #include "midx.h"
+#include "csum-file.h"
 
 struct revindex_entry {
        off_t offset;
@@ -205,10 +208,14 @@ static int load_revindex_from_disk(char *revindex_name,
        size_t revindex_size;
        struct revindex_header *hdr;
 
+       if (git_env_bool(GIT_TEST_REV_INDEX_DIE_ON_DISK, 0))
+               die("dying as requested by '%s'", GIT_TEST_REV_INDEX_DIE_ON_DISK);
+
        fd = git_open(revindex_name);
 
        if (fd < 0) {
-               ret = -1;
+               /* "No file" means return 1. */
+               ret = 1;
                goto cleanup;
        }
        if (fstat(fd, &st)) {
@@ -260,7 +267,7 @@ cleanup:
        return ret;
 }
 
-static int load_pack_revindex_from_disk(struct packed_git *p)
+int load_pack_revindex_from_disk(struct packed_git *p)
 {
        char *revindex_name;
        int ret;
@@ -283,18 +290,58 @@ cleanup:
        return ret;
 }
 
-int load_pack_revindex(struct packed_git *p)
+int load_pack_revindex(struct repository *r, struct packed_git *p)
 {
        if (p->revindex || p->revindex_data)
                return 0;
 
-       if (!load_pack_revindex_from_disk(p))
+       prepare_repo_settings(r);
+
+       if (r->settings.pack_read_reverse_index &&
+           !load_pack_revindex_from_disk(p))
                return 0;
        else if (!create_pack_revindex_in_memory(p))
                return 0;
        return -1;
 }
 
+/*
+ * verify_pack_revindex verifies that the on-disk rev-index for the given
+ * pack-file is the same that would be created if written from scratch.
+ *
+ * A negative number is returned on error.
+ */
+int verify_pack_revindex(struct packed_git *p)
+{
+       int res = 0;
+
+       /* Do not bother checking if not initialized. */
+       if (!p->revindex_map || !p->revindex_data)
+               return res;
+
+       if (!hashfile_checksum_valid((const unsigned char *)p->revindex_map, p->revindex_size)) {
+               error(_("invalid checksum"));
+               res = -1;
+       }
+
+       /* This may fail due to a broken .idx. */
+       if (create_pack_revindex_in_memory(p))
+               return res;
+
+       for (size_t i = 0; i < p->num_objects; i++) {
+               uint32_t nr = p->revindex[i].nr;
+               uint32_t rev_val = get_be32(p->revindex_data + i);
+
+               if (nr != rev_val) {
+                       error(_("invalid rev-index position at %"PRIu64": %"PRIu32" != %"PRIu32""),
+                             (uint64_t)i, nr, rev_val);
+                       res = -1;
+               }
+       }
+
+       return res;
+}
+
 int load_midx_revindex(struct multi_pack_index *m)
 {
        struct strbuf revindex_name = STRBUF_INIT;
@@ -356,7 +403,7 @@ int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos)
 {
        unsigned lo, hi;
 
-       if (load_pack_revindex(p) < 0)
+       if (load_pack_revindex(the_repository, p) < 0)
                return -1;
 
        lo = 0;
index 4974e75eb4d0e9d002fc70a87e5bb4526e1e49f7..6dd47efea10ec69a3438f0a804a71bf13cd91c37 100644 (file)
 #define RIDX_SIGNATURE 0x52494458 /* "RIDX" */
 #define RIDX_VERSION 1
 
-#define GIT_TEST_WRITE_REV_INDEX "GIT_TEST_WRITE_REV_INDEX"
+#define GIT_TEST_NO_WRITE_REV_INDEX "GIT_TEST_NO_WRITE_REV_INDEX"
 #define GIT_TEST_REV_INDEX_DIE_IN_MEMORY "GIT_TEST_REV_INDEX_DIE_IN_MEMORY"
+#define GIT_TEST_REV_INDEX_DIE_ON_DISK "GIT_TEST_REV_INDEX_DIE_ON_DISK"
 
 struct packed_git;
 struct multi_pack_index;
+struct repository;
 
 /*
  * load_pack_revindex populates the revindex's internal data-structures for the
@@ -47,7 +49,23 @@ struct multi_pack_index;
  * If a '.rev' file is present it is mmap'd, and pointers are assigned into it
  * (instead of using the in-memory variant).
  */
-int load_pack_revindex(struct packed_git *p);
+int load_pack_revindex(struct repository *r, struct packed_git *p);
+
+/*
+ * Specifically load a pack revindex from disk.
+ *
+ * Returns 0 on success, 1 on "no .rev file", and -1 when there is an
+ * error parsing the .rev file.
+ */
+int load_pack_revindex_from_disk(struct packed_git *p);
+
+/*
+ * verify_pack_revindex verifies that the on-disk rev-index for the given
+ * pack-file is the same that would be created if written from scratch.
+ *
+ * A negative number is returned on error.
+ */
+int verify_pack_revindex(struct packed_git *p);
 
 /*
  * load_midx_revindex loads the '.rev' file corresponding to the given
index f1714054951e158ca920a4a17a831914962f557e..3b3ce89de6e9c2f13b81ca6b67c9a3b02cee54e3 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
@@ -9,6 +9,8 @@
 #include "pack-mtimes.h"
 #include "oidmap.h"
 #include "pack-objects.h"
+#include "pack-revindex.h"
+#include "wrapper.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
@@ -312,13 +314,13 @@ static void write_mtimes_trailer(struct hashfile *f, const unsigned char *hash)
        hashwrite(f, hash, the_hash_algo->rawsz);
 }
 
-static const char *write_mtimes_file(struct packing_data *to_pack,
-                                    struct pack_idx_entry **objects,
-                                    uint32_t nr_objects,
-                                    const unsigned char *hash)
+static char *write_mtimes_file(struct packing_data *to_pack,
+                              struct pack_idx_entry **objects,
+                              uint32_t nr_objects,
+                              const unsigned char *hash)
 {
        struct strbuf tmp_file = STRBUF_INIT;
-       const char *mtimes_name;
+       char *mtimes_name;
        struct hashfile *f;
        int fd;
 
@@ -544,7 +546,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
                         char **idx_tmp_name)
 {
        const char *rev_tmp_name = NULL;
-       const char *mtimes_tmp_name = NULL;
+       char *mtimes_tmp_name = NULL;
 
        if (adjust_shared_perm(pack_tmp_name))
                die_errno("unable to make temporary pack file readable");
@@ -568,6 +570,9 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
                rename_tmp_packfile(name_buffer, rev_tmp_name, "rev");
        if (mtimes_tmp_name)
                rename_tmp_packfile(name_buffer, mtimes_tmp_name, "mtimes");
+
+       free((char *)rev_tmp_name);
+       free(mtimes_tmp_name);
 }
 
 void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought)
index b120405ccc8a6bf591ddd7e8b9410f2305a88306..57df0c19563853548c4b059f7a45c74dbfeb3668 100644 (file)
 #include "commit.h"
 #include "object.h"
 #include "tag.h"
+#include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
+#include "pack-revindex.h"
 #include "promisor-remote.h"
 #include "wrapper.h"
 
@@ -2151,7 +2154,7 @@ int for_each_object_in_pack(struct packed_git *p,
        int r = 0;
 
        if (flags & FOR_EACH_OBJECT_PACK_ORDER) {
-               if (load_pack_revindex(p))
+               if (load_pack_revindex(the_repository, p))
                        return -1;
        }
 
diff --git a/pager.c b/pager.c
index b66bbff2785cb6ed032edb4f0d9cd68f6a841c36..63055d0873f01c01809927ecd56d09a10f500fbe 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1,9 +1,13 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
+#include "editor.h"
+#include "pager.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
 
+int pager_use_color = 1;
+
 #ifndef DEFAULT_PAGER
 #define DEFAULT_PAGER "less"
 #endif
diff --git a/pager.h b/pager.h
new file mode 100644 (file)
index 0000000..b774330
--- /dev/null
+++ b/pager.h
@@ -0,0 +1,17 @@
+#ifndef PAGER_H
+#define PAGER_H
+
+struct child_process;
+
+const char *git_pager(int stdout_is_tty);
+void setup_pager(void);
+int pager_in_use(void);
+int term_columns(void);
+void term_clear_line(void);
+int decimal_width(uintmax_t);
+int check_pager_config(const char *cmd);
+void prepare_pager_args(struct child_process *, const char *pager);
+
+extern int pager_use_color;
+
+#endif /* PAGER_H */
index 10f2f75e83893a3599616f2ee593ac27fe14fd48..298decf48f77bb7052fc40b582a441455ab06ef8 100644 (file)
@@ -1,11 +1,11 @@
 #include "git-compat-util.h"
 #include "parse-options.h"
 #include "branch.h"
-#include "cache.h"
 #include "commit.h"
 #include "color.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "oid-array.h"
diff --git a/path.c b/path.c
index dff215ac69339dce01cabd9a0f6d01b0e8bcec2f..7c1cd8182a81b9e8892960707cff8a0f7ff174cb 100644 (file)
--- a/path.c
+++ b/path.c
@@ -18,6 +18,7 @@
 #include "object-store.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
+#include "wrapper.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
index 36ae0fea4a3c6ba06899d6248fb2c2a7578b378d..3561d853584ecd1611acfe2358cfaa7adb9b5cd2 100644 (file)
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
index 52544d004e76a011e5078fbc14037bd74a039553..4abf9c983b28df9718415e675c1c1fa0946ebfa4 100644 (file)
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "thread-utils.h"
 #include "repository.h"
+#include "trace2.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
index 76fc4f61e40d8ac6c30b054cf6e2558aa403d96f..0bb938021ba593df826b91d39a2ec7a059e84b61 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "commit.h"
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "utf8.h"
 #include "diff.h"
+#include "pager.h"
 #include "revision.h"
 #include "string-list.h"
 #include "mailmap.h"
index 44c784d75f106c066c85b7a7a6569744332a6be2..72d5e0c73c19eb2a110060a45e46a811d10b676d 100644 (file)
@@ -9,10 +9,12 @@
  */
 
 #define GIT_TEST_PROGRESS_ONLY
-#include "cache.h"
+#include "git-compat-util.h"
+#include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "config.h"
 
index a8dbb788e8f1a0a4cb3c77ba16fda20bb8b9f41a..1adcd6fb0a51a0abc5c93a1fe3fc26dc51d60ab8 100644 (file)
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "config.h"
+#include "trace2.h"
 #include "transport.h"
 #include "strvec.h"
 #include "packfile.h"
index bdb32e1eeb62473b9ae309b266c7f508a480c354..079ba75acf4e84451a80aa764cad3ac77a7d667f 100644 (file)
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
+#include "trace2.h"
 
 static enum protocol_version parse_protocol_version(const char *value)
 {
index cef1a4a01c7902b0b1181a43580639fcead442ff..de66bf80f8409370069fed46ce97dadb25519d7d 100644 (file)
@@ -1,6 +1,27 @@
 #ifndef PROTOCOL_H
 #define PROTOCOL_H
 
+/*
+ * Intensive research over the course of many years has shown that
+ * port 9418 is totally unused by anything else. Or
+ *
+ *     Your search - "port 9418" - did not match any documents.
+ *
+ * as www.google.com puts it.
+ *
+ * This port has been properly assigned for git use by IANA:
+ * git (Assigned-9418) [I06-050728-0001].
+ *
+ *     git  9418/tcp   git pack transfer service
+ *     git  9418/udp   git pack transfer service
+ *
+ * with Linus Torvalds <torvalds@osdl.org> as the point of
+ * contact. September 2005.
+ *
+ * See http://www.iana.org/assignments/port-numbers
+ */
+#define DEFAULT_GIT_PORT 9418
+
 enum protocol_version {
        protocol_unknown_version = -1,
        protocol_v0 = 0,
diff --git a/quote.c b/quote.c
index 7ccb5a06cd161c46ad2deeacc19de7bec99731a2..43c739671ed0cb33cd246a98737136b2154c2a57 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
+#include "path.h"
 #include "quote.h"
 #include "strbuf.h"
 #include "strvec.h"
diff --git a/quote.h b/quote.h
index 87ff458b06dd6430855b39f6cb4833664e630746..0300c291041b02464e55e36a6c820a9faecf260f 100644 (file)
--- a/quote.h
+++ b/quote.h
@@ -3,6 +3,8 @@
 
 struct strbuf;
 
+extern int quote_path_fully;
+
 /* Help to copy the thing properly quoted for the shell safety.
  * any single quote is replaced with '\'', any exclamation point
  * is replaced with '\!', and the whole thing is enclosed in a
index d1ed3b8ee569f7367ff9fab659febe24dfb67121..a1e0cffb9f6cbd15081a6ee154b415db91c22b7b 100644 (file)
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
@@ -10,6 +11,7 @@
 #include "linear-assignment.h"
 #include "diffcore.h"
 #include "commit.h"
+#include "pager.h"
 #include "pretty.h"
 #include "userdiff.h"
 #include "apply.h"
index 2a49178633b0398e167675c5784c74e95c123514..e919af3c77a27cabfe4f9758e78358307173cdae 100644 (file)
 #include "cache-tree.h"
 #include "refs.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tree.h"
 #include "commit.h"
 #include "blob.h"
 #include "environment.h"
 #include "gettext.h"
+#include "mem-pool.h"
+#include "object-name.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 #include "varint.h"
 #include "split-index.h"
 #include "utf8.h"
index 79ed61b9fa4a333d905fe1d5258d20e43ce86bb2..789f40736176e5f597f79d35582224ac8830495e 100644 (file)
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "commit.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "sequencer.h"
@@ -8,6 +9,7 @@
 #include "commit-slab.h"
 #include "config.h"
 #include "dir.h"
+#include "object-name.h"
 #include "wrapper.h"
 
 static const char edit_todo_list_advice[] =
index 72175612f3f32f512999099442214339aac948c7..10aab14f030a63b452090002cd47caecb4b4671c 100644 (file)
@@ -6,7 +6,9 @@
 #include "parse-options.h"
 #include "refs.h"
 #include "wildmatch.h"
+#include "object-name.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "repository.h"
 #include "commit.h"
 #include "remote.h"
diff --git a/refs.c b/refs.c
index 0f369dbde7a092868a767d795911fb3a14168d70..d2a98e1c21f4e9e0be61070aeec48446b0335efc 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2,7 +2,8 @@
  * The backend-independent part of the reference module.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
@@ -15,6 +16,7 @@
 #include "refs/refs-internal.h"
 #include "run-command.h"
 #include "hook.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
index e6a6971381e09a5f153b25d29b69bb5b1c1d6270..d0581ee41ac6181961567627f292ad6a0dbcdc14 100644 (file)
@@ -12,6 +12,7 @@
 #include "../dir-iterator.h"
 #include "../lockfile.h"
 #include "../object.h"
+#include "../object-file.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
index 1eba1015dd5aa8378bf722b50a2b466774b43f0d..2333ed5a1f7afef829ef972f85247b7d4ec78fed 100644 (file)
@@ -9,6 +9,7 @@
 #include "../iterator.h"
 #include "../lockfile.h"
 #include "../chdir-notify.h"
+#include "../wrapper.h"
 #include "../write-or-die.h"
 
 enum mmap_strategy {
index 850d9d3744e94270fb5cd445b4f6b7b18aac8128..cf4ad9070b9c323a94826841a5404329e1d4a071 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef REFS_REF_CACHE_H
 #define REFS_REF_CACHE_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct ref_dir;
 struct ref_store;
index db3bc431fc3e0af4802b5685364ea6a3ade38a6f..acf7b2bb40ac4edc07e98934a51c4d69711bc6cb 100644 (file)
@@ -21,6 +21,7 @@
 #include "setup.h"
 #include "protocol.h"
 #include "quote.h"
+#include "trace2.h"
 #include "transport.h"
 #include "write-or-die.h"
 
index 3a831cb5304937122125c26d9e700be16362af4b..0764fca0db9978336ae5ae13f79853d44a1e0944 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
@@ -9,6 +9,7 @@
 #include "urlmatch.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "diff.h"
index 0a6c0b381fe13b50fb14b5b6e31ca06c0d44f695..d220c5dd9fefa5e9ec3481c24bc302ddfb00bc5e 100644 (file)
@@ -41,10 +41,8 @@ void prepare_repo_settings(struct repository *r)
        repo_cfg_bool(r, "feature.experimental", &experimental, 0);
 
        /* Defaults modified by feature.* */
-       if (experimental) {
+       if (experimental)
                r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
-               r->settings.gc_cruft_packs = 1;
-       }
        if (manyfiles) {
                r->settings.index_version = 4;
                r->settings.index_skip_hash = 1;
@@ -63,6 +61,7 @@ void prepare_repo_settings(struct repository *r)
        repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
        repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
        repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);
+       repo_cfg_bool(r, "pack.readreverseindex", &r->settings.pack_read_reverse_index, 1);
 
        /*
         * The GIT_TEST_MULTI_PACK_INDEX variable is special in that
index f6d9f5db08e0ded1390f1ba0d081585cab6b52a3..c53e480e32601e0ba4ba63ea9ba31accde57a46b 100644 (file)
@@ -14,6 +14,7 @@
 #include "setup.h"
 #include "submodule-config.h"
 #include "sparse-index.h"
+#include "trace2.h"
 #include "promisor-remote.h"
 
 /* The main repository */
index 15a8afc5fb5b31b12bc3495663f9f3ca2f399c7e..1a13ff28677ec0db952971c48ef725347c34bda0 100644 (file)
@@ -33,10 +33,10 @@ struct repo_settings {
        int commit_graph_generation_version;
        int commit_graph_read_changed_paths;
        int gc_write_commit_graph;
-       int gc_cruft_packs;
        int fetch_write_commit_graph;
        int command_requires_full_index;
        int sparse_index;
+       int pack_read_reverse_index;
 
        struct fsmonitor_settings *fsmonitor; /* lazily loaded */
 
index 5516e336d010cac54d3dca4fba026a025825acdc..7abc94bf444dc18fe0eb4d170845bf54c9a7370e 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
@@ -13,6 +13,7 @@
 #include "ll-merge.h"
 #include "attr.h"
 #include "pathspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "strmap.h"
diff --git a/reset.c b/reset.c
index ab300923e04f6066cea56680cafa42306af954bd..48da0adf851e1b09edfc22ffbbc0b1128cbbc5ab 100644 (file)
--- a/reset.c
+++ b/reset.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "refs.h"
 #include "reset.h"
 #include "run-command.h"
index 2b3f0f901e63aeab70dfca86d3067d169dc315e2..d1ea97277127f20c7a5f1dbb5c68fc6d7f2af3de 100644 (file)
@@ -1,7 +1,12 @@
 #ifndef RESOLVE_UNDO_H
 #define RESOLVE_UNDO_H
 
-#include "cache.h"
+struct cache_entry;
+struct index_state;
+struct pathspec;
+struct string_list;
+
+#include "hash.h"
 
 struct resolve_undo_info {
        unsigned int mode[3];
index 106ca1ce6c98f59e29af6c63731c75e9121d6b0a..b33cc1d106a207de3c5a42c413913877c129a28d 100644 (file)
@@ -1,9 +1,11 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
@@ -31,6 +33,7 @@
 #include "worktree.h"
 #include "setup.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
index 614d48fa9a231e4192485d2b1bc75fae91542845..e64bb08a5bf890b1afddfede3519536a714debec 100644 (file)
@@ -8,6 +8,8 @@
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
+#include "trace.h"
+#include "trace2.h"
 #include "quote.h"
 #include "config.h"
 #include "packfile.h"
index de07c37d21001d54d026fb6f5f1de0ebccaf7e9c..1326e1f608907247ca5304fc1838a1002bfc3b5f 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -2,7 +2,7 @@
  * The Scalar command-line interface.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
 #include "parse-options.h"
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "help.h"
 #include "setup.h"
+#include "trace2.h"
 
 static void setup_enlistment_directory(int argc, const char **argv,
                                       const char * const *usagestr,
index f81bbb28d79259f25db58548ca3d51fb8b2f6a2d..2089143555f4fcc9eed6281a61202f0b4ba9a4be 100644 (file)
@@ -14,6 +14,7 @@
 #include "quote.h"
 #include "transport.h"
 #include "version.h"
+#include "wrapper.h"
 #include "oid-array.h"
 #include "gpg-interface.h"
 #include "shallow.h"
@@ -538,7 +539,7 @@ int send_pack(struct send_pack_args *args,
                die(_("the receiving end does not support this repository's hash algorithm"));
 
        if (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {
-               int len;
+               size_t len;
                push_cert_nonce = server_feature_value("push-cert", &len);
                if (push_cert_nonce) {
                        reject_invalid_nonce(push_cert_nonce, len);
index d2c7698c48ceb92f1bd1ceb03496033cc78f35a0..c88d1d95538fbb12b5887e34dd8b790aecd706ab 100644 (file)
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
@@ -7,8 +8,11 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
+#include "pager.h"
 #include "commit.h"
 #include "sequencer.h"
 #include "tag.h"
index 355b6e01a52a0ce25b1a9fdf145749b37085f852..68098ddd1ad6a84b3ad25a85b5361b8f353cd4c0 100644 (file)
@@ -9,6 +9,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "strbuf.h"
 #include "wrapper.h"
diff --git a/setup.c b/setup.c
index 6c5b85e96c1e6bfc5367ec54d068d5d61f329aec..59abc16ba6da9584d7838896fc567a526f4093ad 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
@@ -10,6 +11,8 @@
 #include "chdir-notify.h"
 #include "promisor-remote.h"
 #include "quote.h"
+#include "trace2.h"
+#include "wrapper.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
index b4d726bd5954c4cbf4156c9ea8c98822471c9db4..128f56179edefa7d223508217e5c73aa427e647b 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -17,6 +17,7 @@
 #include "list-objects.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 
 void set_alternate_shallow_file(struct repository *r, const char *path, int override)
index 0af582858bf4175e8c3047cffc10eb156661a631..6cbfd391c47fb531740eb4b963a11b77f8abe29d 100644 (file)
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "color.h"
 #include "config.h"
+#include "editor.h"
 #include "gettext.h"
 #include "sideband.h"
 #include "help.h"
index c98807c655b1fddb6df70e9c4fbf0122264c5b58..5602b74994b0cb84c109ecc04dbe2e692c064eaa 100644 (file)
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "split-index.h"
 #include "ewah/ewok.h"
 
index 7a435ca2c970111b40ac9edba65726e79bd7941d..1a153f47ba348fb3e8c5bdcae9b279cef352f475 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef SPLIT_INDEX_H
 #define SPLIT_INDEX_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct index_state;
 struct strbuf;
index 70a83e7980e0e575cde2d9b8fed5eec1fa9f48e5..729378ec824406da1654a514f88ab71375410bcd 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "string-list.h"
 #include "utf8.h"
@@ -1179,34 +1180,6 @@ int strbuf_normalize_path(struct strbuf *src)
        return 0;
 }
 
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-                             const char *const *env)
-{
-       char *path2 = NULL;
-       int fd, res = 0;
-
-       if (!is_absolute_path(path))
-               path = path2 = xstrdup(git_path("%s", path));
-
-       fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-       if (fd < 0)
-               res = error_errno(_("could not open '%s' for writing"), path);
-       else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
-               res = error_errno(_("could not write to '%s'"), path);
-               close(fd);
-       } else if (close(fd) < 0)
-               res = error_errno(_("could not close '%s'"), path);
-       else {
-               strbuf_reset(buffer);
-               if (launch_editor(path, buffer, env) < 0)
-                       res = error_errno(_("could not edit '%s'"), path);
-               unlink(path);
-       }
-
-       free(path2);
-       return res;
-}
-
 void strbuf_strip_file_from_path(struct strbuf *sb)
 {
        char *path_sep = find_last_dir_sep(sb->buf);
index b980f9edc6d9b79dd0319b06d13f9e5165624653..3dfeadb44c2e93e3e47cd448eaf8fd9133ac47bc 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -640,30 +640,6 @@ void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
 void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
                              int abbrev_len);
 
-/**
- * Launch the user preferred editor to edit a file and fill the buffer
- * with the file's contents upon the user completing their editing. The
- * third argument can be used to set the environment which the editor is
- * run in. If the buffer is NULL the editor is launched as usual but the
- * file's contents are not read into the buffer upon completion.
- */
-int launch_editor(const char *path, struct strbuf *buffer,
-                 const char *const *env);
-
-int launch_sequence_editor(const char *path, struct strbuf *buffer,
-                          const char *const *env);
-
-/*
- * In contrast to `launch_editor()`, this function writes out the contents
- * of the specified file first, then clears the `buffer`, then launches
- * the editor and reads back in the file contents into the `buffer`.
- * Finally, it deletes the temporary file.
- *
- * If `path` is relative, it refers to a file in the `.git` directory.
- */
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-                             const char *const *env);
-
 /*
  * Remove the filename from the provided path string. If the path
  * contains a trailing separator, then the path is considered a directory
index 024fd796b7d02f48452c6cf541e6ebb2ccdadd74..21e39585e8906e8463c9765c044ecb4399b9603c 100644 (file)
@@ -1,10 +1,12 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "convert.h"
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "packfile.h"
index ecf0fcf007481806d9e7f63c6d35f0218bca587e..7fc0812b644ff307e958cb7c172476719b4c3d23 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
@@ -9,6 +9,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "tree-walk.h"
index 94644fac0a39f1bad2af719a01f99b1a551e0e8d..2e78f5134964ffc60d94ee5d3a793a3624e214ba 100644 (file)
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-file.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace2.h"
 
 static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
 static int initialized_fetch_ref_tips;
index 29576c37488593d79978a50d405e107b25dbcc7c..bdfac4cceb2cef503070bdefc338ed73264e40b0 100644 (file)
--- a/t/README
+++ b/t/README
@@ -475,7 +475,7 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to
 use in the test scripts. Recognized values for <hash-algo> are "sha1"
 and "sha256".
 
-GIT_TEST_WRITE_REV_INDEX=<boolean>, when true enables the
+GIT_TEST_NO_WRITE_REV_INDEX=<boolean>, when true disables the
 'pack.writeReverseIndex' setting.
 
 GIT_TEST_SPARSE_INDEX=<boolean>, when true enables index writes to use the
index dc28890a183f1d123b3356131e90fd588aa5a439..0e5538833a8fb58bf5a8f3910af40ff3bfe8c07f 100644 (file)
@@ -94,7 +94,7 @@ int cmd__chmtime(int argc, const char **argv)
        if (timespec_arg(argv[i], &set_time, &set_eq)) {
                ++i;
        } else {
-               if (get == 0) {
+               if (get == 0 && verbose == 0) {
                        fprintf(stderr, "Not a base-10 integer: %s\n", argv[i] + 1);
                        goto usage;
                }
index 2d9232cc68ee12ebcbd8d2ed9c1a81ad67273b6e..0683d46574fa41e6b4186e8ec49d06ce65d93256 100644 (file)
@@ -1,6 +1,6 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "date.h"
+#include "trace.h"
 
 static const char *usage_msg = "\n"
 "  test-tool date relative [time_t]...\n"
index fd48e0ee2c8fdaeec535a5a35b26c36031fe32a6..d1d63feaa9e299ace44d228176cd2b4335193569 100644 (file)
@@ -20,6 +20,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "refs.h"
 #include "revision.h"
 #include "sequencer.h"
index 06ce3a47ccfbfd3e33bb6bbacf796253c3da365f..f23d983c1188b4962b3b0df0da5ff5679cd52863 100644 (file)
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "parse-options.h"
 #include "setup.h"
+#include "trace.h"
 
 static int single;
 static int multi;
index 508eb7066ad278fdb925788e9262f5a554f682db..35a2b8005c225ca09e1facdb4b3dc3e26ddc95a6 100644 (file)
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "setup.h"
 #include "tree.h"
 
index 335e5bb3a9008c8ce1cb31198bd54808c70566dc..737e0c52358c9248d9a4b7cb68df8e5cc6dcca47 100644 (file)
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "mem-pool.h"
 #include "mergesort.h"
 
 static uint32_t minstd_rand(uint32_t *state)
index a7b7b38df1f7641e3cf644f01c36db89ca0ce2c4..1b0e7eecb4d13ae2e70e40729d27c6ad0eb5c615 100644 (file)
@@ -1,6 +1,6 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "oidmap.h"
 #include "setup.h"
 #include "strbuf.h"
index 4f5ac2fadce3d940241c7f8b3fc529bc3318ec71..6355c9e4b6df1b6def6c61556e0609fb3656ef17 100644 (file)
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "setup.h"
 #include "string-list.h"
+#include "trace.h"
 #include "utf8.h"
 
 /*
index b0deaa106a288cf57b10d8e818a575c40eb9fdf4..5b6f2174418101575302a7fd083349414d6f283e 100644 (file)
@@ -1,11 +1,11 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "alloc.h"
 #include "commit.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "ref-filter.h"
 #include "setup.h"
index 40a6ee45af0597e565fa43b59b1bdd33d4807daf..5e462faa9d72e7db2b37d2c7d4380a28f6e3a9bf 100644 (file)
@@ -1,6 +1,6 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "config.h"
+#include "object-name.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
index 0684b690af020442847d2ef94162f311e20abc8a..ceec60656b59119c2bb82651f8ae6057899f41c5 100755 (executable)
@@ -12,8 +12,7 @@ test_lookup_pack_bitmap () {
        test_perf_large_repo
 
        test_expect_success 'setup bitmap config' '
-               git config pack.writebitmaps true &&
-               git config pack.writeReverseIndex true
+               git config pack.writebitmaps true
        '
 
        # we need to create the tag up front such that it is covered by the repack and
index 2575279ab84e8a32239a7ea30f72022d3ff6b9f8..f1d42b62b0585cbca3e4c494bf01142d5f1ffdb7 100755 (executable)
@@ -617,6 +617,36 @@ test_expect_success 'renaming to bogus section is rejected' '
        test_must_fail git config --rename-section branch.zwei "bogus name"
 '
 
+test_expect_success 'renaming a section with a long line' '
+       {
+               printf "[b]\\n" &&
+               printf "  c = d %1024s [a] e = f\\n" " " &&
+               printf "[a] g = h\\n"
+       } >y &&
+       git config -f y --rename-section a xyz &&
+       test_must_fail git config -f y b.e
+'
+
+test_expect_success 'renaming an embedded section with a long line' '
+       {
+               printf "[b]\\n" &&
+               printf "  c = d %1024s [a] [foo] e = f\\n" " " &&
+               printf "[a] g = h\\n"
+       } >y &&
+       git config -f y --rename-section a xyz &&
+       test_must_fail git config -f y foo.e
+'
+
+test_expect_success 'renaming a section with an overly-long line' '
+       {
+               printf "[b]\\n" &&
+               printf "  c = d %525000s e" " " &&
+               printf "[a] g = h\\n"
+       } >y &&
+       test_must_fail git config -f y --rename-section a xyz 2>err &&
+       grep "refusing to work with overly long line in .y. on line 2" err
+'
+
 cat >> .git/config << EOF
   [branch "zwei"] a = 1 [branch "vier"]
 EOF
index 65ac7df2d745c4f7a698baf23cc71c2a80221c3e..e95e6d4e7d6419236c1e8bb9bc519b05ea8efec3 100755 (executable)
@@ -126,4 +126,19 @@ test_expect_success SYMLINKS 'symlink escape when deleting file' '
        test_path_is_file .git/delete-me
 '
 
+test_expect_success SYMLINKS '--reject removes .rej symlink if it exists' '
+       test_when_finished "git reset --hard && git clean -dfx" &&
+
+       test_commit file &&
+       echo modified >file.t &&
+       git diff -- file.t >patch &&
+       echo modified-again >file.t &&
+
+       ln -s foo file.t.rej &&
+       test_must_fail git apply patch --reject 2>err &&
+       test_i18ngrep "Rejected hunk" err &&
+       test_path_is_missing foo &&
+       test_path_is_file file.t.rej
+'
+
 test_done
index f8a0f309e2dec0f2ab864851730446bdc7102818..d2ce236d612e9a52c022526762ffe7e491b0bdd1 100755 (executable)
@@ -589,141 +589,6 @@ test_expect_success 'prefetch objects' '
        test_line_count = 1 donelines
 '
 
-test_expect_success 'setup for --stdin-packs tests' '
-       git init stdin-packs &&
-       (
-               cd stdin-packs &&
-
-               test_commit A &&
-               test_commit B &&
-               test_commit C &&
-
-               for id in A B C
-               do
-                       git pack-objects .git/objects/pack/pack-$id \
-                               --incremental --revs <<-EOF || exit 1
-                       refs/tags/$id
-                       EOF
-               done &&
-
-               ls -la .git/objects/pack
-       )
-'
-
-test_expect_success '--stdin-packs with excluded packs' '
-       (
-               cd stdin-packs &&
-
-               PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
-               PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
-               PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
-
-               git pack-objects test --stdin-packs <<-EOF &&
-               $PACK_A
-               ^$PACK_B
-               $PACK_C
-               EOF
-
-               (
-                       git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
-                       git show-index <$(ls .git/objects/pack/pack-C-*.idx)
-               ) >expect.raw &&
-               git show-index <$(ls test-*.idx) >actual.raw &&
-
-               cut -d" " -f2 <expect.raw | sort >expect &&
-               cut -d" " -f2 <actual.raw | sort >actual &&
-               test_cmp expect actual
-       )
-'
-
-test_expect_success '--stdin-packs is incompatible with --filter' '
-       (
-               cd stdin-packs &&
-               test_must_fail git pack-objects --stdin-packs --stdout \
-                       --filter=blob:none </dev/null 2>err &&
-               test_i18ngrep "cannot use --filter with --stdin-packs" err
-       )
-'
-
-test_expect_success '--stdin-packs is incompatible with --revs' '
-       (
-               cd stdin-packs &&
-               test_must_fail git pack-objects --stdin-packs --revs out \
-                       </dev/null 2>err &&
-               test_i18ngrep "cannot use internal rev list with --stdin-packs" err
-       )
-'
-
-test_expect_success '--stdin-packs with loose objects' '
-       (
-               cd stdin-packs &&
-
-               PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
-               PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
-               PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
-
-               test_commit D && # loose
-
-               git pack-objects test2 --stdin-packs --unpacked <<-EOF &&
-               $PACK_A
-               ^$PACK_B
-               $PACK_C
-               EOF
-
-               (
-                       git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
-                       git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
-                       git rev-list --objects --no-object-names \
-                               refs/tags/C..refs/tags/D
-
-               ) >expect.raw &&
-               ls -la . &&
-               git show-index <$(ls test2-*.idx) >actual.raw &&
-
-               cut -d" " -f2 <expect.raw | sort >expect &&
-               cut -d" " -f2 <actual.raw | sort >actual &&
-               test_cmp expect actual
-       )
-'
-
-test_expect_success '--stdin-packs with broken links' '
-       (
-               cd stdin-packs &&
-
-               # make an unreachable object with a bogus parent
-               git cat-file -p HEAD >commit &&
-               sed "s/$(git rev-parse HEAD^)/$(test_oid zero)/" <commit |
-               git hash-object -w -t commit --stdin >in &&
-
-               git pack-objects .git/objects/pack/pack-D <in &&
-
-               PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
-               PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
-               PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
-               PACK_D="$(basename .git/objects/pack/pack-D-*.pack)" &&
-
-               git pack-objects test3 --stdin-packs --unpacked <<-EOF &&
-               $PACK_A
-               ^$PACK_B
-               $PACK_C
-               $PACK_D
-               EOF
-
-               (
-                       git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
-                       git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
-                       git show-index <$(ls .git/objects/pack/pack-D-*.idx) &&
-                       git rev-list --objects --no-object-names \
-                               refs/tags/C..refs/tags/D
-               ) >expect.raw &&
-               git show-index <$(ls test3-*.idx) >actual.raw &&
-
-               cut -d" " -f2 <expect.raw | sort >expect &&
-               cut -d" " -f2 <actual.raw | sort >actual &&
-               test_cmp expect actual
-       )
-'
-
 test_expect_success 'negative window clamps to 0' '
        git pack-objects --progress --window=-1 neg-window <obj-list 2>stderr &&
        check_deltas stderr = 0
index 5500dd084264d170d00629171502484cbb349a0c..662ae9b152047ace348836c9610b9c476f4171d2 100755 (executable)
@@ -62,11 +62,11 @@ test_expect_success 'prune --expire' '
 test_expect_success 'gc: implicit prune --expire' '
        add_blob &&
        test-tool chmtime =-$((2*$week-30)) $BLOB_FILE &&
-       git gc &&
+       git gc --no-cruft &&
        verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
        test_path_is_file $BLOB_FILE &&
        test-tool chmtime =-$((2*$week+1)) $BLOB_FILE &&
-       git gc &&
+       git gc --no-cruft &&
        verbose test $before = $(git count-objects | sed "s/ .*//") &&
        test_path_is_missing $BLOB_FILE
 '
@@ -86,7 +86,7 @@ test_expect_success 'gc: refuse to start with invalid gc.pruneExpire' '
 
 test_expect_success 'gc: start with ok gc.pruneExpire' '
        git config gc.pruneExpire 2.days.ago &&
-       git gc
+       git gc --no-cruft
 '
 
 test_expect_success 'prune: prune nonsense parameters' '
@@ -137,44 +137,44 @@ test_expect_success 'gc --no-prune' '
        add_blob &&
        test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
        git config gc.pruneExpire 2.days.ago &&
-       git gc --no-prune &&
+       git gc --no-prune --no-cruft &&
        verbose test 1 = $(git count-objects | sed "s/ .*//") &&
        test_path_is_file $BLOB_FILE
 '
 
 test_expect_success 'gc respects gc.pruneExpire' '
        git config gc.pruneExpire 5002.days.ago &&
-       git gc &&
+       git gc --no-cruft &&
        test_path_is_file $BLOB_FILE &&
        git config gc.pruneExpire 5000.days.ago &&
-       git gc &&
+       git gc --no-cruft &&
        test_path_is_missing $BLOB_FILE
 '
 
 test_expect_success 'gc --prune=<date>' '
        add_blob &&
        test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
-       git gc --prune=5002.days.ago &&
+       git gc --prune=5002.days.ago --no-cruft &&
        test_path_is_file $BLOB_FILE &&
-       git gc --prune=5000.days.ago &&
+       git gc --prune=5000.days.ago --no-cruft &&
        test_path_is_missing $BLOB_FILE
 '
 
 test_expect_success 'gc --prune=never' '
        add_blob &&
-       git gc --prune=never &&
+       git gc --prune=never --no-cruft &&
        test_path_is_file $BLOB_FILE &&
-       git gc --prune=now &&
+       git gc --prune=now --no-cruft &&
        test_path_is_missing $BLOB_FILE
 '
 
 test_expect_success 'gc respects gc.pruneExpire=never' '
        git config gc.pruneExpire never &&
        add_blob &&
-       git gc &&
+       git gc --no-cruft &&
        test_path_is_file $BLOB_FILE &&
        git config gc.pruneExpire now &&
-       git gc &&
+       git gc --no-cruft &&
        test_path_is_missing $BLOB_FILE
 '
 
@@ -194,7 +194,7 @@ test_expect_success 'gc: prune old objects after local clone' '
                cd aclone &&
                verbose test 1 = $(git count-objects | sed "s/ .*//") &&
                test_path_is_file $BLOB_FILE &&
-               git gc --prune &&
+               git gc --prune --no-cruft &&
                verbose test 0 = $(git count-objects | sed "s/ .*//") &&
                test_path_is_missing $BLOB_FILE
        )
@@ -237,7 +237,7 @@ test_expect_success 'clean pack garbage with gc' '
        >.git/objects/pack/fake2.keep &&
        >.git/objects/pack/fake2.idx &&
        >.git/objects/pack/fake3.keep &&
-       git gc &&
+       git gc --no-cruft &&
        git count-objects -v 2>stderr &&
        grep "^warning:" stderr | sort >actual &&
        cat >expected <<\EOF &&
index 499d5d4c78590ae16879d8dbd386259d847efb76..0883c7c6bd965d5506ca45a10c2c406a2700707a 100755 (executable)
@@ -183,6 +183,18 @@ test_expect_success 'write midx with --stdin-packs' '
 
 compare_results_with_midx "mixed mode (one pack + extra)"
 
+test_expect_success 'write with no objects and preferred pack' '
+       test_when_finished "rm -rf empty" &&
+       git init empty &&
+       test_must_fail git -C empty multi-pack-index write \
+               --stdin-packs --preferred-pack=does-not-exist </dev/null 2>err &&
+       cat >expect <<-EOF &&
+       warning: unknown preferred pack: ${SQ}does-not-exist${SQ}
+       error: no pack files to index.
+       EOF
+       test_cmp expect err
+'
+
 test_expect_success 'write progress off for redirected stderr' '
        git multi-pack-index --object-dir=$objdir write 2>err &&
        test_line_count = 0 err
index d042d26f2b393d52049ba3c9972e2516b03ed239..431a603ca0e61d7085f28333c6a28c120ea45828 100755 (executable)
@@ -1,17 +1,20 @@
 #!/bin/sh
 
 test_description='on-disk reverse index'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # The below tests want control over the 'pack.writeReverseIndex' setting
 # themselves to assert various combinations of it with other options.
-sane_unset GIT_TEST_WRITE_REV_INDEX
+sane_unset GIT_TEST_NO_WRITE_REV_INDEX
 
 packdir=.git/objects/pack
 
 test_expect_success 'setup' '
        test_commit base &&
 
+       test_config pack.writeReverseIndex false &&
        pack=$(git pack-objects --all $packdir/pack) &&
        rev=$packdir/pack-$pack.rev &&
 
@@ -94,6 +97,17 @@ test_expect_success 'reverse index is not generated when available on disk' '
                --batch-check="%(objectsize:disk)" <tip
 '
 
+test_expect_success 'reverse index is ignored when pack.readReverseIndex is false' '
+       test_index_pack true &&
+       test_path_is_file $rev &&
+
+       test_config pack.readReverseIndex false &&
+
+       git rev-parse HEAD >tip &&
+       GIT_TEST_REV_INDEX_DIE_ON_DISK=1 git cat-file \
+               --batch-check="%(objectsize:disk)" <tip
+'
+
 test_expect_success 'revindex in-memory vs on-disk' '
        git init repo &&
        test_when_finished "rm -fr repo" &&
@@ -117,4 +131,78 @@ test_expect_success 'revindex in-memory vs on-disk' '
                test_cmp on-disk in-core
        )
 '
+
+test_expect_success 'fsck succeeds on good rev-index' '
+       test_when_finished rm -fr repo &&
+       git init repo &&
+       (
+               cd repo &&
+
+               test_commit commit &&
+               git -c pack.writeReverseIndex=true repack -ad &&
+               git fsck 2>err &&
+               test_must_be_empty err
+       )
+'
+
+test_expect_success 'set up rev-index corruption tests' '
+       git init corrupt &&
+       (
+               cd corrupt &&
+
+               test_commit commit &&
+               git -c pack.writeReverseIndex=true repack -ad &&
+
+               revfile=$(ls .git/objects/pack/pack-*.rev) &&
+               chmod a+w $revfile &&
+               cp $revfile $revfile.bak
+       )
+'
+
+corrupt_rev_and_verify () {
+       (
+               pos="$1" &&
+               value="$2" &&
+               error="$3" &&
+
+               cd corrupt &&
+               revfile=$(ls .git/objects/pack/pack-*.rev) &&
+
+               # Reset to original rev-file.
+               cp $revfile.bak $revfile &&
+
+               printf "$value" | dd of=$revfile bs=1 seek="$pos" conv=notrunc &&
+               test_must_fail git fsck 2>err &&
+               grep "$error" err
+       )
+}
+
+test_expect_success 'fsck catches invalid checksum' '
+       revfile=$(ls corrupt/.git/objects/pack/pack-*.rev) &&
+       orig_size=$(wc -c <$revfile) &&
+       hashpos=$((orig_size - 10)) &&
+       corrupt_rev_and_verify $hashpos bogus \
+               "invalid checksum"
+'
+
+test_expect_success 'fsck catches invalid row position' '
+       corrupt_rev_and_verify 14 "\07" \
+               "invalid rev-index position"
+'
+
+test_expect_success 'fsck catches invalid header: magic number' '
+       corrupt_rev_and_verify 1 "\07" \
+               "reverse-index file .* has unknown signature"
+'
+
+test_expect_success 'fsck catches invalid header: version' '
+       corrupt_rev_and_verify 7 "\02" \
+               "reverse-index file .* has unsupported version"
+'
+
+test_expect_success 'fsck catches invalid header: hash function' '
+       corrupt_rev_and_verify 11 "\03" \
+               "reverse-index file .* has unsupported hash id"
+'
+
 test_done
diff --git a/t/t5331-pack-objects-stdin.sh b/t/t5331-pack-objects-stdin.sh
new file mode 100755 (executable)
index 0000000..acab316
--- /dev/null
@@ -0,0 +1,240 @@
+#!/bin/sh
+
+test_description='pack-objects --stdin'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+packed_objects () {
+       git show-index <"$1" >tmp-object-list &&
+       cut -d' ' -f2 tmp-object-list | sort &&
+       rm tmp-object-list
+ }
+
+test_expect_success 'setup for --stdin-packs tests' '
+       git init stdin-packs &&
+       (
+               cd stdin-packs &&
+
+               test_commit A &&
+               test_commit B &&
+               test_commit C &&
+
+               for id in A B C
+               do
+                       git pack-objects .git/objects/pack/pack-$id \
+                               --incremental --revs <<-EOF || exit 1
+                       refs/tags/$id
+                       EOF
+               done &&
+
+               ls -la .git/objects/pack
+       )
+'
+
+test_expect_success '--stdin-packs with excluded packs' '
+       (
+               cd stdin-packs &&
+
+               PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
+               PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
+               PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
+
+               git pack-objects test --stdin-packs <<-EOF &&
+               $PACK_A
+               ^$PACK_B
+               $PACK_C
+               EOF
+
+               (
+                       git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
+                       git show-index <$(ls .git/objects/pack/pack-C-*.idx)
+               ) >expect.raw &&
+               git show-index <$(ls test-*.idx) >actual.raw &&
+
+               cut -d" " -f2 <expect.raw | sort >expect &&
+               cut -d" " -f2 <actual.raw | sort >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success '--stdin-packs is incompatible with --filter' '
+       (
+               cd stdin-packs &&
+               test_must_fail git pack-objects --stdin-packs --stdout \
+                       --filter=blob:none </dev/null 2>err &&
+               test_i18ngrep "cannot use --filter with --stdin-packs" err
+       )
+'
+
+test_expect_success '--stdin-packs is incompatible with --revs' '
+       (
+               cd stdin-packs &&
+               test_must_fail git pack-objects --stdin-packs --revs out \
+                       </dev/null 2>err &&
+               test_i18ngrep "cannot use internal rev list with --stdin-packs" err
+       )
+'
+
+test_expect_success '--stdin-packs with loose objects' '
+       (
+               cd stdin-packs &&
+
+               PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
+               PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
+               PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
+
+               test_commit D && # loose
+
+               git pack-objects test2 --stdin-packs --unpacked <<-EOF &&
+               $PACK_A
+               ^$PACK_B
+               $PACK_C
+               EOF
+
+               (
+                       git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
+                       git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
+                       git rev-list --objects --no-object-names \
+                               refs/tags/C..refs/tags/D
+
+               ) >expect.raw &&
+               ls -la . &&
+               git show-index <$(ls test2-*.idx) >actual.raw &&
+
+               cut -d" " -f2 <expect.raw | sort >expect &&
+               cut -d" " -f2 <actual.raw | sort >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success '--stdin-packs with broken links' '
+       (
+               cd stdin-packs &&
+
+               # make an unreachable object with a bogus parent
+               git cat-file -p HEAD >commit &&
+               sed "s/$(git rev-parse HEAD^)/$(test_oid zero)/" <commit |
+               git hash-object -w -t commit --stdin >in &&
+
+               git pack-objects .git/objects/pack/pack-D <in &&
+
+               PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
+               PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
+               PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
+               PACK_D="$(basename .git/objects/pack/pack-D-*.pack)" &&
+
+               git pack-objects test3 --stdin-packs --unpacked <<-EOF &&
+               $PACK_A
+               ^$PACK_B
+               $PACK_C
+               $PACK_D
+               EOF
+
+               (
+                       git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
+                       git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
+                       git show-index <$(ls .git/objects/pack/pack-D-*.idx) &&
+                       git rev-list --objects --no-object-names \
+                               refs/tags/C..refs/tags/D
+               ) >expect.raw &&
+               git show-index <$(ls test3-*.idx) >actual.raw &&
+
+               cut -d" " -f2 <expect.raw | sort >expect &&
+               cut -d" " -f2 <actual.raw | sort >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'pack-objects --stdin with duplicate packfile' '
+       test_when_finished "rm -fr repo" &&
+
+       git init repo &&
+       (
+               cd repo &&
+               test_commit "commit" &&
+               git repack -ad &&
+
+               {
+                       basename .git/objects/pack/pack-*.pack &&
+                       basename .git/objects/pack/pack-*.pack
+               } >packfiles &&
+
+               git pack-objects --stdin-packs generated-pack <packfiles &&
+               packed_objects .git/objects/pack/pack-*.idx >expect &&
+               packed_objects generated-pack-*.idx >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'pack-objects --stdin with same packfile excluded and included' '
+       test_when_finished "rm -fr repo" &&
+
+       git init repo &&
+       (
+               cd repo &&
+               test_commit "commit" &&
+               git repack -ad &&
+
+               {
+                       basename .git/objects/pack/pack-*.pack &&
+                       printf "^%s\n" "$(basename .git/objects/pack/pack-*.pack)"
+               } >packfiles &&
+
+               git pack-objects --stdin-packs generated-pack <packfiles &&
+               packed_objects generated-pack-*.idx >packed-objects &&
+               test_must_be_empty packed-objects
+       )
+'
+
+test_expect_success 'pack-objects --stdin with packfiles from alternate object database' '
+       test_when_finished "rm -fr shared member" &&
+
+       # Set up a shared repository with a single packfile.
+       git init shared &&
+       test_commit -C shared "shared-objects" &&
+       git -C shared repack -ad &&
+       basename shared/.git/objects/pack/pack-*.pack >packfile &&
+
+       # Set up a repository that is connected to the shared repository. This
+       # repository has no objects on its own, but we still expect to be able
+       # to pack objects from its alternate.
+       git clone --shared shared member &&
+       git -C member pack-objects --stdin-packs generated-pack <packfile &&
+       test_cmp shared/.git/objects/pack/pack-*.pack member/generated-pack-*.pack
+'
+
+test_expect_success 'pack-objects --stdin with packfiles from main and alternate object database' '
+       test_when_finished "rm -fr shared member" &&
+
+       # Set up a shared repository with a single packfile.
+       git init shared &&
+       test_commit -C shared "shared-commit" &&
+       git -C shared repack -ad &&
+
+       # Set up a repository that is connected to the shared repository. This
+       # repository has a second packfile so that we can verify that it is
+       # possible to write packs that include packfiles from different object
+       # databases.
+       git clone --shared shared member &&
+       test_commit -C member "local-commit" &&
+       git -C member repack -dl &&
+
+       {
+               basename shared/.git/objects/pack/pack-*.pack &&
+               basename member/.git/objects/pack/pack-*.pack
+       } >packfiles &&
+
+       {
+               packed_objects shared/.git/objects/pack/pack-*.idx &&
+               packed_objects member/.git/objects/pack/pack-*.idx
+       } | sort >expected-objects &&
+
+       git -C member pack-objects --stdin-packs generated-pack <packfiles &&
+       packed_objects member/generated-pack-*.idx >actual-objects &&
+       test_cmp expected-objects actual-objects
+'
+
+test_done
index 20d063fb9ae72c4df77a00dd5d5cb6da65640238..151c76eb09b7831edd803e6cad27dddc4b5489ec 100755 (executable)
@@ -15,6 +15,19 @@ generate_references () {
        done
 }
 
+test_expect_success 'set up fake upload-pack' '
+       # This can be used to simulate an upload-pack that just shows the
+       # contents of the "input" file (prepared with the test-tool pkt-line
+       # helper), and does not do any negotiation (since ls-remote does not
+       # need it).
+       write_script cat-input <<-\EOF
+       # send our initial advertisement/response
+       cat input
+       # soak up the flush packet from the client
+       cat
+       EOF
+'
+
 test_expect_success 'dies when no remote found' '
        test_must_fail git ls-remote
 '
@@ -231,22 +244,25 @@ test_expect_success 'protocol v2 supports hiderefs' '
 
 test_expect_success 'ls-remote --symref' '
        git fetch origin &&
-       echo "ref: refs/heads/main      HEAD" >expect &&
+       echo "ref: refs/heads/main      HEAD" >expect.v2 &&
        generate_references \
                HEAD \
-               refs/heads/main >>expect &&
+               refs/heads/main >>expect.v2 &&
+       echo "ref: refs/remotes/origin/main     refs/remotes/origin/HEAD" >>expect.v2 &&
        oid=$(git rev-parse HEAD) &&
-       echo "$oid      refs/remotes/origin/HEAD" >>expect &&
+       echo "$oid      refs/remotes/origin/HEAD" >>expect.v2 &&
        generate_references \
                refs/remotes/origin/main \
                refs/tags/mark \
                refs/tags/mark1.1 \
                refs/tags/mark1.10 \
-               refs/tags/mark1.2 >>expect &&
-       # Protocol v2 supports sending symrefs for refs other than HEAD, so use
-       # protocol v0 here.
-       GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
-       test_cmp expect actual
+               refs/tags/mark1.2 >>expect.v2 &&
+       # v0 does not show non-HEAD symrefs
+       grep -v "ref: refs/remotes" <expect.v2 >expect.v0 &&
+       git -c protocol.version=0 ls-remote --symref >actual.v0 &&
+       test_cmp expect.v0 actual.v0 &&
+       git -c protocol.version=2 ls-remote --symref >actual.v2 &&
+       test_cmp expect.v2 actual.v2
 '
 
 test_expect_success 'ls-remote with filtered symref (refname)' '
@@ -255,76 +271,41 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
        ref: refs/heads/main    HEAD
        $rev    HEAD
        EOF
-       # Protocol v2 supports sending symrefs for refs other than HEAD, so use
-       # protocol v0 here.
-       GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . HEAD >actual &&
+       git ls-remote --symref . HEAD >actual &&
        test_cmp expect actual
 '
 
-test_expect_failure 'ls-remote with filtered symref (--heads)' '
+test_expect_success 'ls-remote with filtered symref (--heads)' '
        git symbolic-ref refs/heads/foo refs/tags/mark &&
-       cat >expect <<-EOF &&
+       cat >expect.v2 <<-EOF &&
        ref: refs/tags/mark     refs/heads/foo
        $rev    refs/heads/foo
        $rev    refs/heads/main
        EOF
-       # Protocol v2 supports sending symrefs for refs other than HEAD, so use
-       # protocol v0 here.
-       GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
-       test_cmp expect actual
+       grep -v "^ref: refs/tags/" <expect.v2 >expect.v0 &&
+       git -c protocol.version=0 ls-remote --symref --heads . >actual.v0 &&
+       test_cmp expect.v0 actual.v0 &&
+       git -c protocol.version=2 ls-remote --symref --heads . >actual.v2 &&
+       test_cmp expect.v2 actual.v2
 '
 
-test_expect_success 'ls-remote --symref omits filtered-out matches' '
-       cat >expect <<-EOF &&
-       $rev    refs/heads/foo
-       $rev    refs/heads/main
+test_expect_success 'indicate no refs in v0 standards-compliant empty remote' '
+       # Git does not produce an output like this, but it does match the
+       # standard and is produced by other implementations like JGit. So
+       # hard-code the case we care about.
+       #
+       # The actual capabilities do not matter; there are none that would
+       # change how ls-remote behaves.
+       oid=0000000000000000000000000000000000000000 &&
+       test-tool pkt-line pack >input.q <<-EOF &&
+       $oid capabilities^{}Qcaps-go-here
+       0000
        EOF
-       # Protocol v2 supports sending symrefs for refs other than HEAD, so use
-       # protocol v0 here.
-       GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
-       test_cmp expect actual &&
-       GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . "refs/heads/*" >actual &&
-       test_cmp expect actual
-'
-
-test_lazy_prereq GIT_DAEMON '
-       test_bool_env GIT_TEST_GIT_DAEMON true
-'
+       q_to_nul <input.q >input &&
 
-# This test spawns a daemon, so run it only if the user would be OK with
-# testing with git-daemon.
-test_expect_success PIPE,JGIT,GIT_DAEMON 'indicate no refs in standards-compliant empty remote' '
-       test_set_port JGIT_DAEMON_PORT &&
-       JGIT_DAEMON_PID= &&
-       git init --bare empty.git &&
-       >empty.git/git-daemon-export-ok &&
-       mkfifo jgit_daemon_output &&
-       {
-               jgit daemon --port="$JGIT_DAEMON_PORT" . >jgit_daemon_output &
-               JGIT_DAEMON_PID=$!
-       } &&
-       test_when_finished kill "$JGIT_DAEMON_PID" &&
-       {
-               read line &&
-               case $line in
-               Exporting*)
-                       ;;
-               *)
-                       echo "Expected: Exporting" &&
-                       false;;
-               esac &&
-               read line &&
-               case $line in
-               "Listening on"*)
-                       ;;
-               *)
-                       echo "Expected: Listening on" &&
-                       false;;
-               esac
-       } <jgit_daemon_output &&
        # --exit-code asks the command to exit with 2 when no
        # matching refs are found.
-       test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git
+       test_expect_code 2 git ls-remote --exit-code --upload-pack=./cat-input .
 '
 
 test_expect_success 'ls-remote works outside repository' '
@@ -345,8 +326,8 @@ test_expect_success 'ls-remote --sort fails gracefully outside repository' '
 test_expect_success 'ls-remote patterns work with all protocol versions' '
        git for-each-ref --format="%(objectname)        %(refname)" \
                refs/heads/main refs/remotes/origin/main >expect &&
-       git -c protocol.version=1 ls-remote . main >actual.v1 &&
-       test_cmp expect actual.v1 &&
+       git -c protocol.version=0 ls-remote . main >actual.v0 &&
+       test_cmp expect actual.v0 &&
        git -c protocol.version=2 ls-remote . main >actual.v2 &&
        test_cmp expect actual.v2
 '
@@ -354,10 +335,49 @@ test_expect_success 'ls-remote patterns work with all protocol versions' '
 test_expect_success 'ls-remote prefixes work with all protocol versions' '
        git for-each-ref --format="%(objectname)        %(refname)" \
                refs/heads/ refs/tags/ >expect &&
-       git -c protocol.version=1 ls-remote --heads --tags . >actual.v1 &&
-       test_cmp expect actual.v1 &&
+       git -c protocol.version=0 ls-remote --heads --tags . >actual.v0 &&
+       test_cmp expect actual.v0 &&
        git -c protocol.version=2 ls-remote --heads --tags . >actual.v2 &&
        test_cmp expect actual.v2
 '
 
+test_expect_success 'v0 clients can handle multiple symrefs' '
+       # Modern versions of Git will not return multiple symref capabilities
+       # for v0, so we have to hard-code the response. Note that we will
+       # always use both v0 and object-format=sha1 here, as the hard-coded
+       # response reflects a server that only supports those.
+       oid=1234567890123456789012345678901234567890 &&
+       symrefs="symref=refs/remotes/origin/HEAD:refs/remotes/origin/main" &&
+       symrefs="$symrefs symref=HEAD:refs/heads/main" &&
+
+       # Likewise we want to make sure our parser is not fooled by the string
+       # "symref" appearing as part of an earlier cap. But there is no way to
+       # do that via upload-pack, as arbitrary strings can appear only in a
+       # "symref" value itself (where we skip past the values as a whole)
+       # and "agent" (which always appears after "symref", so putting our
+       # parser in a confused state is less interesting).
+       caps="some other caps including a-fake-symref-cap" &&
+
+       test-tool pkt-line pack >input.q <<-EOF &&
+       $oid HEADQ$caps $symrefs
+       $oid refs/heads/main
+       $oid refs/remotes/origin/HEAD
+       $oid refs/remotes/origin/main
+       0000
+       EOF
+       q_to_nul <input.q >input &&
+
+       cat >expect <<-EOF &&
+       ref: refs/heads/main    HEAD
+       $oid    HEAD
+       $oid    refs/heads/main
+       ref: refs/remotes/origin/main   refs/remotes/origin/HEAD
+       $oid    refs/remotes/origin/HEAD
+       $oid    refs/remotes/origin/main
+       EOF
+
+       git ls-remote --symref --upload-pack=./cat-input . >actual &&
+       test_cmp expect actual
+'
+
 test_done
index d9acb639512ae6bdf30c8bdd4a0b4d498541dd84..69509d0c11db655a12fc6ed20215ed25976c46eb 100755 (executable)
@@ -210,90 +210,95 @@ prepare_cruft_history () {
        git reset HEAD^^
 }
 
-assert_cruft_packs () {
-       find .git/objects/pack -name "*.mtimes" >mtimes &&
-       sed -e 's/\.mtimes$/\.pack/g' mtimes >packs &&
-
-       test_file_not_empty packs &&
-       while read pack
-       do
-               test_path_is_file "$pack" || return 1
-       done <packs
-}
-
 assert_no_cruft_packs () {
        find .git/objects/pack -name "*.mtimes" >mtimes &&
        test_must_be_empty mtimes
 }
 
-test_expect_success 'gc --cruft generates a cruft pack' '
-       test_when_finished "rm -fr crufts" &&
-       git init crufts &&
+for argv in \
+       "gc" \
+       "-c gc.cruftPacks=true gc" \
+       "-c gc.cruftPacks=false gc --cruft"
+do
+       test_expect_success "git $argv generates a cruft pack" '
+               test_when_finished "rm -fr repo" &&
+               git init repo &&
+               (
+                       cd repo &&
+
+                       prepare_cruft_history &&
+                       git $argv &&
+
+                       find .git/objects/pack -name "*.mtimes" >mtimes &&
+                       sed -e 's/\.mtimes$/\.pack/g' mtimes >packs &&
+
+                       test_file_not_empty packs &&
+                       while read pack
+                       do
+                               test_path_is_file "$pack" || return 1
+                       done <packs
+               )
+       '
+done
+
+for argv in \
+       "gc --no-cruft" \
+       "-c gc.cruftPacks=false gc" \
+       "-c gc.cruftPacks=true gc --no-cruft"
+do
+       test_expect_success "git $argv does not generate a cruft pack" '
+               test_when_finished "rm -fr repo" &&
+               git init repo &&
+               (
+                       cd repo &&
+
+                       prepare_cruft_history &&
+                       git $argv &&
+
+                       assert_no_cruft_packs
+               )
+       '
+done
+
+test_expect_success '--keep-largest-pack ignores cruft packs' '
+       test_when_finished "rm -fr repo" &&
+       git init repo &&
        (
-               cd crufts &&
+               cd repo &&
 
+               # Generate a pack for reachable objects (of which there
+               # are 3), and one for unreachable objects (of which
+               # there are 6).
                prepare_cruft_history &&
                git gc --cruft &&
-               assert_cruft_packs
-       )
-'
-
-test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
-       test_when_finished "rm -fr crufts" &&
-       git init crufts &&
-       (
-               cd crufts &&
-
-               prepare_cruft_history &&
-               git -c gc.cruftPacks=true gc &&
-               assert_cruft_packs
-       )
-'
-
-test_expect_success 'feature.experimental=true generates a cruft pack' '
-       git init crufts &&
-       test_when_finished "rm -fr crufts" &&
-       (
-               cd crufts &&
 
-               prepare_cruft_history &&
-               git -c feature.experimental=true gc &&
-               assert_cruft_packs
-       )
-'
+               mtimes="$(find .git/objects/pack -type f -name "pack-*.mtimes")" &&
+               sz="$(test_file_size "${mtimes%.mtimes}.pack")" &&
 
-test_expect_success 'feature.experimental=false allows explicit cruft packs' '
-       git init crufts &&
-       test_when_finished "rm -fr crufts" &&
-       (
-               cd crufts &&
+               # Ensure that the cruft pack gets removed (due to
+               # `--prune=now`) despite it being the largest pack.
+               git -c gc.bigPackThreshold=$sz gc --cruft --prune=now &&
 
-               prepare_cruft_history &&
-               git -c gc.cruftPacks=true -c feature.experimental=false gc &&
-               assert_cruft_packs
+               assert_no_cruft_packs
        )
 '
 
-test_expect_success 'feature.experimental=true can be overridden' '
-       git init crufts &&
-       test_when_finished "rm -fr crufts" &&
+test_expect_success 'gc.bigPackThreshold ignores cruft packs' '
+       test_when_finished "rm -fr repo" &&
+       git init repo &&
        (
-               cd crufts &&
+               cd repo &&
 
+               # Generate a pack for reachable objects (of which there
+               # are 3), and one for unreachable objects (of which
+               # there are 6).
                prepare_cruft_history &&
-               git -c feature.expiremental=true -c gc.cruftPacks=false gc &&
-               assert_no_cruft_packs
-       )
-'
+               git gc --cruft &&
 
-test_expect_success 'feature.experimental=false avoids cruft packs by default' '
-       git init crufts &&
-       test_when_finished "rm -fr crufts" &&
-       (
-               cd crufts &&
+               # Ensure that the cruft pack gets removed (due to
+               # `--prune=now`) despite it being the largest pack.
+               git gc --cruft --prune=now --keep-largest-pack &&
 
-               prepare_cruft_history &&
-               git -c feature.experimental=false gc &&
                assert_no_cruft_packs
        )
 '
index 3968b47ed53b7e55eab26fdf8e34aa1472a1bf78..dbfa8a4d4c22b717450fb8d073c6835616d6d556 100755 (executable)
@@ -101,7 +101,7 @@ do
        '
 
        test_expect_success "simultaneous gc ($title)" '
-               git gc --prune=12.hours.ago
+               git gc --no-cruft --prune=12.hours.ago
        '
 
        test_expect_success "finish writing out commit ($title)" '
@@ -131,7 +131,7 @@ do
        '
 
        test_expect_success "simultaneous gc ($title)" '
-               git gc --prune=12.hours.ago
+               git gc --no-cruft --prune=12.hours.ago
        '
 
        # tree should have been refreshed by write-tree
@@ -151,7 +151,7 @@ test_expect_success 'do not complain about existing broken links (commit)' '
        some message
        EOF
        commit=$(git hash-object -t commit -w broken-commit) &&
-       git gc -q 2>stderr &&
+       git gc --no-cruft -q 2>stderr &&
        verbose git cat-file -e $commit &&
        test_must_be_empty stderr
 '
@@ -161,7 +161,7 @@ test_expect_success 'do not complain about existing broken links (tree)' '
        100644 blob $(test_oid 003)     foo
        EOF
        tree=$(git mktree --missing <broken-tree) &&
-       git gc -q 2>stderr &&
+       git gc --no-cruft -q 2>stderr &&
        git cat-file -e $tree &&
        test_must_be_empty stderr
 '
@@ -176,7 +176,7 @@ test_expect_success 'do not complain about existing broken links (tag)' '
        this is a broken tag
        EOF
        tag=$(git hash-object -t tag -w broken-tag) &&
-       git gc -q 2>stderr &&
+       git gc --no-cruft -q 2>stderr &&
        git cat-file -e $tag &&
        test_must_be_empty stderr
 '
index 48f86cb3678140ba1b0f914da8ebb442abd754b8..ccbc416402894aeda02a70b9c248f5ed8ed4d825 100755 (executable)
@@ -221,84 +221,91 @@ test_expect_success GPG 'amending already signed commit' '
 test_expect_success GPG 'show good signature with custom format' '
        cat >expect <<-\EOF &&
        G
+       ultimate
        13B6F51ECDDE430D
        C O Mitter <committer@example.com>
        73D758744BE721698EC54E8713B6F51ECDDE430D
        73D758744BE721698EC54E8713B6F51ECDDE430D
        EOF
-       git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual &&
+       git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual &&
        test_cmp expect actual
 '
 
 test_expect_success GPG 'show bad signature with custom format' '
        cat >expect <<-\EOF &&
        B
+       undefined
        13B6F51ECDDE430D
        C O Mitter <committer@example.com>
 
 
        EOF
-       git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" $(cat forged1.commit) >actual &&
+       git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" $(cat forged1.commit) >actual &&
        test_cmp expect actual
 '
 
 test_expect_success GPG 'show untrusted signature with custom format' '
        cat >expect <<-\EOF &&
        U
+       undefined
        65A0EEA02E30CAD7
        Eris Discordia <discord@example.net>
        F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7
        D4BE22311AD3131E5EDA29A461092E85B7227189
        EOF
-       git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
+       git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
        test_cmp expect actual
 '
 
 test_expect_success GPG 'show untrusted signature with undefined trust level' '
        cat >expect <<-\EOF &&
+       U
        undefined
        65A0EEA02E30CAD7
        Eris Discordia <discord@example.net>
        F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7
        D4BE22311AD3131E5EDA29A461092E85B7227189
        EOF
-       git log -1 --format="%GT%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
+       git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
        test_cmp expect actual
 '
 
 test_expect_success GPG 'show untrusted signature with ultimate trust level' '
        cat >expect <<-\EOF &&
+       G
        ultimate
        13B6F51ECDDE430D
        C O Mitter <committer@example.com>
        73D758744BE721698EC54E8713B6F51ECDDE430D
        73D758744BE721698EC54E8713B6F51ECDDE430D
        EOF
-       git log -1 --format="%GT%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual &&
+       git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual &&
        test_cmp expect actual
 '
 
 test_expect_success GPG 'show unknown signature with custom format' '
        cat >expect <<-\EOF &&
        E
+       undefined
        65A0EEA02E30CAD7
 
 
 
        EOF
-       GNUPGHOME="$GNUPGHOME_NOT_USED" git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
+       GNUPGHOME="$GNUPGHOME_NOT_USED" git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
        test_cmp expect actual
 '
 
 test_expect_success GPG 'show lack of signature with custom format' '
        cat >expect <<-\EOF &&
        N
+       undefined
 
 
 
 
        EOF
-       git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" seventh-unsigned >actual &&
+       git log -1 --format="%G?%n%GT%n%GK%n%GS%n%GF%n%GP" seventh-unsigned >actual &&
        test_cmp expect actual
 '
 
index 4aabe98139a37eb8bc1d2f3e824048dbdd7f9915..faa739eeb91f020976a92656e0a06bf3f06a64cc 100755 (executable)
@@ -106,6 +106,23 @@ test_expect_success SYMLINKS '--local keeps packs when alternate is objectdir '
        test_cmp expect actual
 '
 
+test_expect_success '--local disables writing bitmaps when connected to alternate ODB' '
+       test_when_finished "rm -rf shared member" &&
+
+       git init shared &&
+       git clone --shared shared member &&
+       (
+               cd member &&
+               test_commit "object" &&
+               GIT_TEST_MULTI_PACK_INDEX=0 git repack -Adl --write-bitmap-index 2>err &&
+               cat >expect <<-EOF &&
+               warning: disabling bitmap writing, as some objects are not being packed
+               EOF
+               test_cmp expect err &&
+               test_path_is_missing .git/objects/pack-*.bitmap
+       )
+'
+
 test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' '
        mkdir alt_objects/pack &&
        mv .git/objects/pack/* alt_objects/pack &&
index 8821fbd2dd55844e54f55553b442ec419755546c..00f28fb558ced5cbb4c7667f9b6ce597ee7fb782 100755 (executable)
@@ -10,6 +10,12 @@ objdir=.git/objects
 packdir=$objdir/pack
 midx=$objdir/pack/multi-pack-index
 
+packed_objects () {
+       git show-index <"$1" >tmp-object-list &&
+       cut -d' ' -f2 tmp-object-list | sort &&
+       rm tmp-object-list
+ }
+
 test_expect_success '--geometric with no packs' '
        git init geometric &&
        test_when_finished "rm -fr geometric" &&
@@ -281,4 +287,162 @@ test_expect_success '--geometric with pack.packSizeLimit' '
        )
 '
 
+test_expect_success '--geometric --write-midx with packfiles in main and alternate ODB' '
+       test_when_finished "rm -fr shared member" &&
+
+       # Create a shared repository that will serve as the alternate object
+       # database for the member linked to it. It has got some objects on its
+       # own that are packed into a single packfile.
+       git init shared &&
+       test_commit -C shared common-object &&
+       git -C shared repack -ad &&
+
+       # We create member so that its alternates file points to the shared
+       # repository. We then create a commit in it so that git-repack(1) has
+       # something to repack.
+       # of the shared object database.
+       git clone --shared shared member &&
+       test_commit -C member unique-object &&
+       git -C member repack --geometric=2 --write-midx 2>err &&
+       test_must_be_empty err &&
+
+       # We should see that a new packfile was generated.
+       find shared/.git/objects/pack -type f -name "*.pack" >packs &&
+       test_line_count = 1 packs &&
+
+       # We should also see a multi-pack-index. This multi-pack-index should
+       # never refer to any packfiles in the alternate object database.
+       test_path_is_file member/.git/objects/pack/multi-pack-index &&
+       test-tool read-midx member/.git/objects >packs.midx &&
+       grep "^pack-.*\.idx$" packs.midx | sort >actual &&
+       basename member/.git/objects/pack/pack-*.idx >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '--geometric --with-midx with no local objects' '
+       test_when_finished "rm -fr shared member" &&
+
+       # Create a repository with a single packfile that acts as alternate
+       # object database.
+       git init shared &&
+       test_commit -C shared "shared-objects" &&
+       git -C shared repack -ad &&
+
+       # Create a second repository linked to the first one and perform a
+       # geometric repack on it.
+       git clone --shared shared member &&
+       git -C member repack --geometric 2 --write-midx 2>err &&
+       test_must_be_empty err &&
+
+       # Assert that we wrote neither a new packfile nor a multi-pack-index.
+       # We should not have a packfile because the single packfile in the
+       # alternate object database does not invalidate the geometric sequence.
+       # And we should not have a multi-pack-index because these only index
+       # local packfiles, and there are none.
+       test_dir_is_empty member/$packdir
+'
+
+test_expect_success '--geometric with same pack in main and alternate ODB' '
+       test_when_finished "rm -fr shared member" &&
+
+       # Create a repository with a single packfile that acts as alternate
+       # object database.
+       git init shared &&
+       test_commit -C shared "shared-objects" &&
+       git -C shared repack -ad &&
+
+       # We create the member repository as an exact copy so that it has the
+       # same packfile.
+       cp -r shared member &&
+       test-tool path-utils real_path shared/.git/objects >member/.git/objects/info/alternates &&
+       find shared/.git/objects -type f >expected-files &&
+
+       # Verify that we can repack objects as expected without observing any
+       # error. Having the same packfile in both ODBs used to cause an error
+       # in git-pack-objects(1).
+       git -C member repack --geometric 2 2>err &&
+       test_must_be_empty err &&
+       # Nothing should have changed.
+       find shared/.git/objects -type f >actual-files &&
+       test_cmp expected-files actual-files
+'
+
+test_expect_success '--geometric -l with non-intact geometric sequence across ODBs' '
+       test_when_finished "rm -fr shared member" &&
+
+       git init shared &&
+       test_commit_bulk -C shared --start=1 1 &&
+
+       git clone --shared shared member &&
+       test_commit_bulk -C member --start=2 1 &&
+
+       # Verify that our assumptions actually hold: both generated packfiles
+       # should have three objects and should be non-equal.
+       packed_objects shared/.git/objects/pack/pack-*.idx >shared-objects &&
+       packed_objects member/.git/objects/pack/pack-*.idx >member-objects &&
+       test_line_count = 3 shared-objects &&
+       test_line_count = 3 member-objects &&
+       ! test_cmp shared-objects member-objects &&
+
+       # Perform the geometric repack. With `-l`, we should only see the local
+       # packfile and thus arrive at the conclusion that the geometric
+       # sequence is intact. We thus expect no changes.
+       #
+       # Note that we are tweaking mtimes of the packfiles so that we can
+       # verify they did not change. This is done in order to detect the case
+       # where we do repack objects, but the resulting packfile is the same.
+       test-tool chmtime --verbose =0 member/.git/objects/pack/* >expected-member-packs &&
+       git -C member repack --geometric=2 -l -d &&
+       test-tool chmtime --verbose member/.git/objects/pack/* >actual-member-packs &&
+       test_cmp expected-member-packs actual-member-packs &&
+
+       {
+               packed_objects shared/.git/objects/pack/pack-*.idx &&
+               packed_objects member/.git/objects/pack/pack-*.idx
+       } | sort >expected-objects &&
+
+       # On the other hand, when doing a non-local geometric repack we should
+       # see both packfiles and thus repack them. We expect that the shared
+       # object database was not changed.
+       test-tool chmtime --verbose =0 shared/.git/objects/pack/* >expected-shared-packs &&
+       git -C member repack --geometric=2 -d &&
+       test-tool chmtime --verbose shared/.git/objects/pack/* >actual-shared-packs &&
+       test_cmp expected-shared-packs actual-shared-packs &&
+
+       # Furthermore, we expect that the member repository now has a single
+       # packfile that contains the combined shared and non-shared objects.
+       ls member/.git/objects/pack/pack-*.idx >actual &&
+       test_line_count = 1 actual &&
+       packed_objects member/.git/objects/pack/pack-*.idx >actual-objects &&
+       test_line_count = 6 actual-objects &&
+       test_cmp expected-objects actual-objects
+'
+
+test_expect_success '--geometric -l disables writing bitmaps with non-local packfiles' '
+       test_when_finished "rm -fr shared member" &&
+
+       git init shared &&
+       test_commit_bulk -C shared --start=1 1 &&
+
+       git clone --shared shared member &&
+       test_commit_bulk -C member --start=2 1 &&
+
+       # When performing a geometric repack with `-l` while connected to an
+       # alternate object database that has a packfile we do not have full
+       # coverage of objects. As a result, we expect that writing the bitmap
+       # will be disabled.
+       git -C member repack -l --geometric=2 --write-midx --write-bitmap-index 2>err &&
+       cat >expect <<-EOF &&
+       warning: disabling bitmap writing, as some objects are not being packed
+       EOF
+       test_cmp expect err &&
+       test_path_is_missing member/.git/objects/pack/multi-pack-index-*.bitmap &&
+
+       # On the other hand, when we repack without `-l`, we should see that
+       # the bitmap gets created.
+       git -C member repack --geometric=2 --write-midx --write-bitmap-index 2>err &&
+       test_must_be_empty err &&
+       test_path_is_file member/.git/objects/pack/multi-pack-index-*.bitmap
+'
+
 test_done
index 0de83b5d2b07011210eaa3f2f516705a57065f62..65203462466ed024d8200a76a91cef6d388a0d7a 100755 (executable)
@@ -2326,6 +2326,37 @@ test_expect_success $PREREQ 'invoke hook' '
        )
 '
 
+expected_file_counter_output () {
+       total=$1
+       count=0
+       while test $count -ne $total
+       do
+               count=$((count + 1)) &&
+               echo "$count/$total" || return
+       done
+}
+
+test_expect_success $PREREQ '--validate hook allows counting of messages' '
+       test_when_finished "rm -rf my-hooks.log" &&
+       test_config core.hooksPath "my-hooks" &&
+       mkdir -p my-hooks &&
+
+       write_script my-hooks/sendemail-validate <<-\EOF &&
+               num=$GIT_SENDEMAIL_FILE_COUNTER &&
+               tot=$GIT_SENDEMAIL_FILE_TOTAL &&
+               echo "$num/$tot" >>my-hooks.log || exit 1
+       EOF
+
+       >my-hooks.log &&
+       expected_file_counter_output 4 >expect &&
+       git send-email \
+               --from="Example <from@example.com>" \
+               --to=nobody@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               --validate -3 --cover-letter --force &&
+       test_cmp expect my-hooks.log
+'
+
 test_expect_success $PREREQ 'test that send-email works outside a repo' '
        nongit git send-email \
                --from="Example <nobody@example.com>" \
index aa55b41b9a97eaaadf9910ddfd62e0e349d405c8..ac237a1f906b2a05226c4cc7002763813dc543b7 100755 (executable)
@@ -388,9 +388,7 @@ test_expect_success 'B: accept branch name "TEMP_TAG"' '
 
        INPUT_END
 
-       test_when_finished "rm -f .git/TEMP_TAG
-               git gc
-               git prune" &&
+       test_when_finished "rm -f .git/TEMP_TAG && git gc --prune=now" &&
        git fast-import <input &&
        test $(test-tool ref-store main resolve-ref TEMP_TAG 0 | cut -f1 -d " " ) != "$ZERO_OID" &&
        test $(git rev-parse main) = $(git rev-parse TEMP_TAG^)
@@ -406,8 +404,7 @@ test_expect_success 'B: accept empty committer' '
        INPUT_END
 
        test_when_finished "git update-ref -d refs/heads/empty-committer-1
-               git gc
-               git prune" &&
+               git gc --prune=now" &&
        git fast-import <input &&
        out=$(git fsck) &&
        echo "$out" &&
@@ -452,8 +449,7 @@ test_expect_success 'B: accept and fixup committer with no name' '
        INPUT_END
 
        test_when_finished "git update-ref -d refs/heads/empty-committer-2
-               git gc
-               git prune" &&
+               git gc --prune=now" &&
        git fast-import <input &&
        out=$(git fsck) &&
        echo "$out" &&
@@ -1778,8 +1774,7 @@ test_expect_success 'P: verbatim SHA gitlinks' '
        INPUT_END
 
        git branch -D sub &&
-       git gc &&
-       git prune &&
+       git gc --prune=now &&
        git fast-import <input &&
        test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
 '
diff --git a/tag.c b/tag.c
index 01ed67d6fa6ac214393f887df1c4e9826e5dbe08..96dbd5b2d5501e31b7a7bb75d7630347bfdc24c0 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "tag.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "tree.h"
diff --git a/templates/hooks--sendemail-validate.sample b/templates/hooks--sendemail-validate.sample
new file mode 100755 (executable)
index 0000000..640bcf8
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+# An example hook script to validate a patch (and/or patch series) before
+# sending it via email.
+#
+# The hook should exit with non-zero status after issuing an appropriate
+# message if it wants to prevent the email(s) from being sent.
+#
+# To enable this hook, rename this file to "sendemail-validate".
+#
+# By default, it will only check that the patch(es) can be applied on top of
+# the default upstream branch without conflicts in a secondary worktree. After
+# validation (successful or not) of the last patch of a series, the worktree
+# will be deleted.
+#
+# The following config variables can be set to change the default remote and
+# remote ref that are used to apply the patches against:
+#
+#   sendemail.validateRemote (default: origin)
+#   sendemail.validateRemoteRef (default: HEAD)
+#
+# Replace the TODO placeholders with appropriate checks according to your
+# needs.
+
+validate_cover_letter () {
+       file="$1"
+       # TODO: Replace with appropriate checks (e.g. spell checking).
+       true
+}
+
+validate_patch () {
+       file="$1"
+       # Ensure that the patch applies without conflicts.
+       git am -3 "$file" || return
+       # TODO: Replace with appropriate checks for this patch
+       # (e.g. checkpatch.pl).
+       true
+}
+
+validate_series () {
+       # TODO: Replace with appropriate checks for the whole series
+       # (e.g. quick build, coding style checks, etc.).
+       true
+}
+
+# main -------------------------------------------------------------------------
+
+if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
+then
+       remote=$(git config --default origin --get sendemail.validateRemote) &&
+       ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
+       worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
+       git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
+       git config --replace-all sendemail.validateWorktree "$worktree"
+else
+       worktree=$(git config --get sendemail.validateWorktree)
+fi || {
+       echo "sendemail-validate: error: failed to prepare worktree" >&2
+       exit 1
+}
+
+unset GIT_DIR GIT_WORK_TREE
+cd "$worktree" &&
+
+if grep -q "^diff --git " "$1"
+then
+       validate_patch "$1"
+else
+       validate_cover_letter "$1"
+fi &&
+
+if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
+then
+       git config --unset-all sendemail.validateWorktree &&
+       trap 'git worktree remove -ff "$worktree"' EXIT &&
+       validate_series
+fi
index 5adad1925d1a051c38c08f911dd6d5824e5de305..c33a554f921eca089d7535609fe7023614ad1985 100644 (file)
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tmp-objdir.h"
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "dir.h"
 #include "environment.h"
+#include "object-file.h"
 #include "sigchain.h"
 #include "string-list.h"
 #include "strbuf.h"
diff --git a/trace.c b/trace.c
index 81318a2455df4c9c3c0725bdd31314788cee4a17..592c141d785a913d45a6910f048b087204ddecdc 100644 (file)
--- a/trace.c
+++ b/trace.c
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "quote.h"
 #include "setup.h"
+#include "trace.h"
 #include "wrapper.h"
 
 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
index e8ba62c0c3dc8293bd973f7d5c39d024f5eb85f7..21264df71b79bd3672011ed79c0ad61d93671e7e 100644 (file)
--- a/trace2.c
+++ b/trace2.c
@@ -7,6 +7,7 @@
 #include "thread-utils.h"
 #include "version.h"
 #include "trace.h"
+#include "trace2.h"
 #include "trace2/tr2_cfg.h"
 #include "trace2/tr2_cmd_name.h"
 #include "trace2/tr2_ctr.h"
index 76d146ee88b8ff1e96441873ffe8ea79bf6f2d25..6b816940dc64d8803c89c866bc2d0acdae849ad6 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "transport.h"
 #include "quote.h"
 #include "run-command.h"
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "remote.h"
 #include "string-list.h"
index 89a220425ecf0e5a2684f76038827f7e8f0241d1..67afdae57c1c1d0da0d88b1e9823ed6b4fefe4ca 100644 (file)
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
 #include "string-list.h"
 #include "oid-array.h"
 #include "sigchain.h"
+#include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "bundle-uri.h"
@@ -317,7 +320,7 @@ static struct ref *handshake(struct transport *transport, int for_push,
        struct git_transport_data *data = transport->data;
        struct ref *refs = NULL;
        struct packet_reader reader;
-       int sid_len;
+       size_t sid_len;
        const char *server_sid;
 
        connect_setup(transport, for_push);
index 38b6556478d037b67422e44e49453a7de60d7c9f..2993c48c2f31072d7d1109df85d58dbcbf321caa 100644 (file)
@@ -4,7 +4,9 @@
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
+#include "trace2.h"
 #include "tree.h"
 #include "pathspec.h"
 #include "json-writer.h"
diff --git a/tree.c b/tree.c
index 2b78708766bc275651d0289fe4646c3bbf19b79c..e9d51ce2e00c00bf2ae7e2bee8daf69cb809620a 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -2,6 +2,7 @@
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "commit.h"
index 3ded68ecb6df517e6eb03ba1e00641a4894d4420..c0732aa0c2d5052e26c5893ea3aa8ef9595c5ae7 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "strvec.h"
 #include "repository.h"
 #include "config.h"
@@ -17,6 +18,7 @@
 #include "sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "fsmonitor.h"
 #include "object-store.h"
 #include "promisor-remote.h"
index 61c06eb7c506e7753fd291a8a32539d2fc21496b..30622aeebff91f64cd9799412e531bdbb2110bc2 100644 (file)
@@ -2,6 +2,7 @@
 #define UNPACK_TREES_H
 
 #include "cache.h"
+#include "convert.h"
 #include "strvec.h"
 #include "string-list.h"
 #include "tree-walk.h"
index e23f16dfdd220036f3b5bb93d24d8c1b4e7f4b96..08633dc1216b8ce0cf994c90bd019ba0696faafe 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
@@ -8,6 +8,7 @@
 #include "sideband.h"
 #include "repository.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "object.h"
 #include "commit.h"
@@ -22,6 +23,7 @@
 #include "version.h"
 #include "string-list.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "prio-queue.h"
 #include "protocol.h"
 #include "quote.h"
@@ -30,6 +32,7 @@
 #include "commit-graph.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "wrapper.h"
 #include "write-or-die.h"
 
 /* Remember to update object flag allocation in object.h */
@@ -1067,7 +1070,7 @@ static void receive_needs(struct upload_pack_data *data,
                const char *features;
                struct object_id oid_buf;
                const char *arg;
-               int feature_len;
+               size_t feature_len;
 
                reset_timeout(data->timeout);
                if (packet_reader_read(reader) != PACKET_READ_NORMAL)
index cfbd257fdbae4795d61754383f7e1a932fab862e..24ff7dfdc28a43a0f2b8535fd417b84eb0bede42 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "walker.h"
index ee83757590269f063a83c9c89cbd1b64ae22c044..c130d7518bf489aa2aa20cbf07b15a00d0b99489 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 static intmax_t count_fsync_writeout_only;
index 4bef09de1ca55adc2046dafe4df8d0aa93b9d37f..97b9c1c035974c269f5b9d042155e196d8193b10 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
@@ -7,6 +8,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"
@@ -18,6 +20,8 @@
 #include "column.h"
 #include "setup.h"
 #include "strbuf.h"
+#include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"