]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/ci-use-macos-13'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Nov 2023 02:03:59 +0000 (11:03 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Nov 2023 02:03:59 +0000 (11:03 +0900)
Replace macos-12 used at GitHub CI with macos-13.

* js/ci-use-macos-13:
  ci: upgrade to using macos-13

442 files changed:
.mailmap
Documentation/CodingGuidelines
Documentation/MyFirstContribution.txt
Documentation/RelNotes/2.43.0.txt [new file with mode: 0644]
Documentation/ReviewingGuidelines.txt
Documentation/SubmittingPatches
Documentation/ToolsForGit.txt
Documentation/config.txt
Documentation/config/advice.txt
Documentation/config/alias.txt
Documentation/config/apply.txt
Documentation/config/attr.txt [new file with mode: 0644]
Documentation/config/branch.txt
Documentation/config/checkout.txt
Documentation/config/clean.txt
Documentation/config/clone.txt
Documentation/config/color.txt
Documentation/config/column.txt
Documentation/config/commit.txt
Documentation/config/core.txt
Documentation/config/credential.txt
Documentation/config/diff.txt
Documentation/config/fastimport.txt
Documentation/config/fetch.txt
Documentation/config/format.txt
Documentation/config/fsck.txt
Documentation/config/fsmonitor--daemon.txt
Documentation/config/gc.txt
Documentation/config/gpg.txt
Documentation/config/gui.txt
Documentation/config/http.txt
Documentation/config/i18n.txt
Documentation/config/imap.txt
Documentation/config/index.txt
Documentation/config/log.txt
Documentation/config/mailinfo.txt
Documentation/config/maintenance.txt
Documentation/config/man.txt
Documentation/config/merge.txt
Documentation/config/mergetool.txt
Documentation/config/notes.txt
Documentation/config/pack.txt
Documentation/config/push.txt
Documentation/config/receive.txt
Documentation/config/rerere.txt
Documentation/config/safe.txt
Documentation/config/sendemail.txt
Documentation/config/sequencer.txt
Documentation/config/splitindex.txt
Documentation/config/stash.txt
Documentation/config/status.txt
Documentation/config/submodule.txt
Documentation/config/trace2.txt
Documentation/config/transfer.txt
Documentation/config/user.txt
Documentation/config/versionsort.txt
Documentation/diff-generate-patch.txt
Documentation/diff-options.txt
Documentation/fetch-options.txt
Documentation/fsck-msgids.txt
Documentation/git-am.txt
Documentation/git-apply.txt
Documentation/git-archive.txt
Documentation/git-bisect.txt
Documentation/git-blame.txt
Documentation/git-branch.txt
Documentation/git-bugreport.txt
Documentation/git-check-attr.txt
Documentation/git-check-ignore.txt
Documentation/git-check-ref-format.txt
Documentation/git-checkout-index.txt
Documentation/git-checkout.txt
Documentation/git-clean.txt
Documentation/git-commit.txt
Documentation/git-count-objects.txt
Documentation/git-credential-cache.txt
Documentation/git-credential-store.txt
Documentation/git-credential.txt
Documentation/git-daemon.txt
Documentation/git-diff-files.txt
Documentation/git-diff-index.txt
Documentation/git-diff-tree.txt
Documentation/git-difftool.txt
Documentation/git-fast-import.txt
Documentation/git-fetch-pack.txt
Documentation/git-for-each-ref.txt
Documentation/git-format-patch.txt
Documentation/git-fsck.txt
Documentation/git-fsmonitor--daemon.txt
Documentation/git-gc.txt
Documentation/git-get-tar-commit-id.txt
Documentation/git-grep.txt
Documentation/git-hash-object.txt
Documentation/git-help.txt
Documentation/git-hook.txt
Documentation/git-http-backend.txt
Documentation/git-http-fetch.txt
Documentation/git-http-push.txt
Documentation/git-index-pack.txt
Documentation/git-init.txt
Documentation/git-interpret-trailers.txt
Documentation/git-log.txt
Documentation/git-ls-files.txt
Documentation/git-mailsplit.txt
Documentation/git-maintenance.txt
Documentation/git-merge-base.txt
Documentation/git-merge-tree.txt
Documentation/git-merge.txt
Documentation/git-mergetool--lib.txt
Documentation/git-mergetool.txt
Documentation/git-mktag.txt
Documentation/git-mktree.txt
Documentation/git-mv.txt
Documentation/git-name-rev.txt
Documentation/git-pack-objects.txt
Documentation/git-prune-packed.txt
Documentation/git-prune.txt
Documentation/git-push.txt
Documentation/git-quiltimport.txt
Documentation/git-range-diff.txt
Documentation/git-read-tree.txt
Documentation/git-rebase.txt
Documentation/git-receive-pack.txt
Documentation/git-remote-ext.txt
Documentation/git-remote-fd.txt
Documentation/git-repack.txt
Documentation/git-replace.txt
Documentation/git-request-pull.txt
Documentation/git-restore.txt
Documentation/git-rev-list.txt
Documentation/git-rev-parse.txt
Documentation/git-revert.txt
Documentation/git-rm.txt
Documentation/git-send-email.txt
Documentation/git-send-pack.txt
Documentation/git-sh-setup.txt
Documentation/git-show-branch.txt
Documentation/git-show-ref.txt
Documentation/git-show.txt
Documentation/git-status.txt
Documentation/git-stripspace.txt
Documentation/git-symbolic-ref.txt
Documentation/git-update-index.txt
Documentation/git-update-ref.txt
Documentation/git-update-server-info.txt
Documentation/git-upload-pack.txt
Documentation/git-var.txt
Documentation/git-verify-pack.txt
Documentation/git-whatchanged.txt
Documentation/git.txt
Documentation/gitattributes.txt
Documentation/gitcli.txt
Documentation/gitdiffcore.txt
Documentation/giteveryday.txt
Documentation/gitformat-bundle.txt
Documentation/gitformat-chunk.txt
Documentation/gitformat-pack.txt
Documentation/githooks.txt
Documentation/gitk.txt
Documentation/gitprotocol-capabilities.txt
Documentation/gitprotocol-common.txt
Documentation/gitprotocol-http.txt
Documentation/gitprotocol-pack.txt
Documentation/gitprotocol-v2.txt
Documentation/gitsubmodules.txt
Documentation/gittutorial.txt
Documentation/gitweb.conf.txt
Documentation/gitweb.txt
Documentation/glossary-content.txt
Documentation/howto/coordinate-embargoed-releases.txt
Documentation/howto/maintain-git.txt
Documentation/howto/use-git-daemon.txt
Documentation/howto/using-merge-subtree.txt
Documentation/i18n.txt
Documentation/mergetools/vimdiff.txt
Documentation/pretty-formats.txt
Documentation/pretty-options.txt
Documentation/pull-fetch-param.txt
Documentation/rev-list-options.txt
Documentation/technical/api-index-skel.txt
Documentation/technical/api-simple-ipc.txt
Documentation/technical/bitmap-format.txt
Documentation/technical/commit-graph.txt
Documentation/technical/parallel-checkout.txt
Documentation/technical/partial-clone.txt
Documentation/technical/racy-git.txt
Documentation/technical/reftable.txt
Documentation/technical/repository-version.txt
Documentation/technical/rerere.txt
Documentation/urls-remotes.txt
Documentation/urls.txt
Documentation/user-manual.txt
GIT-VERSION-GEN
Makefile
RelNotes
add-interactive.c
attr.c
attr.h
bloom.c
branch.c
builtin/add.c
builtin/am.c
builtin/bisect.c
builtin/branch.c
builtin/bugreport.c
builtin/check-attr.c
builtin/checkout-index.c
builtin/checkout.c
builtin/commit-graph.c
builtin/describe.c
builtin/diff.c
builtin/fast-export.c
builtin/fast-import.c
builtin/fetch.c
builtin/fsmonitor--daemon.c
builtin/gc.c
builtin/grep.c
builtin/index-pack.c
builtin/interpret-trailers.c
builtin/log.c
builtin/ls-tree.c
builtin/merge-tree.c
builtin/merge.c
builtin/pack-objects.c
builtin/read-tree.c
builtin/rebase.c
builtin/reflog.c
builtin/repack.c
builtin/stash.c
builtin/submodule--helper.c
builtin/unpack-objects.c
builtin/update-index.c
builtin/update-ref.c
builtin/worktree.c
bulk-checkin.c
bulk-checkin.h
bundle-uri.c
chunk-format.c
chunk-format.h
color.c
commit-graph.c
commit-graph.h
commit-reach.c
compat/fsmonitor/fsm-health-darwin.c
compat/fsmonitor/fsm-ipc-win32.c
compat/fsmonitor/fsm-listen-darwin.c
compat/fsmonitor/fsm-listen-win32.c
compat/fsmonitor/fsm-path-utils-win32.c
compat/fsmonitor/fsm-settings-win32.c
config.c
config.h
contrib/README
contrib/completion/git-completion.bash
contrib/credential/libsecret/git-credential-libsecret.c
contrib/credential/wincred/git-credential-wincred.c
contrib/git-jump/git-jump
contrib/subtree/git-subtree.sh
contrib/subtree/t/t7900-subtree.sh
credential.c
csum-file.c
diagnose.c
diff-lib.c
diff-merges.c
diff.c
diff.h
dir.c
dir.h
entry.c
entry.h
environment.c
environment.h
fsck.c
fsck.h
fsmonitor--daemon.h
fsmonitor-ipc.c
fsmonitor-settings.c
git-gui/Makefile
git-gui/README.md
git-gui/git-gui.sh
git-gui/lib/choose_repository.tcl
git-gui/lib/shortcut.tcl
git-p4.py
git-send-email.perl
graph.c
grep.c
hex-ll.c [new file with mode: 0644]
hex-ll.h [new file with mode: 0644]
hex.c
hex.h
imap-send.c
list-objects.c
log-tree.c
log-tree.h
mailinfo.c
merge-ort.c
merge-recursive.c
merge-recursive.h
midx.c
midx.h
negotiator/noop.c
object-file.c
pack-bitmap-write.c
pack-bitmap.c
pack-objects.c
pack-revindex.c
parse-options-cb.c
parse-options.c
parse-options.h
parse.c [new file with mode: 0644]
parse.h [new file with mode: 0644]
pathspec.c
po/README.md
preload-index.c
pretty.c
progress.c
prompt.c
range-diff.c
rebase.c
ref-filter.c
refs/files-backend.c
refs/ref-cache.c
rerere.c
resolve-undo.c
resolve-undo.h
revision.c
revision.h
sequencer.c
sparse-index.c
statinfo.c
strbuf.c
strbuf.h
t/README
t/helper/test-env-helper.c
t/helper/test-find-pack.c [new file with mode: 0644]
t/helper/test-index-version.c [deleted file]
t/helper/test-parse-options.c
t/helper/test-simple-ipc.c
t/helper/test-tool.c
t/helper/test-tool.h
t/helper/test-trace2.c
t/helper/test-truncate.c [new file with mode: 0644]
t/lib-chunk.sh [new file with mode: 0644]
t/lib-chunk/corrupt-chunk-file.pl [new file with mode: 0644]
t/lib-credential.sh
t/lib-rebase.sh
t/perf/p2000-sparse-operations.sh
t/t0003-attributes.sh
t/t0040-parse-options.sh
t/t0081-find-pack.sh [new file with mode: 0755]
t/t0091-bugreport.sh
t/t0301-credential-cache.sh
t/t0303-credential-external.sh
t/t1092-sparse-checkout-compatibility.sh
t/t1410-reflog.sh
t/t1450-fsck.sh
t/t1500-rev-parse.sh
t/t1502-rev-parse-parseopt.sh
t/t1502/.gitattributes [new file with mode: 0644]
t/t1502/optionspec-neg [new file with mode: 0644]
t/t1502/optionspec-neg.help [new file with mode: 0644]
t/t1502/optionspec.help [new file with mode: 0755]
t/t1600-index.sh
t/t1700-split-index.sh
t/t2004-checkout-cache-temp.sh
t/t2030-unresolve-info.sh
t/t2070-restore.sh
t/t2104-update-index-skip-worktree.sh
t/t2107-update-index-basic.sh
t/t2400-worktree-add.sh
t/t2407-worktree-heads.sh
t/t3200-branch.sh
t/t3202-show-branch.sh
t/t3206-range-diff.sh
t/t3400-rebase.sh
t/t3501-revert-cherry-pick.sh
t/t3903-stash.sh
t/t4013-diff-various.sh
t/t4014-format-patch.sh
t/t4052-stat-output.sh
t/t4068-diff-symmetric-merge-base.sh
t/t4205-log-pretty-formats.sh
t/t4207-log-decoration-colors.sh
t/t4214-log-graph-octopus.sh
t/t4215-log-skewed-merges.sh
t/t4216-log-bloom.sh
t/t4300-merge-tree.sh
t/t4301-merge-tree-write-tree.sh
t/t5001-archive-attr.sh
t/t5317-pack-objects-filter-objects.sh
t/t5318-commit-graph.sh
t/t5319-multi-pack-index.sh
t/t5324-split-commit-graph.sh
t/t5328-commit-graph-64bit-time.sh
t/t5329-pack-objects-cruft.sh
t/t5500-fetch-pack.sh
t/t5521-pull-options.sh
t/t6009-rev-list-parent.sh
t/t6017-rev-list-stdin.sh
t/t6300-for-each-ref.sh
t/t6406-merge-attr.sh
t/t6416-recursive-corner-cases.sh
t/t6433-merge-toplevel.sh
t/t6437-submodule-merge.sh
t/t6500-gc.sh
t/t6700-tree-depth.sh [new file with mode: 0755]
t/t7201-co.sh
t/t7419-submodule-set-branch.sh
t/t7420-submodule-set-url.sh
t/t7508-status.sh
t/t7513-interpret-trailers.sh
t/t7601-merge-pull-config.sh
t/t7602-merge-octopus-many.sh
t/t7603-merge-reduce-heads.sh
t/t7607-merge-state.sh
t/t7608-merge-messages.sh
t/t7700-repack.sh
t/t7704-repack-cruft.sh [new file with mode: 0755]
t/t7810-grep.sh
t/t7900-maintenance.sh
t/t9001-send-email.sh
t/t9902-completion.sh
trace2/tr2_sysenv.c
trace2/tr2_tgt_event.c
trace2/tr2_tgt_normal.c
trailer.c
trailer.h
tree-diff.c
tree-walk.c
tree-walk.h
tree.c
tree.h
unicode-width.h
unpack-trees.c
unpack-trees.h
upload-pack.c
url.c
urlmatch.c
worktree.c
wrapper.c
wrapper.h
write-or-die.c
wt-status.c

index dc31d70b8c1e98b14a4e76d5fa0e35cfd0bccc34..82129be449f94b9872087717a03f1e3d5e2fac1a 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -59,9 +59,9 @@ David Reiss <dreiss@facebook.com> <dreiss@dreiss-vmware.(none)>
 David S. Miller <davem@davemloft.net>
 David Turner <novalis@novalis.org> <dturner@twopensource.com>
 David Turner <novalis@novalis.org> <dturner@twosigma.com>
-Derrick Stolee <derrickstolee@github.com> <stolee@gmail.com>
-Derrick Stolee <derrickstolee@github.com> Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
-Derrick Stolee <derrickstolee@github.com> <dstolee@microsoft.com>
+Derrick Stolee <stolee@gmail.com> <derrickstolee@github.com>
+Derrick Stolee <stolee@gmail.com> Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
+Derrick Stolee <stolee@gmail.com> <dstolee@microsoft.com>
 Deskin Miller <deskinm@umich.edu>
 Đoàn Trần Công Danh <congdanhqx@gmail.com> Doan Tran Cong Danh
 Dirk Süsserott <newsletter@dirk.my1.cc>
index 9495df835d5d8170773c0cea071161cc034ca666..8d3a467c0135319162b71290810917cca5f8316f 100644 (file)
@@ -1,5 +1,5 @@
-Like other projects, we also have some guidelines to keep to the
-code.  For Git in general, a few rough rules are:
+Like other projects, we also have some guidelines for our code.  For
+Git in general, a few rough rules are:
 
  - Most importantly, we never say "It's in POSIX; we'll happily
    ignore your needs should your system not conform to it."
@@ -40,7 +40,7 @@ As for more concrete guidelines, just imitate the existing code
 contributing to). It is always preferable to match the _local_
 convention. New code added to Git suite is expected to match
 the overall style of existing code. Modifications to existing
-code is expected to match the style the surrounding code already
+code are expected to match the style the surrounding code already
 uses (even if it doesn't match the overall style of existing code).
 
 But if you must have a list of rules, here are some language
index 62d11a5cd7f909e2e038e1f768bafddc82be210d..7cfed60c2e984f4fa29aca68983c2260faf451ee 100644 (file)
@@ -160,10 +160,11 @@ in order to keep the declarations alphabetically sorted:
 int cmd_psuh(int argc, const char **argv, const char *prefix);
 ----
 
-Be sure to `#include "builtin.h"` in your `psuh.c`.
+Be sure to `#include "builtin.h"` in your `psuh.c`. You'll also need to
+`#include "gettext.h"` to use functions related to printing output text.
 
-Go ahead and add some throwaway printf to that function. This is a decent
-starting point as we can now add build rules and register the command.
+Go ahead and add some throwaway printf to the `cmd_psuh` function. This is a
+decent starting point as we can now add build rules and register the command.
 
 NOTE: Your throwaway text, as well as much of the text you will be adding over
 the course of this tutorial, is user-facing. That means it needs to be
diff --git a/Documentation/RelNotes/2.43.0.txt b/Documentation/RelNotes/2.43.0.txt
new file mode 100644 (file)
index 0000000..836fcb5
--- /dev/null
@@ -0,0 +1,286 @@
+Git v2.43 Release Notes
+=======================
+
+Backward Compatibility Notes
+
+ * The "--rfc" option of "git format-patch" used to be a valid way to
+   override an earlier "--subject-prefix=<something>" on the command
+   line and replace it with "[RFC PATCH]", but from this release, it
+   merely prefixes the string "RFC " in front of the given subject
+   prefix.  If you are negatively affected by this change, please use
+   "--subject-prefix=PATCH --rfc" as a replacement.
+
+ * "git rev-list --stdin" learned to take non-revisions (like "--not")
+   recently from the standard input, but the way such a "--not" was
+   handled was quite confusing, which has been rethought.  The updated
+   rule is that "--not" given from the command line only affects revs
+   given from the command line that comes but not revs read from the
+   standard input, and "--not" read from the standard input affects
+   revs given from the standard input and not revs given from the
+   command line.
+
+UI, Workflows & Features
+
+ * A message written in olden time prevented a branch from getting
+   checked out saying it is already checked out elsewhere, but these
+   days, we treat a branch that is being bisected or rebased just like
+   a branch that is checked out and protect it.  Rephrase the message
+   to say that the branch is in use.
+
+ * Hourly and other schedule of "git maintenance" jobs are randomly
+   distributed now.
+
+ * "git cmd -h" learned to signal which options can be negated by
+   listing such options like "--[no-]opt".
+
+ * The way authentication related data other than passwords (e.g.
+   oath token and password expiration data) are stored in libsecret
+   keyrings has been rethought.
+
+ * Update the libsecret and wincred credential helpers to correctly
+   match which credential to erase; they erased the wrong entry in
+   some cases.
+
+ * Git GUI updates.
+
+ * "git format-patch" learns a way to feed cover letter description,
+   that (1) can be used on detached HEAD where there is no branch
+   description available, and (2) also can override the branch
+   description if there is one.
+
+ * Use of --max-pack-size to allow multiple packfiles to be created is
+   now supported even when we are sending unreachable objects to cruft
+   packs.
+
+ * "git format-patch --rfc --subject-prefix=<foo>" used to ignore the
+   "--subject-prefix" option and used "[RFC PATCH]"; now we will add
+   "RFC" prefix to whatever subject prefix is specified.
+
+ * "git log --format" has been taught the %(decorate) placeholder.
+
+ * The default log message created by "git revert", when reverting a
+   commit that records a revert, has been tweaked, to encourage people
+   describe complex "revert of revert of revert" situation better in
+   their own words.
+
+ * The command-line completion support (in contrib/) learned to
+   complete "git commit --trailer=" for possible trailer keys.
+
+ * "git update-index" learns "--show-index-version" to inspect
+   the index format version used by the on-disk index file.
+
+ * "git diff" learned diff.statNameWidth configuration variable, to
+   give the default width for the name part in the "--stat" output.
+
+ * "git range-diff --notes=foo" compared "log --notes=foo --notes" of
+   the two ranges, instead of using just the specified notes tree.
+
+ * The command line completion script (in contrib/) can be told to
+   complete aliases by including ": git <cmd> ;" in the alias to tell
+   it that the alias should be completed similar to how "git <cmd>" is
+   completed.  The parsing code for the alias as been loosened to
+   allow ';' without an extra space before it.
+
+ * "git for-each-ref" and friends learned to apply mailmap to
+   authorname and other fields.
+
+ * "git repack" machinery learns to pay attention to the "--filter="
+   option.
+
+ * "git repack" learned "--max-cruft-size" to prevent cruft packs from
+   growing without bounds.
+
+ * "git merge-tree" learned to take strategy backend specific options
+   via the "-X" option, like "git merge" does.
+
+ * "git log" and friends learned "--dd" that is a short-hand for
+   "--diff-merges=first-parent -p".
+
+ * The attribute subsystem learned to honor `attr.tree` configuration
+   that specifies which tree to read the .gitattributes files from.
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ * "git check-attr" has been taught to work better with sparse-index.
+
+ * It may be tempting to leave the help text NULL for a command line
+   option that is either hidden or too obvious, but "git subcmd -h"
+   and "git subcmd --help-all" would have segfaulted if done so.  Now
+   the help text is optional.
+
+ * Tests that are known to pass with LSan are now marked as such.
+
+ * Flaky "git p4" tests, as well as "git svn" tests, are now skipped
+   in the (rather expensive) sanitizer CI job.
+
+ * Tests with LSan from time to time seem to emit harmless message
+   that makes our tests unnecessarily flaky; we work it around by
+   filtering the uninteresting output.
+
+ * Unused parameters to functions are marked as such, and/or removed,
+   in order to bring us closer to -Wunused-parameter clean.
+
+ * The code to keep track of existing packs in the repository while
+   repacking has been refactored.
+
+ * The "streaming" interface used for bulk-checkin codepath has been
+   narrowed to take only blob objects for now, with no real loss of
+   functionality.
+
+ * GitHub CI workflow has learned to trigger Coverity check.
+
+ * Test coverage for trailers has been improved.
+
+ * The code to iterate over loose references have been optimized to
+   reduce the number of lstat() system calls.
+   (merge 2cdb796101 vd/loose-ref-iteration-optimization later to maint).
+
+ * The codepaths that read "chunk" formatted files have been corrected
+   to pay attention to the chunk size and notice broken files.
+
+
+Fixes since v2.42
+-----------------
+
+ * Overly long label names used in the sequencer machinery are now
+   chopped to fit under filesystem limitation.
+
+ * Scalar updates.
+
+ * Tweak GitHub Actions CI so that pushing the same commit to multiple
+   branch tips at the same time will not waste building and testing
+   the same thing twice.
+
+ * The commit-graph verification code that detects mixture of zero and
+   non-zero generation numbers has been updated.
+
+ * "git diff -w --exit-code" with various options did not work
+   correctly, which is being addressed.
+
+ * transfer.unpackLimit ought to be used as a fallback, but overrode
+   fetch.unpackLimit and receive.unpackLimit instead.
+
+ * The use of API between two calls to require_clean_work_tree() from
+   the sequencer code has been cleaned up for consistency.
+
+ * "git diff --no-such-option" and other corner cases around the exit
+   status of the "diff" command has been corrected.
+
+ * "git for-each-ref --sort='contents:size'" sorts the refs according
+   to size numerically, giving a ref that points at a blob twelve-byte
+   (12) long before showing a blob hundred-byte (100) long.
+
+ * We now limit depth of the tree objects and maximum length of
+   pathnames recorded in tree objects.
+   (merge 4d5693ba05 jk/tree-name-and-depth-limit later to maint).
+
+ * Various fixes to the behavior of "rebase -i" when the command got
+   interrupted by conflicting changes.
+
+ * References from description of the `--patch` option in various
+   manual pages have been simplified and improved.
+
+ * "git grep -e A --no-or -e B" is accepted, even though the negation
+   of "or" did not mean anything, which has been tightened.
+
+ * The completion script (in contrib/) has been taught to treat the
+   "-t" option to "git checkout" and "git switch" just like the
+   "--track" option, to complete remote-tracking branches.
+
+ * "git diff --no-index -R <(one) <(two)" did not work correctly,
+   which has been corrected.
+
+ * Update "git maintenance" timers' implementation based on systemd
+   timers to work with WSL.
+
+ * "git diff --cached" codepath did not fill the necessary stat
+   information for a file when fsmonitor knows it is clean and ended
+   up behaving as if it is not clean, which has been corrected.
+
+ * Clarify how "alias.foo = : git cmd ; aliased-command-string" should
+   be spelled with necessary whitespaces around punctuation marks to
+   work.
+
+ * HTTP Header redaction code has been adjusted for a newer version of
+   cURL library that shows its traces differently from earlier
+   versions.
+
+ * An error message given by "git send-email" when given a malformed
+   address did not give correct information, which has been corrected.
+
+ * UBSan options were not propagated through the test framework to git
+   run via the httpd, unlike ASan options, which has been corrected.
+
+ * "checkout --merge -- path" and "update-index --unresolve path" did
+   not resurrect conflicted state that was resolved to remove path,
+   but now they do.
+   (merge 5bdedac3c7 jc/unresolve-removal later to maint).
+
+ * The display width table for unicode characters has been updated for
+   Unicode 15.1
+   (merge 872976c37e bb/unicode-width-table-15 later to maint).
+
+ * Update mailmap entry for Derrick.
+   (merge 6e5457d8c7 ds/mailmap-entry-update later to maint).
+
+ * In .gitmodules files, submodules are keyed by their names, and the
+   path to the submodule whose name is $name is specified by the
+   submodule.$name.path variable.  There were a few codepaths that
+   mixed the name and path up when consulting the submodule database,
+   which have been corrected.  It took long for these bugs to be found
+   as the name of a submodule initially is the same as its path, and
+   the problem does not surface until it is moved to a different path,
+   which apparently happens very rarely.
+
+ * "git diff --merge-base X other args..." insisted that X must be a
+   commit and errored out when given an annotated tag that peels to a
+   commit, but we only need it to be a committish.  This has been
+   corrected.
+   (merge 4adceb5a29 ar/diff-index-merge-base-fix later to maint).
+
+ * Fix "git merge-tree" to stop segfaulting when the --attr-source
+   option is used.
+   (merge e95bafc52f jc/merge-ort-attr-index-fix later to maint).
+
+ * Unlike "git log --pretty=%D", "git log --pretty="%(decorate)" did
+   not auto-initialize the decoration subsystem, which has been
+   corrected.
+
+ * Feeding "git stash store" with a random commit that was not created
+   by "git stash create" now errors out.
+   (merge d9b6634589 jc/fail-stash-to-store-non-stash later to maint).
+
+ * The index file has room only for lower 32-bit of the file size in
+   the cached stat information, which means cached stat information
+   will have 0 in its sd_size member for a file whose size is multiple
+   of 4GiB.  This is mistaken for a racily clean path.  Avoid it by
+   storing a bogus sd_size value instead for such files.
+   (merge 5143ac07b1 bc/racy-4gb-files later to maint).
+
+ * "git p4" tried to store symlinks to LFS when told, but has been
+   fixed not to do so, because it does not make sense.
+   (merge 10c89a02b0 mm/p4-symlink-with-lfs later to maint).
+
+ * The codepath to handle recipient addresses `git send-email
+   --compose` learns from the user was completely broken, which has
+   been corrected.
+   (merge 3ec6167567 jk/send-email-fix-addresses-from-composed-messages later to maint).
+
+ * "cd sub && git grep -f patterns" tried to read "patterns" file at
+   the top level of the working tree; it has been corrected to read
+   "sub/patterns" instead.
+
+
+ * "git reflog expire --single-worktree" has been broken for the past
+   20 months or so, which has been corrected.
+
+ * "git send-email" did not have certain pieces of data computed yet
+   when it tried to validate the outging messages and its recipient
+   addresses, which has been sorted out.
+
+ * "git bugreport" learned to complain when it received a command line
+   argument that it will not use.
+
+ * Other code cleanup, docfix, build fix, etc.
+   (merge c2c349a15c xz/commit-title-soft-limit-doc later to maint).
index 0e323d54779a7c680ee8471330c85609f4644d43..515d470d23c1f178a60a2ea7734ba8930da42cba 100644 (file)
@@ -19,7 +19,7 @@ Principles
 Selecting patch(es) to review
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 If you are looking for a patch series in need of review, start by checking
-latest "What's cooking in git.git" email
+the latest "What's cooking in git.git" email
 (https://lore.kernel.org/git/xmqqilm1yp3m.fsf@gitster.g/[example]). The "What's
 cooking" emails & replies can be found using the query `s:"What's cooking"` on
 the https://lore.kernel.org/git/[`lore.kernel.org` mailing list archive];
@@ -126,7 +126,7 @@ Terminology
 -----------
 nit: ::
        Denotes a small issue that should be fixed, such as a typographical error
-       or mis-alignment of conditions in an `if()` statement.
+       or misalignment of conditions in an `if()` statement.
 
 aside: ::
 optional: ::
index 973d7a81d4492d627c77ce3c6db105ae917fb957..bce7f97815cb52a5ebbba4289b4b5013929b99ee 100644 (file)
@@ -87,7 +87,7 @@ maintainer.
 Under truly exceptional circumstances where you absolutely must depend
 on a select few topic branches that are already in `next` but not in
 `master`, you may want to create your own custom base-branch by forking
-`master` and merging the required topic branches to it. You could then
+`master` and merging the required topic branches into it. You could then
 work on top of this base-branch.  But keep in mind that this base-branch
 would only be known privately to you.  So when you are ready to send
 your patches to the list, be sure to communicate how you created it in
@@ -266,7 +266,7 @@ date)", like this:
        noticed that ...
 ....
 
-The "Copy commit summary" command of gitk can be used to obtain this
+The "Copy commit reference" command of gitk can be used to obtain this
 format (with the subject enclosed in a pair of double-quotes), or this
 invocation of `git show`:
 
@@ -393,8 +393,8 @@ mailing list{security-ml}, instead of the public mailing list.
 
 Learn to use format-patch and send-email if possible.  These commands
 are optimized for the workflow of sending patches, avoiding many ways
-your existing e-mail client that is optimized for "multipart/*" mime
-type e-mails to corrupt and render your patches unusable.
+your existing e-mail client (often optimized for "multipart/*" MIME
+type e-mails) might render your patches unusable.
 
 People on the Git mailing list need to be able to read and
 comment on the changes you are submitting.  It is important for
@@ -515,8 +515,8 @@ repositories.
 
        git://git.ozlabs.org/~paulus/gitk
 
-   Those who are interested in improve gitk can volunteer to help Paul
-   in maintaining it cf. <YntxL/fTplFm8lr6@cleo>.
+   Those who are interested in improving gitk can volunteer to help Paul
+   maintain it, cf. <YntxL/fTplFm8lr6@cleo>.
 
 - `po/` comes from the localization coordinator, Jiang Xin:
 
@@ -556,7 +556,7 @@ help you find out who they are.
 
 In any time between the (2)-(3) cycle, the maintainer may pick it up
 from the list and queue it to `seen`, in order to make it easier for
-people play with it without having to pick up and apply the patch to
+people to play with it without having to pick up and apply the patch to
 their trees themselves.
 
 [[patch-status]]
index 5060d0d2314c316364b7579236a1c2572c62ba64..ae7690b45d08b3c3ba9775d17d43d0f658a71360 100644 (file)
@@ -5,7 +5,7 @@ Tools for developing Git
 [[summary]]
 == Summary
 
-This document gathers tips, scripts and configuration file to help people
+This document gathers tips, scripts, and configuration files to help people
 working on Git's codebase use their favorite tools while following Git's
 coding style.
 
@@ -32,7 +32,7 @@ information on using the script.
 
 This is adapted from Linux's suggestion in its CodingStyle document:
 
-- To follow rules of the CodingGuideline, it's useful to put the following in
+- To follow the rules in CodingGuidelines, it's useful to put the following in
 GIT_CHECKOUT/.dir-locals.el, assuming you use cperl-mode:
 ----
 ;; note the first part is useful for C editing, too
index 229b63a454c035dcd6fa6797b29788ae67c053a4..e3a74dd1c19db44b3a0980cc778bf0ab4ba60b07 100644 (file)
@@ -11,7 +11,7 @@ file. The file `/etc/gitconfig` can be used to store a system-wide
 default configuration.
 
 The configuration variables are used by both the Git plumbing
-and the porcelains. The variables are divided into sections, wherein
+and the porcelain commands. The variables are divided into sections, wherein
 the fully qualified variable name of the variable itself is the last
 dot-separated segment and the section name is everything before the last
 dot. The variable names are case-insensitive, allow only alphanumeric
@@ -103,7 +103,7 @@ was found.  See below for examples.
 Conditional includes
 ~~~~~~~~~~~~~~~~~~~~
 
-You can include a config file from another conditionally by setting a
+You can conditionally include a config file from another by setting an
 `includeIf.<condition>.path` variable to the name of the file to be
 included.
 
@@ -118,7 +118,7 @@ are:
        pattern, the include condition is met.
 +
 The .git location may be auto-discovered, or come from `$GIT_DIR`
-environment variable. If the repository is auto discovered via a .git
+environment variable. If the repository is auto-discovered via a .git
 file (e.g. from submodules, or a linked worktree), the .git location
 would be the final location where the .git directory is, not where the
 .git file is.
@@ -371,6 +371,8 @@ other popular tools, and describe them in your documentation.
 
 include::config/advice.txt[]
 
+include::config/attr.txt[]
+
 include::config/core.txt[]
 
 include::config/add.txt[]
index c548a91e6761c762b19f26e2bb1f5a36f8192ba9..2737381a11a1b40dfb2ec3f6f6b182f83a91c9fd 100644 (file)
@@ -5,7 +5,7 @@ advice.*::
 +
 --
        ambiguousFetchRefspec::
-               Advice shown when fetch refspec for multiple remotes map to
+               Advice shown when a fetch refspec for multiple remotes maps to
                the same remote-tracking branch namespace and causes branch
                tracking set-up to fail.
        fetchShowForcedUpdates::
@@ -63,7 +63,7 @@ advice.*::
                the template shown when writing commit messages in
                linkgit:git-commit[1], and in the help message shown
                by linkgit:git-switch[1] or
-               linkgit:git-checkout[1] when switching branch.
+               linkgit:git-checkout[1] when switching branches.
        statusUoption::
                Advise to consider using the `-u` option to linkgit:git-status[1]
                when the command takes more than 2 seconds to enumerate untracked
@@ -87,7 +87,7 @@ advice.*::
        detachedHead::
                Advice shown when you used
                linkgit:git-switch[1] or linkgit:git-checkout[1]
-               to move to the detach HEAD state, to instruct how to
+               to move to the detached HEAD state, to instruct how to
                create a local branch after the fact.
        suggestDetachingHead::
                Advice shown when linkgit:git-switch[1] refuses to detach HEAD
@@ -101,7 +101,7 @@ advice.*::
                otherwise caused a remote-tracking branch to be
                checked out. See the `checkout.defaultRemote`
                configuration variable for how to set a given remote
-               to used by default in some situations where this
+               to be used by default in some situations where this
                advice would be printed.
        amWorkDir::
                Advice that shows the location of the patch file when
index f1ca739d574293fd001322a2cc272e2cc0510344..01df96fab3df11f1c804e26ed7c312cd7490e2fd 100644 (file)
@@ -4,7 +4,7 @@ alias.*::
        `git last` is equivalent to `git cat-file commit HEAD`. To avoid
        confusion and troubles with script usage, aliases that
        hide existing Git commands are ignored. Arguments are split by
-       spaces, the usual shell quoting and escaping is supported.
+       spaces, the usual shell quoting and escaping are supported.
        A quote pair or a backslash can be used to quote them.
 +
 Note that the first word of an alias does not necessarily have to be a
index 8fb8ef763dfdf2475af3addafa3cefd7d859ad8a..f9908e210a838dfaf78315b1ce146655a7cf19ca 100644 (file)
@@ -2,10 +2,10 @@ apply.ignoreWhitespace::
        When set to 'change', tells 'git apply' to ignore changes in
        whitespace, in the same way as the `--ignore-space-change`
        option.
-       When set to one of: no, none, never, false tells 'git apply' to
+       When set to one of: no, none, never, false, it tells 'git apply' to
        respect all whitespace differences.
        See linkgit:git-apply[1].
 
 apply.whitespace::
-       Tells 'git apply' how to handle whitespaces, in the same way
+       Tells 'git apply' how to handle whitespace, in the same way
        as the `--whitespace` option. See linkgit:git-apply[1].
diff --git a/Documentation/config/attr.txt b/Documentation/config/attr.txt
new file mode 100644 (file)
index 0000000..1a482d6
--- /dev/null
@@ -0,0 +1,7 @@
+attr.tree::
+       A reference to a tree in the repository from which to read attributes,
+       instead of the `.gitattributes` file in the working tree. In a bare
+       repository, this defaults to `HEAD:.gitattributes`. If the value does
+       not resolve to a valid tree object, an empty tree is used instead.
+       When the `GIT_ATTR_SOURCE` environment variable or `--attr-source`
+       command line option are used, this configuration variable has no effect.
index 445341a906b241ab1ed11093b1b0fa908e0954da..432b9cd2c0e66721c135a14bd4e3f09dee6bcc92 100644 (file)
@@ -36,7 +36,7 @@ branch.sort::
 
 branch.<name>.remote::
        When on branch <name>, it tells 'git fetch' and 'git push'
-       which remote to fetch from/push to.  The remote to push to
+       which remote to fetch from or push to.  The remote to push to
        may be overridden with `remote.pushDefault` (for all branches).
        The remote to push to, for the current branch, may be further
        overridden by `branch.<name>.pushRemote`.  If no remote is
@@ -64,7 +64,7 @@ branch.<name>.merge::
        handled like the remote part of a refspec, and must match a
        ref which is fetched from the remote given by
        "branch.<name>.remote".
-       The merge information is used by 'git pull' (which at first calls
+       The merge information is used by 'git pull' (which first calls
        'git fetch') to lookup the default branch for merging. Without
        this option, 'git pull' defaults to merge the first refspec fetched.
        Specify multiple values to get an octopus merge.
@@ -99,5 +99,5 @@ for details).
 branch.<name>.description::
        Branch description, can be edited with
        `git branch --edit-description`. Branch description is
-       automatically added in the format-patch cover letter or
+       automatically added to the format-patch cover letter or
        request-pull summary.
index bfbca90f0e90bdcac2fb814ab90c74d2d7f1b0d7..a3230229938055323ead98e6d6bdfd032b911b1b 100644 (file)
@@ -30,7 +30,7 @@ checkout.workers::
        all commands that perform checkout. E.g. checkout, clone, reset,
        sparse-checkout, etc.
 +
-Note: parallel checkout usually delivers better performance for repositories
+Note: Parallel checkout usually delivers better performance for repositories
 located on SSDs or over NFS. For repositories on spinning disks and/or machines
 with a small number of cores, the default sequential checkout often performs
 better. The size and compression level of a repository might also influence how
@@ -39,6 +39,6 @@ well the parallel version performs.
 checkout.thresholdForParallelism::
        When running parallel checkout with a small number of files, the cost
        of subprocess spawning and inter-process communication might outweigh
-       the parallelization gains. This setting allows to define the minimum
+       the parallelization gains. This setting allows you to define the minimum
        number of files for which parallel checkout should be attempted. The
        default is 100.
index a807c925b9ca8ce4ca783fe2880ec986ef0d5b83..f05b9403b5ad903ea68d68e896acaff253bfde37 100644 (file)
@@ -1,3 +1,3 @@
 clean.requireForce::
        A boolean to make git-clean do nothing unless given -f,
-       -i or -n.   Defaults to true.
+       -i, or -n.  Defaults to true.
index 26f4fb137a738ead96e0a9848df9a383aa432305..d037b57f729e5e10549235b6278c123754d0aee8 100644 (file)
@@ -4,8 +4,8 @@ clone.defaultRemoteName::
        option to linkgit:git-clone[1].
 
 clone.rejectShallow::
-       Reject to clone a repository if it is a shallow one, can be overridden by
-       passing option `--reject-shallow` in command line. See linkgit:git-clone[1]
+       Reject cloning a repository if it is a shallow one; this can be overridden by
+       passing the `--reject-shallow` option on the command line. See linkgit:git-clone[1]
 
 clone.filterSubmodules::
        If a partial clone filter is provided (see `--filter` in
index 1795b2d16be2f01ba10ecfd6a2128444b99a85ec..2f2275ac6975f2a47cafc719d886e2f2b8c71a71 100644 (file)
@@ -106,7 +106,7 @@ color.grep.<slot>::
        matching text in context lines
 `matchSelected`;;
        matching text in selected lines. Also, used to customize the following
-       linkgit:git-log[1] subcommands: `--grep`, `--author` and `--committer`.
+       linkgit:git-log[1] subcommands: `--grep`, `--author`, and `--committer`.
 `selected`;;
        non-matching text in selected lines. Also, used to customize the
        following linkgit:git-log[1] subcommands: `--grep`, `--author` and
index 76aa2f29dc2108fa20d575c4bc49791bc9c02c96..01e4198429ed46c96b7e25a70ed7b58c4844a29a 100644 (file)
@@ -43,7 +43,7 @@ column.branch::
        See `column.ui` for details.
 
 column.clean::
-       Specify the layout when list items in `git clean -i`, which always
+       Specify the layout when listing items in `git clean -i`, which always
        shows files and directories in columns. See `column.ui` for details.
 
 column.status::
@@ -51,5 +51,5 @@ column.status::
        See `column.ui` for details.
 
 column.tag::
-       Specify whether to output tag listing in `git tag` in columns.
+       Specify whether to output tag listings in `git tag` in columns.
        See `column.ui` for details.
index 2c95573930bedf8d5aed0a0b19927c73ac8e39f7..62f0d92fda51de04a75b4fc074befaa96c554851 100644 (file)
@@ -2,7 +2,7 @@ commit.cleanup::
        This setting overrides the default of the `--cleanup` option in
        `git commit`. See linkgit:git-commit[1] for details. Changing the
        default can be useful when you always want to keep lines that begin
-       with comment character `#` in your log message, in which case you
+       with the comment character `#` in your log message, in which case you
        would do `git config commit.cleanup whitespace` (note that you will
        have to remove the help lines that begin with `#` in the commit log
        template yourself, if you do this).
@@ -25,5 +25,5 @@ commit.template::
        new commit messages.
 
 commit.verbose::
-       A boolean or int to specify the level of verbose with `git commit`.
+       A boolean or int to specify the level of verbosity with `git commit`.
        See linkgit:git-commit[1].
index dfbdaf00b8bc2239e7e106c8b78a2dd90d44ac9b..0e8c2832bf9b8a5251c51f346ecfcf47c7e8d530 100644 (file)
@@ -736,3 +736,9 @@ core.abbrev::
        If set to "no", no abbreviation is made and the object names
        are shown in their full length.
        The minimum length is 4.
+
+core.maxTreeDepth::
+       The maximum depth Git is willing to recurse while traversing a
+       tree (e.g., "a/b/cde/f" has a depth of 4). This is a fail-safe
+       to allow Git to abort cleanly, and should not generally need to
+       be adjusted. The default is 4096.
index 512f31876e17ed6892ff7f1858a891f0f7938b29..0221c3e620da89abb62f26110f400ecb0d6ff71a 100644 (file)
@@ -21,7 +21,7 @@ credential.username::
 
 credential.<url>.*::
        Any of the credential.* options above can be applied selectively to
-       some credentials. For example "credential.https://example.com.username"
+       some credentials. For example, "credential.https://example.com.username"
        would set the default username only for https connections to
        example.com. See linkgit:gitcredentials[7] for details on how URLs are
        matched.
@@ -31,6 +31,6 @@ credentialCache.ignoreSIGHUP::
 
 credentialStore.lockTimeoutMS::
        The length of time, in milliseconds, for git-credential-store to retry
-       when trying to lock the credentials file. Value 0 means not to retry at
+       when trying to lock the credentials file. A value of 0 means not to retry at
        all; -1 means to try indefinitely. Default is 1000 (i.e., retry for
        1s).
index 35a7bf86d7774c67dbd129cc29b009aae46c81a9..bd5ae0c3378adbd5661a202dc1f8fcfbf27ac4a1 100644 (file)
@@ -1,6 +1,6 @@
 diff.autoRefreshIndex::
        When using 'git diff' to compare with work tree
-       files, do not consider stat-only change as changed.
+       files, do not consider stat-only changes as changed.
        Instead, silently run `git update-index --refresh` to
        update the cached stat information for paths whose
        contents in the work tree match the contents in the
@@ -52,6 +52,10 @@ directories with less than 10% of the total amount of changed files,
 and accumulating child directory counts in the parent directories:
 `files,10,cumulative`.
 
+diff.statNameWidth::
+       Limit the width of the filename part in --stat output. If set, applies
+       to all commands generating --stat output except format-patch.
+
 diff.statGraphWidth::
        Limit the width of the graph part in --stat output. If set, applies
        to all commands generating --stat output except format-patch.
index c1166e330d55da332d4fa591b4083f86f2adb606..903677d7efefa03d607c9b076ac1a7bf14304105 100644 (file)
@@ -1,8 +1,8 @@
 fastimport.unpackLimit::
        If the number of objects imported by linkgit:git-fast-import[1]
        is below this limit, then the objects will be unpacked into
-       loose object files.  However if the number of imported objects
-       equals or exceeds this limit then the pack will be stored as a
+       loose object files.  However, if the number of imported objects
+       equals or exceeds this limit, then the pack will be stored as a
        pack.  Storing the pack from a fast-import can make the import
        operation complete faster, especially on slow filesystems.  If
        not set, the value of `transfer.unpackLimit` is used instead.
index 568f0f75b3027d374a53857c06cf481ff376c6b7..aea5b97477b64ef664b6b35faad78b2eb618db9a 100644 (file)
@@ -52,8 +52,8 @@ fetch.pruneTags::
 
 fetch.output::
        Control how ref update status is printed. Valid values are
-       `full` and `compact`. Default value is `full`. See section
-       OUTPUT in linkgit:git-fetch[1] for detail.
+       `full` and `compact`. Default value is `full`. See the
+       OUTPUT section in linkgit:git-fetch[1] for details.
 
 fetch.negotiationAlgorithm::
        Control how information about the commits in the local repository
index 8cf6f00d9365cf19b6244ba005d078c5ebed8a05..c98412b697efea446b5291c0bc52af3611ade5e0 100644 (file)
@@ -68,7 +68,7 @@ format.encodeEmailHeaders::
        Defaults to true.
 
 format.pretty::
-       The default pretty format for log/show/whatchanged command,
+       The default pretty format for log/show/whatchanged command.
        See linkgit:git-log[1], linkgit:git-show[1],
        linkgit:git-whatchanged[1].
 
index a3c865df5679e32958b8351076aa80579a067ffb..8e9e508933f8949ff6aa738d3f7460faeaa289db 100644 (file)
@@ -11,13 +11,13 @@ to clone or fetch it set `fetch.fsck.<msg-id>`.
 +
 The rest of the documentation discusses `fsck.*` for brevity, but the
 same applies for the corresponding `receive.fsck.*` and
-`fetch.<msg-id>.*`. variables.
+`fetch.fsck.*`. variables.
 +
-Unlike variables like `color.ui` and `core.editor` the
+Unlike variables like `color.ui` and `core.editor`, the
 `receive.fsck.<msg-id>` and `fetch.fsck.<msg-id>` variables will not
 fall back on the `fsck.<msg-id>` configuration if they aren't set. To
-uniformly configure the same fsck settings in different circumstances
-all three of them they must all set to the same values.
+uniformly configure the same fsck settings in different circumstances,
+all three of them must be set to the same values.
 +
 When `fsck.<msg-id>` is set, errors can be switched to warnings and
 vice versa by configuring the `fsck.<msg-id>` setting where the
@@ -36,19 +36,19 @@ Setting an unknown `fsck.<msg-id>` value will cause fsck to die, but
 doing the same for `receive.fsck.<msg-id>` and `fetch.fsck.<msg-id>`
 will only cause git to warn.
 +
-See `Fsck Messages` section of linkgit:git-fsck[1] for supported
+See the `Fsck Messages` section of linkgit:git-fsck[1] for supported
 values of `<msg-id>`.
 
 
 fsck.skipList::
        The path to a list of object names (i.e. one unabbreviated SHA-1 per
        line) that are known to be broken in a non-fatal way and should
-       be ignored. On versions of Git 2.20 and later comments ('#'), empty
-       lines, and any leading and trailing whitespace is ignored. Everything
+       be ignored. On versions of Git 2.20 and later, comments ('#'), empty
+       lines, and any leading and trailing whitespace are ignored. Everything
        but a SHA-1 per line will error out on older versions.
 +
 This feature is useful when an established project should be accepted
-despite early commits containing errors that can be safely ignored
+despite early commits containing errors that can be safely ignored,
 such as invalid committer email addresses.  Note: corrupt objects
 cannot be skipped with this setting.
 +
@@ -58,11 +58,11 @@ Like `fsck.<msg-id>` this variable has corresponding
 Unlike variables like `color.ui` and `core.editor` the
 `receive.fsck.skipList` and `fetch.fsck.skipList` variables will not
 fall back on the `fsck.skipList` configuration if they aren't set. To
-uniformly configure the same fsck settings in different circumstances
-all three of them they must all set to the same values.
+uniformly configure the same fsck settings in different circumstances,
+all three of them must be set to the same values.
 +
 Older versions of Git (before 2.20) documented that the object names
-list should be sorted. This was never a requirement, the object names
+list should be sorted. This was never a requirement; the object names
 could appear in any order, but when reading the list we tracked whether
 the list was sorted for the purposes of an internal binary search
 implementation, which could save itself some work with an already sorted
index c225c6c9e74cbd043489108ca843c129f0aa98de..671f9b94628446b1ee4704d6e6730c22719ebcaf 100644 (file)
@@ -1,5 +1,5 @@
 fsmonitor.allowRemote::
-    By default, the fsmonitor daemon refuses to work against network-mounted
+    By default, the fsmonitor daemon refuses to work with network-mounted
     repositories. Setting `fsmonitor.allowRemote` to `true` overrides this
     behavior.  Only respected when `core.fsmonitor` is set to `true`.
 
index ca47eb200882a251ddf7ad644151bb6e896b242f..664a3c28747c8e508e78caa97a607aa909e3efa1 100644 (file)
@@ -24,7 +24,7 @@ gc.auto::
        default value is 6700.
 +
 Setting this to 0 disables not only automatic packing based on the
-number of loose objects, but any other heuristic `git gc --auto` will
+number of loose objects, but also any other heuristic `git gc --auto` will
 otherwise use to determine if there's work to do, such as
 `gc.autoPackLimit`.
 
@@ -39,7 +39,7 @@ See the `gc.bigPackThreshold` configuration variable below. When in
 use, it'll affect how the auto pack limit works.
 
 gc.autoDetach::
-       Make `git gc --auto` return immediately and run in background
+       Make `git gc --auto` return immediately and run in the background
        if the system supports it. Default is true.
 
 gc.bigPackThreshold::
@@ -86,6 +86,12 @@ gc.cruftPacks::
        linkgit:git-repack[1]) instead of as loose objects. The default
        is `true`.
 
+gc.maxCruftSize::
+       Limit the size of new cruft packs when repacking. When
+       specified in addition to `--max-cruft-size`, the command line
+       option takes priority. See the `--max-cruft-size` option of
+       linkgit:git-repack[1].
+
 gc.pruneExpire::
        When 'git gc' is run, it will call 'prune --expire 2.weeks.ago'
        (and 'repack --cruft --cruft-expiration 2.weeks.ago' if using
@@ -145,6 +151,22 @@ Multiple hooks are supported, but all must exit successfully, else the
 operation (either generating a cruft pack or unpacking unreachable
 objects) will be halted.
 
+gc.repackFilter::
+       When repacking, use the specified filter to move certain
+       objects into a separate packfile.  See the
+       `--filter=<filter-spec>` option of linkgit:git-repack[1].
+
+gc.repackFilterTo::
+       When repacking and using a filter, see `gc.repackFilter`, the
+       specified location will be used to create the packfile
+       containing the filtered out objects. **WARNING:** The
+       specified location should be accessible, using for example the
+       Git alternates mechanism, otherwise the repo could be
+       considered corrupt by Git as it migh not be able to access the
+       objects in that packfile. See the `--filter-to=<dir>` option
+       of linkgit:git-repack[1] and the `objects/info/alternates`
+       section of linkgit:gitrepository-layout[5].
+
 gc.rerereResolved::
        Records of conflicted merge you resolved earlier are
        kept for this many days when 'git rerere gc' is run.
index 37e2831cd511c8a6f00112f9e357ab58c44ddf98..5cf32b179dc8bd5559be08e040b14a96ce158fd7 100644 (file)
@@ -4,7 +4,7 @@ gpg.program::
        same command-line interface as GPG, namely, to verify a detached
        signature, "`gpg --verify $signature - <$file`" is run, and the
        program is expected to signal a good signature by exiting with
-       code 0, and to generate an ASCII-armored detached signature, the
+       code 0.  To generate an ASCII-armored detached signature, the
        standard input of "`gpg -bsau $key`" is fed with the contents to be
        signed, and the program is expected to send the result to its
        standard output.
@@ -25,7 +25,7 @@ gpg.<format>.program::
 gpg.minTrustLevel::
        Specifies a minimum trust level for signature verification.  If
        this option is unset, then signature verification for merge
-       operations require a key with at least `marginal` trust.  Other
+       operations requires a key with at least `marginal` trust.  Other
        operations that perform signature verification require a key
        with at least `undefined` trust.  Setting this option overrides
        the required trust-level for all operations.  Supported values,
@@ -38,7 +38,7 @@ gpg.minTrustLevel::
 * `ultimate`
 
 gpg.ssh.defaultKeyCommand::
-       This command that will be run when user.signingkey is not set and a ssh
+       This command will be run when user.signingkey is not set and a ssh
        signature is requested. On successful exit a valid ssh public key
        prefixed with `key::` is expected in the first line of its output.
        This allows for a script doing a dynamic lookup of the correct public
index 0c087fd8c9313e5e68dcd7cd7a91b6900936febc..171be774d243fd2822fa51875feab38618d82193 100644 (file)
@@ -24,7 +24,7 @@ gui.matchTrackingBranch::
        not. Default: "false".
 
 gui.newBranchTemplate::
-       Is used as suggested name when creating new branches using the
+       Is used as suggested name when creating new branches using the
        linkgit:git-gui[1].
 
 gui.pruneDuringFetch::
index 51a70781e58cf9923cb0b1b84104c6d011dbd5f8..2d4e0c9b869b567200cfc5805600b51deaa41669 100644 (file)
@@ -254,13 +254,13 @@ http.lowSpeedLimit, http.lowSpeedTime::
 
 http.noEPSV::
        A boolean which disables using of EPSV ftp command by curl.
-       This can helpful with some "poor" ftp servers which don't
+       This can be helpful with some "poor" ftp servers which don't
        support EPSV mode. Can be overridden by the `GIT_CURL_FTP_NO_EPSV`
        environment variable. Default is false (curl will use EPSV).
 
 http.userAgent::
        The HTTP USER_AGENT string presented to an HTTP server.  The default
-       value represents the version of the client Git such as git/1.7.1.
+       value represents the version of the Git client such as git/1.7.1.
        This option allows you to override this value to a more common value
        such as Mozilla/4.0.  This may be necessary, for instance, if
        connecting through a firewall that restricts HTTP connections to a set
index cc256217317c666f79cc8d39604643d1fcb32b6a..6e72fdb45bd0cde5ca5e90ba189d8a6696df8ef2 100644 (file)
@@ -2,7 +2,7 @@ i18n.commitEncoding::
        Character encoding the commit messages are stored in; Git itself
        does not care per se, but this information is necessary e.g. when
        importing commits from emails or in the gitk graphical history
-       browser (and possibly at other places in the future or in other
+       browser (and possibly in other places in the future or in other
        porcelains). See e.g. linkgit:git-mailinfo[1]. Defaults to 'utf-8'.
 
 i18n.logOutputEncoding::
index 06166fb5c04fe9e1d83d51990f945b11ce1877e9..3d28f7264374e69f45afc9efb201136cb2049c8b 100644 (file)
@@ -4,7 +4,7 @@ imap.folder::
        "[Gmail]/Drafts". Required.
 
 imap.tunnel::
-       Command used to setup a tunnel to the IMAP server through which
+       Command used to set up a tunnel to the IMAP server through which
        commands will be piped instead of using a direct network connection
        to the server. Required when imap.host is not set.
 
@@ -37,7 +37,7 @@ imap.preformattedHTML::
        format=fixed email.  Default is `false`.
 
 imap.authMethod::
-       Specify authenticate method for authentication with IMAP server.
+       Specify the authentication method for authenticating with the IMAP server.
        If Git was built with the NO_CURL option, or if your curl version is older
        than 7.34.0, or if you're running git-imap-send with the `--no-curl`
        option, the only supported method is 'CRAM-MD5'. If this is not set
index 23c7985eb40974e2557c8bd3d271073c0b49bc58..3eff42036033ea90fb751b364a14ced17f5a25ad 100644 (file)
@@ -23,7 +23,7 @@ index.threads::
        Specifies the number of threads to spawn when loading the index.
        This is meant to reduce index load time on multiprocessor machines.
        Specifying 0 or 'true' will cause Git to auto-detect the number of
-       CPU's and set the number of threads accordingly. Specifying 1 or
+       CPUs and set the number of threads accordingly. Specifying 1 or
        'false' will disable multithreading. Defaults to 'true'.
 
 index.version::
index 5f96cf87fb96ce7366f11f80b48f9c9bf9fd13f6..9003a8219143ab75524391303df2f88ca8922e86 100644 (file)
@@ -9,7 +9,7 @@ log.date::
        `--date` option.  See linkgit:git-log[1] for details.
 +
 If the format is set to "auto:foo" and the pager is in use, format
-"foo" will be the used for the date format. Otherwise "default" will
+"foo" will be used for the date format. Otherwise, "default" will
 be used.
 
 log.decorate::
index 3854d4ae37cd77efca402a3911220baf4f0eb37d..ec3a5d81f7255aab044eea2b3667bb35c01236f2 100644 (file)
@@ -1,6 +1,6 @@
 mailinfo.scissors::
        If true, makes linkgit:git-mailinfo[1] (and therefore
        linkgit:git-am[1]) act by default as if the --scissors option
-       was provided on the command-line. When active, this features
+       was provided on the command-line. When active, this feature
        removes everything from the message body before a scissors
        line (i.e. consisting mainly of ">8", "8<" and "-").
index 18f056213145e595d0a57792e716f29521122997..69a4f05153e3ba08fda7d181d5d8defc3351cbd4 100644 (file)
@@ -12,7 +12,7 @@ maintenance.strategy::
        then that value is used instead of the one provided by
        `maintenance.strategy`. The possible strategy strings are:
 +
-* `none`: This default setting implies no task are run at any schedule.
+* `none`: This default setting implies no tasks are run at any schedule.
 * `incremental`: This setting optimizes for performing small maintenance
   activities that do not delete any data. This does not schedule the `gc`
   task, but runs the `prefetch` and `commit-graph` tasks hourly, the
index a727d987a8d48c3f4e6b43acd852d77da8f8b108..5a0f82cc2327a2007df24f4582e05a223959e7a0 100644 (file)
@@ -5,7 +5,7 @@ man.viewer::
 man.<tool>.cmd::
        Specify the command to invoke the specified man viewer. The
        specified command is evaluated in shell with the man page
-       passed as argument. (See linkgit:git-help[1].)
+       passed as an argument. (See linkgit:git-help[1].)
 
 man.<tool>.path::
        Override the path for the given tool that may be used to
index 99e83dd36e53e6079721a5a123fdf6392f4fc2b8..8851b6cedef980c106b9e86541862b517aa1f2ad 100644 (file)
@@ -7,7 +7,7 @@ merge.conflictStyle::
        marker and the original text before the `=======` marker.  The
        "merge" style tends to produce smaller conflict regions than diff3,
        both because of the exclusion of the original text, and because
-       when a subset of lines match on the two sides they are just pulled
+       when a subset of lines match on the two sides, they are just pulled
        out of the conflict region.  Another alternate style, "zdiff3", is
        similar to diff3 but removes matching lines on the two sides from
        the conflict region when those matching lines appear near either
index 56a7eeeffb4336ec05c52e96df59b501a41460bf..294f61efd12fdf863e648b076462f4a9a1aa75b7 100644 (file)
@@ -22,8 +22,8 @@ mergetool.<tool>.trustExitCode::
        For a custom merge command, specify whether the exit code of
        the merge command can be used to determine whether the merge was
        successful.  If this is not set to true then the merge target file
-       timestamp is checked and the merge assumed to have been successful
-       if the file has been updated, otherwise the user is prompted to
+       timestamp is checked, and the merge is assumed to have been successful
+       if the file has been updated; otherwise, the user is prompted to
        indicate the success of the merge.
 
 mergetool.meld.hasOutput::
@@ -37,7 +37,7 @@ mergetool.meld.hasOutput::
 
 mergetool.meld.useAutoMerge::
        When the `--auto-merge` is given, meld will merge all non-conflicting
-       parts automatically, highlight the conflicting parts and wait for
+       parts automatically, highlight the conflicting parts, and wait for
        user decision.  Setting `mergetool.meld.useAutoMerge` to `true` tells
        Git to unconditionally use the `--auto-merge` option with `meld`.
        Setting this value to `auto` makes git detect whether `--auto-merge`
@@ -47,7 +47,7 @@ mergetool.meld.useAutoMerge::
 
 mergetool.vimdiff.layout::
        The vimdiff backend uses this variable to control how its split
-       windows look like. Applies even if you are using Neovim (`nvim`) or
+       windows appear. Applies even if you are using Neovim (`nvim`) or
        gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section
 ifndef::git-mergetool[]
        in linkgit:git-mergetool[1].
@@ -55,7 +55,7 @@ endif::[]
        for details.
 
 mergetool.hideResolved::
-       During a merge Git will automatically resolve as many conflicts as
+       During a merge, Git will automatically resolve as many conflicts as
        possible and write the 'MERGED' file containing conflict markers around
        any conflicts that it cannot resolve; 'LOCAL' and 'REMOTE' normally
        represent the versions of the file from before Git's conflict
@@ -74,7 +74,7 @@ mergetool.keepTemporaries::
        When invoking a custom merge tool, Git uses a set of temporary
        files to pass to the tool. If the tool returns an error and this
        variable is set to `true`, then these temporary files will be
-       preserved, otherwise they will be removed after the tool has
+       preserved; otherwise, they will be removed after the tool has
        exited. Defaults to `false`.
 
 mergetool.writeToTemp::
index c7c4811734b5c935c89b52eb3b3ddef58f49689d..43db8e808d7ab763898ce5a860b8d4644bbc9f69 100644 (file)
@@ -1,7 +1,7 @@
 notes.mergeStrategy::
        Which merge strategy to choose by default when resolving notes
        conflicts.  Must be one of `manual`, `ours`, `theirs`, `union`, or
-       `cat_sort_uniq`.  Defaults to `manual`.  See "NOTES MERGE STRATEGIES"
+       `cat_sort_uniq`.  Defaults to `manual`.  See the "NOTES MERGE STRATEGIES"
        section of linkgit:git-notes[1] for more information on each strategy.
 +
 This setting can be overridden by passing the `--strategy` option to
index 3748136d141e4193682655559d91f143f31305ec..f50df9dbce89891f0c6d4a5563c5ab73be4325df 100644 (file)
@@ -74,7 +74,7 @@ pack.threads::
        warning. This is meant to reduce packing time on multiprocessor
        machines. The required amount of memory for the delta search window
        is however multiplied by the number of threads.
-       Specifying 0 will cause Git to auto-detect the number of CPU's
+       Specifying 0 will cause Git to auto-detect the number of CPUs
        and set the number of threads accordingly.
 
 pack.indexVersion::
@@ -83,11 +83,11 @@ pack.indexVersion::
        the new pack index with capabilities for packs larger than 4 GB
        as well as proper protection against the repacking of corrupted
        packs.  Version 2 is the default.  Note that version 2 is enforced
-       and this config option ignored whenever the corresponding pack is
+       and this config option is ignored whenever the corresponding pack is
        larger than 2 GB.
 +
 If you have an old Git that does not understand the version 2 `*.idx` file,
-cloning or fetching over a non native protocol (e.g. "http")
+cloning or fetching over a non-native protocol (e.g. "http")
 that will copy both `*.pack` file and corresponding `*.idx` file from the
 other side may give you a repository that cannot be accessed with your
 older version of Git. If the `*.pack` file is smaller than 2 GB, however,
@@ -102,8 +102,8 @@ pack.packSizeLimit::
        in the creation of multiple packfiles.
 +
 Note that this option is rarely useful, and may result in a larger total
-on-disk size (because Git will not store deltas between packs), as well
-as worse runtime performance (object lookup within multiple packs is
+on-disk size (because Git will not store deltas between packs) and
+worse runtime performance (object lookup within multiple packs is
 slower than a single pack, and optimizations like reachability bitmaps
 cannot cope with multiple packs).
 +
index 43338b65e843dd93b6373cc2edfe3600f7bf200d..0acbbea18a320f8adabf08db4f4570ef58a5edaf 100644 (file)
@@ -35,7 +35,7 @@ push.default::
 
 * `tracking` - This is a deprecated synonym for `upstream`.
 
-* `simple` - pushes the current branch with the same name on the remote.
+* `simple` - push the current branch with the same name on the remote.
 +
 If you are working on a centralized workflow (pushing to the same repository you
 pull from, which is typically `origin`), then you need to configure an upstream
@@ -67,7 +67,7 @@ new default).
 --
 
 push.followTags::
-       If set to true enable `--follow-tags` option by default.  You
+       If set to true, enable `--follow-tags` option by default.  You
        may override this configuration at time of push by specifying
        `--no-follow-tags`.
 
index 85d5b5a3d2d8bf3952398628c188e4030cc3312d..c77e55b1cdd217e062450679920223a733995f77 100644 (file)
@@ -14,12 +14,12 @@ receive.autogc::
 
 receive.certNonceSeed::
        By setting this variable to a string, `git receive-pack`
-       will accept a `git push --signed` and verifies it by using
+       will accept a `git push --signed` and verify it by using
        a "nonce" protected by HMAC using this string as a secret
        key.
 
 receive.certNonceSlop::
-       When a `git push --signed` sent a push certificate with a
+       When a `git push --signed` sends a push certificate with a
        "nonce" that was issued by a receive-pack serving the same
        repository within this many seconds, export the "nonce"
        found in the certificate to `GIT_PUSH_CERT_NONCE` to the
index 40abdf6a6b5d8872772991c167c879cbb63f0ce5..3a78b5ebb1dc02e1f6cec1647ab94709018df7ff 100644 (file)
@@ -1,7 +1,7 @@
 rerere.autoUpdate::
        When set to true, `git-rerere` updates the index with the
        resulting contents after it cleanly resolves conflicts using
-       previously recorded resolution.  Defaults to false.
+       previously recorded resolutions.  Defaults to false.
 
 rerere.enabled::
        Activate recording of resolved conflicts, so that identical
index bde7f31459b98136a31a7eb1d457c5c43fddea54..577df40223a095b999b38a41df6c3a1cd1252de2 100644 (file)
@@ -14,7 +14,7 @@ repository that contains a bare repository and running a Git command
 within that directory.
 +
 This config setting is only respected in protected configuration (see
-<<SCOPES>>). This prevents the untrusted repository from tampering with
+<<SCOPES>>). This prevents untrusted repositories from tampering with
 this value.
 
 safe.directory::
@@ -32,7 +32,7 @@ override any such directories specified in the system config), add a
 `safe.directory` entry with an empty value.
 +
 This config setting is only respected in protected configuration (see
-<<SCOPES>>). This prevents the untrusted repository from tampering with this
+<<SCOPES>>). This prevents untrusted repositories from tampering with this
 value.
 +
 The value of this setting is interpolated, i.e. `~/<path>` expands to a
index 92a9ebe98c63e5fe75eb98237543d41d9f15c502..7fc770ee9e69d77b3743c8bff1b8bef35bb96f36 100644 (file)
@@ -36,7 +36,7 @@ sendemail.aliasesFile::
 
 sendemail.aliasFileType::
        Format of the file(s) specified in sendemail.aliasesFile. Must be
-       one of 'mutt', 'mailrc', 'pine', 'elm', or 'gnus', or 'sendmail'.
+       one of 'mutt', 'mailrc', 'pine', 'elm', 'gnus', or 'sendmail'.
 +
 What an alias file in each format looks like can be found in
 the documentation of the email program of the same name. The
@@ -91,7 +91,7 @@ sendemail.smtpBatchSize::
        See also the `--batch-size` option of linkgit:git-send-email[1].
 
 sendemail.smtpReloginDelay::
-       Seconds wait before reconnecting to smtp server.
+       Seconds to wait before reconnecting to the smtp server.
        See also the `--relogin-delay` option of linkgit:git-send-email[1].
 
 sendemail.forbidSendmailVariables::
index b48d532a96976ba2b9d967212f9ec2943291375f..e664eef01d10dede9b6a334e84635346e539955a 100644 (file)
@@ -2,4 +2,4 @@ sequence.editor::
        Text editor used by `git rebase -i` for editing the rebase instruction file.
        The value is meant to be interpreted by the shell when it is used.
        It can be overridden by the `GIT_SEQUENCE_EDITOR` environment variable.
-       When not configured the default commit message editor is used instead.
+       When not configured, the default commit message editor is used instead.
index afdb186df8ba6d39819d75b0542dcf4d89aafa18..cfaa29610b5a0051bed8119337c6f70ca994747d 100644 (file)
@@ -3,10 +3,10 @@ splitIndex.maxPercentChange::
        percent of entries the split index can contain compared to the
        total number of entries in both the split index and the shared
        index before a new shared index is written.
-       The value should be between 0 and 100. If the value is 0 then
-       a new shared index is always written, if it is 100 a new
+       The value should be between 0 and 100. If the value is 0, then
+       a new shared index is always written; if it is 100, a new
        shared index is never written.
-       By default the value is 20, so a new shared index is written
+       By default, the value is 20, so a new shared index is written
        if the number of entries in the split index would be greater
        than 20 percent of the total number of entries.
        See linkgit:git-update-index[1].
index b9f609ed76b7f3ff41aef03ecf0ea22fd1d355ea..ec1edaeba68aa3351331f03f981ceff9412d0899 100644 (file)
@@ -1,14 +1,14 @@
 stash.showIncludeUntracked::
        If this is set to true, the `git stash show` command will show
        the untracked files of a stash entry.  Defaults to false. See
-       description of 'show' command in linkgit:git-stash[1].
+       the description of the 'show' command in linkgit:git-stash[1].
 
 stash.showPatch::
        If this is set to true, the `git stash show` command without an
        option will show the stash entry in patch form.  Defaults to false.
-       See description of 'show' command in linkgit:git-stash[1].
+       See the description of the 'show' command in linkgit:git-stash[1].
 
 stash.showStat::
        If this is set to true, the `git stash show` command without an
-       option will show diffstat of the stash entry.  Defaults to true.
-       See description of 'show' command in linkgit:git-stash[1].
+       option will show diffstat of the stash entry.  Defaults to true.
+       See the description of the 'show' command in linkgit:git-stash[1].
index 0fc704ab80b2239ed03752846158c59dff56c31b..2ff8237f8fc4585e7a2a4c9e7a27f121bbd9d7e2 100644 (file)
@@ -47,7 +47,7 @@ status.showUntrackedFiles::
        contain only untracked files, are shown with the directory name
        only. Showing untracked files means that Git needs to lstat() all
        the files in the whole repository, which might be slow on some
-       systems. So, this variable controls how the commands displays
+       systems. So, this variable controls how the commands display
        the untracked files. Possible values are:
 +
 --
@@ -62,7 +62,7 @@ of linkgit:git-status[1] and linkgit:git-commit[1].
 
 status.submoduleSummary::
        Defaults to false.
-       If this is set to a non zero number or true (identical to -1 or an
+       If this is set to a non-zero number or true (identical to -1 or an
        unlimited number), the submodule summary will be enabled and a
        summary of commits for modified submodules will be shown (see
        --summary-limit option of linkgit:git-submodule[1]). Please note
index 6490527b45bcd4819be3fe412bcfc0aab7740ee6..0672d9911724d184b7b49ee0e50de3e992a0eac5 100644 (file)
@@ -2,7 +2,7 @@ submodule.<name>.url::
        The URL for a submodule. This variable is copied from the .gitmodules
        file to the git config via 'git submodule init'. The user can change
        the configured URL before obtaining the submodule via 'git submodule
-       update'. If neither submodule.<name>.active or submodule.active are
+       update'. If neither submodule.<name>.active nor submodule.active are
        set, the presence of this variable is used as a fallback to indicate
        whether the submodule is of interest to git commands.
        See linkgit:git-submodule[1] and linkgit:gitmodules[5] for details.
@@ -35,7 +35,7 @@ submodule.<name>.ignore::
        a submodule as modified. When set to "all", it will never be considered
        modified (but it will nonetheless show up in the output of status and
        commit when it has been staged), "dirty" will ignore all changes
-       to the submodules work tree and
+       to the submodule's work tree and
        takes only differences between the HEAD of the submodule and the commit
        recorded in the superproject into account. "untracked" will additionally
        let submodules with modified tracked files in their work tree show up.
index fe1642f0d40251d466c78639fff44475edb6b25b..3b6bca2b7ae44c99404699745c4da3bfd2633681 100644 (file)
@@ -66,6 +66,6 @@ trace2.destinationDebug::
 
 trace2.maxFiles::
        Integer.  When writing trace files to a target directory, do not
-       write additional traces if we would exceed this many files. Instead,
+       write additional traces if doing so would exceed this many files. Instead,
        write a sentinel file that will block further tracing to this
        directory. Defaults to 0, which disables this check.
index c3ac767d1e4de152865ec82de6a995a9b4934834..a9cbdb88a1fe11f364da005bdfe490cd2e28dc0b 100644 (file)
@@ -7,7 +7,7 @@ transfer.credentialsInUrl::
        and any other direct use of the configured URL.
 +
 Note that this is currently limited to detecting credentials in
-`remote.<name>.url` configuration, it won't detect credentials in
+`remote.<name>.url` configuration; it won't detect credentials in
 `remote.<name>.pushurl` configuration.
 +
 You might want to enable this to prevent inadvertent credentials
@@ -21,12 +21,12 @@ exposure, e.g. because:
   system.
 * The git programs will pass the full URL to one another as arguments
   on the command-line, meaning the credentials will be exposed to other
-  users on OS's or systems that allow other users to see the full
+  unprivileged users on systems that allow them to see the full
   process list of other users. On linux the "hidepid" setting
   documented in procfs(5) allows for configuring this behavior.
 +
 If such concerns don't apply to you then you probably don't need to be
-concerned about credentials exposure due to storing that sensitive
+concerned about credentials exposure due to storing sensitive
 data in git's configuration files. If you do want to use this, set
 `transfer.credentialsInUrl` to one of these values:
 +
index ec9233b060a82c41dd9a01785a6f1e748ddf0ad9..2ffc38d164786fbe7be6a5d3ee770e6869ba7825 100644 (file)
@@ -5,14 +5,14 @@ author.email::
 committer.name::
 committer.email::
        The `user.name` and `user.email` variables determine what ends
-       up in the `author` and `committer` field of commit
+       up in the `author` and `committer` fields of commit
        objects.
        If you need the `author` or `committer` to be different, the
-       `author.name`, `author.email`, `committer.name` or
+       `author.name`, `author.email`, `committer.name`, or
        `committer.email` variables can be set.
-       Also, all of these can be overridden by the `GIT_AUTHOR_NAME`,
+       All of these can be overridden by the `GIT_AUTHOR_NAME`,
        `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_NAME`,
-       `GIT_COMMITTER_EMAIL` and `EMAIL` environment variables.
+       `GIT_COMMITTER_EMAIL`, and `EMAIL` environment variables.
 +
 Note that the `name` forms of these variables conventionally refer to
 some form of a personal name.  See linkgit:git-commit[1] and the
@@ -40,7 +40,7 @@ user.signingKey::
        your private ssh key or the public key when ssh-agent is used.
        Alternatively it can contain a public key prefixed with `key::`
        directly (e.g.: "key::ssh-rsa XXXXXX identifier"). The private key
-       needs to be available via ssh-agent. If not set git will call
+       needs to be available via ssh-agent. If not set Git will call
        gpg.ssh.defaultKeyCommand (e.g.: "ssh-add -L") and try to use the
        first key available. For backward compatibility, a raw key which
        begins with "ssh-", such as "ssh-rsa XXXXXX identifier", is treated
index 6c7cc054fad2503dabf21073624875d2b6035abe..0cff0908193a29ff5e482cbd3a6780460b3399eb 100644 (file)
@@ -19,14 +19,14 @@ with those suffixes.  E.g. if "-pre" appears before "-rc" in the
 configuration, then all "1.0-preX" tags will be listed before any
 "1.0-rcX" tags.  The placement of the main release tag relative to tags
 with various suffixes can be determined by specifying the empty suffix
-among those other suffixes.  E.g. if the suffixes "-rc", "", "-ck" and
+among those other suffixes.  E.g. if the suffixes "-rc", "", "-ck", and
 "-bfs" appear in the configuration in this order, then all "v4.8-rcX" tags
 are listed first, followed by "v4.8", then "v4.8-ckX" and finally
 "v4.8-bfsX".
 +
-If more than one suffixes match the same tagname, then that tagname will
+If more than one suffix matches the same tagname, then that tagname will
 be sorted according to the suffix which starts at the earliest position in
-the tagname.  If more than one different matching suffixes start at
+the tagname.  If more than one different matching suffix starts at
 that earliest position, then that tagname will be sorted according to the
 longest of those suffixes.
 The sorting order between different suffixes is undefined if they are
index 546adf79e5a52cf100c71154bb9710cc5c68aaf6..4b5aa5c2e045f5c135b96fb9ec03b06aad0b91ea 100644 (file)
@@ -17,7 +17,7 @@ You can customize the creation of patch text via the
 What the -p option produces is slightly different from the traditional
 diff format:
 
-1.   It is preceded with a "git diff" header that looks like this:
+1.   It is preceded by a "git diff" header that looks like this:
 
        diff --git a/file1 b/file2
 +
@@ -25,9 +25,9 @@ The `a/` and `b/` filenames are the same unless rename/copy is
 involved.  Especially, even for a creation or a deletion,
 `/dev/null` is _not_ used in place of the `a/` or `b/` filenames.
 +
-When rename/copy is involved, `file1` and `file2` show the
+When rename/copy is involved, `file1` and `file2` show the
 name of the source file of the rename/copy and the name of
-the file that rename/copy produces, respectively.
+the file that the rename/copy produces, respectively.
 
 2.   It is followed by one or more extended header lines:
 
@@ -77,7 +77,7 @@ separate lines indicate the old and the new mode.
 
 5.  Hunk headers mention the name of the function to which the hunk
     applies.  See "Defining a custom hunk-header" in
-    linkgit:gitattributes[5] for details of how to tailor to this to
+    linkgit:gitattributes[5] for details of how to tailor this to
     specific languages.
 
 
@@ -89,7 +89,7 @@ produce a 'combined diff' when showing a merge. This is the default
 format when showing merges with linkgit:git-diff[1] or
 linkgit:git-show[1]. Note also that you can give suitable
 `--diff-merges` option to any of these commands to force generation of
-diffs in specific format.
+diffs in specific format.
 
 A "combined diff" format looks like this:
 
@@ -123,7 +123,7 @@ index fabadb8,cc95eb0..4866510
                for_each_ref(get_name);
 ------------
 
-1.   It is preceded with a "git diff" header, that looks like
+1.   It is preceded by a "git diff" header, that looks like
      this (when the `-c` option is used):
 
        diff --combined file
@@ -142,22 +142,22 @@ or like this (when the `--cc` option is used):
 +
 The `mode <mode>,<mode>..<mode>` line appears only if at least one of
 the <mode> is different from the rest. Extended headers with
-information about detected contents movement (renames and
-copying detection) are designed to work with diff of two
+information about detected content movement (renames and
+copying detection) are designed to work with the diff of two
 <tree-ish> and are not used by combined diff format.
 
-3.   It is followed by two-line from-file/to-file header
+3.   It is followed by a two-line from-file/to-file header:
 
        --- a/file
        +++ b/file
 +
-Similar to two-line header for traditional 'unified' diff
+Similar to the two-line header for the traditional 'unified' diff
 format, `/dev/null` is used to signal created or deleted
 files.
 +
 However, if the --combined-all-paths option is provided, instead of a
-two-line from-file/to-file you get a N+1 line from-file/to-file header,
-where N is the number of parents in the merge commit
+two-line from-file/to-file, you get an N+1 line from-file/to-file header,
+where N is the number of parents in the merge commit:
 
        --- a/file
        --- a/file
@@ -197,7 +197,7 @@ added, from the point of view of that parent).
 In the above example output, the function signature was changed
 from both files (hence two `-` removals from both file1 and
 file2, plus `++` to mean one line that was added does not appear
-in either file1 or file2).  Also eight other lines are the same
+in either file1 or file2).  Also, eight other lines are the same
 from file1 but do not appear in file2 (hence prefixed with `+`).
 
 When shown by `git diff-tree -c`, it compares the parents of a
index c07488b123c63111a84c027b4d80720383dc82b8..53ec3c9a3476bd12b8a8f4b6c31552b2767d8366 100644 (file)
@@ -37,66 +37,79 @@ endif::git-diff[]
 endif::git-format-patch[]
 
 ifdef::git-log[]
---diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc|remerge|r)::
+-m::
+       Show diffs for merge commits in the default format. This is
+       similar to '--diff-merges=on', except `-m` will
+       produce no output unless `-p` is given as well.
+
+-c::
+       Produce combined diff output for merge commits.
+       Shortcut for '--diff-merges=combined -p'.
+
+--cc::
+       Produce dense combined diff output for merge commits.
+       Shortcut for '--diff-merges=dense-combined -p'.
+
+--dd::
+       Produce diff with respect to first parent for both merge and
+       regular commits.
+       Shortcut for '--diff-merges=first-parent -p'.
+
+--remerge-diff::
+       Produce remerge-diff output for merge commits.
+       Shortcut for '--diff-merges=remerge -p'.
+
 --no-diff-merges::
+       Synonym for '--diff-merges=off'.
+
+--diff-merges=<format>::
        Specify diff format to be used for merge commits. Default is
-       {diff-merges-default} unless `--first-parent` is in use, in which case
-       `first-parent` is the default.
+       {diff-merges-default} unless `--first-parent` is in use, in
+       which case `first-parent` is the default.
 +
---diff-merges=(off|none):::
---no-diff-merges:::
+The following formats are supported:
++
+--
+off, none::
        Disable output of diffs for merge commits. Useful to override
        implied value.
 +
---diff-merges=on:::
---diff-merges=m:::
--m:::
-       This option makes diff output for merge commits to be shown in
-       the default format. `-m` will produce the output only if `-p`
-       is given as well. The default format could be changed using
-       `log.diffMerges` configuration parameter, which default value
+on, m::
+       Make diff output for merge commits to be shown in the default
+       format. The default format can be changed using
+       `log.diffMerges` configuration variable, whose default value
        is `separate`.
 +
---diff-merges=first-parent:::
---diff-merges=1:::
-       This option makes merge commits show the full diff with
-       respect to the first parent only.
+first-parent, 1::
+       Show full diff with respect to first parent. This is the same
+       format as `--patch` produces for non-merge commits.
++
+separate::
+       Show full diff with respect to each of parents.
+       Separate log entry and diff is generated for each parent.
 +
---diff-merges=separate:::
-       This makes merge commits show the full diff with respect to
-       each of the parents. Separate log entry and diff is generated
-       for each parent.
+combined, c::
+       Show differences from each of the parents to the merge
+       result simultaneously instead of showing pairwise diff between
+       a parent and the result one at a time. Furthermore, it lists
+       only files which were modified from all parents.
 +
---diff-merges=remerge:::
---diff-merges=r:::
---remerge-diff:::
-       With this option, two-parent merge commits are remerged to
-       create a temporary tree object -- potentially containing files
-       with conflict markers and such.  A diff is then shown between
-       that temporary tree and the actual merge commit.
+dense-combined, cc::
+       Further compress output produced by `--diff-merges=combined`
+       by omitting uninteresting hunks whose contents in the parents
+       have only two variants and the merge result picks one of them
+       without modification.
++
+remerge, r::
+       Remerge two-parent merge commits to create a temporary tree
+       object--potentially containing files with conflict markers
+       and such.  A diff is then shown between that temporary tree
+       and the actual merge commit.
 +
 The output emitted when this option is used is subject to change, and
 so is its interaction with other options (unless explicitly
 documented).
-+
---diff-merges=combined:::
---diff-merges=c:::
--c:::
-       With this option, diff output for a merge commit shows the
-       differences from each of the parents to the merge result
-       simultaneously instead of showing pairwise diff between a
-       parent and the result one at a time. Furthermore, it lists
-       only files which were modified from all parents. `-c` implies
-       `-p`.
-+
---diff-merges=dense-combined:::
---diff-merges=cc:::
---cc:::
-       With this option the output produced by
-       `--diff-merges=combined` is further compressed by omitting
-       uninteresting hunks whose contents in the parents have only
-       two variants and the merge result picks one of them without
-       modification.  `--cc` implies `-p`.
+--
 
 --combined-all-paths::
        This flag causes combined diffs (used for merge commits) to
@@ -204,14 +217,15 @@ have to use `--diff-algorithm=default` option.
        part. Maximum width defaults to terminal width, or 80 columns
        if not connected to a terminal, and can be overridden by
        `<width>`. The width of the filename part can be limited by
-       giving another width `<name-width>` after a comma. The width
-       of the graph part can be limited by using
-       `--stat-graph-width=<width>` (affects all commands generating
-       a stat graph) or by setting `diff.statGraphWidth=<width>`
-       (does not affect `git format-patch`).
-       By giving a third parameter `<count>`, you can limit the
-       output to the first `<count>` lines, followed by `...` if
-       there are more.
+       giving another width `<name-width>` after a comma or by setting
+       `diff.statNameWidth=<width>`. The width of the graph part can be
+       limited by using `--stat-graph-width=<width>` or by setting
+       `diff.statGraphWidth=<width>`. Using `--stat` or
+       `--stat-graph-width` affects all commands generating a stat graph,
+       while setting `diff.statNameWidth` or `diff.statGraphWidth`
+       does not affect `git format-patch`.
+       By giving a third parameter `<count>`, you can limit the output to
+       the first `<count>` lines, followed by `...` if there are more.
 +
 These parameters can also be set individually with `--stat-width=<width>`,
 `--stat-name-width=<name-width>` and `--stat-count=<count>`.
@@ -300,7 +314,7 @@ ifndef::git-format-patch[]
 
 -z::
 ifdef::git-log[]
-       Separate the commits with NULs instead of with new newlines.
+       Separate the commits with NULs instead of newlines.
 +
 Also, when `--raw` or `--numstat` has been given, do not munge
 pathnames and use NULs as output field terminators.
@@ -732,7 +746,7 @@ matches "`fooasdfbar`" and "`foo/bar/baz/asdf`" but not "`foobarx`".
 --rotate-to=<file>::
        Discard the files before the named <file> from the output
        (i.e. 'skip to'), or move them to the end of the output
-       (i.e. 'rotate to').  These were invented primarily for use
+       (i.e. 'rotate to').  These options were invented primarily for the use
        of the `git difftool` command, and may not be very useful
        otherwise.
 
index 41fc7ca3c67f5d31d5a771de906394480f265d9f..a1d6633a4f15b719a33615ca0ce2805ec2fa0b3e 100644 (file)
@@ -43,7 +43,7 @@ the current repository has the same history as the source repository.
 --update-shallow::
        By default when fetching from a shallow repository,
        `git fetch` refuses refs that require updating
-       .git/shallow. This option updates .git/shallow and accept such
+       .git/shallow. This option updates .git/shallow and accepts such
        refs.
 
 --negotiation-tip=<commit|glob>::
@@ -96,7 +96,7 @@ endif::git-pull[]
 
 -f::
 --force::
-       When 'git fetch' is used with `<src>:<dst>` refspec it may
+       When 'git fetch' is used with `<src>:<dst>` refspec, it may
        refuse to update the local branch as discussed
 ifdef::git-pull[]
        in the `<refspec>` part of the linkgit:git-fetch[1]
index 12eae8a2225a3c4d216fd05c874c1ed2930b5545..f643585a34e7617806c63b8f4afa7a4105bb989b 100644 (file)
 `hasDotgit`::
        (WARN) A tree contains an entry named `.git`.
 
+`largePathname`::
+       (WARN) A tree contains an entry with a very long path name. If
+       the value of `fsck.largePathname` contains a colon, that value
+       is used as the maximum allowable length (e.g., "warn:10" would
+       complain about any path component of 11 or more bytes). The
+       default value is 4096.
+
 `mailmapSymlink`::
        (INFO) `.mailmap` is a symlink.
 
        (ERROR) Missing space before date in an author/committer line.
 
 `missingSpaceBeforeEmail`::
-       (ERROR) Missing space before the email in author/committer line.
+       (ERROR) Missing space before the email in an author/committer line.
 
 `missingTag`::
        (ERROR) Unexpected end after `type` line in a tag object.
        (FATAL) Missing end-of-line in the object header.
 
 `zeroPaddedDate`::
-       (ERROR) Found a zero padded date in an author/commiter line.
+       (ERROR) Found a zero padded date in an author/committer line.
 
 `zeroPaddedFilemode`::
        (WARN) Found a zero padded filemode in a tree.
index 82dadbecc857bb114504f757bc3bc799c8de9d69..e080458d6c45891ec1db74b9df155aeab111e79f 100644 (file)
@@ -22,8 +22,8 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Splits mail messages in a mailbox into commit log message,
-authorship information and patches, and applies them to the
+Splits mail messages in a mailbox into commit log messages,
+authorship information, and patches, and applies them to the
 current branch. You could think of it as a reverse operation
 of linkgit:git-format-patch[1] run on a branch with a straight
 history without merges.
@@ -69,7 +69,7 @@ OPTIONS
 --empty=(stop|drop|keep)::
        By default, or when the option is set to 'stop', the command
        errors out on an input e-mail message lacking a patch
-       and stops into the middle of the current am session. When this
+       and stops in the middle of the current am session. When this
        option is set to 'drop', skip such an e-mail message instead.
        When this option is set to 'keep', create an empty commit,
        recording the contents of the e-mail message as its log.
@@ -94,7 +94,7 @@ OPTIONS
        Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
        The proposed commit log message taken from the e-mail
        is re-coded into UTF-8 encoding (configuration variable
-       `i18n.commitEncoding` can be used to specify project's
+       `i18n.commitEncoding` can be used to specify the project's
        preferred encoding if it is not UTF-8).
 +
 This was optional in prior versions of git, but now it is the
@@ -134,7 +134,7 @@ include::rerere-options.txt[]
        automatically. This option allows the user to bypass the automatic
        detection and specify the patch format that the patch(es) should be
        interpreted as. Valid formats are mbox, mboxrd,
-       stgit, stgit-series and hg.
+       stgit, stgit-series, and hg.
 
 -i::
 --interactive::
@@ -192,7 +192,7 @@ include::rerere-options.txt[]
 
 --abort::
        Restore the original branch and abort the patching operation.
-       Revert contents of files involved in the am operation to their
+       Revert the contents of files involved in the am operation to their
        pre-am state.
 
 --quit::
index 5e16e6db7e2e0273dacbb76b5d7f4cd6ee0462ec..9cce68a38be10f3a4ff3130adb1a2b300835cdcb 100644 (file)
@@ -23,8 +23,8 @@ DESCRIPTION
 Reads the supplied diff output (i.e. "a patch") and applies it to files.
 When running from a subdirectory in a repository, patched paths
 outside the directory are ignored.
-With the `--index` option the patch is also applied to the index, and
-with the `--cached` option the patch is only applied to the index.
+With the `--index` option, the patch is also applied to the index, and
+with the `--cached` option, the patch is only applied to the index.
 Without these options, the command applies the patch only to files,
 and does not require them to be in a Git repository.
 
@@ -52,7 +52,7 @@ OPTIONS
 --summary::
        Instead of applying the patch, output a condensed
        summary of information obtained from git diff extended
-       headers, such as creations, renames and mode changes.
+       headers, such as creations, renames, and mode changes.
        Turns off "apply".
 
 --check::
@@ -140,7 +140,7 @@ linkgit:git-config[1]).
        applying a diff generated with `--unified=0`. To bypass these
        checks use `--unidiff-zero`.
 +
-Note, for the reasons stated above usage of context-free patches is
+Note, for the reasons stated above, the usage of context-free patches is
 discouraged.
 
 --apply::
@@ -159,9 +159,9 @@ discouraged.
 
 --allow-binary-replacement::
 --binary::
-       Historically we did not allow binary patch applied
+       Historically we did not allow binary patch application
        without an explicit permission from the user, and this
-       flag was the way to do so.  Currently we always allow binary
+       flag was the way to do so.  Currently, we always allow binary
        patch application, so this is a no-op.
 
 --exclude=<path-pattern>::
@@ -257,7 +257,7 @@ the `--unsafe-paths` option to override this safety check.  This option
 has no effect when `--index` or `--cached` is in use.
 
 --allow-empty::
-       Don't return error for patches containing no diff. This includes
+       Don't return an error for patches containing no diff. This includes
        empty patches and patches with commit text only.
 
 CONFIGURATION
index 6bab201d37548dd5c4f911baf981f3fc1995a889..98526f2bebad16e2814f084005c12c2359378ec2 100644 (file)
@@ -21,14 +21,14 @@ structure for the named tree, and writes it out to the standard
 output.  If <prefix> is specified it is
 prepended to the filenames in the archive.
 
-'git archive' behaves differently when given a tree ID versus when
-given a commit ID or tag ID.  In the first case the current time is
-used as the modification time of each file in the archive.  In the latter
-case the commit time as recorded in the referenced commit object is
-used instead.  Additionally the commit ID is stored in a global
-extended pax header if the tar format is used; it can be extracted
-using 'git get-tar-commit-id'. In ZIP files it is stored as a file
-comment.
+'git archive' behaves differently when given a tree ID as opposed to a
+commit ID or tag ID. When a tree ID is provided, the current time is
+used as the modification time of each file in the archive. On the
+other hand, when a commit ID or tag ID is provided, the commit time as
+recorded in the referenced commit object is used instead.
+Additionally the commit ID is stored in a global extended pax header
+if the tar format is used; it can be extracted using 'git
+get-tar-commit-id'. In ZIP files it is stored as a file comment.
 
 OPTIONS
 -------
index 7872dba3aefa3de62175f0e88bfac1473bbe0723..191b4a42b6dcca3f270e9087ad9f7aa6b214f0e0 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 The command takes various subcommands, and different options depending
 on the subcommand:
 
- git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>]
+ git bisect start [--term-(new|bad)=<term-new> --term-(old|good)=<term-old>]
                  [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]
  git bisect (bad|new|<term-new>) [<rev>]
  git bisect (good|old|<term-old>) [<rev>...]
@@ -26,7 +26,7 @@ on the subcommand:
  git bisect (visualize|view)
  git bisect replay <logfile>
  git bisect log
- git bisect run <cmd>...
+ git bisect run <cmd> [<arg>...]
  git bisect help
 
 This command uses a binary search algorithm to find which commit in
index f69a871a96f7589015c723ccdfdd95c6c1d610ed..5720d04ffe4e7434c1798cad4833e233fc71f534 100644 (file)
@@ -77,7 +77,7 @@ include::blame-options.txt[]
 
 -e::
 --show-email::
-       Show the author email instead of author name (Default: off).
+       Show the author email instead of the author name (Default: off).
        This can also be controlled via the `blame.showEmail` config
        option.
 
@@ -100,7 +100,7 @@ When neither `--porcelain` nor `--incremental` option is specified,
 `git blame` will output annotation for each line with:
 
 - abbreviated object name for the commit the line came from;
-- author ident (by default author name and date, unless `-s` or `-e`
+- author ident (by default the author name and date, unless `-s` or `-e`
   is specified); and
 - line number
 
@@ -128,7 +128,7 @@ at least once for each commit:
 - the filename in the commit that the line is attributed to.
 - the first line of the commit log message ("summary").
 
-The contents of the actual line is output after the above
+The contents of the actual line are output after the above
 header, prefixed by a TAB. This is to allow adding more
 header elements later.
 
@@ -170,7 +170,7 @@ which limits the annotation to the body of the `hello` subroutine.
 
 When you are not interested in changes older than version
 v2.6.18, or changes older than 3 weeks, you can use revision
-range specifiers  similar to 'git rev-list':
+range specifiers similar to 'git rev-list':
 
        git blame v2.6.18.. -- foo
        git blame --since=3.weeks -- foo
index d207da9101a5cfe6441a03360191d3b6b8a73a46..4395aa935438aaac47cfe41f5db7a1eadafe8a25 100644 (file)
@@ -324,7 +324,7 @@ superproject's "origin/main", but tracks the submodule's "origin/main".
        multiple times, in which case the last key becomes the primary
        key. The keys supported are the same as those in `git
        for-each-ref`. Sort order defaults to the value configured for the
-       `branch.sort` variable if exists, or to sorting based on the
+       `branch.sort` variable if it exists, or to sorting based on the
        full refname (including `refs/...` prefix). This lists
        detached HEAD (if present) first, then local branches and
        finally remote-tracking branches. See linkgit:git-config[1].
index eca726e57911af2cc1f0643cafdcf887c20bfa32..392d9eb6aec6b0d43930c93a322f415dc75b4c5c 100644 (file)
@@ -13,10 +13,11 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Captures information about the user's machine, Git client, and repository state,
-as well as a form requesting information about the behavior the user observed,
-into a single text file which the user can then share, for example to the Git
-mailing list, in order to report an observed bug.
+Collects information about the user's machine, Git client, and repository
+state, in addition to a form requesting information about the behavior the
+user observed, and stores it in a single text file which the user can then
+share, for example to the Git mailing list, in order to report an observed
+bug.
 
 The following information is requested from the user:
 
index 6e4f3aaf34c9579004be4c3f8d644287913f1505..cb5a6c8f335e128408e9b6b54cbb4037751e7932 100644 (file)
@@ -29,7 +29,7 @@ OPTIONS
 
 --stdin::
        Read pathnames from the standard input, one per line,
-       instead of from the command-line.
+       instead of from the command line.
 
 -z::
        The output format is modified to be machine-parsable.
@@ -38,7 +38,7 @@ OPTIONS
 
 --source=<tree-ish>::
        Check attributes against the specified tree-ish. It is common to
-       specify the source tree by naming a commit, branch or tag associated
+       specify the source tree by naming a commit, branch, or tag associated
        with it.
 
 \--::
@@ -60,7 +60,7 @@ unless `-z` is in effect, in which case NUL is used as delimiter:
 
 
 <path> is the path of a file being queried, <attribute> is an attribute
-being queried and <info> can be either:
+being queried, and <info> can be either:
 
 'unspecified';; when the attribute is not defined for the path.
 'unset';;      when the attribute is defined as false.
index 2892799e32f9855bba3b5244e7051d11618fa846..3e3b4e344629d951e7318dace83f38d5752fc76c 100644 (file)
@@ -50,7 +50,7 @@ linkgit:gitignore[5].
        with a NUL character instead of a linefeed character.
 
 -n, --non-matching::
-       Show given paths which don't match any pattern.  This only
+       Show given paths which don't match any pattern.  This only
        makes sense when `--verbose` is enabled, otherwise it would
        not be possible to distinguish between paths which match a
        pattern and those which don't.
index ee6a4144fbef1aebf422c2e393b6d38c8fb4fb60..2aacfd18088d6506bfd8aa3ca7380888e8dbcffa 100644 (file)
@@ -48,7 +48,7 @@ Git imposes the following rules on how references are named:
 
 . They cannot begin or end with a slash `/` or contain multiple
   consecutive slashes (see the `--normalize` option below for an
-  exception to this rule)
+  exception to this rule).
 
 . They cannot end with a dot `.`.
 
@@ -85,7 +85,7 @@ The rule `git check-ref-format --branch $name` implements
 may be stricter than what `git check-ref-format refs/heads/$name`
 says (e.g. a dash may appear at the beginning of a ref component,
 but it is explicitly forbidden at the beginning of a branch name).
-When run with `--branch` option in a repository, the input is first
+When run with the `--branch` option in a repository, the input is first
 expanded for the ``previous checkout syntax''
 `@{-n}`.  For example, `@{-1}` is a way to refer the last thing that
 was checked out using "git switch" or "git checkout" operation.
index 01dbd5cbf540ea96de2a1fd9b9ce0580077c29fa..faf8d6ca36fb7c3bfd7a8e880efe284746cdc94d 100644 (file)
@@ -18,7 +18,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Will copy all files listed from the index to the working directory
+Copies all listed files from the index to the working directory
 (not overwriting existing files).
 
 OPTIONS
@@ -53,11 +53,11 @@ OPTIONS
 
 --stage=<number>|all::
        Instead of checking out unmerged entries, copy out the
-       files from named stage.  <number> must be between 1 and 3.
+       files from the named stage.  <number> must be between 1 and 3.
        Note: --stage=all automatically implies --temp.
 
 --temp::
-       Instead of copying the files to the working directory
+       Instead of copying the files to the working directory,
        write the content to temporary files.  The temporary name
        associations will be written to stdout.
 
@@ -66,8 +66,8 @@ OPTIONS
        set.
 
 --stdin::
-       Instead of taking list of paths from the command line,
-       read list of paths from the standard input.  Paths are
+       Instead of taking list of paths from the command line,
+       read the list of paths from the standard input.  Paths are
        separated by LF (i.e. one path per line) by default.
 
 -z::
index 4af0904f4729b463d3b63bf3479f5e4b313773fd..240c54639e8e85b5a3ecf1fb8fec0266614ec9b5 100644 (file)
@@ -12,8 +12,10 @@ SYNOPSIS
 'git checkout' [-q] [-f] [-m] --detach [<branch>]
 'git checkout' [-q] [-f] [-m] [--detach] <commit>
 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] <new-branch>] [<start-point>]
-'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>...
-'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]
+'git checkout' [-f] <tree-ish> [--] <pathspec>...
+'git checkout' [-f] <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]
+'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>...
+'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul]
 'git checkout' (-p|--patch) [<tree-ish>] [--] [<pathspec>...]
 
 DESCRIPTION
@@ -41,7 +43,7 @@ $ git checkout -b <branch> --track <remote>/<branch>
 You could omit `<branch>`, in which case the command degenerates to
 "check out the current branch", which is a glorified no-op with
 rather expensive side-effects to show only the tracking information,
-if exists, for the current branch.
+if it exists, for the current branch.
 
 'git checkout' -b|-B <new-branch> [<start-point>]::
 
@@ -260,7 +262,8 @@ and mark the resolved paths with `git add` (or `git rm` if the merge
 should result in deletion of the path).
 +
 When checking out paths from the index, this option lets you recreate
-the conflicted merge in the specified paths.
+the conflicted merge in the specified paths.  This option cannot be
+used when checking out paths from a tree-ish.
 +
 When switching branches with `--merge`, staged changes may be lost.
 
index 5e1a3d5148c5ebaeb4e9110fc382dbeed5383b2d..69331e3f05a13eed6ffb084e292f8452b241f13c 100644 (file)
@@ -103,7 +103,7 @@ filter by pattern::
    This shows the files and directories to be deleted and issues an
    "Input ignore patterns>>" prompt. You can input space-separated
    patterns to exclude files and directories from deletion.
-   E.g. "*.c *.h" will excludes files end with ".c" and ".h" from
+   E.g. "*.c *.h" will exclude files ending with ".c" and ".h" from
    deletion. When you are satisfied with the filtered result, press
    ENTER (empty) back to the main menu.
 
index 225c6c9f2e5f8f513e1e56ae77bc45d8c2097da4..a6cef5d82038771c5f7e91f788f14de6394de158 100644 (file)
@@ -541,7 +541,7 @@ DISCUSSION
 ----------
 
 Though not required, it's a good idea to begin the commit message
-with a single short (less than 50 character) line summarizing the
+with a single short (no more than 50 characters) line summarizing the
 change, followed by a blank line and then a more thorough description.
 The text up to the first blank line in a commit message is treated
 as the commit title, and that title is used throughout Git.
index cb9b4d2e460adaa46ee863c37283840c2bdb9333..97f9f1261010f5473b6748dc3dc0a2e0a93fd4f5 100644 (file)
@@ -12,7 +12,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-This counts the number of unpacked object files and disk space consumed by
+Counts the number of unpacked object files and disk space consumed by
 them, to help you decide when it is a good time to repack.
 
 
@@ -20,7 +20,7 @@ OPTIONS
 -------
 -v::
 --verbose::
-       Report in more detail:
+       Provide more detailed reports:
 +
 count: the number of loose objects
 +
@@ -33,7 +33,7 @@ size-pack: disk space consumed by the packs, in KiB (unless -H is specified)
 prune-packable: the number of loose objects that are also present in
 the packs. These objects could be pruned using `git prune-packed`.
 +
-garbage: the number of files in object database that are neither valid loose
+garbage: the number of files in the object database that are neither valid loose
 objects nor valid packs
 +
 size-garbage: disk space consumed by garbage files, in KiB (unless -H is
index f473994a864e9575d57844e1640e8dfb4eea00dd..487cc557a87feaa688d5e333dcecd2f83eb1ec48 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 
 This command caches credentials for use by future Git programs.
 The stored credentials are kept in memory of the cache-daemon
-process (instead of written to a file) and are forgotten after a
+process (instead of being written to a file) and are forgotten after a
 configurable timeout. Credentials are forgotten sooner if the
 cache-daemon dies, for example if the system restarts. The cache
 is accessible over a Unix domain socket, restricted to the current
index 76b0798856336fe739e8325ed1b5716abb099bfe..71864a872642e85734d86f1c52479e7a22b1dfe0 100644 (file)
@@ -33,7 +33,7 @@ OPTIONS
 
        Use `<path>` to lookup and store credentials. The file will have its
        filesystem permissions set to prevent other users on the system
-       from reading it, but will not be encrypted or otherwise
+       from reading it, but it will not be encrypted or otherwise
        protected. If not specified, credentials will be searched for from
        `~/.git-credentials` and `$XDG_CONFIG_HOME/git/credentials`, and
        credentials will be written to `~/.git-credentials` if it exists, or
index a220afed4f35ba2a2ea1d7bd68dd07b1353d3522..918a0aa42b24156ce814ba61cd2006928807ee08 100644 (file)
@@ -94,7 +94,7 @@ unlocked) before it returned `password=secr3t`.
      that `git credential` will ask for a new password in its next
      invocation. In either case, `git credential` should be fed with
      the credential description obtained from step (2) (which also
-     contain the ones provided in step (1)).
+     contains the fields provided in step (1)).
 
 [[IOFMT]]
 INPUT/OUTPUT FORMAT
index 236df516c7313d702f9908229afa4d4030e154ab..e064f91c9e35899abd70f78a6f37158a0794f113 100644 (file)
@@ -138,7 +138,7 @@ otherwise `stderr`.
 --user-path::
 --user-path=<path>::
        Allow {tilde}user notation to be used in requests.  When
-       specified with no parameter, requests to
+       specified with no parameter, a request to
        git://host/{tilde}alice/foo is taken as a request to access
        'foo' repository in the home directory of user `alice`.
        If `--user-path=path` is specified, the same request is
index 591e3801b7b164cfdf412864cee46a7612b21fd2..bf78e3143138136f4e2c3998799a16a19f2dc3bb 100644 (file)
@@ -26,7 +26,7 @@ include::diff-options.txt[]
 -2 --ours::
 -3 --theirs::
 -0::
-       Diff against the "base" version, "our branch" or "their
+       Diff against the "base" version, "our branch", or "their
        branch" respectively.  With these options, diffs for
        merged entries are not shown.
 +
@@ -37,12 +37,12 @@ omit diff output for unmerged entries and just show "Unmerged".
 -c::
 --cc::
        This compares stage 2 (our branch), stage 3 (their
-       branch) and the working tree file and outputs a combined
+       branch), and the working tree file and outputs a combined
        diff, similar to the way 'diff-tree' shows a merge
        commit with these flags.
 
 -q::
-       Remain silent even on nonexistent files
+       Remain silent even for nonexistent files
 
 
 include::diff-format.txt[]
index c30d8f0da8a28ff309185bf3878e3a462074d627..4de1d4c8f11e6065da2c60c0112b72f85af7daa3 100644 (file)
@@ -13,10 +13,10 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Compares the content and mode of the blobs found in a tree object
+Compare the content and mode of the blobs found in a tree object
 with the corresponding tracked files in the working tree, or with the
 corresponding paths in the index.  When <path> arguments are present,
-compares only paths matching those patterns.  Otherwise all tracked
+compare only paths matching those patterns.  Otherwise all tracked
 files are compared.
 
 OPTIONS
index 274d5eaba93dab2cb0374c64ea95934693c73ddf..143318c411a0761777d8a318450b4a71b69870d7 100644 (file)
@@ -15,7 +15,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Compares the content and mode of the blobs found via two tree objects.
+Compare the content and mode of blobs found via two tree objects.
 
 If there is only one <tree-ish> given, the commit is compared with its parents
 (see --stdin below).
@@ -34,10 +34,10 @@ include::diff-options.txt[]
        matching one of the provided pathspecs.
 
 -r::
-        recurse into sub-trees
+       Recurse into sub-trees.
 
 -t::
-       show tree entry itself as well as subtrees.  Implies -r.
+       Show tree entry itself as well as subtrees.  Implies -r.
 
 --root::
        When `--root` is specified the initial commit will be shown as a big
@@ -78,7 +78,7 @@ commits (but not trees).
        By default, 'git diff-tree --stdin' shows differences,
        either in machine-readable form (without `-p`) or in patch
        form (with `-p`).  This output can be suppressed.  It is
-       only useful with `-v` flag.
+       only useful with the `-v` flag.
 
 -v::
        This flag causes 'git diff-tree --stdin' to also show
@@ -104,10 +104,10 @@ include::pretty-options.txt[]
        This flag changes the way a merge commit patch is displayed,
        in a similar way to the `-c` option. It implies the `-c`
        and `-p` options and further compresses the patch output
-       by omitting uninteresting hunks whose the contents in the parents
+       by omitting uninteresting hunks whose contents in the parents
        have only two variants and the merge result picks one of them
        without modification.  When all hunks are uninteresting, the commit
-       itself and the commit log message is not shown, just like in any other
+       itself and the commit log message are not shown, just like in any other
        "empty diff" case.
 
 --combined-all-paths::
index ac0ac6fa02205a5946beaafc538c0764bee85cb4..50cb080085e7708eb117e58fc42920c710452b31 100644 (file)
@@ -36,7 +36,7 @@ OPTIONS
 
 --rotate-to=<file>::
        Start showing the diff for the given path,
-       the paths before it will move to end and output.
+       the paths before it will move to the end and output.
 
 --skip-to=<file>::
        Start showing the diff for the given path, skipping all
@@ -78,7 +78,7 @@ with custom merge tool commands and has the same value as `$MERGED`.
        Print a list of diff tools that may be used with `--tool`.
 
 --[no-]symlinks::
-       'git difftool''s default behavior is create symlinks to the
+       'git difftool''s default behavior is to create symlinks to the
        working tree when run in `--dir-diff` mode and the right-hand
        side of the comparison yields the same content as the file in
        the working tree.
index 8b5dd6add006d111688fc1193d77ebe6b45422a5..bd7b1e0a2eaf3ebf595475580d81d6771b8b4166 100644 (file)
@@ -622,7 +622,7 @@ in octal.  Git only supports the following modes:
 * `100755` or `755`: A normal, but executable, file.
 * `120000`: A symlink, the content of the file will be the link target.
 * `160000`: A gitlink, SHA-1 of the object refers to a commit in
-  another repository. Git links can only be specified by SHA or through
+  another repository. Git links can only be specified either by SHA or through
   a commit mark. They are used to implement submodules.
 * `040000`: A subdirectory.  Subdirectories can only be specified by
   SHA or through a tree mark set with `--import-marks`.
@@ -1353,7 +1353,7 @@ the marks back to the source repository, it is easy to verify the
 accuracy and completeness of the import by comparing each Git
 commit to the corresponding source revision.
 
-Coming from a system such as Perforce or Subversion this should be
+Coming from a system such as Perforce or Subversion, this should be
 quite simple, as the fast-import mark can also be the Perforce changeset
 number or the Subversion revision number.
 
index 46747d5f429164f817444cd502d8bff4dc5cbe4d..b3467664d30bde111af06ec0e915e6def2b1b4b2 100644 (file)
@@ -69,7 +69,7 @@ be in a separate packet, and the list must end with a flush packet.
 
 --upload-pack=<git-upload-pack>::
        Use this to specify the path to 'git-upload-pack' on the
-       remote side, if is not found on your $PATH.
+       remote side, if it is not found on your $PATH.
        Installations of sshd ignores the user's environment
        setup scripts for login shells (e.g. .bash_profile) and
        your privately installed git may not be found on the system
index 11b2bc3121626d047b415f805e98b380be0ef1e4..e86d5700ddfe02e72e1cad809f29c555b15b6495 100644 (file)
@@ -303,7 +303,11 @@ Fields that have name-email-date tuple as its value (`author`,
 and `date` to extract the named component.  For email fields (`authoremail`,
 `committeremail` and `taggeremail`), `:trim` can be appended to get the email
 without angle brackets, and `:localpart` to get the part before the `@` symbol
-out of the trimmed email.
+out of the trimmed email. In addition to these, the `:mailmap` option and the
+corresponding `:mailmap,trim` and `:mailmap,localpart` can be used (order does
+not matter) to get values of the name and email according to the .mailmap file
+or according to the file set in the mailmap.file or mailmap.blob configuration
+variable (see linkgit:gitmailmap[5]).
 
 The raw data in an object is `raw`.
 
index 373b46fc0de64f4c7426f683b95f24f95ff9cd84..aaafce24be20c5690adeb9d9e59133285fa10f96 100644 (file)
@@ -55,7 +55,7 @@ A "message" generated by the command consists of three parts:
 * The "patch", which is the "diff -p --stat" output (see
   linkgit:git-diff[1]) between the commit and its parent.
 
-The log message and the patch is separated by a line with a
+The log message and the patch are separated by a line with a
 three-dash line.
 
 There are two ways to specify which commits to operate on.
@@ -215,11 +215,21 @@ is greater than 100 bytes, then the mode will be `message`, otherwise
 If `<mode>` is `none`, both the cover letter subject and body will be
 populated with placeholder text.
 
+--description-file=<file>::
+       Use the contents of <file> instead of the branch's description
+       for generating the cover letter.
+
 --subject-prefix=<subject prefix>::
        Instead of the standard '[PATCH]' prefix in the subject
-       line, instead use '[<subject prefix>]'. This
-       allows for useful naming of a patch series, and can be
-       combined with the `--numbered` option.
+       line, instead use '[<subject prefix>]'. This can be used
+       to name a patch series, and can be combined with the
+       `--numbered` option.
++
+The configuration variable `format.subjectPrefix` may also be used
+to configure a subject prefix to apply to a given repository for
+all patches. This is often useful on mailing lists which receive
+patches for several repositories and can be used to disambiguate
+the patches (with a value of e.g. "PATCH my-project").
 
 --filename-max-length=<n>::
        Instead of the standard 64 bytes, chomp the generated output
@@ -229,9 +239,9 @@ populated with placeholder text.
        variable, or 64 if unconfigured.
 
 --rfc::
-       Alias for `--subject-prefix="RFC PATCH"`. RFC means "Request For
-       Comments"; use this when sending an experimental patch for
-       discussion rather than application.
+       Prepends "RFC" to the subject prefix (producing "RFC PATCH" by
+       default). RFC means "Request For Comments"; use this when sending
+       an experimental patch for discussion rather than application.
 
 -v <n>::
 --reroll-count=<n>::
index b6a0f8a085ca14060681b6ed1ec812728d6e799f..5b82e4605c2e91dc647330409af81728b665a80a 100644 (file)
@@ -24,7 +24,7 @@ OPTIONS
        An object to treat as the head of an unreachability trace.
 +
 If no objects are given, 'git fsck' defaults to using the
-index file, all SHA-1 references in `refs` namespace, and all reflogs
+index file, all SHA-1 references in the `refs` namespace, and all reflogs
 (unless --no-reflogs is given) as heads.
 
 --unreachable::
@@ -64,7 +64,7 @@ index file, all SHA-1 references in `refs` namespace, and all reflogs
 --connectivity-only::
        Check only the connectivity of reachable objects, making sure
        that any objects referenced by a reachable tag, commit, or tree
-       is present. This speeds up the operation by avoiding reading
+       are present. This speeds up the operation by avoiding reading
        blobs entirely (though it does still check that referenced blobs
        exist). This will detect corruption in commits and trees, but
        not do any semantic checks (e.g., for format errors). Corruption
@@ -79,7 +79,7 @@ care about this output and want to speed it up further.
        recorded with g+w bit set, which was created by older
        versions of Git.  Existing repositories, including the
        Linux kernel, Git itself, and sparse repository have old
-       objects that triggers this check, but it is recommended
+       objects that trigger this check, but it is recommended
        to check new projects with this flag.
 
 --verbose::
index 8238eadb0e166a97537fdfd28296df6c31e7e342..8585d19f4d89870027df745197d6dc85a1944db4 100644 (file)
@@ -70,10 +70,10 @@ the change (as happening against the super repo).  However, the client
 will properly ignore these extra events, so performance may be affected
 but it will not cause an incorrect result.
 
-By default, the fsmonitor daemon refuses to work against network-mounted
+By default, the fsmonitor daemon refuses to work with network-mounted
 repositories; this may be overridden by setting `fsmonitor.allowRemote` to
 `true`. Note, however, that the fsmonitor daemon is not guaranteed to work
-correctly with all network-mounted repositories and such use is considered
+correctly with all network-mounted repositories, so such use is considered
 experimental.
 
 On Mac OS, the inter-process communication (IPC) between various Git
@@ -83,10 +83,10 @@ but not on network-mounted filesystems, NTFS, or FAT32.  Other filesystems
 may or may not have the needed support; the fsmonitor daemon is not guaranteed
 to work with these filesystems and such use is considered experimental.
 
-By default, the socket is created in the `.git` directory, however, if the
-`.git` directory is on a network-mounted filesystem, it will be instead be
+By default, the socket is created in the `.git` directory.  However, if the
+`.git` directory is on a network-mounted filesystem, it will instead be
 created at `$HOME/.git-fsmonitor-*` unless `$HOME` itself is on a
-network-mounted filesystem in which case you must set the configuration
+network-mounted filesystem, in which case you must set the configuration
 variable `fsmonitor.socketDir` to the path of a directory on a Mac OS native
 filesystem in which to create the socket file.
 
index 90806fd26aa4ac0d1fef93d25384af3799818896..b5561c458a101c32a51ccca8599d4898e166b174 100644 (file)
@@ -59,6 +59,13 @@ be performed as well.
        cruft pack instead of storing them as loose objects. `--cruft`
        is on by default.
 
+--max-cruft-size=<n>::
+       When packing unreachable objects into a cruft pack, limit the
+       size of new cruft packs to be at most `<n>` bytes. Overrides any
+       value specified via the `gc.maxCruftSize` configuration. See
+       the `--max-cruft-size` option of linkgit:git-repack[1] for
+       more.
+
 --prune=<date>::
        Prune loose objects older than date (default is 2 weeks ago,
        overridable by the config variable `gc.pruneExpire`).
index ac44d85b0b5c7f12a2d5473b3be0b0e4511cf58f..b537bb45b138f49e8298a9fdf8f26866fe8e9b72 100644 (file)
@@ -20,7 +20,7 @@ and extract the commit ID stored in it.  It reads only the first
 1024 bytes of input, thus its runtime is not influenced by the size
 of the tar archive very much.
 
-If no commit ID is found, 'git get-tar-commit-id' quietly exists with a
+If no commit ID is found, 'git get-tar-commit-id' quietly exits with a
 return code of 1.  This can happen if the archive had not been created
 using 'git archive' or if the first parameter of 'git archive' had been
 a tree ID instead of a commit ID or tag.
index dabdbe8471de5d36bf55589aa74a270901ff882e..0d0103c780af8c454db02a33c909343fb7bd51be 100644 (file)
@@ -337,7 +337,7 @@ The `--threads` option (and the grep.threads configuration) will be ignored when
 
 When grepping the object store (with `--cached` or giving tree objects), running
 with multiple threads might perform slower than single threaded if `--textconv`
-is given and there're too many text conversions. So if you experience low
+is given and there are too many text conversions. So if you experience low
 performance in this case, it might be desirable to use `--threads=1`.
 
 CONFIGURATION
index 8577f7a7d4087d347bddf39b45c9c5365e2dafa6..ef4719ae41c700f5dde933a69ae6c8cf8c5fd3bf 100644 (file)
@@ -39,10 +39,10 @@ OPTIONS
        of from the command-line.
 
 --path::
-       Hash object as it were located at the given path. The location of
-       file does not directly influence on the hash value, but path is
-       used to determine what Git filters should be applied to the object
-       before it can be placed to the object database, and, as result of
+       Hash object as if it were located at the given path. The location of
+       the file does not directly influence the hash value, but the path is
+       used to determine which Git filters should be applied to the object
+       before it can be placed in the object database.  As a result of
        applying filters, the actual blob put into the object database may
        differ from the given file. This option is mainly useful for hashing
        temporary files located outside of the working directory or files
index 2b0b5e390dcb94a651ca92ded8c1542a175f7f09..f0bedc1f96433e6d7667519c1c7d307c46d17dc3 100644 (file)
@@ -42,13 +42,13 @@ former is internally converted into the latter.
 
 To display the linkgit:git[1] man page, use `git help git`.
 
-This page can be displayed with 'git help help' or `git help --help`
+This page can be displayed with 'git help help' or `git help --help`.
 
 OPTIONS
 -------
 -a::
 --all::
-       Prints all the available commands on the standard output.
+       Print all the available commands on the standard output.
 
 --no-external-commands::
        When used with `--all`, exclude the listing of external "git-*"
@@ -59,7 +59,7 @@ OPTIONS
        aliases.
 
 --verbose::
-       When used with `--all` print description for all recognized
+       When used with `--all`, print description for all recognized
        commands. This is the default.
 
 -c::
@@ -69,10 +69,10 @@ OPTIONS
 
 -g::
 --guides::
-       Prints a list of the Git concept guides on the standard output.
+       Print a list of the Git concept guides on the standard output.
 
 --user-interfaces::
-       Prints a list of the repository, command and file interfaces
+       Print a list of the repository, command and file interfaces
        documentation on the standard output.
 +
 In-repository file interfaces such as `.git/info/exclude` are
@@ -85,7 +85,7 @@ pseudo-configuration such as the file-based `.git/hooks/*` interface
 described in linkgit:githooks[5].
 
 --developer-interfaces::
-       Print list of file formats, protocols and other developer
+       Print list of file formats, protocols and other developer
        interfaces documentation on the standard output.
 
 -i::
@@ -109,7 +109,7 @@ other display programs (see below).
        format. A web browser will be used for that purpose.
 +
 The web browser can be specified using the configuration variable
-`help.browser`, or `web.browser` if the former is not set. If none of
+`help.browser`, or `web.browser` if the former is not set. If neither of
 these config variables is set, the 'git web{litdd}browse' helper script
 (called by 'git help') will pick a suitable default. See
 linkgit:git-web{litdd}browse[1] for more information about this.
@@ -129,8 +129,8 @@ line option:
 * "info" corresponds to '-i|--info',
 * "web" or "html" correspond to '-w|--web'.
 
-help.browser, web.browser and browser.<tool>.path
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+help.browser, web.browser, and browser.<tool>.path
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The `help.browser`, `web.browser` and `browser.<tool>.path` will also
 be checked if the 'web' format is chosen (either by command-line
index 3407f3c2c078264505d28455c93c6ec5424234b1..f6cc72d2ca9c7090c5391618d67abbfe1a1dd8e6 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-A command interface to running git hooks (see linkgit:githooks[5]),
+A command interface for running git hooks (see linkgit:githooks[5]),
 for use by other scripted git commands.
 
 SUBCOMMANDS
@@ -32,7 +32,7 @@ OPTIONS
 -------
 
 --to-stdin::
-       For "run"; Specify a file which will be streamed into the
+       For "run"; specify a file which will be streamed into the
        hook's stdin. The hook will receive the entire file from
        beginning to EOF.
 
index 0c5c0dde19f0b0f4fe271c1d9e7a5dcc01efe48e..f37ddaded82b42b5093ad9b1ea791c2979d743f1 100644 (file)
@@ -23,7 +23,7 @@ discussion of `GIT_PROTOCOL` in the ENVIRONMENT section below.
 It verifies that the directory has the magic file
 "git-daemon-export-ok", and it will refuse to export any Git directory
 that hasn't explicitly been marked for export this way (unless the
-`GIT_HTTP_EXPORT_ALL` environmental variable is set).
+`GIT_HTTP_EXPORT_ALL` environment variable is set).
 
 By default, only the `upload-pack` service is enabled, which serves
 'git fetch-pack' and 'git ls-remote' clients, which are invoked from
@@ -42,12 +42,12 @@ http.getanyfile::
        any file within the repository, including objects that are
        no longer reachable from a branch but are still present.
        It is enabled by default, but a repository can disable it
-       by setting this configuration item to `false`.
+       by setting this configuration value to `false`.
 
 http.uploadpack::
        This serves 'git fetch-pack' and 'git ls-remote' clients.
        It is enabled by default, but a repository can disable it
-       by setting this configuration item to `false`.
+       by setting this configuration value to `false`.
 
 http.receivepack::
        This serves 'git send-pack' clients, allowing push.  It is
@@ -265,12 +265,12 @@ by the invoking web server, including:
 * QUERY_STRING
 * REQUEST_METHOD
 
-The `GIT_HTTP_EXPORT_ALL` environmental variable may be passed to
+The `GIT_HTTP_EXPORT_ALL` environment variable may be passed to
 'git-http-backend' to bypass the check for the "git-daemon-export-ok"
 file in each repository before allowing export of that repository.
 
 The `GIT_HTTP_MAX_REQUEST_BUFFER` environment variable (or the
-`http.maxRequestBuffer` config variable) may be set to change the
+`http.maxRequestBuffer` config option) may be set to change the
 largest ref negotiation request that git will handle during a fetch; any
 fetch requiring a larger buffer will not succeed.  This value should not
 normally need to be changed, but may be helpful if you are fetching from
index 319062c021bb2c44686cd993898d502405531646..4ec7c68d3b9ecd18b3358563c2c1de4addff6eb0 100644 (file)
@@ -31,7 +31,7 @@ commit-id::
        Report what is downloaded.
 
 -w <filename>::
-        Writes the commit-id into the filename under $GIT_DIR/refs/<filename> on
+       Writes the commit-id into the specified filename under $GIT_DIR/refs/<filename> on
         the local end after the transfer is complete.
 
 --stdin::
index 7c6a6dd7f6a7fc9c75bf0ae595b12732d5c17765..ce0d80821259277f9112ad28b002f4c72bdb8348 100644 (file)
@@ -13,12 +13,12 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Sends missing objects to remote repository, and updates the
+Sends missing objects to the remote repository, and updates the
 remote branch.
 
 *NOTE*: This command is temporarily disabled if your libcurl
 is older than 7.16, as the combination has been reported
-not to work and sometimes corrupts repository.
+not to work and sometimes corrupts the repository.
 
 OPTIONS
 -------
@@ -44,7 +44,7 @@ OPTIONS
 -d::
 -D::
        Remove <ref> from remote repository.  The specified branch
-       cannot be the remote HEAD.  If -d is specified the following
+       cannot be the remote HEAD.  If -d is specified, the following
        other conditions must also be met:
 
        - Remote HEAD must resolve to an object that exists locally
@@ -83,8 +83,8 @@ and where it is pushed is determined by using the destination side.
 Without `--force`, the <src> ref is stored at the remote only if
 <dst> does not exist, or <dst> is a proper subset (i.e. an
 ancestor) of <src>.  This check, known as "fast-forward check",
-is performed in order to avoid accidentally overwriting the
-remote ref and lose other peoples' commits from there.
+is performed to avoid accidentally overwriting the
+remote ref and losing other peoples' commits from there.
 
 With `--force`, the fast-forward check is disabled for all refs.
 
index 4e71c256ecb08fe44ef656c85b7246e6f2f458b1..6486620c3d8f2a2d7a9bb623c362d02465b06be4 100644 (file)
@@ -16,10 +16,10 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Reads a packed archive (.pack) from the specified file, and
-builds a pack index file (.idx) for it. Optionally writes a
+Reads a packed archive (.pack) from the specified file,
+builds a pack index file (.idx) for it, and optionally writes a
 reverse-index (.rev) for the specified pack. The packed
-archive together with the pack index can then be placed in
+archive, together with the pack index, can then be placed in
 the objects/pack/ directory of a Git repository.
 
 
@@ -68,8 +68,8 @@ OPTIONS
        updated to use objects contained in the pack.
 
 --keep=<msg>::
-       Like --keep create a .keep file before moving the index into
-       its final destination, but rather than creating an empty file
+       Like --keep, create a .keep file before moving the index into
+       its final destination.  However, instead of creating an empty file
        place '<msg>' followed by an LF into the .keep file.  The '<msg>'
        message can later be searched for within all .keep files to
        locate any which have outlived their usefulness.
index 160dea1372cd9ae87f1bad9744e2ae045ed1b5b6..6f0d2973bf444a510ae4989dee9aa1e360eee247 100644 (file)
@@ -29,7 +29,7 @@ to use instead of `./.git` for the base of the repository.
 
 If the object storage directory is specified via the
 `$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories
-are created underneath - otherwise the default `$GIT_DIR/objects`
+are created underneath; otherwise, the default `$GIT_DIR/objects`
 directory is used.
 
 Running 'git init' in an existing repository is safe. It will not
@@ -66,10 +66,10 @@ DIRECTORY" section below.)
 
 Instead of initializing the repository as a directory to either `$GIT_DIR` or
 `./.git/`, create a text file there containing the path to the actual
-repository.  This file acts as filesystem-agnostic Git symbolic link to the
+repository.  This file acts as filesystem-agnostic Git symbolic link to the
 repository.
 +
-If this is reinitialization, the repository will be moved to the specified path.
+If this is reinitialization, the repository will be moved to the specified path.
 
 -b <branch-name>::
 --initial-branch=<branch-name>::
@@ -99,7 +99,7 @@ specified.
 
 'group' (or 'true')::
 
-Make the repository group-writable, (and g+sx, since the git group may be not
+Make the repository group-writable, (and g+sx, since the git group may not be
 the primary group of all users). This is used to loosen the permissions of an
 otherwise safe umask(2) value. Note that the umask still applies to the other
 permission bits (e.g. if umask is '0022', using 'group' will not remove read
@@ -115,7 +115,7 @@ Same as 'group', but make the repository readable by all users.
 '<perm>' is a 3-digit octal number prefixed with `0` and each file
 will have mode '<perm>'. '<perm>' will override users' umask(2)
 value (and not only loosen permissions as 'group' and 'all'
-does). '0640' will create a repository which is group-readable, but
+do). '0640' will create a repository which is group-readable, but
 not group-writable or accessible to others. '0660' will create a repo
 that is readable and writable to the current user and group, but
 inaccessible to others (directories and executable files get their
index 55d89614661c5c46c8dd69fb149cfec70d72fc85..418265f044d65000e9ae22235b9801644f9c2170 100644 (file)
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 'git interpret-trailers' [--in-place] [--trim-empty]
-                       [(--trailer <token>[(=|:)<value>])...]
+                       [(--trailer (<key>|<keyAlias>)[(=|:)<value>])...]
                        [--parse] [<file>...]
 
 DESCRIPTION
@@ -31,10 +31,15 @@ the last two lines starting with "Signed-off-by" are trailers.
 
 This command reads commit messages from either the
 <file> arguments or the standard input if no <file> is specified.
-If `--parse` is specified, the output consists of the parsed trailers.
-Otherwise, this command applies the arguments passed using the
-`--trailer` option, if any, to each input file. The result is emitted on the
-standard output.
+If `--parse` is specified, the output consists of the parsed trailers
+coming from the input, without influencing them with any command line
+options or configuration variables.
+
+Otherwise, this command applies `trailer.*` configuration variables
+(which could potentially add new trailers, as well as reposition them),
+as well as any command line arguments that can override configuration
+variables (such as `--trailer=...` which could also add new trailers),
+to each input file. The result is emitted on the standard output.
 
 This command can also operate on the output of linkgit:git-format-patch[1],
 which is more elaborate than a plain commit message. Namely, such output
@@ -48,22 +53,32 @@ are applied to each input and the way any existing trailer in
 the input is changed. They also make it possible to
 automatically add some trailers.
 
-By default, a '<token>=<value>' or '<token>:<value>' argument given
+By default, a '<key>=<value>' or '<key>:<value>' argument given
 using `--trailer` will be appended after the existing trailers only if
-the last trailer has a different (<token>, <value>) pair (or if there
-is no existing trailer). The <token> and <value> parts will be trimmed
+the last trailer has a different (<key>, <value>) pair (or if there
+is no existing trailer). The <key> and <value> parts will be trimmed
 to remove starting and trailing whitespace, and the resulting trimmed
-<token> and <value> will appear in the output like this:
+<key> and <value> will appear in the output like this:
 
 ------------------------------------------------
-token: value
+key: value
 ------------------------------------------------
 
-This means that the trimmed <token> and <value> will be separated by
-`': '` (one colon followed by one space). For convenience, the <token> can be a
-shortened string key (e.g., "sign") instead of the full string which should
-appear before the separator on the output (e.g., "Signed-off-by"). This can be
-configured using the 'trailer.<token>.key' configuration variable.
+This means that the trimmed <key> and <value> will be separated by
+`': '` (one colon followed by one space).
+
+For convenience, a <keyAlias> can be configured to make using `--trailer`
+shorter to type on the command line. This can be configured using the
+'trailer.<keyAlias>.key' configuration variable. The <keyAlias> must be a prefix
+of the full <key> string, although case sensitivity does not matter. For
+example, if you have
+
+------------------------------------------------
+trailer.sign.key "Signed-off-by: "
+------------------------------------------------
+
+in your configuration, you only need to specify `--trailer="sign: foo"`
+on the command line instead of `--trailer="Signed-off-by: foo"`.
 
 By default the new trailer will appear at the end of all the existing
 trailers. If there is no existing trailer, the new trailer will appear
@@ -80,14 +95,14 @@ non-whitespace lines before a line that starts with '---' (followed by a
 space or the end of the line).
 
 When reading trailers, there can be no whitespace before or inside the
-<token>, but any number of regular space and tab characters are allowed
-between the <token> and the separator. There can be whitespaces before,
+<key>, but any number of regular space and tab characters are allowed
+between the <key> and the separator. There can be whitespaces before,
 inside or after the <value>. The <value> may be split over multiple lines
 with each subsequent line starting with at least one whitespace, like
 the "folding" in RFC 822. Example:
 
 ------------------------------------------------
-token: This is a very long value, with spaces and
+key: This is a very long value, with spaces and
   newlines in it.
 ------------------------------------------------
 
@@ -104,35 +119,44 @@ OPTIONS
        the whole trailer will be removed from the output.
        This applies to existing trailers as well as new trailers.
 
---trailer <token>[(=|:)<value>]::
-       Specify a (<token>, <value>) pair that should be applied as a
+--trailer <key>[(=|:)<value>]::
+       Specify a (<key>, <value>) pair that should be applied as a
        trailer to the inputs. See the description of this
        command.
 
 --where <placement>::
 --no-where::
        Specify where all new trailers will be added.  A setting
-       provided with '--where' overrides all configuration variables
+       provided with '--where' overrides the `trailer.where` and any
+       applicable `trailer.<keyAlias>.where` configuration variables
        and applies to all '--trailer' options until the next occurrence of
-       '--where' or '--no-where'. Possible values are `after`, `before`,
-       `end` or `start`.
+       '--where' or '--no-where'. Upon encountering '--no-where', clear the
+       effect of any previous use of '--where', such that the relevant configuration
+       variables are no longer overridden. Possible placements are `after`,
+       `before`, `end` or `start`.
 
 --if-exists <action>::
 --no-if-exists::
        Specify what action will be performed when there is already at
-       least one trailer with the same <token> in the input.  A setting
-       provided with '--if-exists' overrides all configuration variables
+       least one trailer with the same <key> in the input.  A setting
+       provided with '--if-exists' overrides the `trailer.ifExists` and any
+       applicable `trailer.<keyAlias>.ifExists` configuration variables
        and applies to all '--trailer' options until the next occurrence of
-       '--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`,
+       '--if-exists' or '--no-if-exists'. Upon encountering '--no-if-exists, clear the
+       effect of any previous use of '--if-exists, such that the relevant configuration
+       variables are no longer overridden. Possible actions are `addIfDifferent`,
        `addIfDifferentNeighbor`, `add`, `replace` and `doNothing`.
 
 --if-missing <action>::
 --no-if-missing::
        Specify what action will be performed when there is no other
-       trailer with the same <token> in the input.  A setting
-       provided with '--if-missing' overrides all configuration variables
+       trailer with the same <key> in the input.  A setting
+       provided with '--if-missing' overrides the `trailer.ifMissing` and any
+       applicable `trailer.<keyAlias>.ifMissing` configuration variables
        and applies to all '--trailer' options until the next occurrence of
-       '--if-missing' or '--no-if-missing'. Possible actions are `doNothing`
+       '--if-missing' or '--no-if-missing'. Upon encountering '--no-if-missing,
+       clear the effect of any previous use of '--if-missing, such that the relevant
+       configuration variables are no longer overridden. Possible actions are `doNothing`
        or `add`.
 
 --only-trailers::
@@ -140,16 +164,19 @@ OPTIONS
 
 --only-input::
        Output only trailers that exist in the input; do not add any
-       from the command-line or by following configured `trailer.*`
-       rules.
+       from the command-line or by applying `trailer.*` configuration
+       variables.
 
 --unfold::
-       Remove any whitespace-continuation in trailers, so that each
-       trailer appears on a line by itself with its full content.
+       If a trailer has a value that runs over multiple lines (aka "folded"),
+       reformat the value into a single line.
 
 --parse::
        A convenience alias for `--only-trailers --only-input
-       --unfold`.
+       --unfold`. This makes it easier to only see the trailers coming from the
+       input without influencing them with any command line options or
+       configuration variables, while also making the output machine-friendly with
+       --unfold.
 
 --no-divider::
        Do not treat `---` as the end of the commit message. Use this
@@ -170,11 +197,11 @@ used when another separator is not specified in the config for this
 trailer.
 +
 For example, if the value for this option is "%=$", then only lines
-using the format '<token><sep><value>' with <sep> containing '%', '='
+using the format '<key><sep><value>' with <sep> containing '%', '='
 or '$' and then spaces will be considered trailers. And '%' will be
 the default separator used, so by default trailers will appear like:
-'<token>% <value>' (one percent sign and one space will appear between
-the token and the value).
+'<key>% <value>' (one percent sign and one space will appear between
+the key and the value).
 
 trailer.where::
        This option tells where a new trailer will be added.
@@ -188,41 +215,41 @@ If it is `start`, then each new trailer will appear at the start,
 instead of the end, of the existing trailers.
 +
 If it is `after`, then each new trailer will appear just after the
-last trailer with the same <token>.
+last trailer with the same <key>.
 +
 If it is `before`, then each new trailer will appear just before the
-first trailer with the same <token>.
+first trailer with the same <key>.
 
 trailer.ifexists::
        This option makes it possible to choose what action will be
        performed when there is already at least one trailer with the
-       same <token> in the input.
+       same <key> in the input.
 +
 The valid values for this option are: `addIfDifferentNeighbor` (this
 is the default), `addIfDifferent`, `add`, `replace` or `doNothing`.
 +
 With `addIfDifferentNeighbor`, a new trailer will be added only if no
-trailer with the same (<token>, <value>) pair is above or below the line
+trailer with the same (<key>, <value>) pair is above or below the line
 where the new trailer will be added.
 +
 With `addIfDifferent`, a new trailer will be added only if no trailer
-with the same (<token>, <value>) pair is already in the input.
+with the same (<key>, <value>) pair is already in the input.
 +
 With `add`, a new trailer will be added, even if some trailers with
-the same (<token>, <value>) pair are already in the input.
+the same (<key>, <value>) pair are already in the input.
 +
-With `replace`, an existing trailer with the same <token> will be
+With `replace`, an existing trailer with the same <key> will be
 deleted and the new trailer will be added. The deleted trailer will be
-the closest one (with the same <token>) to the place where the new one
+the closest one (with the same <key>) to the place where the new one
 will be added.
 +
 With `doNothing`, nothing will be done; that is no new trailer will be
-added if there is already one with the same <token> in the input.
+added if there is already one with the same <key> in the input.
 
 trailer.ifmissing::
        This option makes it possible to choose what action will be
        performed when there is not yet any trailer with the same
-       <token> in the input.
+       <key> in the input.
 +
 The valid values for this option are: `add` (this is the default) and
 `doNothing`.
@@ -231,34 +258,40 @@ With `add`, a new trailer will be added.
 +
 With `doNothing`, nothing will be done.
 
-trailer.<token>.key::
-       This `key` will be used instead of <token> in the trailer. At
-       the end of this key, a separator can appear and then some
-       space characters. By default the only valid separator is ':',
-       but this can be changed using the `trailer.separators` config
-       variable.
+trailer.<keyAlias>.key::
+       Defines a <keyAlias> for the <key>. The <keyAlias> must be a
+       prefix (case does not matter) of the <key>. For example, in `git
+       config trailer.ack.key "Acked-by"` the "Acked-by" is the <key> and
+       the "ack" is the <keyAlias>. This configuration allows the shorter
+       `--trailer "ack:..."` invocation on the command line using the "ack"
+       <keyAlias> instead of the longer `--trailer "Acked-by:..."`.
++
+At the end of the <key>, a separator can appear and then some
+space characters. By default the only valid separator is ':',
+but this can be changed using the `trailer.separators` config
+variable.
 +
-If there is a separator, then the key will be used instead of both the
-<token> and the default separator when adding the trailer.
+If there is a separator in the key, then it overrides the default
+separator when adding the trailer.
 
-trailer.<token>.where::
+trailer.<keyAlias>.where::
        This option takes the same values as the 'trailer.where'
        configuration variable and it overrides what is specified by
-       that option for trailers with the specified <token>.
+       that option for trailers with the specified <keyAlias>.
 
-trailer.<token>.ifexists::
+trailer.<keyAlias>.ifexists::
        This option takes the same values as the 'trailer.ifexists'
        configuration variable and it overrides what is specified by
-       that option for trailers with the specified <token>.
+       that option for trailers with the specified <keyAlias>.
 
-trailer.<token>.ifmissing::
+trailer.<keyAlias>.ifmissing::
        This option takes the same values as the 'trailer.ifmissing'
        configuration variable and it overrides what is specified by
-       that option for trailers with the specified <token>.
+       that option for trailers with the specified <keyAlias>.
 
-trailer.<token>.command::
-       Deprecated in favor of 'trailer.<token>.cmd'.
-       This option behaves in the same way as 'trailer.<token>.cmd', except
+trailer.<keyAlias>.command::
+       Deprecated in favor of 'trailer.<keyAlias>.cmd'.
+       This option behaves in the same way as 'trailer.<keyAlias>.cmd', except
        that it doesn't pass anything as argument to the specified command.
        Instead the first occurrence of substring $ARG is replaced by the
        <value> that would be passed as argument.
@@ -266,29 +299,29 @@ trailer.<token>.command::
 Note that $ARG in the user's command is
 only replaced once and that the original way of replacing $ARG is not safe.
 +
-When both 'trailer.<token>.cmd' and 'trailer.<token>.command' are given
-for the same <token>, 'trailer.<token>.cmd' is used and
-'trailer.<token>.command' is ignored.
+When both 'trailer.<keyAlias>.cmd' and 'trailer.<keyAlias>.command' are given
+for the same <keyAlias>, 'trailer.<keyAlias>.cmd' is used and
+'trailer.<keyAlias>.command' is ignored.
 
-trailer.<token>.cmd::
+trailer.<keyAlias>.cmd::
        This option can be used to specify a shell command that will be called
-       once to automatically add a trailer with the specified <token>, and then
-       called each time a '--trailer <token>=<value>' argument is specified to
+       once to automatically add a trailer with the specified <keyAlias>, and then
+       called each time a '--trailer <keyAlias>=<value>' argument is specified to
        modify the <value> of the trailer that this option would produce.
 +
 When the specified command is first called to add a trailer
-with the specified <token>, the behavior is as if a special
-'--trailer <token>=<value>' argument was added at the beginning
+with the specified <keyAlias>, the behavior is as if a special
+'--trailer <keyAlias>=<value>' argument was added at the beginning
 of the "git interpret-trailers" command, where <value>
 is taken to be the standard output of the command with any
 leading and trailing whitespace trimmed off.
 +
-If some '--trailer <token>=<value>' arguments are also passed
+If some '--trailer <keyAlias>=<value>' arguments are also passed
 on the command line, the command is called again once for each
-of these arguments with the same <token>. And the <value> part
+of these arguments with the same <keyAlias>. And the <value> part
 of these arguments, if any, will be passed to the command as its
 first argument. This way the command can produce a <value> computed
-from the <value> passed in the '--trailer <token>=<value>' argument.
+from the <value> passed in the '--trailer <keyAlias>=<value>' argument.
 
 EXAMPLES
 --------
index 2a66cf888074656ce775ad93551603c15fed4ddc..579682172fe45816403f4d5ceffc03949eac5b3a 100644 (file)
@@ -120,11 +120,11 @@ By default, `git log` does not generate any diff output. The options
 below can be used to show the changes made by each commit.
 
 Note that unless one of `--diff-merges` variants (including short
-`-m`, `-c`, and `--cc` options) is explicitly given, merge commits
+`-m`, `-c`, `--cc`, and `--dd` options) is explicitly given, merge commits
 will not show a diff, even if a diff format like `--patch` is
 selected, nor will they match search options like `-S`. The exception
 is when `--first-parent` is in use, in which case `first-parent` is
-the default format.
+the default format for merge commits.
 
 :git-log: 1
 :diff-merges-default: `off`
index 1bc0328bb789283461bc1b7143830a6d88e06eb0..f65a8cd91d4bb40e986c3610b6f1c2b89c719ace 100644 (file)
@@ -25,12 +25,12 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-This merges the file listing in the index with the actual working
+This command merges the file listing in the index with the actual working
 directory list, and shows different combinations of the two.
 
-One or more of the options below may be used to determine the files
+Several flags can be used to determine which files are
 shown, and each file may be printed multiple times if there are
-multiple entries in the index or multiple statuses are applicable for
+multiple entries in the index or if multiple statuses are applicable for
 the relevant file selection options.
 
 OPTIONS
@@ -62,7 +62,7 @@ OPTIONS
        matching an exclude pattern.  When showing "other" files
        (i.e. when used with '-o'), show only those matched by an
        exclude pattern.  Standard ignore rules are not automatically
-       activated, therefore at least one of the `--exclude*` options
+       activated; therefore, at least one of the `--exclude*` options
        is required.
 
 -s::
@@ -141,7 +141,7 @@ OPTIONS
        Show status tags together with filenames.  Note that for
        scripting purposes, linkgit:git-status[1] `--porcelain` and
        linkgit:git-diff-files[1] `--name-status` are almost always
-       superior alternatives, and users should look at
+       superior alternatives; users should look at
        linkgit:git-status[1] `--short` or linkgit:git-diff[1]
        `--name-status` for more user-friendly alternatives.
 +
index e3b2a88c4b75f1f6e23feb8a09030469468d9ca8..3f0a6662c81efb6fee6589aa41c2b8e945c36644 100644 (file)
@@ -34,7 +34,7 @@ OPTIONS
 
 -b::
        If any file doesn't begin with a From line, assume it is a
-       single mail message instead of signaling error.
+       single mail message instead of signaling an error.
 
 -d<prec>::
        Instead of the default 4 digits with leading zeros,
index 805e5a2e3a044b4e1f5a345ecafa2dccb87565ce..51d0f7e94b6a0182089d5d7f48ab9f9d1cb9f572 100644 (file)
@@ -102,9 +102,9 @@ prefetch::
        requested refs within `refs/prefetch/`. Also, tags are not updated.
 +
 This is done to avoid disrupting the remote-tracking branches. The end users
-expect these refs to stay unmoved unless they initiate a fetch.  With prefetch
-task, however, the objects necessary to complete a later real fetch would
-already be obtained, so the real fetch would go faster.  In the ideal case,
+expect these refs to stay unmoved unless they initiate a fetch.  However,
+with the prefetch task, the objects necessary to complete a later real fetch
+would already be obtained, making the real fetch faster.  In the ideal case,
 it will just become an update to a bunch of remote-tracking branches without
 any object transfer.
 
index b01ba3d35650969ff446627e4f2f403eb84c7c0e..5ab957cfbc1420d5dca07a21dbf6708777ee754e 100644 (file)
@@ -18,7 +18,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-'git merge-base' finds best common ancestor(s) between two commits to use
+'git merge-base' finds the best common ancestor(s) between two commits to use
 in a three-way merge.  One common ancestor is 'better' than another common
 ancestor if the latter is an ancestor of the former.  A common ancestor
 that does not have any better common ancestor is a 'best common
@@ -28,7 +28,7 @@ merge base for a pair of commits.
 OPERATION MODES
 ---------------
 
-As the most common special case, specifying only two commits on the
+In the most common special case, specifying only two commits on the
 command line means computing the merge base between the given two commits.
 
 More generally, among the two commits to compute the merge base from,
@@ -64,7 +64,7 @@ from linkgit:git-show-branch[1] when used with the `--merge-base` option.
        the two commits, but also takes into account the reflog of
        <ref> to see if the history leading to <commit> forked from
        an earlier incarnation of the branch <ref> (see discussion
-       on this mode below).
+       of this mode below).
 
 OPTIONS
 -------
@@ -88,7 +88,7 @@ For example, with this topology:
 
 the merge base between 'A' and 'B' is '1'.
 
-Given three commits 'A', 'B' and 'C', `git merge-base A B C` will compute the
+Given three commits 'A', 'B', and 'C', `git merge-base A B C` will compute the
 merge base between 'A' and a hypothetical commit 'M', which is a merge
 between 'B' and 'C'.  For example, with this topology:
 
@@ -130,7 +130,7 @@ When the history involves criss-cross merges, there can be more than one
 ---2---o---o---B
 ....
 
-both '1' and '2' are merge-bases of A and B.  Neither one is better than
+both '1' and '2' are merge bases of A and B.  Neither one is better than
 the other (both are 'best' merge bases).  When the `--all` option is not given,
 it is unspecified which best one is output.
 
@@ -204,7 +204,7 @@ will find B0, and
 
     $ git rebase --onto origin/master $fork_point topic
 
-will replay D0, D1 and D on top of B to create a new history of this
+will replay D0, D1, and D on top of B to create a new history of this
 shape:
 
 ....
index ffc4fbf7e89a89b075bb00bafcb041c19adc271f..b50acace3bc367ad7b73d2da10252e6b5f2e0d07 100644 (file)
@@ -19,12 +19,12 @@ DESCRIPTION
 This command has a modern `--write-tree` mode and a deprecated
 `--trivial-merge` mode.  With the exception of the
 <<DEPMERGE,DEPRECATED DESCRIPTION>> section at the end, the rest of
-this documentation describes modern `--write-tree` mode.
+this documentation describes the modern `--write-tree` mode.
 
 Performs a merge, but does not make any new commits and does not read
 from or write to either the working tree or index.
 
-The performed merge will use the same feature as the "real"
+The performed merge will use the same features as the "real"
 linkgit:git-merge[1], including:
 
   * three way content merges of individual files
@@ -253,7 +253,7 @@ Do NOT attempt to guess or make the user guess the conflict types from
 the <<CFI,Conflicted file info>> list.  The information there is
 insufficient to do so.  For example: Rename/rename(1to2) conflicts (both
 sides renamed the same file differently) will result in three different
-file having higher order stages (but each only has one higher order
+files having higher order stages (but each only has one higher order
 stage), with no way (short of the <<IM,Informational messages>> section)
 to determine which three files are related.  File/directory conflicts
 also result in a file with exactly one higher order stage.
@@ -263,7 +263,7 @@ a file with exactly one higher order stage.  In all cases, the
 <<IM,Informational messages>> section has the necessary info, though it
 is not designed to be machine parseable.
 
-Do NOT assume that each paths from <<CFI,Conflicted file info>>, and
+Do NOT assume that each path from <<CFI,Conflicted file info>>, and
 the logical conflicts in the <<IM,Informational messages>> have a
 one-to-one mapping, nor that there is a one-to-many mapping, nor a
 many-to-one mapping.  Many-to-many mappings exist, meaning that each
index 8625c5cb0ec2d31ac264789d80a80b6c5a0c38b9..e8ab34031919fa4d2ac920e1cd706c77c7c65138 100644 (file)
@@ -336,7 +336,7 @@ After seeing a conflict, you can do two things:
 You can work through the conflict with a number of tools:
 
  * Use a mergetool.  `git mergetool` to launch a graphical
-   mergetool which will work you through the merge.
+   mergetool which will work through the merge with you.
 
  * Look at the diffs.  `git diff` will show a three-way diff,
    highlighting changes from both the `HEAD` and `MERGE_HEAD`
index 3e8f59ac0e46abc35b88723492fa2d411b2756ca..0726b560d432884eabc8834a51c2fbd68d74ad92 100644 (file)
@@ -28,22 +28,22 @@ to define the operation mode for the functions listed below.
 FUNCTIONS
 ---------
 get_merge_tool::
-       returns a merge tool. the return code is 1 if we returned a guessed
+       Returns a merge tool. The return code is 1 if we returned a guessed
        merge tool, else 0. '$GIT_MERGETOOL_GUI' may be set to 'true' to
        search for the appropriate guitool.
 
 get_merge_tool_cmd::
-       returns the custom command for a merge tool.
+       Returns the custom command for a merge tool.
 
 get_merge_tool_path::
-       returns the custom path for a merge tool.
+       Returns the custom path for a merge tool.
 
 initialize_merge_tool::
-       bring merge tool specific functions into scope so they can be used or
+       Brings merge tool specific functions into scope so they can be used or
        overridden.
 
 run_merge_tool::
-       launches a merge tool given the tool name and a true/false
+       Launches a merge tool given the tool name and a true/false
        flag to indicate whether a merge base is present.
        '$MERGED', '$LOCAL', '$REMOTE', and '$BASE' must be defined
        for use by the merge tool.
index 07535f6576e81a936c3b65481de7d1b53c4120a8..b9e20c5dcd8c52df8e0782bc5d92e3a5ac5361b2 100644 (file)
@@ -17,7 +17,7 @@ Use `git mergetool` to run one of several merge utilities to resolve
 merge conflicts.  It is typically run after 'git merge'.
 
 If one or more <file> parameters are given, the merge tool program will
-be run to resolve differences on each file (skipping those without
+be run to resolve differences in each file (skipping those without
 conflicts).  Specifying a directory will include all unresolved files in
 that path.  If no <file> names are specified, 'git mergetool' will run
 the merge tool program on every file with merge conflicts.
@@ -49,7 +49,7 @@ variable `mergetool.<tool>.cmd`.
 +
 When 'git mergetool' is invoked with this tool (either through the
 `-t` or `--tool` option or the `merge.tool` configuration
-variable) the configured command line will be invoked with `$BASE`
+variable), the configured command line will be invoked with `$BASE`
 set to the name of a temporary file containing the common base for
 the merge, if available; `$LOCAL` set to the name of a temporary
 file containing the contents of the file on the current branch;
@@ -81,7 +81,7 @@ success of the resolution after the custom tool has exited.
 
 -g::
 --gui::
-       When 'git-mergetool' is invoked with the `-g` or `--gui` option
+       When 'git-mergetool' is invoked with the `-g` or `--gui` option,
        the default merge tool will be read from the configured
        `merge.guitool` variable instead of `merge.tool`. If
        `merge.guitool` is not set, we will fallback to the tool
@@ -115,7 +115,7 @@ These are safe to remove once a file has been merged and its
 `git mergetool` session has completed.
 
 Setting the `mergetool.keepBackup` configuration variable to `false`
-causes `git mergetool` to automatically remove the backup as files
+causes `git mergetool` to automatically remove the backup files as files
 are successfully merged.
 
 BACKEND SPECIFIC HINTS
index b2a2e80d42143a928380bf93e98ac6203442fcc8..006d759962ac61a927d2a08bfa831d1692cc63c4 100644 (file)
@@ -14,7 +14,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-Reads a tag contents on standard input and creates a tag object. The
+Reads a tag's contents on standard input and creates a tag object. The
 output is the new tag's <object> identifier.
 
 This command is mostly equivalent to linkgit:git-hash-object[1]
@@ -27,7 +27,7 @@ write a tag found in `my-tag`:
 The difference is that mktag will die before writing the tag if the
 tag doesn't pass a linkgit:git-fsck[1] check.
 
-The "fsck" check done mktag is stricter than what linkgit:git-fsck[1]
+The "fsck" check done by mktag is stricter than what linkgit:git-fsck[1]
 would run by default in that all `fsck.<msg-id>` messages are promoted
 from warnings to errors (so e.g. a missing "tagger" line is an error).
 
@@ -56,7 +56,7 @@ has a very simple fixed format: four lines of
   tagger <tagger>
 
 followed by some 'optional' free-form message (some tags created
-by older Git may not have `tagger` line).  The message, when it
+by older Git may not have `tagger` line).  The message, when it
 exists, is separated by a blank line from the header.  The
 message part may contain a signature that Git itself doesn't
 care about, but that can be verified with gpg.
index 76b44f4da103872d9b39c893b62286d37b159693..383f09dd333f86d96288a776a1395696473b0fdb 100644 (file)
@@ -25,13 +25,13 @@ OPTIONS
 
 --missing::
        Allow missing objects.  The default behaviour (without this option)
-       is to verify that each tree entry's sha1 identifies an existing
+       is to verify that each tree entry's hash identifies an existing
        object.  This option has no effect on the treatment of gitlink entries
        (aka "submodules") which are always allowed to be missing.
 
 --batch::
        Allow building of more than one tree object before exiting.  Each
-       tree is separated by a single blank line. The final new-line is
+       tree is separated by a single blank line. The final newline is
        optional.  Note - if the `-z` option is used, lines are terminated
        with NUL.
 
index fb0220fd18dc2b99cab472f5b52dfe9930d4bdf9..7f991a3380201fe4c9f66e9c99604dc16b467f73 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Move or rename a file, directory or symlink.
+Move or rename a file, directory, or symlink.
 
  git mv [-v] [-f] [-n] [-k] <source> <destination>
  git mv [-v] [-f] [-n] [-k] <source> ... <destination directory>
index 5c56c870253505395ce3a68216b5b9d329fb02e0..d4f1c4d5945e8ed38c243ecee0920bd6e38219a5 100644 (file)
@@ -26,7 +26,7 @@ OPTIONS
 
 --refs=<pattern>::
        Only use refs whose names match a given shell pattern.  The pattern
-       can be one of branch name, tag name or fully qualified ref name. If
+       can be a branch name, a tag name, or a fully qualified ref name. If
        given multiple times, use refs whose names match any of the given shell
        patterns. Use `--no-refs` to clear any previous ref patterns given.
 
index a9995a932ca2d246db2bf756792c92b2431970eb..e32404c6aaee30f39f3f128839171601999bccb3 100644 (file)
@@ -116,9 +116,7 @@ unreachable object whose mtime is newer than the `--cruft-expiration`).
 +
 Incompatible with `--unpack-unreachable`, `--keep-unreachable`,
 `--pack-loose-unreachable`, `--stdin-packs`, as well as any other
-options which imply `--revs`. Also incompatible with `--max-pack-size`;
-when this option is set, the maximum pack size is not inferred from
-`pack.packSizeLimit`.
+options which imply `--revs`.
 
 --cruft-expiration=<approxidate>::
        If specified, objects are eliminated from the cruft pack if they
@@ -298,8 +296,8 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
        nevertheless.
 
 --filter=<filter-spec>::
-       Requires `--stdout`.  Omits certain objects (usually blobs) from
-       the resulting packfile.  See linkgit:git-rev-list[1] for valid
+       Omits certain objects (usually blobs) from the resulting
+       packfile.  See linkgit:git-rev-list[1] for valid
        `<filter-spec>` forms.
 
 --no-filter::
index 844d6f808a0c2f740d62ac7dbe5ed0c328546262..db742dcfeea84f0afe1eef8a4fdeb939b4e0dadf 100644 (file)
@@ -15,7 +15,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 This program searches the `$GIT_OBJECT_DIRECTORY` for all objects that currently
-exist in a pack file as well as the independent object directories.
+exist in a pack file as well as in the independent object directories.
 
 All such extra objects are removed.
 
index 03552dd86fc412b622aff2bcf8feda8e71711b3e..9a45571b901b1579e6c377a73359d7e4002438db 100644 (file)
@@ -18,7 +18,7 @@ NOTE: In most cases, users should run 'git gc', which calls
 'git prune'. See the section "NOTES", below.
 
 This runs 'git fsck --unreachable' using all the refs
-available in `refs/`, optionally with additional set of
+available in `refs/`, optionally with an additional set of
 objects specified on the command line, and prunes all unpacked
 objects unreachable from any of these head objects from the object database.
 In addition, it
index 003bc7d9ce0771fa9fc18d086d85de898e0a16c7..9b7cfbc5c1d8496c2649b4d6375e699b546fa6c5 100644 (file)
@@ -48,7 +48,7 @@ local one.
 OPTIONS[[OPTIONS]]
 ------------------
 <repository>::
-       The "remote" repository that is destination of a push
+       The "remote" repository that is the destination of a push
        operation.  This parameter can be either a URL
        (see the section <<URLS,GIT URLS>> below) or the name
        of a remote (see the section <<REMOTES,REMOTES>> below).
index 70562dc4c0235d53501bab56ff98af6169b8f968..40e02d92eb2419c32be66a69afb353c6d384c717 100644 (file)
@@ -38,14 +38,14 @@ OPTIONS
        a patch.  At the time of this writing only missing author
        information is warned about.
 
---author Author Name <Author Email>::
+--author 'Author Name <Author Email>'::
        The author name and email address to use when no author
        information can be found in the patch description.
 
 --patches <dir>::
        The directory to find the quilt patches.
 +
-The default for the patch directory is patches
+The default for the patch directory is 'patches'
 or the value of the `$QUILT_PATCHES` environment
 variable.
 
index 0b393715d707015a245eb1afe26dfbe044e8fcd6..fbdbe0befebab63b0316a29aaf420f9538cce43c 100644 (file)
@@ -70,7 +70,7 @@ to revert to color all lines according to the outer diff markers
        Defaults to 60. Try a larger value if `git range-diff` erroneously
        considers a large change a total rewrite (deletion of one commit
        and addition of another), and a smaller one in the reverse case.
-       See the ``Algorithm`` section below for an explanation why this is
+       See the ``Algorithm`` section below for an explanation of why this is
        needed.
 
 --left-only::
@@ -166,7 +166,7 @@ A typical output of `git range-diff` would look like this:
 
 In this example, there are 3 old and 3 new commits, where the developer
 removed the 3rd, added a new one before the first two, and modified the
-commit message of the 2nd commit as well its diff.
+commit message of the 2nd commit as well as its diff.
 
 When the output goes to a terminal, it is color-coded by default, just
 like regular `git diff`'s output. In addition, the first line (adding a
index b09707474df0ec523ac7e53192103a6edf0dca51..1c48c289963063c2e0db605bbb27c35dd803270c 100644 (file)
@@ -25,15 +25,15 @@ fast-forward (i.e. 2-way) merge, or a 3-way merge, with the `-m`
 flag.  When used with `-m`, the `-u` flag causes it to also update
 the files in the work tree with the result of the merge.
 
-Trivial merges are done by 'git read-tree' itself.  Only conflicting paths
-will be in unmerged state when 'git read-tree' returns.
+Only trivial merges are done by 'git read-tree' itself.  Only conflicting paths
+will be in an unmerged state when 'git read-tree' returns.
 
 OPTIONS
 -------
 -m::
        Perform a merge, not just a read.  The command will
        refuse to run if your index file has unmerged entries,
-       indicating that you have not finished previous merge you
+       indicating that you have not finished previous merge you
        started.
 
 --reset::
index e7b39ad244a4bebc90e9c1974e4239ae771c56d4..b4526ca24612803e7b9a5242d706afd0459b7089 100644 (file)
@@ -289,7 +289,7 @@ See also INCOMPATIBLE OPTIONS below.
 +
 See also INCOMPATIBLE OPTIONS below.
 
---empty={drop,keep,ask}::
+--empty=(drop|keep|ask)::
        How to handle commits that are not empty to start and are not
        clean cherry-picks of any upstream commit, but which become
        empty after rebasing (because they contain a subset of already
@@ -695,7 +695,7 @@ be dropped automatically with `--no-keep-empty`).
 Similar to the apply backend, by default the merge backend drops
 commits that become empty unless `-i`/`--interactive` is specified (in
 which case it stops and asks the user what to do).  The merge backend
-also has an `--empty={drop,keep,ask}` option for changing the behavior
+also has an `--empty=(drop|keep|ask)` option for changing the behavior
 of handling commits that become empty.
 
 Directory rename detection
index 65ff518ccff49ea65812b70e9e46fac75733b7e6..20aca92073d8c9d65fc78ce5f3f48a02239333f5 100644 (file)
@@ -18,10 +18,10 @@ information fed from the remote end.
 
 This command is usually not invoked directly by the end user.
 The UI for the protocol is on the 'git send-pack' side, and the
-program pair is meant to be used to push updates to remote
+program pair is meant to be used to push updates to remote
 repository.  For pull operations, see linkgit:git-fetch-pack[1].
 
-The command allows for creation and fast-forwarding of sha1 refs
+The command allows for the creation and fast-forwarding of sha1 refs
 (heads/tags) on the remote end (strictly speaking, it is the
 local end 'git-receive-pack' runs, but to the user who is sitting at
 the send-pack end, it is updating the remote.  Confused?)
index 88ea7e1cc01201ccf68ec1e2b8ccd2cda633903a..b33ee3c9e863b6bb3e5924ee021aeaa9b408466b 100644 (file)
@@ -44,15 +44,15 @@ The following sequences have a special meaning:
        This argument will not be passed to '<command>'. Instead, it
        will cause the helper to start by sending git:// service requests to
        the remote side with the service field set to an appropriate value and
-       the repository field set to rest of the argument. Default is not to send
+       the repository field set to the rest of the argument. Default is not to send
        such a request.
 +
-This is useful if remote side is git:// server accessed over
+This is useful if the remote side is git:// server accessed over
 some tunnel.
 
 '%V' (must be first characters in argument)::
        This argument will not be passed to '<command>'. Instead it sets
-       the vhost field in the git:// service request (to rest of the argument).
+       the vhost field in the git:// service request (to the rest of the argument).
        Default is not to send vhost in such request (if sent).
 
 ENVIRONMENT VARIABLES
@@ -82,12 +82,12 @@ begins with `ext::`.  Examples:
 
 "ext::ssh -i /home/foo/.ssh/somekey user&#64;host.example %S 'foo/repo'"::
        Like host.example:foo/repo, but use /home/foo/.ssh/somekey as
-       keypair and user as user on remote side. This avoids needing to
+       keypair and user as the user on the remote side. This avoids the need to
        edit .ssh/config.
 
 "ext::socat -t3600 - ABSTRACT-CONNECT:/git-server %G/somerepo"::
        Represents repository with path /somerepo accessible over
-       git protocol at abstract namespace address /git-server.
+       git protocol at the abstract namespace address /git-server.
 
 "ext::git-server-alias foo %G/repo"::
        Represents a repository with path /repo accessed using the
index 0451ceb8a26dfc0b4ef06dced69a2005bc4e5448..1dd2648a7904bb73c626019e9ab66e0db009ecf5 100644 (file)
@@ -13,19 +13,19 @@ DESCRIPTION
 -----------
 This helper uses specified file descriptors to connect to a remote Git server.
 This is not meant for end users but for programs and scripts calling git
-fetch, push or archive.
+fetch, push, or archive.
 
 If only <infd> is given, it is assumed to be a bidirectional socket connected
-to remote Git server (git-upload-pack, git-receive-pack or
+to a remote Git server (git-upload-pack, git-receive-pack, or
 git-upload-archive). If both <infd> and <outfd> are given, they are assumed
 to be pipes connected to a remote Git server (<infd> being the inbound pipe
-and <outfd> being the outbound pipe.
+and <outfd> being the outbound pipe).
 
 It is assumed that any handshaking procedures have already been completed
 (such as sending service request for git://) before this helper is started.
 
 <anything> can be any string. It is ignored. It is meant for providing
-information to user in the URL in case that URL is displayed in some
+information to the user in the URL in case that URL is displayed in some
 context.
 
 ENVIRONMENT VARIABLES
@@ -45,7 +45,7 @@ EXAMPLES
 `git push fd::7,8 master (as URL)`::
        Push master, using file descriptor #7 to read data from
        git-receive-pack and file descriptor #8 to write data to
-       same service.
+       the same service.
 
 `git push fd::7,8/bar master`::
        Same as above.
index b63e8abc7d1bd951fa57f74b1b7d213db2916c55..c902512a9e89b07446a606b95cdff52ecc385c44 100644 (file)
@@ -74,6 +74,17 @@ to the new separate pack will be written.
        immediately instead of waiting for the next `git gc` invocation.
        Only useful with `--cruft -d`.
 
+--max-cruft-size=<n>::
+       Repack cruft objects into packs as large as `<n>` bytes before
+       creating new packs. As long as there are enough cruft packs
+       smaller than `<n>`, repacking will cause a new cruft pack to
+       be created containing objects from any combined cruft packs,
+       along with any new unreachable objects. Cruft packs larger than
+       `<n>` will not be modified. When the new cruft pack is larger
+       than `<n>` bytes, it will be split into multiple packs, all of
+       which are guaranteed to be at most `<n>` bytes in size. Only
+       useful with `--cruft -d`.
+
 --expire-to=<dir>::
        Write a cruft pack containing pruned objects (if any) to the
        directory `<dir>`. This option is useful for keeping a copy of
@@ -143,6 +154,29 @@ depth is 4095.
        a larger and slower repository; see the discussion in
        `pack.packSizeLimit`.
 
+--filter=<filter-spec>::
+       Remove objects matching the filter specification from the
+       resulting packfile and put them into a separate packfile. Note
+       that objects used in the working directory are not filtered
+       out. So for the split to fully work, it's best to perform it
+       in a bare repo and to use the `-a` and `-d` options along with
+       this option.  Also `--no-write-bitmap-index` (or the
+       `repack.writebitmaps` config option set to `false`) should be
+       used otherwise writing bitmap index will fail, as it supposes
+       a single packfile containing all the objects. See
+       linkgit:git-rev-list[1] for valid `<filter-spec>` forms.
+
+--filter-to=<dir>::
+       Write the pack containing filtered out objects to the
+       directory `<dir>`. Only useful with `--filter`. This can be
+       used for putting the pack on a separate object directory that
+       is accessed through the Git alternates mechanism. **WARNING:**
+       If the packfile containing the filtered out objects is not
+       accessible, the repo can become corrupt as it might not be
+       possible to access the objects in that packfile. See the
+       `objects` and `objects/info/alternates` sections of
+       linkgit:gitrepository-layout[5].
+
 -b::
 --write-bitmap-index::
        Write a reachability bitmap index as part of the repack. This
@@ -165,7 +199,7 @@ depth is 4095.
        Exclude the given pack from repacking. This is the equivalent
        of having `.keep` file on the pack. `<pack-name>` is the
        pack file name without leading directory (e.g. `pack-123.pack`).
-       The option could be specified multiple times to keep multiple
+       The option can be specified multiple times to keep multiple
        packs.
 
 --unpack-unreachable=<when>::
index f271d758c38230410165238de266db7de2d73f71..4f257126e33cc779d1f407ce61cdfbde3cf9ffad 100644 (file)
@@ -35,7 +35,7 @@ Replacement references will be used by default by all Git commands
 except those doing reachability traversal (prune, pack transfer and
 fsck).
 
-It is possible to disable use of replacement references for any
+It is possible to disable the use of replacement references for any
 command using the `--no-replace-objects` option just after 'git'.
 
 For example if commit 'foo' has been replaced by commit 'bar':
@@ -111,7 +111,7 @@ OPTIONS
 FORMATS
 -------
 
-The following format are available:
+The following formats are available:
 
 * 'short':
        <replaced sha1>
index fa5a42670929a9994b7d3580e1e3c76a69b0ab6a..15dcbb6d91c89eac48623f119e417824b5154e26 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 Generate a request asking your upstream project to pull changes into
 their tree.  The request, printed to the standard output,
 begins with the branch description, summarizes
-the changes and indicates from where they can be pulled.
+the changes, and indicates from where they can be pulled.
 
 The upstream project is expected to have the commit named by
 `<start>` and the output asks it to integrate the changes you made
@@ -50,7 +50,7 @@ EXAMPLES
 --------
 
 Imagine that you built your work on your `master` branch on top of
-the `v1.0` release, and want it to be integrated to the project.
+the `v1.0` release, and want it to be integrated into the project.
 First you push that change to your public repository for others to
 see:
 
index 5964810caa4153a6628ca312669a77a90b41943a..975825b44aa4d01309c46c1923228c372a50e886 100644 (file)
@@ -78,6 +78,8 @@ all modified paths.
 --theirs::
        When restoring files in the working tree from the index, use
        stage #2 ('ours') or #3 ('theirs') for unmerged paths.
+       This option cannot be used when checking out paths from a
+       tree-ish (i.e. with the `--source` option).
 +
 Note that during `git rebase` and `git pull --rebase`, 'ours' and
 'theirs' may appear swapped. See the explanation of the same options
@@ -87,6 +89,8 @@ in linkgit:git-checkout[1] for details.
 --merge::
        When restoring files on the working tree from the index,
        recreate the conflicted merge in the unmerged paths.
+       This option cannot be used when checking out paths from a
+       tree-ish (i.e. with the `--source` option).
 
 --conflict=<style>::
        The same as `--merge` option above, but changes the way the
@@ -101,7 +105,7 @@ in linkgit:git-checkout[1] for details.
        specified. Unmerged paths on the working tree are left alone.
 
 --ignore-skip-worktree-bits::
-       In sparse checkout mode, by default is to only update entries
+       In sparse checkout mode, the default is to only update entries
        matched by `<pathspec>` and sparse patterns in
        $GIT_DIR/info/sparse-checkout. This option ignores the sparse
        patterns and unconditionally restores any files in
@@ -195,7 +199,7 @@ the same as using linkgit:git-reset[1])
 $ git restore --staged hello.c
 ------------
 
-or you can restore both the index and the working tree (this the same
+or you can restore both the index and the working tree (this is the same
 as using linkgit:git-checkout[1])
 
 ------------
index 51029a22715cb3b52fdad8cb868070d9ac626246..2e05c4b510927a66560ade549d9b7a05987e9d33 100644 (file)
@@ -17,9 +17,9 @@ DESCRIPTION
 :git-rev-list: 1
 include::rev-list-description.txt[]
 
-'rev-list' is a very essential Git command, since it
+'rev-list' is an essential Git command, since it
 provides the ability to build and traverse commit ancestry graphs. For
-this reason, it has a lot of different options that enables it to be
+this reason, it has a lot of different options that enable it to be
 used by commands as different as 'git bisect' and
 'git repack'.
 
index f26a7591e3737df6bcf190fc26f0fe2bf50fcd83..912fab9f5e00b6e286b1d80a8164d76224408682 100644 (file)
@@ -14,7 +14,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-Many Git porcelainish commands take mixture of flags
+Many Git porcelainish commands take mixture of flags
 (i.e. parameters that begin with a dash '-') and parameters
 meant for the underlying 'git rev-list' command they use internally
 and flags and parameters for the other commands they use
@@ -36,7 +36,7 @@ Each of these options must appear first on the command line.
 --sq-quote::
        Use 'git rev-parse' in shell quoting mode (see SQ-QUOTE
        section below). In contrast to the `--sq` option below, this
-       mode does only quoting. Nothing else is done to command input.
+       mode only does quoting. Nothing else is done to command input.
 
 Options for --parseopt
 ~~~~~~~~~~~~~~~~~~~~~~
@@ -156,7 +156,7 @@ for another option.
        are not refs (i.e. branch or tag names; or more
        explicitly disambiguating "heads/master" form, when you
        want to name the "master" branch when there is an
-       unfortunately named tag "master"), and show them as full
+       unfortunately named tag "master"), and shows them as full
        refnames (e.g. "refs/heads/master").
 
 Options for Objects
@@ -383,7 +383,7 @@ Each line of options has this format:
        dash to separate words in a multi-word argument hint.
 
 The remainder of the line, after stripping the spaces, is used
-as the help associated to the option.
+as the help associated with the option.
 
 Blank lines are ignored, and lines that don't match this specification are used
 as option group headers (start the line with a space to create such
@@ -398,7 +398,7 @@ some-command [<options>] <args>...
 
 some-command does foo and bar!
 --
-h,help    show the help
+h,help!   show the help
 
 foo       some nifty option --foo
 bar=      some cool option --bar with an argument
@@ -424,10 +424,10 @@ usage: some-command [<options>] <args>...
     some-command does foo and bar!
 
     -h, --help            show the help
-    --foo                 some nifty option --foo
-    --bar ...             some cool option --bar with an argument
-    --baz <arg>           another cool option --baz with a named argument
-    --qux[=<path>]        qux may take a path argument but has meaning by itself
+    --[no-]foo            some nifty option --foo
+    --[no-]bar ...        some cool option --bar with an argument
+    --[no-]baz <arg>      another cool option --baz with a named argument
+    --[no-]qux[=<path>]   qux may take a path argument but has meaning by itself
 
 An option group Header
     -C[...]               option C with an optional argument
index d2e10d3dceb60e0a6c8322a47f8017701338710e..cbe0208834d51f89cf9020bdf55ce96be4221ae5 100644 (file)
@@ -142,6 +142,16 @@ EXAMPLES
        changes. The revert only modifies the working tree and the
        index.
 
+DISCUSSION
+----------
+
+While git creates a basic commit message automatically, it is
+_strongly_ recommended to explain why the original commit is being
+reverted.
+In addition, repeatedly reverting reverts will result in increasingly
+unwieldy subject lines, for example 'Reapply "Reapply "<original subject>""'.
+Please consider rewording these to be shorter and more unique.
+
 CONFIGURATION
 -------------
 
index 81bc23f3cdbb56fbb8e0bd79c2bae40d35772cac..363a26934f54e06a4870cd1b7657082591f80f21 100644 (file)
@@ -163,7 +163,7 @@ will be staged (unless --cached or -n are used).
 
 A submodule is considered up to date when the HEAD is the same as
 recorded in the index, no tracked files are modified and no untracked
-files that aren't ignored are present in the submodules work tree.
+files that aren't ignored are present in the submodule's work tree.
 Ignored files are deemed expendable and won't stop a submodule's work
 tree from being removed.
 
index 492a82323dab8e144e96897a78e1daf22c76be6e..465011bad5021a602ef74169a499e29a61c32e1a 100644 (file)
@@ -68,11 +68,12 @@ This option may be specified multiple times.
        Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
        to edit an introductory message for the patch series.
 +
-When `--compose` is used, git send-email will use the From, Subject, and
-In-Reply-To headers specified in the message. If the body of the message
-(what you type after the headers and a blank line) only contains blank
-(or Git: prefixed) lines, the summary won't be sent, but From, Subject,
-and In-Reply-To headers will be used unless they are removed.
+When `--compose` is used, git send-email will use the From, To, Cc, Bcc,
+Subject, Reply-To, and In-Reply-To headers specified in the message. If
+the body of the message (what you type after the headers and a blank
+line) only contains blank (or Git: prefixed) lines, the summary won't be
+sent, but the headers mentioned above will be used unless they are
+removed.
 +
 Missing From or In-Reply-To headers will be prompted for.
 +
@@ -468,8 +469,8 @@ Information
 
 --dump-aliases::
        Instead of the normal operation, dump the shorthand alias names from
-       the configured alias file(s), one per line in alphabetical order. Note,
-       this only includes the alias name and not its expanded email addresses.
+       the configured alias file(s), one per line in alphabetical order. Note
+       that this only includes the alias name and not its expanded email addresses.
        See 'sendemail.aliasesfile' for more information about aliases.
 
 
index 595b002152fda5dbdedbc65d7feda8d0c4f9ec20..b9e73f2e77b1ccd35ac76ce075a59b362fa7f1dd 100644 (file)
@@ -55,7 +55,7 @@ be in a separate packet, and the list must end with a flush packet.
 --force::
        Usually, the command refuses to update a remote ref that
        is not an ancestor of the local ref used to overwrite it.
-       This flag disables the check.  What this means is that
+       This flag disables the check.  This means that
        the remote repository can lose commits; use it with
        care.
 
@@ -106,7 +106,7 @@ SPECIFYING THE REFS
 There are three ways to specify which refs to update on the
 remote end.
 
-With `--all` flag, all refs that exist locally are transferred to
+With the `--all` flag, all refs that exist locally are transferred to
 the remote side.  You cannot specify any '<ref>' if you use
 this flag.
 
@@ -115,9 +115,9 @@ both on the local side and on the remote side are updated.
 
 When one or more '<ref>' are specified explicitly (whether on the
 command line or via `--stdin`), it can be either a
-single pattern, or a pair of such pattern separated by a colon
+single pattern, or a pair of such patterns separated by a colon
 ":" (this means that a ref name cannot have a colon in it).  A
-single pattern '<name>' is just shorthand for '<name>:<name>'.
+single pattern '<name>' is just shorthand for '<name>:<name>'.
 
 Each pattern pair consists of the source side (before the colon)
 and the destination side (after the colon).  The ref to be
@@ -130,7 +130,7 @@ name. See linkgit:git-rev-parse[1].
  - It is an error if <src> does not match exactly one of the
    local refs.
 
- - It is an error if <dst> matches more than one remote refs.
+ - It is an error if <dst> matches more than one remote ref.
 
  - If <dst> does not match any remote ref, either
 
@@ -143,9 +143,9 @@ name. See linkgit:git-rev-parse[1].
 
 Without `--force`, the <src> ref is stored at the remote only if
 <dst> does not exist, or <dst> is a proper subset (i.e. an
-ancestor) of <src>.  This check, known as "fast-forward check",
-is performed in order to avoid accidentally overwriting the
-remote ref and lose other peoples' commits from there.
+ancestor) of <src>.  This check, known as the "fast-forward check",
+is performed to avoid accidentally overwriting the
+remote ref and losing other people's commits from there.
 
 With `--force`, the fast-forward check is disabled for all refs.
 
index 8632612c31d07818659ff4f68ee567c789e5cd48..bdaf6e5fc4fa79f055e7eb1717464716ea420cc8 100644 (file)
@@ -22,7 +22,7 @@ The 'git sh-setup' scriptlet is designed to be sourced (using
 the normal Git directories and a few helper shell functions.
 
 Before sourcing it, your script should set up a few variables;
-`USAGE` (and `LONG_USAGE`, if any) is used to define message
+`USAGE` (and `LONG_USAGE`, if any) is used to define the message
 given by `usage()` shell function.  `SUBDIRECTORY_OK` can be set
 if the script can run from a subdirectory of the working tree
 (some commands do not).
index 58cf6210cde2d3d1889d9fc9ac1b49bafaaa09e2..c771c89770787356193bd4e241b1fae8069f8d48 100644 (file)
@@ -50,7 +50,7 @@ OPTIONS
 
 --current::
        With this option, the command includes the current
-       branch to the list of revs to be shown when it is not
+       branch in the list of revs to be shown when it is not
        given on the command line.
 
 --topo-order::
@@ -125,7 +125,7 @@ OPTIONS
        default to color output.
        Same as `--color=never`.
 
-Note that --more, --list, --independent and --merge-base options
+Note that --more, --list, --independent, and --merge-base options
 are mutually exclusive.
 
 
@@ -137,14 +137,14 @@ their commit message. The branch head that is pointed at by
 $GIT_DIR/HEAD is prefixed with an asterisk `*` character while other
 heads are prefixed with a `!` character.
 
-Following these N lines, one-line log for each commit is
+Following these N lines, one-line log for each commit is
 displayed, indented N places.  If a commit is on the I-th
 branch, the I-th indentation character shows a `+` sign;
 otherwise it shows a space.  Merge commits are denoted by
 a `-` sign.  Each commit shows a short name that
 can be used as an extended SHA-1 to name that commit.
 
-The following example shows three branches, "master", "fixes"
+The following example shows three branches, "master", "fixes",
 and "mhf":
 
 ------------------------------------------------
@@ -154,7 +154,7 @@ $ git show-branch master fixes mhf
   ! [mhf] Allow "+remote:local" refspec to cause --force when fetching.
 ---
   + [mhf] Allow "+remote:local" refspec to cause --force when fetching.
-  + [mhf~1] Use git-octopus when pulling more than one heads.
+  + [mhf~1] Use git-octopus when pulling more than one head.
  +  [fixes] Introduce "reset type" flag to "git reset"
   + [mhf~2] "git fetch --force".
   + [mhf~3] Use .git/remote/origin, not .git/branches/origin.
@@ -197,7 +197,7 @@ $ git show-branch --reflog="10,1 hour ago" --list master
 
 shows 10 reflog entries going back from the tip as of 1 hour ago.
 Without `--list`, the output also shows how these tips are
-topologically related with each other.
+topologically related to each other.
 
 CONFIGURATION
 -------------
index 2fe274b8faa6d304bb27a7bc2bb9b09810a94217..36e81b9dec45c08a19d5ef4d7840037923d02f8d 100644 (file)
@@ -144,7 +144,7 @@ use:
 -----------------------------------------------------------------------------
 
 This will show "refs/heads/master" but also "refs/remote/other-repo/master",
-if such references exists.
+if such references exist.
 
 When using the `--verify` flag, the command requires an exact path:
 
index 03c06345186f24757cac10c8e939fb13722aaa59..5eb67439affbef1a7fccb6a745220977b6a0a45d 100644 (file)
@@ -61,7 +61,7 @@ EXAMPLES
 --------
 
 `git show v1.0.0`::
-       Shows the tag `v1.0.0`, along with the object the tags
+       Shows the tag `v1.0.0`, along with the object the tag
        points at.
 
 `git show v1.0.0^{tree}`::
index a051b1e8f383abc618397ea7e2ac2f173d30a111..10fecc51a75d4783c68565d25302c50480d626ce 100644 (file)
@@ -245,11 +245,12 @@ U           U    unmerged, both modified
 ....
 
 Submodules have more state and instead report
-               M    the submodule has a different HEAD than
-                    recorded in the index
-               m    the submodule has modified content
-               ?    the submodule has untracked files
-since modified content or untracked files in a submodule cannot be added
+
+* 'M' = the submodule has a different HEAD than recorded in the index
+* 'm' = the submodule has modified content
+* '?' = the submodule has untracked files
+
+This is since modified content or untracked files in a submodule cannot be added
 via `git add` in the superproject to prepare a commit.
 
 'm' and '?' are applied recursively. For example if a nested submodule
index 2438f76da05ebf013103a08962d634c4baa9ea15..a293327581aa54e120d1edc3b72467e42c250af4 100644 (file)
@@ -29,7 +29,7 @@ With no arguments, this will:
 In the case where the input consists entirely of whitespace characters, no
 output will be produced.
 
-*NOTE*: This is intended for cleaning metadata, prefer the `--whitespace=fix`
+*NOTE*: This is intended for cleaning metadata. Prefer the `--whitespace=fix`
 mode of linkgit:git-apply[1] for correcting whitespace of patches or files in
 the repository.
 
@@ -37,11 +37,11 @@ OPTIONS
 -------
 -s::
 --strip-comments::
-       Skip and remove all lines starting with comment character (default '#').
+       Skip and remove all lines starting with comment character (default '#').
 
 -c::
 --comment-lines::
-       Prepend comment character and blank to each line. Lines will automatically
+       Prepend the comment character and a blank space to each line. Lines will automatically
        be terminated with a newline. On empty lines, only the comment character
        will be prepended.
 
index 102c83eb19e98a7c14f8de879cca93d610b5fd34..761b154bcbb58b7c27245fb77e10c4f2e6a8a063 100644 (file)
@@ -27,7 +27,7 @@ symbolic ref.
 
 A symbolic ref is a regular file that stores a string that
 begins with `ref: refs/`.  For example, your `.git/HEAD` is
-a regular file whose contents is `ref: refs/heads/master`.
+a regular file whose content is `ref: refs/heads/master`.
 
 OPTIONS
 -------
index f4bb9c5daf95c6669210429d7a560565dadc91d5..8c47890a6a89bd7c0dbb2e3d259961262e4db3f7 100644 (file)
@@ -49,7 +49,7 @@ OPTIONS
 --remove::
        If a specified file is in the index but is missing then it's
        removed.
-       Default behavior is to ignore removed file.
+       Default behavior is to ignore removed files.
 
 --refresh::
        Looks at the current index and checks to see if merges or
@@ -95,7 +95,7 @@ OPTIONS
        the index.  If you want to change the working tree file,
        you need to unset the bit to tell Git.  This is
        sometimes helpful when working with a big project on a
-       filesystem that has very slow lstat(2) system call
+       filesystem that has very slow lstat(2) system call
        (e.g. cifs).
 +
 Git will fail (gracefully) in case it needs to modify this file
@@ -108,7 +108,7 @@ you will need to handle the situation manually.
        without regard to the "assume unchanged" setting.
 
 --[no-]skip-worktree::
-       When one of these flags is specified, the object name recorded
+       When one of these flags is specified, the object names recorded
        for the paths are not updated. Instead, these options
        set and unset the "skip-worktree" bit for the paths. See
        section "Skip-worktree bit" below for more information.
@@ -119,7 +119,7 @@ you will need to handle the situation manually.
        the `--remove` option was specified.
 
 --[no-]fsmonitor-valid::
-       When one of these flags is specified, the object name recorded
+       When one of these flags is specified, the object names recorded
        for the paths are not updated. Instead, these options
        set and unset the "fsmonitor valid" bit for the paths. See
        section "File System Monitor" below for more information.
@@ -127,7 +127,7 @@ you will need to handle the situation manually.
 -g::
 --again::
        Runs 'git update-index' itself on the paths whose index
-       entries are different from those from the `HEAD` commit.
+       entries are different from those of the `HEAD` commit.
 
 --unresolve::
        Restores the 'unmerged' or 'needs updating' state of a
@@ -151,24 +151,30 @@ you will need to handle the situation manually.
        automatically removed with warning messages.
 
 --stdin::
-       Instead of taking list of paths from the command line,
-       read list of paths from the standard input.  Paths are
+       Instead of taking list of paths from the command line,
+       read list of paths from the standard input.  Paths are
        separated by LF (i.e. one path per line) by default.
 
 --verbose::
-        Report what is being added and removed from index.
+       Report what is being added and removed from the index.
 
 --index-version <n>::
        Write the resulting index out in the named on-disk format version.
-       Supported versions are 2, 3 and 4. The current default version is 2
+       Supported versions are 2, 3, and 4. The current default version is 2
        or 3, depending on whether extra features are used, such as
-       `git add -N`.
+       `git add -N`.  With `--verbose`, also report the version the index
+       file uses before and after this command.
 +
 Version 4 performs a simple pathname compression that reduces index
 size by 30%-50% on large repositories, which results in faster load
-time. Version 4 is relatively young (first released in 1.8.0 in
-October 2012). Other Git implementations such as JGit and libgit2
-may not support it yet.
+time.  Git supports it since version 1.8.0, released in October 2012,
+and support for it was added to libgit2 in 2016 and to JGit in 2020.
+Older versions of this manual page called it "relatively young", but
+it should be considered mature technology these days.
+
+--show-index-version::
+       Report the index format version used by the on-disk index file.
+       See `--index-version` above.
 
 -z::
        Only meaningful with `--stdin` or `--index-info`; paths are
index 48b6683071e65be1abf29ece20dc90c5f0579ec3..0561808cca04a6873909ad18a6fd5f6e9af8b8de 100644 (file)
@@ -118,7 +118,7 @@ verify::
        <oldvalue> is zero or missing, the ref must not exist.
 
 option::
-       Modify behavior of the next command naming a <ref>.
+       Modify the behavior of the next command naming a <ref>.
        The only valid option is `no-deref` to avoid dereferencing
        a symbolic ref.
 
index 17e429dbd095605835bdf6b67d96bd8a92559cac..6bc9b50d89f7aac6921e6b9fd9b2659d1d81d3af 100644 (file)
@@ -23,13 +23,13 @@ OPTIONS
 -------
 -f::
 --force::
-       update the info files from scratch.
+       Update the info files from scratch.
 
 OUTPUT
 ------
 
 Currently the command updates the following files.  Please see
-linkgit:gitrepository-layout[5] for description of
+linkgit:gitrepository-layout[5] for description of
 what they are for:
 
 * objects/info/packs
index b656b4756752f6d91098b85d2766a80e86ca092a..7ad60bc3485bc80606fbf38bb13a4ba0e8f0902e 100644 (file)
@@ -26,7 +26,7 @@ OPTIONS
 -------
 
 --[no-]strict::
-       Do not try <directory>/.git/ if <directory> is no Git directory.
+       Do not try <directory>/.git/ if <directory> is not a Git directory.
 
 --timeout=<n>::
        Interrupt transfer after <n> seconds of inactivity.
index c38fb3968bcabc6215f535ec569e3f5e258aee62..0680568dfda732e9786011cd7b8088a91fca1662 100644 (file)
@@ -19,7 +19,7 @@ no value.
 OPTIONS
 -------
 -l::
-       Cause the logical variables to be listed. In addition, all the
+       Display the logical variables. In addition, all the
        variables of the Git configuration file .git/config are listed
        as well. (However, the configuration variables listing functionality
        is deprecated in favor of `git config -l`.)
index b8720dce8abc34fffee6fa1235c48976ad44f1fb..d7e886918aa7af8accc73737e51cacc38118f747 100644 (file)
@@ -15,7 +15,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 Reads given idx file for packed Git archive created with the
-'git pack-objects' command and verifies idx file and the
+'git pack-objects' command and verifies the idx file and the
 corresponding pack file.
 
 OPTIONS
@@ -25,13 +25,13 @@ OPTIONS
 
 -v::
 --verbose::
-       After verifying the pack, show list of objects contained
+       After verifying the pack, show the list of objects contained
        in the pack and a histogram of delta chain length.
 
 -s::
 --stat-only::
        Do not verify the pack contents; only show the histogram of delta
-       chain length.  With `--verbose`, list of objects is also shown.
+       chain length.  With `--verbose`, the list of objects is also shown.
 
 \--::
        Do not interpret any more arguments as options.
index 8b63ceb00e71a5e2f09cf7686b0978dcf71d1e03..8e55e0bb1ec8a6aaeaef5f6b615929850f63c358 100644 (file)
@@ -3,7 +3,7 @@ git-whatchanged(1)
 
 NAME
 ----
-git-whatchanged - Show logs with difference each commit introduces
+git-whatchanged - Show logs with differences each commit introduces
 
 
 SYNOPSIS
@@ -18,11 +18,11 @@ Shows commit logs and diff output each commit introduces.
 
 New users are encouraged to use linkgit:git-log[1] instead.  The
 `whatchanged` command is essentially the same as linkgit:git-log[1]
-but defaults to show the raw format diff output and to skip merges.
+but defaults to showing the raw format diff output and skipping merges.
 
-The command is kept primarily for historical reasons; fingers of
+The command is primarily kept for historical reasons; fingers of
 many people who learned Git long before `git log` was invented by
-reading Linux kernel mailing list are trained to type it.
+reading the Linux kernel mailing list are trained to type it.
 
 
 Examples
index 11228956cd5ec400b498d7483b8a4f71ec433ab2..9aeabde26200e1585d8d5283b6cdbc85ef8a37dc 100644 (file)
@@ -96,9 +96,9 @@ foo.bar= ...`) sets `foo.bar` to the empty string which `git config
        to avoid ambiguity with `<name>` containing one.
 +
 This is useful for cases where you want to pass transitory
-configuration options to git, but are doing so on OS's where
-other processes might be able to read your cmdline
-(e.g. `/proc/self/cmdline`), but not your environ
+configuration options to git, but are doing so on operating systems
+where other processes might be able to read your command line
+(e.g. `/proc/self/cmdline`), but not your environment
 (e.g. `/proc/self/environ`). That behavior is the default on
 Linux, but may not be on your system.
 +
index 6deb89a2967708dfc2c560ac72c29907a5b6334a..8c1793c14880439da7103bc07f0f89a11137fc86 100644 (file)
@@ -1151,8 +1151,8 @@ will be stored via placeholder `%P`.
 ^^^^^^^^^^^^^^^^^^^^^^
 
 This attribute controls the length of conflict markers left in
-the work tree file during a conflicted merge.  Only setting to
-the value to a positive integer has any meaningful effect.
+the work tree file during a conflicted merge.  Only a positive
+integer has a meaningful effect.
 
 For example, this line in `.gitattributes` can be used to tell the merge
 machinery to leave much longer (instead of the usual 7-character-long)
index 1819a5a1859c5479064823bd786e98267f7037b5..e5fac943227a23a5bf9214cddb08d48b0ce3c5ca 100644 (file)
@@ -23,10 +23,10 @@ arguments.  Here are the rules:
     A subcommand may take dashed options (which may take their own
     arguments, e.g. "--max-parents 2") and arguments.  You SHOULD
     give dashed options first and then arguments.  Some commands may
-    accept dashed options after you have already gave non-option
+    accept dashed options after you have already given non-option
     arguments (which may make the command ambiguous), but you should
     not rely on it (because eventually we may find a way to fix
-    these ambiguity by enforcing the "options then args" rule).
+    these ambiguities by enforcing the "options then args" rule).
 
  * Revisions come first and then paths.
    E.g. in `git diff v1.0 v2.0 arch/x86 include/asm-x86`,
@@ -37,12 +37,12 @@ arguments.  Here are the rules:
    they can be disambiguated by placing `--` between them.
    E.g. `git diff -- HEAD` is, "I have a file called HEAD in my work
    tree.  Please show changes between the version I staged in the index
-   and what I have in the work tree for that file", not "show difference
+   and what I have in the work tree for that file", not "show the difference
    between the HEAD commit and the work tree as a whole".  You can say
    `git diff HEAD --` to ask for the latter.
 
  * Without disambiguating `--`, Git makes a reasonable guess, but errors
-   out and asking you to disambiguate when ambiguous.  E.g. if you have a
+   out and asks you to disambiguate when ambiguous.  E.g. if you have a
    file called HEAD in your work tree, `git diff HEAD` is ambiguous, and
    you have to say either `git diff HEAD --` or `git diff -- HEAD` to
    disambiguate.
index 0d57f86abc4a51c9665f88ff34103bbe94f09009..3cda2e07c24a96af8ff1c08c46780b5fdb490f4f 100644 (file)
@@ -173,7 +173,7 @@ Note that when rename detection is on but both copy and break
 detection are off, rename detection adds a preliminary step that first
 checks if files are moved across directories while keeping their
 filename the same.  If there is a file added to a directory whose
-contents is sufficiently similar to a file with the same name that got
+contents are sufficiently similar to a file with the same name that got
 deleted from a different directory, it will mark them as renames and
 exclude them from the later quadratic step (the one that pairwise
 compares all unmatched files to find the "best" matches, determined by
@@ -213,7 +213,7 @@ from the original, and does not count insertion.  If you removed
 only 10 lines from a 100-line document, even if you added 910
 new lines to make a new 1000-line document, you did not do a
 complete rewrite.  diffcore-break breaks such a case in order to
-help diffcore-rename to consider such filepairs as candidate of
+help diffcore-rename to consider such filepairs as candidate of
 rename/copy detection, but if filepairs broken that way were not
 matched with other filepairs to create rename/copy, then this
 transformation merges them back into the original
@@ -230,13 +230,13 @@ like these:
 
 * -B/60 (the same as above, since diffcore-break defaults to 50%).
 
-Note that earlier implementation left a broken pair as separate
-creation and deletion patches.  This was an unnecessary hack and
+Note that earlier implementation left a broken pair as separate
+creation and deletion patches.  This was an unnecessary hack, and
 the latest implementation always merges all the broken pairs
 back into modifications, but the resulting patch output is
 formatted differently for easier review in case of such
-a complete rewrite by showing the entire contents of old version
-prefixed with '-', followed by the entire contents of new
+a complete rewrite by showing the entire contents of the old version
+prefixed with '-', followed by the entire contents of the new
 version prefixed with '+'.
 
 
@@ -263,7 +263,7 @@ textual diff has an added or a deleted line that matches the given
 regular expression.  This means that it will detect in-file (or what
 rename-detection considers the same file) moves, which is noise.  The
 implementation runs diff twice and greps, and this can be quite
-expensive.  To speed things up binary files without textconv filters
+expensive.  To speed things up, binary files without textconv filters
 will be ignored.
 
 When `-S` or `-G` are used without `--pickaxe-all`, only filepairs
index faba2ef0881c52e8c6c2e5ec0f5702c0b1ba5028..6cfdd0e07b46f269c059e38409dffe45d44a59f9 100644 (file)
@@ -14,7 +14,7 @@ DESCRIPTION
 -----------
 
 Git users can broadly be grouped into four categories for the purposes of
-describing here a small set of useful command for everyday Git.
+describing here a small set of useful commands for everyday Git.
 
 *      <<STANDALONE,Individual Developer (Standalone)>> commands are essential
        for anybody who makes a commit, even for somebody who works alone.
@@ -229,7 +229,7 @@ without a formal "merging". Or longhand +
   git am -3 -k`
 
 An alternate participant submission mechanism is using the
-`git request-pull` or pull-request mechanisms (e.g as used on
+`git request-pull` or pull-request mechanisms (e.g. as used on
 GitHub (www.github.com) to notify your upstream of your
 contribution.
 
index 00e0a20e6571969ebeabca8da5d9815be65d682b..1b75cf71cec103f8a5e36056532f888d1ac58e71 100644 (file)
@@ -67,7 +67,7 @@ A Git bundle consists of several parts.
 * "Capabilities", which are only in the v3 format, indicate functionality that
        the bundle requires to be read properly.
 
-* "Prerequisites" lists the objects that are NOT included in the bundle and the
+* "Prerequisites" list the objects that are NOT included in the bundle and the
   reader of the bundle MUST already have, in order to use the data in the
   bundle. The objects stored in the bundle may refer to prerequisite objects and
   anything reachable from them (e.g. a tree object in the bundle can reference
@@ -86,10 +86,10 @@ In the bundle format, there can be a comment following a prerequisite obj-id.
 This is a comment and it has no specific meaning. The writer of the bundle MAY
 put any string here. The reader of the bundle MUST ignore the comment.
 
-Note on the shallow clone and a Git bundle
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Note on shallow clones and Git bundles
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Note that the prerequisites does not represent a shallow-clone boundary. The
+Note that the prerequisites do not represent a shallow-clone boundary. The
 semantics of the prerequisites and the shallow-clone boundaries are different,
 and the Git bundle v2 format cannot represent a shallow clone repository.
 
index 57202ede273ad266be910045294fd74853dd193c..3315df6201dc964886652c494b2123260de9f434 100644 (file)
@@ -42,7 +42,7 @@ Each row consists of a 4-byte chunk identifier (ID) and an 8-byte offset.
 Each integer is stored in network-byte order.
 
 The chunk identifier `ID[i]` is a label for the data stored within this
-fill from `OFFSET[i]` (inclusive) to `OFFSET[i+1]` (exclusive). Thus, the
+file from `OFFSET[i]` (inclusive) to `OFFSET[i+1]` (exclusive). Thus, the
 size of the `i`th chunk is equal to the difference between `OFFSET[i+1]`
 and `OFFSET[i]`. This requires that the chunk data appears contiguously
 in the same order as the table of contents.
@@ -67,7 +67,7 @@ caller is responsible for opening the `hashfile` and writing header
 information so the file format is identifiable before the chunk-based
 format begins.
 
-Then, call `add_chunk()` for each chunk that is intended for write. This
+Then, call `add_chunk()` for each chunk that is intended for writing. This
 populates the `chunkfile` with information about the order and size of
 each chunk to write. Provide a `chunk_write_fn` function pointer to
 perform the write of the chunk data upon request.
index 0c1be2dbe85caf3300a314c374dd12d54b7434a7..4a4d87e7dbf5ceedb294833254281bcffb3b9880 100644 (file)
@@ -17,8 +17,8 @@ $GIT_DIR/objects/pack/multi-pack-index
 DESCRIPTION
 -----------
 
-The Git pack format is now Git stores most of its primary repository
-data. Over the lietime af a repository loose objects (if any) and
+The Git pack format is how Git stores most of its primary repository
+data. Over the lifetime of a repository, loose objects (if any) and
 smaller packs are consolidated into larger pack(s). See
 linkgit:git-gc[1] and linkgit:git-pack-objects[1].
 
@@ -48,7 +48,7 @@ Similarly, in SHA-256 repositories, these values are computed using SHA-256.
      Observation: we cannot have more than 4G versions ;-) and
      more than 4G objects in a pack.
 
-   - The header is followed by number of object entries, each of
+   - The header is followed by number of object entries, each of
      which looks like this:
 
      (undeltified representation)
@@ -62,7 +62,7 @@ Similarly, in SHA-256 repositories, these values are computed using SHA-256.
         is an OBJ_OFS_DELTA object
      compressed delta data
 
-     Observation: length of each object is encoded in a variable
+     Observation: the length of each object is encoded in a variable
      length format and is not constrained to 32-bit or anything.
 
   - The trailer records a pack checksum of all of the above.
@@ -117,7 +117,7 @@ the delta data is a sequence of instructions to reconstruct the object
 from the base object. If the base object is deltified, it must be
 converted to canonical form first. Each instruction appends more and
 more data to the target object until it's complete. There are two
-supported instructions so far: one for copy a byte range from the
+supported instructions so far: one for copying a byte range from the
 source object and one for inserting new data embedded in the
 instruction itself.
 
@@ -137,7 +137,7 @@ copy. Offset and size are in little-endian order.
 
 All offset and size bytes are optional. This is to reduce the
 instruction size when encoding small offsets or sizes. The first seven
-bits in the first octet determines which of the next seven octets is
+bits in the first octet determine which of the next seven octets is
 present. If bit zero is set, offset1 is present. If bit one is set
 offset2 is present and so on.
 
@@ -161,9 +161,9 @@ converted to 0x10000.
   | 0xxxxxxx |    data    |
   +----------+============+
 
-This is the instruction to construct target object without the base
+This is the instruction to construct the target object without the base
 object. The following data is appended to the target object. The first
-seven bits of the first octet determines the size of data in
+seven bits of the first octet determine the size of data in
 bytes. The size must be non-zero.
 
 ==== Reserved instruction
@@ -294,7 +294,7 @@ Pack file entry: <+
 
   - The same trailer as a v1 pack file:
 
-    A copy of the pack checksum at the end of
+    A copy of the pack checksum at the end of the
     corresponding packfile.
 
     Index checksum of all of the above.
@@ -588,51 +588,17 @@ later on.
 It is linkgit:git-gc[1] that is typically responsible for removing expired
 unreachable objects.
 
-=== Caution for mixed-version environments
-
-Repositories that have cruft packs in them will continue to work with any older
-version of Git. Note, however, that previous versions of Git which do not
-understand the `.mtimes` file will use the cruft pack's mtime as the mtime for
-all of the objects in it. In other words, do not expect older (pre-cruft pack)
-versions of Git to interpret or even read the contents of the `.mtimes` file.
-
-Note that having mixed versions of Git GC-ing the same repository can lead to
-unreachable objects never being completely pruned. This can happen under the
-following circumstances:
-
-  - An older version of Git running GC explodes the contents of an existing
-    cruft pack loose, using the cruft pack's mtime.
-  - A newer version running GC collects those loose objects into a cruft pack,
-    where the .mtime file reflects the loose object's actual mtimes, but the
-    cruft pack mtime is "now".
-
-Repeating this process will lead to unreachable objects not getting pruned as a
-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
-setting the `gc.cruftPacks` configuration to "false" until all writers
-understand cruft packs.
-
 === Alternatives
 
 Notable alternatives to this design include:
 
-  - The location of the per-object mtime data, and
-  - Storing unreachable objects in multiple cruft packs.
+  - The location of the per-object mtime data.
 
 On the location of mtime data, a new auxiliary file tied to the pack was chosen
 to avoid complicating the `.idx` format. If the `.idx` format were ever to gain
 support for optional chunks of data, it may make sense to consolidate the
 `.mtimes` format into the `.idx` itself.
 
-Storing unreachable objects among multiple cruft packs (e.g., creating a new
-cruft pack during each repacking operation including only unreachable objects
-which aren't already stored in an earlier cruft pack) is significantly more
-complicated to construct, and so aren't pursued here. The obvious drawback to
-the current implementation is that the entire cruft pack must be re-written from
-scratch.
-
 GIT
 ---
 Part of the linkgit:git[1] suite
index 86f804720ae71fc3d0db94623663539bd05a06f2..883982e7a0516204ddd2f2f9e14775fa17e2a810 100644 (file)
@@ -80,7 +80,7 @@ If it exits with non-zero status, then the working tree will not be
 committed after applying the patch.
 
 It can be used to inspect the current working tree and refuse to
-make a commit if it does not pass certain test.
+make a commit if it does not pass certain tests.
 
 The default 'pre-applypatch' hook, when enabled, runs the
 'pre-commit' hook, if the latter is enabled.
@@ -157,7 +157,7 @@ If the exit status is non-zero, `git commit` will abort.
 The purpose of the hook is to edit the message file in place, and
 it is not suppressed by the `--no-verify` option.  A non-zero exit
 means a failure of the hook and aborts the commit.  It should not
-be used as replacement for pre-commit hook.
+be used as a replacement for the pre-commit hook.
 
 The sample `prepare-commit-msg` hook that comes with Git removes the
 help message found in the commented portion of the commit template.
@@ -345,7 +345,7 @@ for the user.
 
 The default 'update' hook, when enabled--and with
 `hooks.allowunannotated` config option unset or set to false--prevents
-unannotated tags to be pushed.
+unannotated tags from being pushed.
 
 [[proc-receive]]
 proc-receive
@@ -379,12 +379,12 @@ following example for the protocol, the letter 'S' stands for
     S: ... ...
     S: flush-pkt
 
-    # Receive result from the hook.
+    # Receive results from the hook.
     # OK, run this command successfully.
     H: PKT-LINE(ok <ref>)
     # NO, I reject it.
     H: PKT-LINE(ng <ref> <reason>)
-    # Fall through, let 'receive-pack' to execute it.
+    # Fall through, let 'receive-pack' execute it.
     H: PKT-LINE(ok <ref>)
     H: PKT-LINE(option fall-through)
     # OK, but has an alternate reference.  The alternate reference name
index d50e9ed10e04c688b6ee898b20e24a1cd796cc78..c2213bb77b380a213c1d4a8f6230790b9d8ecb57 100644 (file)
@@ -26,7 +26,7 @@ changes each commit introduces are shown.  Finally, it supports some
 gitk-specific options.
 
 gitk generally only understands options with arguments in the
-'sticked' form (see linkgit:gitcli[7]) due to limitations in the
+'stuck' form (see linkgit:gitcli[7]) due to limitations in the
 command-line parser.
 
 rev-list options and arguments
index 0fb5ea0c1ca7547679d060f8fe2be7d2edf58c86..d6c6effc2151ffa136f0f2e36a07b659e25c43e4 100644 (file)
@@ -30,7 +30,7 @@ to be in effect. The client MUST NOT ask for capabilities the server
 did not say it supports.
 
 Server MUST diagnose and abort if capabilities it does not understand
-was sent.  Server MUST NOT ignore capabilities that client requested
+were sent.  Server MUST NOT ignore capabilities that client requested
 and server advertised.  As a consequence of these rules, server MUST
 NOT advertise capabilities it does not understand.
 
@@ -61,8 +61,8 @@ complete cut across the DAG, or the client has said "done".
 Without multi_ack, a client sends have lines in --date-order until
 the server has found a common base.  That means the client will send
 have lines that are already known by the server to be common, because
-they overlap in time with another branch that the server hasn't found
-a common base on yet.
+they overlap in time with another branch on which the server hasn't found
+a common base yet.
 
 For example suppose the client has commits in caps that the server
 doesn't and the server has commits in lower case that the client
@@ -88,7 +88,7 @@ interleaved with S-R-Q.
 
 multi_ack_detailed
 ------------------
-This is an extension of multi_ack that permits client to better
+This is an extension of multi_ack that permits the client to better
 understand the server's in-memory state. See linkgit:gitprotocol-pack[5],
 section "Packfile Negotiation" for more information.
 
@@ -135,7 +135,7 @@ to disable the feature in a backwards-compatible manner.
 side-band, side-band-64k
 ------------------------
 
-This capability means that server can send, and client understand multiplexed
+This capability means that the server can send, and the client can understand, multiplexed
 progress reports and error info interleaved with the packfile itself.
 
 These two options are mutually exclusive. A modern client always
@@ -163,14 +163,14 @@ Further, with side-band and its up to 1000-byte messages, it's actually
 same deal, you have up to 65519 bytes of data and 1 byte for the stream
 code.
 
-The client MUST send only maximum of one of "side-band" and "side-
-band-64k".  Server MUST diagnose it as an error if client requests
+The client MUST send only one of "side-band" and "side-
+band-64k".  The server MUST diagnose it as an error if client requests
 both.
 
 ofs-delta
 ---------
 
-Server can send, and client understand PACKv2 with delta referring to
+The server can send, and the client can understand, PACKv2 with delta referring to
 its base by position in pack rather than by an obj-id.  That is, they can
 send/read OBJ_OFS_DELTA (aka type 6) in a packfile.
 
@@ -252,7 +252,7 @@ the current shallow boundary, instead of the depth from remote refs.
 no-progress
 -----------
 
-The client was started with "git clone -q" or something, and doesn't
+The client was started with "git clone -q" or something similar, and doesn't
 want that side band 2.  Basically the client just says "I do not
 wish to receive stream 2 on sideband, so do not send it to me, and if
 you did, I will drop it on the floor anyway".  However, the sideband
@@ -273,7 +273,7 @@ request include-tag only has to do with the client's desires for tag
 data, whether or not a server had advertised objects in the
 refs/tags/* namespace.
 
-Servers MUST pack the tags if their referrant is packed and the client
+Servers MUST pack the tags if their referent is packed and the client
 has requested include-tags.
 
 Clients MUST be prepared for the case where a server has ignored
index 1486651bd1002f3c121c703caae154caa822fedc..cdc9d6e707586cc1f7c23de318957d2e42ef5d88 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-This document sets defines things common to various over-the-wire
+This document defines things common to various over-the-wire
 protocols and file formats used in Git.
 
 ABNF Notation
index ccc13f0a40758ac5f8268472354998d63331bf92..21b73b7a1f5bd0bee369cb56070ea6b684390446 100644 (file)
@@ -42,7 +42,7 @@ both the "smart" and "dumb" HTTP protocols used by Git operate
 by appending additional path components onto the end of the user
 supplied `$GIT_URL` string.
 
-An example of a dumb client requesting for a loose object:
+An example of a dumb client requesting a loose object:
 
   $GIT_URL:     http://example.com:8080/git/repo.git
   URL request:  http://example.com:8080/git/repo.git/objects/d0/49f6c27a2244e12041955e262a404c7faba355
@@ -379,7 +379,7 @@ C: Place any object seen into set `advertised`.
 C: Build an empty set, `common`, to hold the objects that are later
    determined to be on both ends.
 
-C: Build a set, `want`, of the objects from `advertised` the client
+C: Build a set, `want`, of the objects from `advertised` that the client
    wants to fetch, based on what it saw during ref discovery.
 
 C: Start a queue, `c_pending`, ordered by commit time (popping newest
@@ -423,7 +423,7 @@ multiple commands. Object names MUST be given using the object format
 negotiated through the `object-format` capability (default SHA-1).
 
 The `have` list is created by popping the first 32 commits
-from `c_pending`.  Less can be supplied if `c_pending` empties.
+from `c_pending`.  Fewer can be supplied if `c_pending` empties.
 
 If the client has sent 256 "have" commits and has not yet
 received one of those back from `s_common`, or the client has
index dd4108b7a3b95456e0887fc41aed4e381261bd41..837b691c892b31e204948c29b986337809683ce1 100644 (file)
@@ -30,7 +30,7 @@ pkt-line Format
 ---------------
 
 The descriptions below build on the pkt-line format described in
-linkgit:gitprotocol-common[5]. When the grammar indicate `PKT-LINE(...)`, unless
+linkgit:gitprotocol-common[5]. When the grammar indicates `PKT-LINE(...)`, unless
 otherwise noted the usual pkt-line LF rules apply: the sender SHOULD
 include a LF, but the receiver MUST NOT complain if it is not present.
 
@@ -137,7 +137,7 @@ an absolute path in the remote filesystem.
                    v
     ssh user@example.com "git-upload-pack '/project.git'"
 
-In a "user@host:path" format URI, its relative to the user's home
+In a "user@host:path" format URI, it's relative to the user's home
 directory, because the Git client will run:
 
      git clone user@example.com:project.git
@@ -325,7 +325,7 @@ a positive depth, this step is skipped.
 
 If the client has requested a positive depth, the server will compute
 the set of commits which are no deeper than the desired depth. The set
-of commits start at the client's wants.
+of commits starts at the client's wants.
 
 The server writes 'shallow' lines for each
 commit whose parents will not be sent as a result. The server writes
index acb97ad0c22440a5039d8cf3da6f00dd60295a24..8c1e7c61eac751d352b9268ff2d57b357ce62ed4 100644 (file)
@@ -29,7 +29,7 @@ protocol.  Protocol v2 will improve upon v1 in the following ways:
     semantics the http remote helper can simply act as a proxy
 
 In protocol v2 communication is command oriented.  When first contacting a
-server a list of capabilities will advertised.  Some of these capabilities
+server a list of capabilities will be advertised.  Some of these capabilities
 will be commands which a client can request be executed.  Once a command
 has completed, a client can reuse the connection and request that other
 commands be executed.
index 941858a6ecce88440975f02c2462f6aa8692b0bc..8400d591da0e8a93035d72a947b07728055eeebd 100644 (file)
@@ -78,7 +78,7 @@ Submodule operations can be configured using the following mechanisms
 
  * The command line for those commands that support taking submodules
    as part of their pathspecs. Most commands have a boolean flag
-   `--recurse-submodules` which specify whether to recurse into submodules.
+   `--recurse-submodules` which specifies whether to recurse into submodules.
    Examples are `grep` and `checkout`.
    Some commands take enums, such as `fetch` and `push`, where you can
    specify how submodules are affected.
@@ -192,7 +192,7 @@ For example:
   [submodule "baz"]
     url = https://example.org/baz
 
-In the above config only the submodule 'bar' and 'baz' are active,
+In the above config only the submodules 'bar' and 'baz' are active,
 'bar' due to (1) and 'baz' due to (3). 'foo' is inactive because
 (1) takes precedence over (3)
 
@@ -274,7 +274,7 @@ will not be checked out by default; you can instruct `clone` to recurse
 into submodules. The `init` and `update` subcommands of `git submodule`
 will maintain submodules checked out and at an appropriate revision in
 your working tree. Alternatively you can set `submodule.recurse` to have
-`checkout` recursing into submodules (note that `submodule.recurse` also
+`checkout` recurse into submodules (note that `submodule.recurse` also
 affects other Git commands, see linkgit:git-config[1] for a complete list).
 
 
index c7cadd8aaf1a0e6606d2b559b674526bc687849a..4759408788070baba26b94e91dde74a9e6c6dda5 100644 (file)
@@ -137,10 +137,10 @@ which will automatically notice any modified (but not new) files, add
 them to the index, and commit, all in one step.
 
 A note on commit messages: Though not required, it's a good idea to
-begin the commit message with a single short (less than 50 character)
-line summarizing the change, followed by a blank line and then a more
-thorough description. The text up to the first blank line in a commit
-message is treated as the commit title, and that title is used
+begin the commit message with a single short (no more than 50
+characters) line summarizing the change, followed by a blank line and
+then a more thorough description. The text up to the first blank line in
+a commit message is treated as the commit title, and that title is used
 throughout Git.  For example, linkgit:git-format-patch[1] turns a
 commit into email, and it uses the title on the Subject line and the
 rest of the commit in the body.
index 34b1d6e224356cd3e9a637d0d5bdbef2f6ee269d..b078fef6f5c6ff09c9db52ee8a3d3945144b6fc1 100644 (file)
@@ -53,7 +53,7 @@ following order:
    `/etc/gitweb-common.conf`),
 
  * either per-instance configuration file (defaults to 'gitweb_config.perl'
-   in the same directory as the installed gitweb), or if it does not exists
+   in the same directory as the installed gitweb), or if it does not exist
    then fallback system-wide configuration file (defaults to `/etc/gitweb.conf`).
 
 Values obtained in later configuration files override values obtained earlier
index af6bf3c45ec1b78c13a0886c2824eb980099c706..1030e9667ea8c2a0089cef0a725f57581093aa19 100644 (file)
@@ -8,7 +8,7 @@ gitweb - Git web interface (web frontend to Git repositories)
 SYNOPSIS
 --------
 To get started with gitweb, run linkgit:git-instaweb[1] from a Git repository.
-This would configure and start your web server, and run web browser pointing to
+This will configure and start your web server, and run a web browser pointing to
 gitweb.
 
 
@@ -20,13 +20,13 @@ Gitweb provides a web interface to Git repositories.  Its features include:
 * Browsing every revision of the repository.
 * Viewing the contents of files in the repository at any revision.
 * Viewing the revision log of branches, history of files and directories,
-  see what was changed when, by who.
+  seeing what was changed, when, and by whom.
 * Viewing the blame/annotation details of any file (if enabled).
 * Generating RSS and Atom feeds of commits, for any branch.
   The feeds are auto-discoverable in modern web browsers.
-* Viewing everything that was changed in a revision, and step through
+* Viewing everything that was changed in a revision, and stepping through
   revisions one at a time, viewing the history of the repository.
-* Finding commits which commit messages matches given search term.
+* Finding commits whose commit messages match a given search term.
 
 See http://repo.or.cz/w/git.git/tree/HEAD:/gitweb/[] for gitweb source code,
 browsed using gitweb itself.
@@ -41,9 +41,9 @@ for details.
 Repositories
 ~~~~~~~~~~~~
 Gitweb can show information from one or more Git repositories.  These
-repositories have to be all on local filesystem, and have to share common
+repositories have to be all on local filesystem, and have to share common
 repository root, i.e. be all under a single parent repository (but see also
-"Advanced web server setup" section, "Webserver configuration with multiple
+the "Advanced web server setup" section, "Webserver configuration with multiple
 projects' root" subsection).
 
 -----------------------------------------------------------------------
@@ -51,7 +51,7 @@ our $projectroot = '/path/to/parent/directory';
 -----------------------------------------------------------------------
 
 The default value for `$projectroot` is `/pub/git`.  You can change it during
-building gitweb via `GITWEB_PROJECTROOT` build configuration variable.
+building gitweb via the `GITWEB_PROJECTROOT` build configuration variable.
 
 By default all Git repositories under `$projectroot` are visible and available
 to gitweb.  The list of projects is generated by default by scanning the
@@ -66,7 +66,7 @@ found at "$projectroot/$repo".
 
 Projects list file format
 ~~~~~~~~~~~~~~~~~~~~~~~~~
-Instead of having gitweb find repositories by scanning filesystem
+Instead of having gitweb find repositories by scanning the filesystem
 starting from $projectroot, you can provide a pre-generated list of
 visible projects by setting `$projects_list` to point to a plain text
 file with a list of projects (with some additional info).
index 5a537268e275e45142640820942004b5cd731dbb..65c89e7b3eb0178d9167ef714c42d9ad3873f2f5 100644 (file)
@@ -186,7 +186,7 @@ current branch integrates with) obviously do not work, as there is no
        points at the directory that is the real repository.
 
 [[def_grafts]]grafts::
-       Grafts enables two otherwise different lines of development to be joined
+       Grafts enable two otherwise different lines of development to be joined
        together by recording fake ancestry information for commits. This way
        you can make Git pretend the set of <<def_parent,parents>> a <<def_commit,commit>> has
        is different from what was recorded when the commit was
index e653775bab18ddeacb03ec16beaa6d25af5ecf3d..b9cb95e82f0eca994c7a0b9149e028feef83bdec 100644 (file)
@@ -145,7 +145,7 @@ Opening a Security Advisory draft
 
 The first step is to https://github.com/git/git/security/advisories/new[open
 an advisory]. Technically, this is not necessary. However, it is the most
-convenient way to obtain the CVE number and it give us a private repository
+convenient way to obtain the CVE number and it gives us a private repository
 associated with it that can be used to collaborate on a fix.
 
 Notifying the Linux distributions
index d07c6d44e53c3bd0e7805efa036f2cf3eeaf79ac..013014bbef67ac149ea8ebdb3093ed8648b5a469 100644 (file)
@@ -104,7 +104,7 @@ by doing the following:
    files in mbox format).
 
  - Write his own patches to address issues raised on the list but
-   nobody has stepped up solving.  Send it out just like other
+   nobody has stepped up to solve.  Send it out just like other
    contributors do, and pick them up just like patches from other
    contributors (see above).
 
@@ -411,13 +411,13 @@ Preparing a "merge-fix"
 
 A merge of two topics may not textually conflict but still have
 conflict at the semantic level. A classic example is for one topic
-to rename an variable and all its uses, while another topic adds a
+to rename a variable and all its uses, while another topic adds a
 new use of the variable under its old name. When these two topics
 are merged together, the reference to the variable newly added by
 the latter topic will still use the old name in the result.
 
 The Meta/Reintegrate script that is used by redo-jch and redo-seen
-scripts implements a crude but usable way to work this issue around.
+scripts implements a crude but usable way to work around this issue.
 When the script merges branch $X, it checks if "refs/merge-fix/$X"
 exists, and if so, the effect of it is squashed into the result of
 the mechanical merge.  In other words,
index 7af2e52cf312c474d5888855fb86b7456a2d82db..2cad9b3ca5366fd115569e1e8d3b7484fed75bfd 100644 (file)
@@ -4,7 +4,7 @@ How to use git-daemon
 =====================
 
 Git can be run in inetd mode and in stand alone mode. But all you want is
-let a coworker pull from you, and therefore need to set up a Git server
+to let a coworker pull from you, and therefore need to set up a Git server
 real quick, right?
 
 Note that git-daemon is not really chatty at the moment, especially when
index a499a94ac2289ac6664035d339e37914748757d2..3bd581ac3591b6c3bf49a77c60e705539ab8319d 100644 (file)
@@ -11,7 +11,7 @@ Message-ID: <BAYC1-PASMTP12374B54BA370A1E1C6E78AE4E0@CEZ.ICE>
 How to use the subtree merge strategy
 =====================================
 
-There are situations where you want to include contents in your project
+There are situations where you want to include content in your project
 from an independently developed project. You can just pull from the
 other project as long as there are no conflicting paths.
 
index 6c6baeeeb75bd8ff15e7b2ec1f3c394e0c9ef845..3a866af4a4205d0cd101d862c45e7d96bd5718fa 100644 (file)
@@ -34,7 +34,7 @@ project find it more convenient to use legacy encodings, Git
 does not forbid it.  However, there are a few things to keep in
 mind.
 
-. 'git commit' and 'git commit-tree' issues
+. 'git commit' and 'git commit-tree' issue
   a warning if the commit log message given to it does not look
   like a valid UTF-8 string, unless you explicitly say your
   project uses a legacy encoding.  The way to say this is to
@@ -46,7 +46,7 @@ mind.
 ------------
 +
 Commit objects created with the above setting record the value
-of `i18n.commitEncoding` in its `encoding` header.  This is to
+of `i18n.commitEncoding` in their `encoding` header.  This is to
 help other people who look at them later.  Lack of this header
 implies that the commit log message is encoded in UTF-8.
 
index 2d631e9b1f242f334d9751823b5771d8e1d84112..d1a4c468e6354e47f52579d6e44f2387b51ba811 100644 (file)
@@ -32,10 +32,10 @@ have special meaning:
   - `+` is used to "open a new tab"
   - `,` is used to "open a new vertical split"
   - `/` is used to "open a new horizontal split"
-  - `@` is used to indicate which is the file containing the final version after
+  - `@` is used to indicate the file containing the final version after
     solving the conflicts. If not present, `MERGED` will be used by default.
 
-The precedence of the operators is this one (you can use parentheses to change
+The precedence of the operators is as follows (you can use parentheses to change
 it):
 
     `@` > `+` > `/` > `,`
@@ -162,7 +162,7 @@ information as the first tab, with a different layout.
 |       REMOTE        |                     |
 ---------------------------------------------
 ....
-Note how in the third tab definition we need to use parenthesis to make `,`
+Note how in the third tab definition we need to use parentheses to make `,`
 have precedence over `/`.
 --
 
index 3b713344597090037bd6cd7bc034aaeed8316656..d38b4ab5666c35e0ae83680abca0e067c7b14792 100644 (file)
@@ -122,7 +122,9 @@ The placeholders are:
 - Placeholders that expand to a single literal character:
 '%n':: newline
 '%%':: a raw '%'
-'%x00':: print a byte from a hex code
+'%x00':: '%x' followed by two hexadecimal digits is replaced with a
+        byte with the hexadecimal digits' value (we will call this
+        "literal formatting code" in the rest of this document).
 
 - Placeholders that affect formatting of later placeholders:
 '%Cred':: switch color to red
@@ -222,13 +224,30 @@ The placeholders are:
        linkgit:git-rev-list[1])
 '%d':: ref names, like the --decorate option of linkgit:git-log[1]
 '%D':: ref names without the " (", ")" wrapping.
-'%(describe[:options])':: human-readable name, like
-                         linkgit:git-describe[1]; empty string for
-                         undescribable commits.  The `describe` string
-                         may be followed by a colon and zero or more
-                         comma-separated options.  Descriptions can be
-                         inconsistent when tags are added or removed at
-                         the same time.
+'%(decorate[:<options>])'::
+ref names with custom decorations. The `decorate` string may be followed by a
+colon and zero or more comma-separated options. Option values may contain
+literal formatting codes. These must be used for commas (`%x2C`) and closing
+parentheses (`%x29`), due to their role in the option syntax.
++
+** 'prefix=<value>': Shown before the list of ref names.  Defaults to "{nbsp}`(`".
+** 'suffix=<value>': Shown after the list of ref names.  Defaults to "`)`".
+** 'separator=<value>': Shown between ref names.  Defaults to "`,`{nbsp}".
+** 'pointer=<value>': Shown between HEAD and the branch it points to, if any.
+                     Defaults to "{nbsp}`->`{nbsp}".
+** 'tag=<value>': Shown before tag names. Defaults to "`tag:`{nbsp}".
+
++
+For example, to produce decorations with no wrapping
+or tag annotations, and spaces as separators:
++
+`%(decorate:prefix=,suffix=,tag=,separator= )`
+
+'%(describe[:<options>])'::
+human-readable name, like linkgit:git-describe[1]; empty string for
+undescribable commits.  The `describe` string may be followed by a colon and
+zero or more comma-separated options.  Descriptions can be inconsistent when
+tags are added or removed at the same time.
 +
 ** 'tags[=<bool-value>]': Instead of only considering annotated tags,
    consider lightweight tags as well.
@@ -281,13 +300,11 @@ endif::git-rev-list[]
 '%gE':: reflog identity email (respecting .mailmap, see
        linkgit:git-shortlog[1] or linkgit:git-blame[1])
 '%gs':: reflog subject
-'%(trailers[:options])':: display the trailers of the body as
-                         interpreted by
-                         linkgit:git-interpret-trailers[1]. The
-                         `trailers` string may be followed by a colon
-                         and zero or more comma-separated options.
-                         If any option is provided multiple times the
-                         last occurrence wins.
+'%(trailers[:<options>])'::
+display the trailers of the body as interpreted by
+linkgit:git-interpret-trailers[1]. The `trailers` string may be followed by
+a colon and zero or more comma-separated options. If any option is provided
+multiple times, the last occurrence wins.
 +
 ** 'key=<key>': only show trailers with specified <key>. Matching is done
    case-insensitively and trailing colon is optional. If option is
index dc685be363a674e754dc62f961558d97d5e65a7d..23888cd612c9fb0c18ac1e24ac56a1a6f2a0a149 100644 (file)
@@ -48,7 +48,7 @@ people using 80-column terminals.
 --expand-tabs::
 --no-expand-tabs::
        Perform a tab expansion (replace each tab with enough spaces
-       to fill to the next display column that is multiple of '<n>')
+       to fill to the next display column that is multiple of '<n>')
        in the log message before showing it in the output.
        `--expand-tabs` is a short-hand for `--expand-tabs=8`, and
        `--no-expand-tabs` is a short-hand for `--expand-tabs=0`,
@@ -73,7 +73,7 @@ environment overrides). See linkgit:git-config[1] for more details.
 With an optional '<ref>' argument, use the ref to find the notes
 to display.  The ref can specify the full refname when it begins
 with `refs/notes/`; when it begins with `notes/`, `refs/` and otherwise
-`refs/notes/` is prefixed to form a full name of the ref.
+`refs/notes/` is prefixed to form the full name of the ref.
 +
 Multiple --notes options can be combined to control which notes are
 being displayed. Examples: "--notes=foo" will show only notes from
@@ -87,6 +87,10 @@ being displayed. Examples: "--notes=foo" will show only notes from
        "--notes --notes=foo --no-notes --notes=bar" will only show notes
        from "refs/notes/bar".
 
+--show-notes-by-default::
+       Show the default notes unless options for displaying specific
+       notes are given.
+
 --show-notes[=<ref>]::
 --[no-]standard-notes::
        These options are deprecated. Use the above --notes/--no-notes
index 95a7390b2c78bddfc2c094fa6f0ba82e2b6de417..c718f7946f065d425c818c09bfd11fd641b73b4f 100644 (file)
@@ -71,7 +71,7 @@ refspec (or `--force`).
 Unlike when pushing with linkgit:git-push[1], any updates outside of
 `refs/{tags,heads}/*` will be accepted without `+` in the refspec (or
 `--force`), whether that's swapping e.g. a tree object for a blob, or
-a commit for another commit that's doesn't have the previous commit as
+a commit for another commit that doesn't have the previous commit as
 an ancestor etc.
 +
 Unlike when pushing with linkgit:git-push[1], there is no
@@ -80,7 +80,7 @@ configuration which'll amend these rules, and nothing like a
 +
 As with pushing with linkgit:git-push[1], all of the rules described
 above about what's not allowed as an update can be overridden by
-adding an the optional leading `+` to a refspec (or using `--force`
+adding an optional leading `+` to a refspec (or using the `--force`
 command line option). The only exception to this is that no amount of
 forcing will make the `refs/heads/*` namespace accept a non-commit
 object.
@@ -88,7 +88,7 @@ object.
 [NOTE]
 When the remote branch you want to fetch is known to
 be rewound and rebased regularly, it is expected that
-its new tip will not be descendant of its previous tip
+its new tip will not be descendant of its previous tip
 (as stored in your remote-tracking branch the last time
 you fetched).  You would want
 to use the `+` sign to indicate non-fast-forward updates
index a4a0cb93b241b8d5d9c9bc9b200a277a0e4f7992..2bf239ff0309aa0e45436c06788f49c094bfac8f 100644 (file)
@@ -56,7 +56,7 @@ endif::git-rev-list[]
        error to use this option unless `--walk-reflogs` is in use.
 
 --grep=<pattern>::
-       Limit the commits output to ones with log message that
+       Limit the commits output to ones with log message that
        matches the specified pattern (regular expression).  With
        more than one `--grep=<pattern>`, commits whose message
        matches any of the given patterns are chosen (but see
@@ -72,7 +72,7 @@ endif::git-rev-list[]
        instead of ones that match at least one.
 
 --invert-grep::
-       Limit the commits output to ones with log message that do not
+       Limit the commits output to ones with log message that do not
        match the pattern specified with `--grep=<pattern>`.
 
 -i::
@@ -151,6 +151,10 @@ endif::git-log[]
 --not::
        Reverses the meaning of the '{caret}' prefix (or lack thereof)
        for all following revision specifiers, up to the next `--not`.
+       When used on the command line before --stdin, the revisions passed
+       through stdin will not be affected by it. Conversely, when passed
+       via standard input, the revisions passed on the command line will
+       not be affected by it.
 
 --all::
        Pretend as if all the refs in `refs/`, along with `HEAD`, are
@@ -240,7 +244,9 @@ endif::git-rev-list[]
        them from standard input as well. This accepts commits and
        pseudo-options like `--all` and `--glob=`. When a `--` separator
        is seen, the following input is treated as paths and used to
-       limit the result.
+       limit the result. Flags like `--not` which are read via standard input
+       are only respected for arguments passed in the same way and will not
+       influence any subsequent command line arguments.
 
 ifdef::git-rev-list[]
 --quiet::
index eda8c195c19629dfe836b36d9baaa21ec06199d6..7780a76b080e4b7ad2c82dc8eb6616e92fd21c4e 100644 (file)
@@ -1,7 +1,7 @@
 Git API Documents
 =================
 
-Git has grown a set of internal API over time.  This collection
+Git has grown a set of internal APIs over time.  This collection
 documents them.
 
 ////////////////////////////////////////////////////////////////
index d44ada98e7db9ccdd7dd622221ee298af5de5000..c4fb152b23291c3978db623b5ebe5eaea1385442 100644 (file)
@@ -2,7 +2,7 @@ Simple-IPC API
 ==============
 
 The Simple-IPC API is a collection of `ipc_` prefixed library routines
-and a basic communication protocol that allow an IPC-client process to
+and a basic communication protocol that allows an IPC-client process to
 send an application-specific IPC-request message to an IPC-server
 process and receive an application-specific IPC-response message.
 
@@ -20,12 +20,12 @@ IPC-client.
 
 The IPC-client routines within a client application process connect
 to the IPC-server and send a request message and wait for a response.
-When received, the response is returned back the caller.
+When received, the response is returned back to the caller.
 
 For example, the `fsmonitor--daemon` feature will be built as a server
 application on top of the IPC-server library routines.  It will have
 threads watching for file system events and a thread pool waiting for
-client connections.  Clients, such as `git status` will request a list
+client connections.  Clients, such as `git status`, will request a list
 of file system events since a point in time and the server will
 respond with a list of changed files and directories.  The formats of
 the request and response are application-specific; the IPC-client and
@@ -37,7 +37,7 @@ Comparison with sub-process model
 
 The Simple-IPC mechanism differs from the existing `sub-process.c`
 model (Documentation/technical/long-running-process-protocol.txt) and
-used by applications like Git-LFS.  In the LFS-style sub-process model
+used by applications like Git-LFS.  In the LFS-style sub-process model,
 the helper is started by the foreground process, communication happens
 via a pair of file descriptors bound to the stdin/stdout of the
 sub-process, the sub-process only serves the current foreground
@@ -102,4 +102,4 @@ stateless request, receive an application-specific
 response, and disconnect.  It is a one round trip facility for
 querying the server.  The Simple-IPC routines hide the socket,
 named pipe, and thread pool details and allow the application
-layer to focus on the application at hand.
+layer to focus on the task at hand.
index c2e652b71a7f698a6843bbf327535b4692538c0f..f5d200939b056076368d4e8a735772fde114599d 100644 (file)
@@ -114,7 +114,7 @@ result in an empty bitmap (no bits set).
 
     * N entries with compressed bitmaps, one for each indexed commit
 +
-Where `N` is the total amount of entries in this bitmap index.
+Where `N` is the total number of entries in this bitmap index.
 Each entry contains the following:
 
        ** {empty}
@@ -126,7 +126,7 @@ Each entry contains the following:
        ** {empty}
        1-byte XOR-offset: ::
            The xor offset used to compress this bitmap. For an entry
-           in position `x`, a XOR offset of `y` means that the actual
+           in position `x`, an XOR offset of `y` means that the actual
            bitmap representing this commit is composed by XORing the
            bitmap for this entry with the bitmap in entry `x-y` (i.e.
            the bitmap `y` entries before this one).
@@ -239,7 +239,7 @@ bitmaps.
 
 For a `.bitmap` containing `nr_entries` reachability bitmaps, the table
 contains a list of `nr_entries` <commit_pos, offset, xor_row> triplets
-(sorted in the ascending order of `commit_pos`). The content of i'th
+(sorted in the ascending order of `commit_pos`). The content of the i'th
 triplet is -
 
        * {empty}
index 86fed0de0f77f97031621ffd4ca94c1cbd2b5ba1..2c26e95e51ab9aacb147fad022c669a2a17e928b 100644 (file)
@@ -136,7 +136,7 @@ Design Details
 
 - Commit grafts and replace objects can change the shape of the commit
   history. The latter can also be enabled/disabled on the fly using
-  `--no-replace-objects`. This leads to difficultly storing both possible
+  `--no-replace-objects`. This leads to difficulty storing both possible
   interpretations of a commit id, especially when computing generation
   numbers. The commit-graph will not be read or written when
   replace-objects or grafts are present.
index 47c9b6183cfad0f3f8e60df2003cd60657a92b0d..b4a144e5f4758d30e523406596b85009336141b0 100644 (file)
@@ -63,7 +63,7 @@ improvements over the sequential code, but there was still too much lock
 contention. A `perf` profiling indicated that around 20% of the runtime
 during a local Linux clone (on an SSD) was spent in locking functions.
 For this reason this approach was rejected in favor of using multiple
-child processes, which led to better performance.
+child processes, which led to better performance.
 
 Multi-Process Solution
 ----------------------
@@ -126,7 +126,7 @@ Then, for each assigned item, each worker:
 
 * W5: Writes the result to the file descriptor opened at W2.
 
-* W6: Calls `fstat()` or lstat()` on the just-written path, and sends
+* W6: Calls `fstat()` or `lstat()` on the just-written path, and sends
   the result back to the main process, together with the end status of
   the operation and the item's identification number.
 
@@ -148,7 +148,7 @@ information, the main process handles the results in two steps:
 
 - First, it updates the in-memory index with the `lstat()` information
   sent by the workers. (This must be done first as this information
-  might me required in the following step.)
+  might be required in the following step.)
 
 - Then it writes the items which collided on disk (i.e. items marked
   with `PC_ITEM_COLLIDED`). More on this below.
@@ -185,7 +185,7 @@ quite straightforward: for each parallel-eligible entry, the main
 process must remove all files that prevent this entry from being written
 (before enqueueing it). This includes any non-directory file in the
 leading path of the entry. Later, when a worker gets assigned the entry,
-it looks again for the non-directories files and for an already existing
+it looks again for the non-directory files and for an already existing
 file at the entry's path. If any of these checks finds something, the
 worker knows that there was a path collision.
 
@@ -232,7 +232,7 @@ conversion and re-encoding, are eligible for parallel checkout.
 Ineligible entries are checked out by the classic sequential codepath
 *before* spawning workers.
 
-Note: submodules's files are also eligible for parallel checkout (as
+Note: submodules' files are also eligible for parallel checkout (as
 long as they don't fall into any of the excluding categories mentioned
 above). But since each submodule is checked out in its own child
 process, we don't mix the superproject's and the submodules' files in
index 92fcee2bfffff8c42a07f0dd4b87421abd94f2bb..cd948b00722cba5ae9f01b31f6a226f8d4497ea8 100644 (file)
@@ -3,7 +3,7 @@ Partial Clone Design Notes
 
 The "Partial Clone" feature is a performance optimization for Git that
 allows Git to function without having a complete copy of the repository.
-The goal of this work is to allow Git better handle extremely large
+The goal of this work is to allow Git to better handle extremely large
 repositories.
 
 During clone and fetch operations, Git downloads the complete contents
@@ -256,7 +256,7 @@ remote in a specific order.
 - Dynamic object fetching currently uses the existing pack protocol V0
   which means that each object is requested via fetch-pack.  The server
   will send a full set of info/refs when the connection is established.
-  If there are large number of refs, this may incur significant overhead.
+  If there are large number of refs, this may incur significant overhead.
 
 
 Future Work
@@ -265,7 +265,7 @@ Future Work
 - Improve the way to specify the order in which promisor remotes are
   tried.
 +
-For example this could allow to specify explicitly something like:
+For example this could allow specifying explicitly something like:
 "When fetching from this remote, I want to use these promisor remotes
 in this order, though, when pushing or fetching to that remote, I want
 to use those promisor remotes in that order."
@@ -322,7 +322,7 @@ Footnotes
 
 [a] expensive-to-modify list of missing objects:  Earlier in the design of
     partial clone we discussed the need for a single list of missing objects.
-    This would essentially be a sorted linear list of OIDs that the were
+    This would essentially be a sorted linear list of OIDs that were
     omitted by the server during a clone or subsequent fetches.
 
 This file would need to be loaded into memory on every object lookup.
index ceda4bbfda4d27c8138c79f207f0d2adadf8bf50..59bea66c0fc6ef704e0ba9e81809a8ad1c2e9058 100644 (file)
@@ -11,7 +11,7 @@ write out the next tree object to be committed.  The state is
 "virtual" in the sense that it does not necessarily have to, and
 often does not, match the files in the working tree.
 
-There are cases Git needs to examine the differences between the
+There are cases where Git needs to examine the differences between the
 virtual working tree state in the index and the files in the
 working tree.  The most obvious case is when the user asks `git
 diff` (or its low level implementation, `git diff-files`) or
@@ -165,9 +165,9 @@ Avoiding runtime penalty
 
 In order to avoid the above runtime penalty, post 1.4.2 Git used
 to have a code that made sure the index file
-got timestamp newer than the youngest files in the index when
-there are many young files with the same timestamp as the
-resulting index file would otherwise would have by waiting
+got timestamp newer than the youngest files in the index when
+there were many young files with the same timestamp as the
+resulting index file otherwise would have by waiting
 before finishing writing the index file out.
 
 I suspected that in practice the situation where many paths in the
@@ -190,7 +190,7 @@ In a large project where raciness avoidance cost really matters,
 however, the initial computation of all object names in the
 index takes more than one second, and the index file is written
 out after all that happens.  Therefore the timestamp of the
-index file will be more than one seconds later than the
+index file will be more than one second later than the
 youngest file in the working tree.  This means that in these
 cases there actually will not be any racily clean entry in
 the resulting index.
index 6a67cc4174f820931a25bbd40c83959237b2983c..dd0b37c4e34738038b0171038dba6b180739d433 100644 (file)
@@ -46,7 +46,7 @@ search lookup, and range scans.
 
 Storage in the file is organized into variable sized blocks. Prefix
 compression is used within a single block to reduce disk space. Block
-size and alignment is tunable by the writer.
+size and alignment are tunable by the writer.
 
 Performance
 ^^^^^^^^^^^
@@ -115,7 +115,7 @@ Varint encoding
 Varint encoding is identical to the ofs-delta encoding method used
 within pack files.
 
-Decoder works such as:
+Decoder works as follows:
 
 ....
 val = buf[ptr] & 0x7f
@@ -175,7 +175,7 @@ log_index*
 footer
 ....
 
-in a log-only file the first log block immediately follows the file
+In a log-only file, the first log block immediately follows the file
 header, without padding to block alignment.
 
 Block size
@@ -247,7 +247,7 @@ uint32( hash_id )
 ....
 
 The header is identical to `version_number=1`, with the 4-byte hash ID
-("sha1" for SHA1 and "s256" for SHA-256) append to the header.
+("sha1" for SHA1 and "s256" for SHA-256) appended to the header.
 
 For maximum backward compatibility, it is recommended to use version 1 when
 writing SHA1 reftables.
@@ -288,7 +288,7 @@ The 2-byte `restart_count` stores the number of entries in the
 `restart_count` to binary search between restarts before starting a
 linear scan.
 
-Exactly `restart_count` 3-byte `restart_offset` values precedes the
+Exactly `restart_count` 3-byte `restart_offset` values precede the
 `restart_count`. Offsets are relative to the start of the block and
 refer to the first byte of any `ref_record` whose name has not been
 prefix compressed. Entries in the `restart_offset` list must be sorted,
index 8ef664b0b9537ad3c8fc554e68448a69a3b7f439..045a76756fcf47401dc61cb55f37df1deff480d7 100644 (file)
@@ -96,7 +96,7 @@ The value of this key is the name of the promisor remote.
 ==== `worktreeConfig`
 
 If set, by default "git config" reads from both "config" and
-"config.worktree" file from GIT_DIR in that order. In
+"config.worktree" files from GIT_DIR in that order. In
 multiple working directory mode, "config" file is shared while
 "config.worktree" is per-working directory (i.e., it's in
 GIT_COMMON_DIR/worktrees/<id>/config.worktree)
index be58f1bee368941cd7f8050fdfc23c55e48e48fa..580f23360a27bf71581ce6d570a041eba62d075a 100644 (file)
@@ -60,7 +60,7 @@ By resolving this conflict, to leave line D, the user declares:
     what AB and AC wanted to do.
 
 As branch AC2 refers to the same commit as AC, the above implies that
-this is also compatible what AB and AC2 wanted to do.
+this is also compatible with what AB and AC2 wanted to do.
 
 By extension, this means that rerere should recognize that the above
 conflicts are the same.  To do this, the labels on the conflict
@@ -76,7 +76,7 @@ examples would both result in the following normalized conflict:
 Sorting hunks
 ~~~~~~~~~~~~~
 
-As before, lets imagine that a common ancestor had a file with line A
+As before, let's imagine that a common ancestor had a file with line A
 its early part, and line X in its late part.  And then four branches
 are forked that do these things:
 
@@ -145,7 +145,7 @@ Nested conflicts
 Nested conflicts are handled very similarly to "simple" conflicts.
 Similar to simple conflicts, the conflict is first normalized by
 stripping the labels from conflict markers, stripping the common ancestor
-version, and the sorting the conflict hunks, both for the outer and the
+version, and sorting the conflict hunks, both for the outer and the
 inner conflict.  This is done recursively, so any number of nested
 conflicts can be handled.
 
index ae8c2db427bb6a5671b6cf598574e8392c715d97..bf17012241536ceb1c407fea04b7b1a84441923f 100644 (file)
@@ -33,7 +33,7 @@ config file would appear like this:
 ------------
 
 The `<pushurl>` is used for pushes only. It is optional and defaults
-to `<URL>`. Pushing to a remote affects all defined pushurls or to all
+to `<URL>`. Pushing to a remote affects all defined pushurls or all
 defined urls if no pushurls are defined. Fetch, however, will only
 fetch from the first defined url if multiple urls are defined.
 
@@ -48,7 +48,7 @@ provide a refspec on the command line.  This file should have the
 following format:
 
 ------------
-       URL: one of the above URL format
+       URL: one of the above URL formats
        Push: <refspec>
        Pull: <refspec>
 
index 1c229d758152b6377e23125967e2041a5fd5be5a..4e79c1589ece05ff21a144e5b48829a5dc39b50f 100644 (file)
@@ -6,9 +6,9 @@ address of the remote server, and the path to the repository.
 Depending on the transport protocol, some of this information may be
 absent.
 
-Git supports ssh, git, http, and https protocols (in addition, ftp,
+Git supports ssh, git, http, and https protocols (in addition, ftp
 and ftps can be used for fetching, but this is inefficient and
-deprecated; do not use it).
+deprecated; do not use them).
 
 The native transport (i.e. git:// URL) does no authentication and
 should be used with caution on unsecured networks.
index 4281396093d7c92d22ccf2a8f7dd7c98400445e2..d8dbe6b56d42a693461d7deae9ac76e214f3d1e4 100644 (file)
@@ -1122,7 +1122,7 @@ choosing "Stage Hunk For Commit").
 === Creating good commit messages
 
 Though not required, it's a good idea to begin the commit message
-with a single short (less than 50 character) line summarizing the
+with a single short (no more than 50 characters) line summarizing the
 change, followed by a blank line and then a more thorough
 description.  The text up to the first blank line in a commit
 message is treated as the commit title, and that title is used
index 226c8c19ffc413b8ffc18af1b81d029964e2e01a..7e71bb38003a314845f6ae90c62273068865f6d1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v2.42.1
+DEF_VER=v2.43.0-rc0
 
 LF='
 '
index 5776309365357a5848c5f03214690e75d7deb57c..03adcb5a48072e2c7edd006ca9b249812f9a39c5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -800,6 +800,7 @@ TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
 TEST_BUILTINS_OBJS += test-env-helper.o
 TEST_BUILTINS_OBJS += test-example-decorate.o
 TEST_BUILTINS_OBJS += test-fast-rebase.o
+TEST_BUILTINS_OBJS += test-find-pack.o
 TEST_BUILTINS_OBJS += test-fsmonitor-client.o
 TEST_BUILTINS_OBJS += test-genrandom.o
 TEST_BUILTINS_OBJS += test-genzeros.o
@@ -808,7 +809,6 @@ TEST_BUILTINS_OBJS += test-hash-speed.o
 TEST_BUILTINS_OBJS += test-hash.o
 TEST_BUILTINS_OBJS += test-hashmap.o
 TEST_BUILTINS_OBJS += test-hexdump.o
-TEST_BUILTINS_OBJS += test-index-version.o
 TEST_BUILTINS_OBJS += test-json-writer.o
 TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
 TEST_BUILTINS_OBJS += test-match-trees.o
@@ -852,6 +852,7 @@ TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
 TEST_BUILTINS_OBJS += test-submodule.o
 TEST_BUILTINS_OBJS += test-subprocess.o
 TEST_BUILTINS_OBJS += test-trace2.o
+TEST_BUILTINS_OBJS += test-truncate.o
 TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
 TEST_BUILTINS_OBJS += test-userdiff.o
 TEST_BUILTINS_OBJS += test-wildmatch.o
@@ -1040,6 +1041,7 @@ LIB_OBJS += hash-lookup.o
 LIB_OBJS += hashmap.o
 LIB_OBJS += help.o
 LIB_OBJS += hex.o
+LIB_OBJS += hex-ll.o
 LIB_OBJS += hook.o
 LIB_OBJS += ident.o
 LIB_OBJS += json-writer.o
@@ -1090,6 +1092,7 @@ LIB_OBJS += pack-write.o
 LIB_OBJS += packfile.o
 LIB_OBJS += pager.o
 LIB_OBJS += parallel-checkout.o
+LIB_OBJS += parse.o
 LIB_OBJS += parse-options-cb.o
 LIB_OBJS += parse-options.o
 LIB_OBJS += patch-delta.o
index 234837ed95ae627e918246d1a736674f8d3dfa46..278cea33c4cc4cfaf34427ee340c163755d935df 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.42.1.txt
\ No newline at end of file
+Documentation/RelNotes/2.43.0.txt
\ No newline at end of file
index 7fd00c5e2502d6aa2c151196f87fb20ed0c0c578..6bf87e7ae71b06ea59d42d238c6242a66fdec0b5 100644 (file)
@@ -1021,9 +1021,9 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
        return res;
 }
 
-static int run_help(struct add_i_state *s, const struct pathspec *unused_ps,
-                   struct prefix_item_list *unused_files,
-                   struct list_and_choose_options *unused_opts)
+static int run_help(struct add_i_state *s, const struct pathspec *ps UNUSED,
+                   struct prefix_item_list *files UNUSED,
+                   struct list_and_choose_options *opts UNUSED)
 {
        color_fprintf_ln(stdout, s->help_color, "status        - %s",
                         _("show paths with changes"));
@@ -1074,7 +1074,7 @@ struct print_command_item_data {
        const char *color, *reset;
 };
 
-static void print_command_item(int i, int selected,
+static void print_command_item(int i, int selected UNUSED,
                               struct string_list_item *item,
                               void *print_command_item_data)
 {
diff --git a/attr.c b/attr.c
index ff0a3e7b61ad0468de7d42305ffc723fbfb9c9e1..e62876dfd3e9beae50d18da63f15285d5974b8ec 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -24,6 +24,8 @@
 #include "tree-walk.h"
 #include "object-name.h"
 
+const char *git_attr_tree;
+
 const char git_attr__true[] = "(builtin)true";
 const char git_attr__false[] = "\0(builtin)false";
 static const char git_attr__unknown[] = "(builtin)unknown";
@@ -807,35 +809,56 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
 static struct attr_stack *read_attr_from_index(struct index_state *istate,
                                               const char *path, unsigned flags)
 {
+       struct attr_stack *stack = NULL;
        char *buf;
        unsigned long size;
+       int sparse_dir_pos = -1;
 
        if (!istate)
                return NULL;
 
        /*
-        * The .gitattributes file only applies to files within its
-        * parent directory. In the case of cone-mode sparse-checkout,
-        * the .gitattributes file is sparse if and only if all paths
-        * within that directory are also sparse. Thus, don't load the
-        * .gitattributes file since it will not matter.
-        *
-        * In the case of a sparse index, it is critical that we don't go
-        * looking for a .gitattributes file, as doing so would cause the
-        * index to expand.
+        * When handling sparse-checkouts, .gitattributes files
+        * may reside within a sparse directory. We distinguish
+        * whether a path exists directly in the index or not by
+        * evaluating if 'pos' is negative.
+        * If 'pos' is negative, the path is not directly present
+        * in the index and is likely within a sparse directory.
+        * For paths not in the index, The absolute value of 'pos'
+        * minus 1 gives us the position where the path would be
+        * inserted in lexicographic order within the index.
+        * We then subtract another 1 from this value
+        * (sparse_dir_pos = -pos - 2) to find the position of the
+        * last index entry which is lexicographically smaller than
+        * the path. This would be the sparse directory containing
+        * the path. By identifying the sparse directory containing
+        * the path, we can correctly read the attributes specified
+        * in the .gitattributes file from the tree object of the
+        * sparse directory.
         */
-       if (!path_in_cone_mode_sparse_checkout(path, istate))
-               return NULL;
+       if (!path_in_cone_mode_sparse_checkout(path, istate)) {
+               int pos = index_name_pos_sparse(istate, path, strlen(path));
 
-       buf = read_blob_data_from_index(istate, path, &size);
-       if (!buf)
-               return NULL;
-       if (size >= ATTR_MAX_FILE_SIZE) {
-               warning(_("ignoring overly large gitattributes blob '%s'"), path);
-               return NULL;
+               if (pos < 0)
+                       sparse_dir_pos = -pos - 2;
        }
 
-       return read_attr_from_buf(buf, path, flags);
+       if (sparse_dir_pos >= 0 &&
+           S_ISSPARSEDIR(istate->cache[sparse_dir_pos]->ce_mode) &&
+           !strncmp(istate->cache[sparse_dir_pos]->name, path, ce_namelen(istate->cache[sparse_dir_pos]))) {
+               const char *relative_path = path + ce_namelen(istate->cache[sparse_dir_pos]);
+               stack = read_attr_from_blob(istate, &istate->cache[sparse_dir_pos]->oid, relative_path, flags);
+       } else {
+               buf = read_blob_data_from_index(istate, path, &size);
+               if (!buf)
+                       return NULL;
+               if (size >= ATTR_MAX_FILE_SIZE) {
+                       warning(_("ignoring overly large gitattributes blob '%s'"), path);
+                       return NULL;
+               }
+               stack = read_attr_from_buf(buf, path, flags);
+       }
+       return stack;
 }
 
 static struct attr_stack *read_attr(struct index_state *istate,
@@ -1173,6 +1196,7 @@ static void collect_some_attrs(struct index_state *istate,
 }
 
 static const char *default_attr_source_tree_object_name;
+static int ignore_bad_attr_tree;
 
 void set_git_attr_source(const char *tree_object_name)
 {
@@ -1184,10 +1208,24 @@ static void compute_default_attr_source(struct object_id *attr_source)
        if (!default_attr_source_tree_object_name)
                default_attr_source_tree_object_name = getenv(GIT_ATTR_SOURCE_ENVIRONMENT);
 
+       if (!default_attr_source_tree_object_name && git_attr_tree) {
+               default_attr_source_tree_object_name = git_attr_tree;
+               ignore_bad_attr_tree = 1;
+       }
+
+       if (!default_attr_source_tree_object_name &&
+           startup_info->have_repository &&
+           is_bare_repository()) {
+               default_attr_source_tree_object_name = "HEAD";
+               ignore_bad_attr_tree = 1;
+       }
+
        if (!default_attr_source_tree_object_name || !is_null_oid(attr_source))
                return;
 
-       if (repo_get_oid_treeish(the_repository, default_attr_source_tree_object_name, attr_source))
+       if (repo_get_oid_treeish(the_repository,
+                                default_attr_source_tree_object_name,
+                                attr_source) && !ignore_bad_attr_tree)
                die(_("bad --attr-source or GIT_ATTR_SOURCE"));
 }
 
diff --git a/attr.h b/attr.h
index 2b745df4054d7a5fe5e537ac4d894ccbd199b9c4..127998ae013c9de221b700144ad2082a78bfcaba 100644 (file)
--- a/attr.h
+++ b/attr.h
@@ -236,4 +236,6 @@ const char *git_attr_global_file(void);
 /* Return whether the system gitattributes file is enabled and should be used. */
 int git_attr_system_is_enabled(void);
 
+extern const char *git_attr_tree;
+
 #endif /* ATTR_H */
diff --git a/bloom.c b/bloom.c
index aef6b5fea2d18f521b4812bd017fe685f635be47..1474aa19fa524ff1695c2b518259f61b1c2023b7 100644 (file)
--- a/bloom.c
+++ b/bloom.c
@@ -29,6 +29,26 @@ static inline unsigned char get_bitmask(uint32_t pos)
        return ((unsigned char)1) << (pos & (BITS_PER_WORD - 1));
 }
 
+static int check_bloom_offset(struct commit_graph *g, uint32_t pos,
+                             uint32_t offset)
+{
+       /*
+        * Note that we allow offsets equal to the data size, which would set
+        * our pointers at one past the end of the chunk memory. This is
+        * necessary because the on-disk index points to the end of the
+        * entries (so we can compute size by comparing adjacent ones). And
+        * naturally the final entry's end is one-past-the-end of the chunk.
+        */
+       if (offset <= g->chunk_bloom_data_size - BLOOMDATA_CHUNK_HEADER_SIZE)
+               return 0;
+
+       warning("ignoring out-of-range offset (%"PRIuMAX") for changed-path"
+               " filter at pos %"PRIuMAX" of %s (chunk size: %"PRIuMAX")",
+               (uintmax_t)offset, (uintmax_t)pos,
+               g->filename, (uintmax_t)g->chunk_bloom_data_size);
+       return -1;
+}
+
 static int load_bloom_filter_from_graph(struct commit_graph *g,
                                        struct bloom_filter *filter,
                                        uint32_t graph_pos)
@@ -51,6 +71,20 @@ static int load_bloom_filter_from_graph(struct commit_graph *g,
        else
                start_index = 0;
 
+       if (check_bloom_offset(g, lex_pos, end_index) < 0 ||
+           check_bloom_offset(g, lex_pos - 1, start_index) < 0)
+               return 0;
+
+       if (end_index < start_index) {
+               warning("ignoring decreasing changed-path index offsets"
+                       " (%"PRIuMAX" > %"PRIuMAX") for positions"
+                       " %"PRIuMAX" and %"PRIuMAX" of %s",
+                       (uintmax_t)start_index, (uintmax_t)end_index,
+                       (uintmax_t)(lex_pos-1), (uintmax_t)lex_pos,
+                       g->filename);
+               return 0;
+       }
+
        filter->len = end_index - start_index;
        filter->data = (unsigned char *)(g->chunk_bloom_data +
                                        sizeof(unsigned char) * start_index +
index 3e4684f79f693059a6272465dd983e149aee5eb9..06f7af9dd47260d87158ba672f90d2b5c37e558e 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -838,7 +838,7 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree)
 
                if (is_shared_symref(worktrees[i], "HEAD", branch)) {
                        skip_prefix(branch, "refs/heads/", &branch);
-                       die(_("'%s' is already checked out at '%s'"),
+                       die(_("'%s' is already used by worktree at '%s'"),
                                branch, worktrees[i]->path);
                }
        }
index 0057392f988fdbaebc55628585b5d519e93307ed..5126d2ede3d7614f764c0cb7cab4b694a792074e 100644 (file)
@@ -231,6 +231,8 @@ static char *chmod_arg;
 
 static int ignore_removal_cb(const struct option *opt, const char *arg, int unset)
 {
+       BUG_ON_OPT_ARG(arg);
+
        /* if we are told to ignore, we are not adding removals */
        *(int *)opt->value = !unset ? 0 : 1;
        return 0;
index 6655059a57c8fc7563bdd17d266faa510bf1c9c6..9f084d58bc705c74d6986541fe81161dcd37df8c 100644 (file)
@@ -92,9 +92,16 @@ enum signoff_type {
        SIGNOFF_EXPLICIT /* --signoff was set on the command-line */
 };
 
-enum show_patch_type {
-       SHOW_PATCH_RAW = 0,
-       SHOW_PATCH_DIFF = 1,
+enum resume_type {
+       RESUME_FALSE = 0,
+       RESUME_APPLY,
+       RESUME_RESOLVED,
+       RESUME_SKIP,
+       RESUME_ABORT,
+       RESUME_QUIT,
+       RESUME_SHOW_PATCH_RAW,
+       RESUME_SHOW_PATCH_DIFF,
+       RESUME_ALLOW_EMPTY,
 };
 
 enum empty_action {
@@ -2191,7 +2198,7 @@ static void am_abort(struct am_state *state)
        am_destroy(state);
 }
 
-static int show_patch(struct am_state *state, enum show_patch_type sub_mode)
+static int show_patch(struct am_state *state, enum resume_type resume_mode)
 {
        struct strbuf sb = STRBUF_INIT;
        const char *patch_path;
@@ -2206,11 +2213,11 @@ static int show_patch(struct am_state *state, enum show_patch_type sub_mode)
                return run_command(&cmd);
        }
 
-       switch (sub_mode) {
-       case SHOW_PATCH_RAW:
+       switch (resume_mode) {
+       case RESUME_SHOW_PATCH_RAW:
                patch_path = am_path(state, msgnum(state));
                break;
-       case SHOW_PATCH_DIFF:
+       case RESUME_SHOW_PATCH_DIFF:
                patch_path = am_path(state, "patch");
                break;
        default:
@@ -2257,57 +2264,25 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
        return 0;
 }
 
-enum resume_type {
-       RESUME_FALSE = 0,
-       RESUME_APPLY,
-       RESUME_RESOLVED,
-       RESUME_SKIP,
-       RESUME_ABORT,
-       RESUME_QUIT,
-       RESUME_SHOW_PATCH,
-       RESUME_ALLOW_EMPTY,
-};
-
-struct resume_mode {
-       enum resume_type mode;
-       enum show_patch_type sub_mode;
-};
-
 static int parse_opt_show_current_patch(const struct option *opt, const char *arg, int unset)
 {
        int *opt_value = opt->value;
-       struct resume_mode *resume = container_of(opt_value, struct resume_mode, mode);
 
+       BUG_ON_OPT_NEG(unset);
+
+       if (!arg)
+               *opt_value = opt->defval;
+       else if (!strcmp(arg, "raw"))
+               *opt_value = RESUME_SHOW_PATCH_RAW;
+       else if (!strcmp(arg, "diff"))
+               *opt_value = RESUME_SHOW_PATCH_DIFF;
        /*
         * Please update $__git_showcurrentpatch in git-completion.bash
         * when you add new options
         */
-       const char *valid_modes[] = {
-               [SHOW_PATCH_DIFF] = "diff",
-               [SHOW_PATCH_RAW] = "raw"
-       };
-       int new_value = SHOW_PATCH_RAW;
-
-       BUG_ON_OPT_NEG(unset);
-
-       if (arg) {
-               for (new_value = 0; new_value < ARRAY_SIZE(valid_modes); new_value++) {
-                       if (!strcmp(arg, valid_modes[new_value]))
-                               break;
-               }
-               if (new_value >= ARRAY_SIZE(valid_modes))
-                       return error(_("invalid value for '%s': '%s'"),
-                                    "--show-current-patch", arg);
-       }
-
-       if (resume->mode == RESUME_SHOW_PATCH && new_value != resume->sub_mode)
-               return error(_("options '%s=%s' and '%s=%s' "
-                                          "cannot be used together"),
-                            "--show-current-patch", arg,
-                            "--show-current-patch", valid_modes[resume->sub_mode]);
-
-       resume->mode = RESUME_SHOW_PATCH;
-       resume->sub_mode = new_value;
+       else
+               return error(_("invalid value for '%s': '%s'"),
+                            "--show-current-patch", arg);
        return 0;
 }
 
@@ -2317,7 +2292,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
        int binary = -1;
        int keep_cr = -1;
        int patch_format = PATCH_FORMAT_UNKNOWN;
-       struct resume_mode resume = { .mode = RESUME_FALSE };
+       enum resume_type resume_mode = RESUME_FALSE;
        int in_progress;
        int ret = 0;
 
@@ -2388,27 +2363,27 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                        PARSE_OPT_NOARG),
                OPT_STRING(0, "resolvemsg", &state.resolvemsg, NULL,
                        N_("override error message when patch failure occurs")),
-               OPT_CMDMODE(0, "continue", &resume.mode,
+               OPT_CMDMODE(0, "continue", &resume_mode,
                        N_("continue applying patches after resolving a conflict"),
                        RESUME_RESOLVED),
-               OPT_CMDMODE('r', "resolved", &resume.mode,
+               OPT_CMDMODE('r', "resolved", &resume_mode,
                        N_("synonyms for --continue"),
                        RESUME_RESOLVED),
-               OPT_CMDMODE(0, "skip", &resume.mode,
+               OPT_CMDMODE(0, "skip", &resume_mode,
                        N_("skip the current patch"),
                        RESUME_SKIP),
-               OPT_CMDMODE(0, "abort", &resume.mode,
+               OPT_CMDMODE(0, "abort", &resume_mode,
                        N_("restore the original branch and abort the patching operation"),
                        RESUME_ABORT),
-               OPT_CMDMODE(0, "quit", &resume.mode,
+               OPT_CMDMODE(0, "quit", &resume_mode,
                        N_("abort the patching operation but keep HEAD where it is"),
                        RESUME_QUIT),
-               { OPTION_CALLBACK, 0, "show-current-patch", &resume.mode,
+               { OPTION_CALLBACK, 0, "show-current-patch", &resume_mode,
                  "(diff|raw)",
                  N_("show the patch being applied"),
                  PARSE_OPT_CMDMODE | PARSE_OPT_OPTARG | PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
-                 parse_opt_show_current_patch, RESUME_SHOW_PATCH },
-               OPT_CMDMODE(0, "allow-empty", &resume.mode,
+                 parse_opt_show_current_patch, RESUME_SHOW_PATCH_RAW },
+               OPT_CMDMODE(0, "allow-empty", &resume_mode,
                        N_("record the empty patch as an empty commit"),
                        RESUME_ALLOW_EMPTY),
                OPT_BOOL(0, "committer-date-is-author-date",
@@ -2420,7 +2395,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                { OPTION_STRING, 'S', "gpg-sign", &state.sign_commit, N_("key-id"),
                  N_("GPG-sign commits"),
                  PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
-               OPT_CALLBACK_F(STOP_ON_EMPTY_COMMIT, "empty", &state.empty_type, "{stop,drop,keep}",
+               OPT_CALLBACK_F(0, "empty", &state.empty_type, "(stop|drop|keep)",
                  N_("how to handle empty patches"),
                  PARSE_OPT_NONEG, am_option_parse_empty),
                OPT_HIDDEN_BOOL(0, "rebasing", &state.rebasing,
@@ -2463,12 +2438,12 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                 *    intend to feed us a patch but wanted to continue
                 *    unattended.
                 */
-               if (argc || (resume.mode == RESUME_FALSE && !isatty(0)))
+               if (argc || (resume_mode == RESUME_FALSE && !isatty(0)))
                        die(_("previous rebase directory %s still exists but mbox given."),
                                state.dir);
 
-               if (resume.mode == RESUME_FALSE)
-                       resume.mode = RESUME_APPLY;
+               if (resume_mode == RESUME_FALSE)
+                       resume_mode = RESUME_APPLY;
 
                if (state.signoff == SIGNOFF_EXPLICIT)
                        am_append_signoff(&state);
@@ -2482,7 +2457,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                 * stray directories.
                 */
                if (file_exists(state.dir) && !state.rebasing) {
-                       if (resume.mode == RESUME_ABORT || resume.mode == RESUME_QUIT) {
+                       if (resume_mode == RESUME_ABORT || resume_mode == RESUME_QUIT) {
                                am_destroy(&state);
                                am_state_release(&state);
                                return 0;
@@ -2493,7 +2468,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                                state.dir);
                }
 
-               if (resume.mode)
+               if (resume_mode)
                        die(_("Resolve operation not in progress, we are not resuming."));
 
                for (i = 0; i < argc; i++) {
@@ -2511,7 +2486,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                strvec_clear(&paths);
        }
 
-       switch (resume.mode) {
+       switch (resume_mode) {
        case RESUME_FALSE:
                am_run(&state, 0);
                break;
@@ -2520,7 +2495,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                break;
        case RESUME_RESOLVED:
        case RESUME_ALLOW_EMPTY:
-               am_resolve(&state, resume.mode == RESUME_ALLOW_EMPTY ? 1 : 0);
+               am_resolve(&state, resume_mode == RESUME_ALLOW_EMPTY ? 1 : 0);
                break;
        case RESUME_SKIP:
                am_skip(&state);
@@ -2532,8 +2507,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                am_rerere_clear();
                am_destroy(&state);
                break;
-       case RESUME_SHOW_PATCH:
-               ret = show_patch(&state, resume.sub_mode);
+       case RESUME_SHOW_PATCH_RAW:
+       case RESUME_SHOW_PATCH_DIFF:
+               ret = show_patch(&state, resume_mode);
                break;
        default:
                BUG("invalid resume value");
index 65478ef40f54e35cbed33234209fc3fac8b4e99b..35938b05fd1c0b51e64a01e58294f267afc4d758 100644 (file)
@@ -26,7 +26,7 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
 static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
 
 #define BUILTIN_GIT_BISECT_START_USAGE \
-       N_("git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>]" \
+       N_("git bisect start [--term-(new|bad)=<term> --term-(old|good)=<term>]" \
           "    [--no-checkout] [--first-parent] [<bad> [<good>...]] [--]" \
           "    [<pathspec>...]")
 #define BUILTIN_GIT_BISECT_STATE_USAGE \
@@ -46,7 +46,7 @@ static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
 #define BUILTIN_GIT_BISECT_LOG_USAGE \
        "git bisect log"
 #define BUILTIN_GIT_BISECT_RUN_USAGE \
-       N_("git bisect run <cmd>...")
+       N_("git bisect run <cmd> [<arg>...]")
 
 static const char * const git_bisect_usage[] = {
        BUILTIN_GIT_BISECT_START_USAGE,
index 08da650516037e2e18b2e99831562db533111254..e7ee9bd0f15028532087132cdc6062e8632568c2 100644 (file)
@@ -173,11 +173,11 @@ static int branch_merged(int kind, const char *name,
            (head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) {
                if (merged)
                        warning(_("deleting branch '%s' that has been merged to\n"
-                               "         '%s', but not yet merged to HEAD."),
+                               "         '%s', but not yet merged to HEAD"),
                                name, reference_name);
                else
                        warning(_("not deleting branch '%s' that is not yet merged to\n"
-                               "         '%s', even though it is merged to HEAD."),
+                               "         '%s', even though it is merged to HEAD"),
                                name, reference_name);
        }
        free(reference_name_to_free);
@@ -190,13 +190,13 @@ static int check_branch_commit(const char *branchname, const char *refname,
 {
        struct commit *rev = lookup_commit_reference(the_repository, oid);
        if (!force && !rev) {
-               error(_("Couldn't look up commit object for '%s'"), refname);
+               error(_("couldn't look up commit object for '%s'"), refname);
                return -1;
        }
        if (!force && !branch_merged(kinds, branchname, rev, head_rev)) {
-               error(_("The branch '%s' is not fully merged.\n"
+               error(_("the branch '%s' is not fully merged.\n"
                      "If you are sure you want to delete it, "
-                     "run 'git branch -D %s'."), branchname, branchname);
+                     "run 'git branch -D %s'"), branchname, branchname);
                return -1;
        }
        return 0;
@@ -207,7 +207,7 @@ static void delete_branch_config(const char *branchname)
        struct strbuf buf = STRBUF_INIT;
        strbuf_addf(&buf, "branch.%s", branchname);
        if (git_config_rename_section(buf.buf, NULL) < 0)
-               warning(_("Update of config-file failed"));
+               warning(_("update of config-file failed"));
        strbuf_release(&buf);
 }
 
@@ -260,8 +260,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                if (kinds == FILTER_REFS_BRANCHES) {
                        const char *path;
                        if ((path = branch_checked_out(name))) {
-                               error(_("Cannot delete branch '%s' "
-                                       "checked out at '%s'"),
+                               error(_("cannot delete branch '%s' "
+                                       "used by worktree at '%s'"),
                                      bname.buf, path);
                                ret = 1;
                                continue;
@@ -275,7 +275,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                                        &oid, &flags);
                if (!target) {
                        if (remote_branch) {
-                               error(_("remote-tracking branch '%s' not found."), bname.buf);
+                               error(_("remote-tracking branch '%s' not found"), bname.buf);
                        } else {
                                char *virtual_name = mkpathdup(fmt_remotes, bname.buf);
                                char *virtual_target = resolve_refdup(virtual_name,
@@ -290,7 +290,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                                                "Did you forget --remote?"),
                                                bname.buf);
                                else
-                                       error(_("branch '%s' not found."), bname.buf);
+                                       error(_("branch '%s' not found"), bname.buf);
                                FREE_AND_NULL(virtual_target);
                        }
                        ret = 1;
@@ -518,11 +518,11 @@ static void reject_rebase_or_bisect_branch(struct worktree **worktrees,
                        continue;
 
                if (is_worktree_being_rebased(wt, target))
-                       die(_("Branch %s is being rebased at %s"),
+                       die(_("branch %s is being rebased at %s"),
                            target, wt->path);
 
                if (is_worktree_being_bisected(wt, target))
-                       die(_("Branch %s is being bisected at %s"),
+                       die(_("branch %s is being bisected at %s"),
                            target, wt->path);
        }
 }
@@ -578,7 +578,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
                if (ref_exists(oldref.buf))
                        recovery = 1;
                else
-                       die(_("Invalid branch name: '%s'"), oldname);
+                       die(_("invalid branch name: '%s'"), oldname);
        }
 
        for (int i = 0; worktrees[i]; i++) {
@@ -594,9 +594,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
 
        if ((copy || !(oldref_usage & IS_HEAD)) && !ref_exists(oldref.buf)) {
                if (oldref_usage & IS_HEAD)
-                       die(_("No commit on branch '%s' yet."), oldname);
+                       die(_("no commit on branch '%s' yet"), oldname);
                else
-                       die(_("No branch named '%s'."), oldname);
+                       die(_("no branch named '%s'"), oldname);
        }
 
        /*
@@ -624,32 +624,32 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
 
        if (!copy && !(oldref_usage & IS_ORPHAN) &&
            rename_ref(oldref.buf, newref.buf, logmsg.buf))
-               die(_("Branch rename failed"));
+               die(_("branch rename failed"));
        if (copy && copy_existing_ref(oldref.buf, newref.buf, logmsg.buf))
-               die(_("Branch copy failed"));
+               die(_("branch copy failed"));
 
        if (recovery) {
                if (copy)
-                       warning(_("Created a copy of a misnamed branch '%s'"),
+                       warning(_("created a copy of a misnamed branch '%s'"),
                                interpreted_oldname);
                else
-                       warning(_("Renamed a misnamed branch '%s' away"),
+                       warning(_("renamed a misnamed branch '%s' away"),
                                interpreted_oldname);
        }
 
        if (!copy && (oldref_usage & IS_HEAD) &&
            replace_each_worktree_head_symref(worktrees, oldref.buf, newref.buf,
                                              logmsg.buf))
-               die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
+               die(_("branch renamed to %s, but HEAD is not updated"), newname);
 
        strbuf_release(&logmsg);
 
        strbuf_addf(&oldsection, "branch.%s", interpreted_oldname);
        strbuf_addf(&newsection, "branch.%s", interpreted_newname);
        if (!copy && git_config_rename_section(oldsection.buf, newsection.buf) < 0)
-               die(_("Branch is renamed, but update of config-file failed"));
+               die(_("branch is renamed, but update of config-file failed"));
        if (copy && strcmp(interpreted_oldname, interpreted_newname) && git_config_copy_section(oldsection.buf, newsection.buf) < 0)
-               die(_("Branch is copied, but update of config-file failed"));
+               die(_("branch is copied, but update of config-file failed"));
        strbuf_release(&oldref);
        strbuf_release(&newref);
        strbuf_release(&oldsection);
@@ -773,7 +773,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
        head = resolve_refdup("HEAD", 0, &head_oid, NULL);
        if (!head)
-               die(_("Failed to resolve HEAD as a valid ref."));
+               die(_("failed to resolve HEAD as a valid ref"));
        if (!strcmp(head, "HEAD"))
                filter.detached = 1;
        else if (!skip_prefix(head, "refs/heads/", &head))
@@ -866,7 +866,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
                if (!argc) {
                        if (filter.detached)
-                               die(_("Cannot give description to detached HEAD"));
+                               die(_("cannot give description to detached HEAD"));
                        branch_name = head;
                } else if (argc == 1) {
                        strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
@@ -878,8 +878,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
                if (!ref_exists(branch_ref.buf))
                        error((!argc || branch_checked_out(branch_ref.buf))
-                             ? _("No commit on branch '%s' yet.")
-                             : _("No branch named '%s'."),
+                             ? _("no commit on branch '%s' yet")
+                             : _("no branch named '%s'"),
                              branch_name);
                else if (!edit_branch_description(branch_name))
                        ret = 0; /* happy */
@@ -892,8 +892,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                if (!argc)
                        die(_("branch name required"));
                else if ((argc == 1) && filter.detached)
-                       die(copy? _("cannot copy the current branch while not on any.")
-                               : _("cannot rename the current branch while not on any."));
+                       die(copy? _("cannot copy the current branch while not on any")
+                               : _("cannot rename the current branch while not on any"));
                else if (argc == 1)
                        copy_or_rename_branch(head, argv[0], copy, copy + rename > 1);
                else if (argc == 2)
@@ -916,14 +916,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                if (!branch) {
                        if (!argc || !strcmp(argv[0], "HEAD"))
                                die(_("could not set upstream of HEAD to %s when "
-                                     "it does not point to any branch."),
+                                     "it does not point to any branch"),
                                    new_upstream);
                        die(_("no such branch '%s'"), argv[0]);
                }
 
                if (!ref_exists(branch->refname)) {
                        if (!argc || branch_checked_out(branch->refname))
-                               die(_("No commit on branch '%s' yet."), branch->name);
+                               die(_("no commit on branch '%s' yet"), branch->name);
                        die(_("branch '%s' does not exist"), branch->name);
                }
 
@@ -946,12 +946,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                if (!branch) {
                        if (!argc || !strcmp(argv[0], "HEAD"))
                                die(_("could not unset upstream of HEAD when "
-                                     "it does not point to any branch."));
+                                     "it does not point to any branch"));
                        die(_("no such branch '%s'"), argv[0]);
                }
 
                if (!branch_has_merge_config(branch))
-                       die(_("Branch '%s' has no upstream information"), branch->name);
+                       die(_("branch '%s' has no upstream information"), branch->name);
 
                strbuf_reset(&buf);
                strbuf_addf(&buf, "branch.%s.remote", branch->name);
@@ -965,11 +965,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                const char *start_name = argc == 2 ? argv[1] : head;
 
                if (filter.kind != FILTER_REFS_BRANCHES)
-                       die(_("The -a, and -r, options to 'git branch' do not take a branch name.\n"
+                       die(_("the -a, and -r, options to 'git branch' do not take a branch name.\n"
                                  "Did you mean to use: -a|-r --list <pattern>?"));
 
                if (track == BRANCH_TRACK_OVERRIDE)
-                       die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead."));
+                       die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead"));
 
                if (recurse_submodules) {
                        create_branches_recursively(the_repository, branch_name,
index d2ae5c305db82cda78851196411f6437f4abbda9..3106e56a130c58994fced2afd8dbd337134861ad 100644 (file)
@@ -126,6 +126,11 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, bugreport_options,
                             bugreport_usage, 0);
 
+       if (argc) {
+               error(_("unknown argument `%s'"), argv[0]);
+               usage(bugreport_usage[0]);
+       }
+
        /* Prepare the path to put the result */
        prefixed_filename = prefix_filename(prefix,
                                            option_output ? option_output : "");
index b22ff748c3e20819887084f1175015a9a6078815..c1da1d184e9f6e24687f751bc67f88641f7083b0 100644 (file)
@@ -122,6 +122,9 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, check_attr_options,
                             check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
 
+       prepare_repo_settings(the_repository);
+       the_repository->settings.command_requires_full_index = 0;
+
        if (repo_read_index(the_repository) < 0) {
                die("invalid cache");
        }
index f62f13f2b5324e15f982071f73b24281d2d9637a..3b68b47615302473cf3e2c5c70f9ebf1c707c3af 100644 (file)
@@ -24,7 +24,7 @@
 static int nul_term_line;
 static int checkout_stage; /* default to checkout stage0 */
 static int ignore_skip_worktree; /* default to 0 */
-static int to_tempfile;
+static int to_tempfile = -1;
 static char topath[4][TEMPORARY_FILENAME_LENGTH + 1];
 
 static struct checkout state = CHECKOUT_INIT;
@@ -193,15 +193,16 @@ static const char * const builtin_checkout_index_usage[] = {
 static int option_parse_stage(const struct option *opt,
                              const char *arg, int unset)
 {
+       int *stage = opt->value;
+
        BUG_ON_OPT_NEG(unset);
 
        if (!strcmp(arg, "all")) {
-               to_tempfile = 1;
-               checkout_stage = CHECKOUT_ALL;
+               *stage = CHECKOUT_ALL;
        } else {
                int ch = arg[0];
                if ('1' <= ch && ch <= '3')
-                       checkout_stage = arg[0] - '0';
+                       *stage = arg[0] - '0';
                else
                        die(_("stage should be between 1 and 3 or all"));
        }
@@ -239,7 +240,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                        N_("write the content to temporary files")),
                OPT_STRING(0, "prefix", &state.base_dir, N_("string"),
                        N_("when creating files, prepend <string>")),
-               OPT_CALLBACK_F(0, "stage", NULL, "(1|2|3|all)",
+               OPT_CALLBACK_F(0, "stage", &checkout_stage, "(1|2|3|all)",
                        N_("copy out the files from named stage"),
                        PARSE_OPT_NONEG, option_parse_stage),
                OPT_END()
@@ -269,6 +270,12 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                state.base_dir = "";
        state.base_dir_len = strlen(state.base_dir);
 
+       if (to_tempfile < 0)
+               to_tempfile = (checkout_stage == CHECKOUT_ALL);
+       if (!to_tempfile && checkout_stage == CHECKOUT_ALL)
+               die(_("options '%s' and '%s' cannot be used together"),
+                   "--stage=all", "--no-temp");
+
        /*
         * when --prefix is specified we do not want to update cache.
         */
index f53612f46870529e87cec15a2f7233c74e4b173d..f02434bc155ba1769a248350afa686322e6110bb 100644 (file)
@@ -523,6 +523,15 @@ static int checkout_paths(const struct checkout_opts *opts,
                            "--merge", "--conflict", "--staged");
        }
 
+       /*
+        * recreating unmerged index entries and writing out data from
+        * unmerged index entries would make no sense when checking out
+        * of a tree-ish.
+        */
+       if ((opts->merge || opts->writeout_stage) && opts->source_tree)
+               die(_("'%s', '%s', or '%s' cannot be used when checking out of a tree"),
+                   "--merge", "--ours", "--theirs");
+
        if (opts->patch_mode) {
                enum add_p_mode patch_mode;
                const char *rev = new_branch_info->name;
@@ -560,6 +569,8 @@ static int checkout_paths(const struct checkout_opts *opts,
 
        if (opts->source_tree)
                read_tree_some(opts->source_tree, &opts->pathspec);
+       if (opts->merge)
+               unmerge_index(&the_index, &opts->pathspec, CE_MATCHED);
 
        ps_matched = xcalloc(opts->pathspec.nr, 1);
 
@@ -583,10 +594,6 @@ static int checkout_paths(const struct checkout_opts *opts,
        }
        free(ps_matched);
 
-       /* "checkout -m path" to recreate conflicted state */
-       if (opts->merge)
-               unmerge_marked_index(&the_index);
-
        /* Any unmerged paths? */
        for (pos = 0; pos < the_index.cache_nr; pos++) {
                const struct cache_entry *ce = the_index.cache[pos];
index c88389df24ed5cb552ca22a4be0e29c625a9ac23..45d035af6007a2a64833015dbe58300493a55f80 100644 (file)
@@ -69,10 +69,12 @@ static int graph_verify(int argc, const char **argv, const char *prefix)
        struct commit_graph *graph = NULL;
        struct object_directory *odb = NULL;
        char *graph_name;
-       int open_ok;
+       char *chain_name;
+       enum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;
        int fd;
        struct stat st;
        int flags = 0;
+       int incomplete_chain = 0;
        int ret;
 
        static struct option builtin_commit_graph_verify_options[] = {
@@ -102,24 +104,39 @@ static int graph_verify(int argc, const char **argv, const char *prefix)
 
        odb = find_odb(the_repository, opts.obj_dir);
        graph_name = get_commit_graph_filename(odb);
-       open_ok = open_commit_graph(graph_name, &fd, &st);
-       if (!open_ok && errno != ENOENT)
+       chain_name = get_commit_graph_chain_filename(odb);
+       if (open_commit_graph(graph_name, &fd, &st))
+               opened = OPENED_GRAPH;
+       else if (errno != ENOENT)
                die_errno(_("Could not open commit-graph '%s'"), graph_name);
+       else if (open_commit_graph_chain(chain_name, &fd, &st))
+               opened = OPENED_CHAIN;
+       else if (errno != ENOENT)
+               die_errno(_("could not open commit-graph chain '%s'"), chain_name);
 
        FREE_AND_NULL(graph_name);
+       FREE_AND_NULL(chain_name);
        FREE_AND_NULL(options);
 
-       if (open_ok)
+       if (opened == OPENED_NONE)
+               return 0;
+       else if (opened == OPENED_GRAPH)
                graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb);
        else
-               graph = read_commit_graph_one(the_repository, odb);
+               graph = load_commit_graph_chain_fd_st(the_repository, fd, &st,
+                                                     &incomplete_chain);
 
-       /* Return failure if open_ok predicted success */
        if (!graph)
-               return !!open_ok;
+               return 1;
 
        ret = verify_commit_graph(the_repository, graph, flags);
        free_commit_graph(graph);
+
+       if (incomplete_chain) {
+               error("one or more commit-graph chain files could not be loaded");
+               ret |= 1;
+       }
+
        return ret;
 }
 
@@ -311,6 +328,7 @@ cleanup:
        FREE_AND_NULL(options);
        string_list_clear(&pack_indexes, 0);
        strbuf_release(&buf);
+       oidset_clear(&commits);
        return result;
 }
 
index a9e375882bf2545736b2d38e65bc744c7d7b3497..fb6b0508f3212db5d41bc33cfe76de441534ca7c 100644 (file)
@@ -561,9 +561,11 @@ static void describe(const char *arg, int last_one)
 static int option_parse_exact_match(const struct option *opt, const char *arg,
                                    int unset)
 {
+       int *val = opt->value;
+
        BUG_ON_OPT_ARG(arg);
 
-       max_candidates = unset ? DEFAULT_CANDIDATES : 0;
+       *val = unset ? DEFAULT_CANDIDATES : 0;
        return 0;
 }
 
@@ -578,7 +580,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "long",       &longformat, N_("always use long format")),
                OPT_BOOL(0, "first-parent", &first_parent, N_("only follow first parent")),
                OPT__ABBREV(&abbrev),
-               OPT_CALLBACK_F(0, "exact-match", NULL, NULL,
+               OPT_CALLBACK_F(0, "exact-match", &max_candidates, NULL,
                               N_("only output exact matches"),
                               PARSE_OPT_NOARG, option_parse_exact_match),
                OPT_INTEGER(0, "candidates", &max_candidates,
index 0b313549c764b7dc0d001b0b793fc160b04059ac..55e7d21755a09c9754d45fea8689cbcbd32939dd 100644 (file)
@@ -474,8 +474,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        repo_init_revisions(the_repository, &rev, prefix);
 
        /* Set up defaults that will apply to both no-index and regular diffs. */
-       rev.diffopt.stat_width = -1;
-       rev.diffopt.stat_graph_width = -1;
+       init_diffstat_widths(&rev.diffopt);
        rev.diffopt.flags.allow_external = 1;
        rev.diffopt.flags.allow_textconv = 1;
 
index 56dc69fac180126a43f8a9ca3ed116ca67283737..70aff515acbe97b20db80cc8b746e28f0149b56f 100644 (file)
@@ -33,9 +33,9 @@ static const char *fast_export_usage[] = {
 };
 
 static int progress;
-static enum { SIGNED_TAG_ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
-static enum { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT;
-static enum { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT;
+static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT;
+static enum tag_of_filtered_mode { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT;
+static enum reencode_mode { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT;
 static int fake_missing_tagger;
 static int use_done_feature;
 static int no_data;
@@ -53,16 +53,18 @@ static struct revision_sources revision_sources;
 static int parse_opt_signed_tag_mode(const struct option *opt,
                                     const char *arg, int unset)
 {
+       enum signed_tag_mode *val = opt->value;
+
        if (unset || !strcmp(arg, "abort"))
-               signed_tag_mode = SIGNED_TAG_ABORT;
+               *val = SIGNED_TAG_ABORT;
        else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore"))
-               signed_tag_mode = VERBATIM;
+               *val = VERBATIM;
        else if (!strcmp(arg, "warn"))
-               signed_tag_mode = WARN;
+               *val = WARN;
        else if (!strcmp(arg, "warn-strip"))
-               signed_tag_mode = WARN_STRIP;
+               *val = WARN_STRIP;
        else if (!strcmp(arg, "strip"))
-               signed_tag_mode = STRIP;
+               *val = STRIP;
        else
                return error("Unknown signed-tags mode: %s", arg);
        return 0;
@@ -71,12 +73,14 @@ static int parse_opt_signed_tag_mode(const struct option *opt,
 static int parse_opt_tag_of_filtered_mode(const struct option *opt,
                                          const char *arg, int unset)
 {
+       enum tag_of_filtered_mode *val = opt->value;
+
        if (unset || !strcmp(arg, "abort"))
-               tag_of_filtered_mode = TAG_FILTERING_ABORT;
+               *val = TAG_FILTERING_ABORT;
        else if (!strcmp(arg, "drop"))
-               tag_of_filtered_mode = DROP;
+               *val = DROP;
        else if (!strcmp(arg, "rewrite"))
-               tag_of_filtered_mode = REWRITE;
+               *val = REWRITE;
        else
                return error("Unknown tag-of-filtered mode: %s", arg);
        return 0;
@@ -85,21 +89,23 @@ static int parse_opt_tag_of_filtered_mode(const struct option *opt,
 static int parse_opt_reencode_mode(const struct option *opt,
                                   const char *arg, int unset)
 {
+       enum reencode_mode *val = opt->value;
+
        if (unset) {
-               reencode_mode = REENCODE_ABORT;
+               *val = REENCODE_ABORT;
                return 0;
        }
 
        switch (git_parse_maybe_bool(arg)) {
        case 0:
-               reencode_mode = REENCODE_NO;
+               *val = REENCODE_NO;
                break;
        case 1:
-               reencode_mode = REENCODE_YES;
+               *val = REENCODE_YES;
                break;
        default:
                if (!strcasecmp(arg, "abort"))
-                       reencode_mode = REENCODE_ABORT;
+                       *val = REENCODE_ABORT;
                else
                        return error("Unknown reencoding mode: %s", arg);
        }
index 4dbb10aff3dacf58b0ecb5daf648cefb16d41f4b..444f41cf8ca8e6ba523f54169a3534d384094196 100644 (file)
@@ -1102,6 +1102,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
                || (pack_size + PACK_SIZE_THRESHOLD + len) < pack_size)
                cycle_packfile();
 
+       the_hash_algo->init_fn(&checkpoint.ctx);
        hashfile_checkpoint(pack_file, &checkpoint);
        offset = checkpoint.offset;
 
index eed4a7cdb6c1d672ab7324ea129d83ea312b688e..fd134ba74d9086cfa44ba1c1b5a5a2597d182bee 100644 (file)
@@ -176,7 +176,7 @@ static int parse_refmap_arg(const struct option *opt, const char *arg, int unset
         * "git fetch --refmap='' origin foo"
         * can be used to tell the command not to store anywhere
         */
-       refspec_append(&refmap, arg);
+       refspec_append(opt->value, arg);
 
        return 0;
 }
@@ -308,7 +308,7 @@ static void clear_item(struct refname_hash_entry *item)
 
 
 static void add_already_queued_tags(const char *refname,
-                                   const struct object_id *old_oid,
+                                   const struct object_id *old_oid UNUSED,
                                    const struct object_id *new_oid,
                                    void *cb_data)
 {
@@ -2204,7 +2204,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                           PARSE_OPT_HIDDEN, option_fetch_parse_recurse_submodules),
                OPT_BOOL(0, "update-shallow", &update_shallow,
                         N_("accept refs that update .git/shallow")),
-               OPT_CALLBACK_F(0, "refmap", NULL, N_("refmap"),
+               OPT_CALLBACK_F(0, "refmap", &refmap, N_("refmap"),
                               N_("specify fetch refmap"), PARSE_OPT_NONEG, parse_refmap_arg),
                OPT_STRING_LIST('o', "server-option", &server_options, N_("server-specific"), N_("option to transmit")),
                OPT_IPVERSION(&family),
index 7e99c4d61ba95942014d8ab2681568f53658fd0d..5d01db5c029e2bf967ab96795bf0b3aef5b6102e 100644 (file)
@@ -129,8 +129,9 @@ struct fsmonitor_cookie_item {
        enum fsmonitor_cookie_item_result result;
 };
 
-static int cookies_cmp(const void *data, const struct hashmap_entry *he1,
-                    const struct hashmap_entry *he2, const void *keydata)
+static int cookies_cmp(const void *data UNUSED,
+                      const struct hashmap_entry *he1,
+                      const struct hashmap_entry *he2, const void *keydata)
 {
        const struct fsmonitor_cookie_item *a =
                container_of(he1, const struct fsmonitor_cookie_item, entry);
@@ -1412,7 +1413,7 @@ done:
        return err;
 }
 
-static int try_to_run_foreground_daemon(int detach_console)
+static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED)
 {
        /*
         * Technically, we don't need to probe for an existing daemon
@@ -1442,7 +1443,8 @@ static int try_to_run_foreground_daemon(int detach_console)
 
 static start_bg_wait_cb bg_wait_cb;
 
-static int bg_wait_cb(const struct child_process *cp, void *cb_data)
+static int bg_wait_cb(const struct child_process *cp UNUSED,
+                     void *cb_data UNUSED)
 {
        enum ipc_active_state s = fsmonitor_ipc__get_state();
 
index 719cae9a88aa0168ce4023434232c9d186d27271..7c11d5ebef052a46cd06b411960fb1c2b3d6ac08 100644 (file)
@@ -52,6 +52,7 @@ static const char * const builtin_gc_usage[] = {
 static int pack_refs = 1;
 static int prune_reflogs = 1;
 static int cruft_packs = 1;
+static unsigned long max_cruft_size;
 static int aggressive_depth = 50;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
@@ -61,6 +62,8 @@ static timestamp_t gc_log_expire_time;
 static const char *gc_log_expire = "1.day.ago";
 static const char *prune_expire = "2.weeks.ago";
 static const char *prune_worktrees_expire = "3.months.ago";
+static char *repack_filter;
+static char *repack_filter_to;
 static unsigned long big_pack_threshold;
 static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
 
@@ -163,6 +166,7 @@ static void gc_config(void)
        git_config_get_int("gc.autopacklimit", &gc_auto_pack_limit);
        git_config_get_bool("gc.autodetach", &detach_auto);
        git_config_get_bool("gc.cruftpacks", &cruft_packs);
+       git_config_get_ulong("gc.maxcruftsize", &max_cruft_size);
        git_config_get_expiry("gc.pruneexpire", &prune_expire);
        git_config_get_expiry("gc.worktreepruneexpire", &prune_worktrees_expire);
        git_config_get_expiry("gc.logexpiry", &gc_log_expire);
@@ -170,6 +174,9 @@ static void gc_config(void)
        git_config_get_ulong("gc.bigpackthreshold", &big_pack_threshold);
        git_config_get_ulong("pack.deltacachesize", &max_delta_cache_size);
 
+       git_config_get_string("gc.repackfilter", &repack_filter);
+       git_config_get_string("gc.repackfilterto", &repack_filter_to);
+
        git_config(git_default_config, NULL);
 }
 
@@ -347,6 +354,9 @@ static void add_repack_all_option(struct string_list *keep_pack)
                strvec_push(&repack, "--cruft");
                if (prune_expire)
                        strvec_pushf(&repack, "--cruft-expiration=%s", prune_expire);
+               if (max_cruft_size)
+                       strvec_pushf(&repack, "--max-cruft-size=%lu",
+                                    max_cruft_size);
        } else {
                strvec_push(&repack, "-A");
                if (prune_expire)
@@ -355,6 +365,11 @@ static void add_repack_all_option(struct string_list *keep_pack)
 
        if (keep_pack)
                for_each_string_list(keep_pack, keep_one_pack, NULL);
+
+       if (repack_filter && *repack_filter)
+               strvec_pushf(&repack, "--filter=%s", repack_filter);
+       if (repack_filter_to && *repack_filter_to)
+               strvec_pushf(&repack, "--filter-to=%s", repack_filter_to);
 }
 
 static void add_repack_incremental_option(void)
@@ -575,6 +590,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                        N_("prune unreferenced objects"),
                        PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
                OPT_BOOL(0, "cruft", &cruft_packs, N_("pack unreferenced objects separately")),
+               OPT_MAGNITUDE(0, "max-cruft-size", &max_cruft_size,
+                             N_("with --cruft, limit the size of new cruft packs")),
                OPT_BOOL(0, "aggressive", &aggressive, N_("be more thorough (increased runtime)")),
                OPT_BOOL_F(0, "auto", &auto_gc, N_("enable auto-gc mode"),
                           PARSE_OPT_NOCOMPLETE),
@@ -1403,7 +1420,7 @@ static void initialize_task_config(int schedule)
        strbuf_release(&config_name);
 }
 
-static int task_option_parse(const struct option *opt,
+static int task_option_parse(const struct option *opt UNUSED,
                             const char *arg, int unset)
 {
        int i, num_selected = 0;
@@ -1708,6 +1725,15 @@ static int get_schedule_cmd(const char **cmd, int *is_available)
        return 1;
 }
 
+static int get_random_minute(void)
+{
+       /* Use a static value when under tests. */
+       if (getenv("GIT_TEST_MAINT_SCHEDULER"))
+               return 13;
+
+       return git_rand() % 60;
+}
+
 static int is_launchctl_available(void)
 {
        const char *cmd = "launchctl";
@@ -1820,6 +1846,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
        struct strbuf plist = STRBUF_INIT, plist2 = STRBUF_INIT;
        struct stat st;
        const char *cmd = "launchctl";
+       int minute = get_random_minute();
 
        get_schedule_cmd(&cmd, NULL);
        preamble = "<?xml version=\"1.0\"?>\n"
@@ -1845,29 +1872,30 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
        case SCHEDULE_HOURLY:
                repeat = "<dict>\n"
                         "<key>Hour</key><integer>%d</integer>\n"
-                        "<key>Minute</key><integer>0</integer>\n"
+                        "<key>Minute</key><integer>%d</integer>\n"
                         "</dict>\n";
                for (i = 1; i <= 23; i++)
-                       strbuf_addf(&plist, repeat, i);
+                       strbuf_addf(&plist, repeat, i, minute);
                break;
 
        case SCHEDULE_DAILY:
                repeat = "<dict>\n"
                         "<key>Day</key><integer>%d</integer>\n"
                         "<key>Hour</key><integer>0</integer>\n"
-                        "<key>Minute</key><integer>0</integer>\n"
+                        "<key>Minute</key><integer>%d</integer>\n"
                         "</dict>\n";
                for (i = 1; i <= 6; i++)
-                       strbuf_addf(&plist, repeat, i);
+                       strbuf_addf(&plist, repeat, i, minute);
                break;
 
        case SCHEDULE_WEEKLY:
-               strbuf_addstr(&plist,
-                             "<dict>\n"
-                             "<key>Day</key><integer>0</integer>\n"
-                             "<key>Hour</key><integer>0</integer>\n"
-                             "<key>Minute</key><integer>0</integer>\n"
-                             "</dict>\n");
+               strbuf_addf(&plist,
+                           "<dict>\n"
+                           "<key>Day</key><integer>0</integer>\n"
+                           "<key>Hour</key><integer>0</integer>\n"
+                           "<key>Minute</key><integer>%d</integer>\n"
+                           "</dict>\n",
+                           minute);
                break;
 
        default:
@@ -1923,7 +1951,7 @@ static int launchctl_add_plists(void)
               launchctl_schedule_plist(exec_path, SCHEDULE_WEEKLY);
 }
 
-static int launchctl_update_schedule(int run_maintenance, int fd)
+static int launchctl_update_schedule(int run_maintenance, int fd UNUSED)
 {
        if (run_maintenance)
                return launchctl_add_plists();
@@ -1984,6 +2012,7 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
        const char *frequency = get_frequency(schedule);
        char *name = schtasks_task_name(frequency);
        struct strbuf tfilename = STRBUF_INIT;
+       int minute = get_random_minute();
 
        get_schedule_cmd(&cmd, NULL);
 
@@ -2004,7 +2033,7 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
        switch (schedule) {
        case SCHEDULE_HOURLY:
                fprintf(tfile->fp,
-                       "<StartBoundary>2020-01-01T01:00:00</StartBoundary>\n"
+                       "<StartBoundary>2020-01-01T01:%02d:00</StartBoundary>\n"
                        "<Enabled>true</Enabled>\n"
                        "<ScheduleByDay>\n"
                        "<DaysInterval>1</DaysInterval>\n"
@@ -2013,12 +2042,13 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
                        "<Interval>PT1H</Interval>\n"
                        "<Duration>PT23H</Duration>\n"
                        "<StopAtDurationEnd>false</StopAtDurationEnd>\n"
-                       "</Repetition>\n");
+                       "</Repetition>\n",
+                       minute);
                break;
 
        case SCHEDULE_DAILY:
                fprintf(tfile->fp,
-                       "<StartBoundary>2020-01-01T00:00:00</StartBoundary>\n"
+                       "<StartBoundary>2020-01-01T00:%02d:00</StartBoundary>\n"
                        "<Enabled>true</Enabled>\n"
                        "<ScheduleByWeek>\n"
                        "<DaysOfWeek>\n"
@@ -2030,19 +2060,21 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
                        "<Saturday />\n"
                        "</DaysOfWeek>\n"
                        "<WeeksInterval>1</WeeksInterval>\n"
-                       "</ScheduleByWeek>\n");
+                       "</ScheduleByWeek>\n",
+                       minute);
                break;
 
        case SCHEDULE_WEEKLY:
                fprintf(tfile->fp,
-                       "<StartBoundary>2020-01-01T00:00:00</StartBoundary>\n"
+                       "<StartBoundary>2020-01-01T00:%02d:00</StartBoundary>\n"
                        "<Enabled>true</Enabled>\n"
                        "<ScheduleByWeek>\n"
                        "<DaysOfWeek>\n"
                        "<Sunday />\n"
                        "</DaysOfWeek>\n"
                        "<WeeksInterval>1</WeeksInterval>\n"
-                       "</ScheduleByWeek>\n");
+                       "</ScheduleByWeek>\n",
+                       minute);
                break;
 
        default:
@@ -2100,7 +2132,7 @@ static int schtasks_schedule_tasks(void)
               schtasks_schedule_task(exec_path, SCHEDULE_WEEKLY);
 }
 
-static int schtasks_update_schedule(int run_maintenance, int fd)
+static int schtasks_update_schedule(int run_maintenance, int fd UNUSED)
 {
        if (run_maintenance)
                return schtasks_schedule_tasks();
@@ -2159,6 +2191,7 @@ static int crontab_update_schedule(int run_maintenance, int fd)
        FILE *cron_list, *cron_in;
        struct strbuf line = STRBUF_INIT;
        struct tempfile *tmpedit = NULL;
+       int minute = get_random_minute();
 
        get_schedule_cmd(&cmd, NULL);
        strvec_split(&crontab_list.args, cmd);
@@ -2213,11 +2246,11 @@ static int crontab_update_schedule(int run_maintenance, int fd)
                        "# replaced in the future by a Git command.\n\n");
 
                strbuf_addf(&line_format,
-                           "%%s %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n",
+                           "%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n",
                            exec_path, exec_path);
-               fprintf(cron_in, line_format.buf, "0", "1-23", "*", "hourly");
-               fprintf(cron_in, line_format.buf, "0", "0", "1-6", "daily");
-               fprintf(cron_in, line_format.buf, "0", "0", "0", "weekly");
+               fprintf(cron_in, line_format.buf, minute, "1-23", "*", "hourly");
+               fprintf(cron_in, line_format.buf, minute, "0", "1-6", "daily");
+               fprintf(cron_in, line_format.buf, minute, "0", "0", "weekly");
                strbuf_release(&line_format);
 
                fprintf(cron_in, "\n%s\n", END_LINE);
@@ -2276,77 +2309,54 @@ static char *xdg_config_home_systemd(const char *filename)
        return xdg_config_home_for("systemd/user", filename);
 }
 
-static int systemd_timer_enable_unit(int enable,
-                                    enum schedule_priority schedule)
-{
-       const char *cmd = "systemctl";
-       struct child_process child = CHILD_PROCESS_INIT;
-       const char *frequency = get_frequency(schedule);
+#define SYSTEMD_UNIT_FORMAT "git-maintenance@%s.%s"
 
-       /*
-        * Disabling the systemd unit while it is already disabled makes
-        * systemctl print an error.
-        * Let's ignore it since it means we already are in the expected state:
-        * the unit is disabled.
-        *
-        * On the other hand, enabling a systemd unit which is already enabled
-        * produces no error.
-        */
-       if (!enable)
-               child.no_stderr = 1;
-
-       get_schedule_cmd(&cmd, NULL);
-       strvec_split(&child.args, cmd);
-       strvec_pushl(&child.args, "--user", enable ? "enable" : "disable",
-                    "--now", NULL);
-       strvec_pushf(&child.args, "git-maintenance@%s.timer", frequency);
-
-       if (start_command(&child))
-               return error(_("failed to start systemctl"));
-       if (finish_command(&child))
-               /*
-                * Disabling an already disabled systemd unit makes
-                * systemctl fail.
-                * Let's ignore this failure.
-                *
-                * Enabling an enabled systemd unit doesn't fail.
-                */
-               if (enable)
-                       return error(_("failed to run systemctl"));
-       return 0;
-}
-
-static int systemd_timer_delete_unit_templates(void)
+static int systemd_timer_delete_timer_file(enum schedule_priority priority)
 {
        int ret = 0;
-       char *filename = xdg_config_home_systemd("git-maintenance@.timer");
-       if (unlink(filename) && !is_missing_file_error(errno))
-               ret = error_errno(_("failed to delete '%s'"), filename);
-       FREE_AND_NULL(filename);
+       const char *frequency = get_frequency(priority);
+       char *local_timer_name = xstrfmt(SYSTEMD_UNIT_FORMAT, frequency, "timer");
+       char *filename = xdg_config_home_systemd(local_timer_name);
 
-       filename = xdg_config_home_systemd("git-maintenance@.service");
        if (unlink(filename) && !is_missing_file_error(errno))
                ret = error_errno(_("failed to delete '%s'"), filename);
 
        free(filename);
+       free(local_timer_name);
        return ret;
 }
 
-static int systemd_timer_delete_units(void)
+static int systemd_timer_delete_service_template(void)
 {
-       return systemd_timer_enable_unit(0, SCHEDULE_HOURLY) ||
-              systemd_timer_enable_unit(0, SCHEDULE_DAILY) ||
-              systemd_timer_enable_unit(0, SCHEDULE_WEEKLY) ||
-              systemd_timer_delete_unit_templates();
+       int ret = 0;
+       char *local_service_name = xstrfmt(SYSTEMD_UNIT_FORMAT, "", "service");
+       char *filename = xdg_config_home_systemd(local_service_name);
+       if (unlink(filename) && !is_missing_file_error(errno))
+               ret = error_errno(_("failed to delete '%s'"), filename);
+
+       free(filename);
+       free(local_service_name);
+       return ret;
 }
 
-static int systemd_timer_write_unit_templates(const char *exec_path)
+/*
+ * Write the schedule information into a git-maintenance@<schedule>.timer
+ * file using a custom minute. This timer file cannot use the templating
+ * system, so we generate a specific file for each.
+ */
+static int systemd_timer_write_timer_file(enum schedule_priority schedule,
+                                         int minute)
 {
+       int res = -1;
        char *filename;
        FILE *file;
        const char *unit;
+       char *schedule_pattern = NULL;
+       const char *frequency = get_frequency(schedule);
+       char *local_timer_name = xstrfmt(SYSTEMD_UNIT_FORMAT, frequency, "timer");
+
+       filename = xdg_config_home_systemd(local_timer_name);
 
-       filename = xdg_config_home_systemd("git-maintenance@.timer");
        if (safe_create_leading_directories(filename)) {
                error(_("failed to create directories for '%s'"), filename);
                goto error;
@@ -2355,6 +2365,23 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
        if (!file)
                goto error;
 
+       switch (schedule) {
+       case SCHEDULE_HOURLY:
+               schedule_pattern = xstrfmt("*-*-* 1..23:%02d:00", minute);
+               break;
+
+       case SCHEDULE_DAILY:
+               schedule_pattern = xstrfmt("Tue..Sun *-*-* 0:%02d:00", minute);
+               break;
+
+       case SCHEDULE_WEEKLY:
+               schedule_pattern = xstrfmt("Mon 0:%02d:00", minute);
+               break;
+
+       default:
+               BUG("Unhandled schedule_priority");
+       }
+
        unit = "# This file was created and is maintained by Git.\n"
               "# Any edits made in this file might be replaced in the future\n"
               "# by a Git command.\n"
@@ -2363,12 +2390,12 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
               "Description=Optimize Git repositories data\n"
               "\n"
               "[Timer]\n"
-              "OnCalendar=%i\n"
+              "OnCalendar=%s\n"
               "Persistent=true\n"
               "\n"
               "[Install]\n"
               "WantedBy=timers.target\n";
-       if (fputs(unit, file) == EOF) {
+       if (fprintf(file, unit, schedule_pattern) < 0) {
                error(_("failed to write to '%s'"), filename);
                fclose(file);
                goto error;
@@ -2377,9 +2404,36 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
                error_errno(_("failed to flush '%s'"), filename);
                goto error;
        }
+
+       res = 0;
+
+error:
+       free(schedule_pattern);
+       free(local_timer_name);
        free(filename);
+       return res;
+}
 
-       filename = xdg_config_home_systemd("git-maintenance@.service");
+/*
+ * No matter the schedule, we use the same service and can make use of the
+ * templating system. When installing git-maintenance@<schedule>.timer,
+ * systemd will notice that git-maintenance@.service exists as a template
+ * and will use this file and insert the <schedule> into the template at
+ * the position of "%i".
+ */
+static int systemd_timer_write_service_template(const char *exec_path)
+{
+       int res = -1;
+       char *filename;
+       FILE *file;
+       const char *unit;
+       char *local_service_name = xstrfmt(SYSTEMD_UNIT_FORMAT, "", "service");
+
+       filename = xdg_config_home_systemd(local_service_name);
+       if (safe_create_leading_directories(filename)) {
+               error(_("failed to create directories for '%s'"), filename);
+               goto error;
+       }
        file = fopen_or_warn(filename, "w");
        if (!file)
                goto error;
@@ -2412,29 +2466,114 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
                error_errno(_("failed to flush '%s'"), filename);
                goto error;
        }
+
+       res = 0;
+
+error:
+       free(local_service_name);
        free(filename);
+       return res;
+}
+
+static int systemd_timer_enable_unit(int enable,
+                                    enum schedule_priority schedule,
+                                    int minute)
+{
+       const char *cmd = "systemctl";
+       struct child_process child = CHILD_PROCESS_INIT;
+       const char *frequency = get_frequency(schedule);
+
+       /*
+        * Disabling the systemd unit while it is already disabled makes
+        * systemctl print an error.
+        * Let's ignore it since it means we already are in the expected state:
+        * the unit is disabled.
+        *
+        * On the other hand, enabling a systemd unit which is already enabled
+        * produces no error.
+        */
+       if (!enable)
+               child.no_stderr = 1;
+       else if (systemd_timer_write_timer_file(schedule, minute))
+               return -1;
+
+       get_schedule_cmd(&cmd, NULL);
+       strvec_split(&child.args, cmd);
+       strvec_pushl(&child.args, "--user", enable ? "enable" : "disable",
+                    "--now", NULL);
+       strvec_pushf(&child.args, SYSTEMD_UNIT_FORMAT, frequency, "timer");
+
+       if (start_command(&child))
+               return error(_("failed to start systemctl"));
+       if (finish_command(&child))
+               /*
+                * Disabling an already disabled systemd unit makes
+                * systemctl fail.
+                * Let's ignore this failure.
+                *
+                * Enabling an enabled systemd unit doesn't fail.
+                */
+               if (enable)
+                       return error(_("failed to run systemctl"));
        return 0;
+}
+
+/*
+ * A previous version of Git wrote the timer units as template files.
+ * Clean these up, if they exist.
+ */
+static void systemd_timer_delete_stale_timer_templates(void)
+{
+       char *timer_template_name = xstrfmt(SYSTEMD_UNIT_FORMAT, "", "timer");
+       char *filename = xdg_config_home_systemd(timer_template_name);
+
+       if (unlink(filename) && !is_missing_file_error(errno))
+               warning(_("failed to delete '%s'"), filename);
 
-error:
        free(filename);
-       systemd_timer_delete_unit_templates();
-       return -1;
+       free(timer_template_name);
+}
+
+static int systemd_timer_delete_unit_files(void)
+{
+       systemd_timer_delete_stale_timer_templates();
+
+       /* Purposefully not short-circuited to make sure all are called. */
+       return systemd_timer_delete_timer_file(SCHEDULE_HOURLY) |
+              systemd_timer_delete_timer_file(SCHEDULE_DAILY) |
+              systemd_timer_delete_timer_file(SCHEDULE_WEEKLY) |
+              systemd_timer_delete_service_template();
+}
+
+static int systemd_timer_delete_units(void)
+{
+       int minute = get_random_minute();
+       /* Purposefully not short-circuited to make sure all are called. */
+       return systemd_timer_enable_unit(0, SCHEDULE_HOURLY, minute) |
+              systemd_timer_enable_unit(0, SCHEDULE_DAILY, minute) |
+              systemd_timer_enable_unit(0, SCHEDULE_WEEKLY, minute) |
+              systemd_timer_delete_unit_files();
 }
 
 static int systemd_timer_setup_units(void)
 {
+       int minute = get_random_minute();
        const char *exec_path = git_exec_path();
 
-       int ret = systemd_timer_write_unit_templates(exec_path) ||
-                 systemd_timer_enable_unit(1, SCHEDULE_HOURLY) ||
-                 systemd_timer_enable_unit(1, SCHEDULE_DAILY) ||
-                 systemd_timer_enable_unit(1, SCHEDULE_WEEKLY);
+       int ret = systemd_timer_write_service_template(exec_path) ||
+                 systemd_timer_enable_unit(1, SCHEDULE_HOURLY, minute) ||
+                 systemd_timer_enable_unit(1, SCHEDULE_DAILY, minute) ||
+                 systemd_timer_enable_unit(1, SCHEDULE_WEEKLY, minute);
+
        if (ret)
                systemd_timer_delete_units();
+       else
+               systemd_timer_delete_stale_timer_templates();
+
        return ret;
 }
 
-static int systemd_timer_update_schedule(int run_maintenance, int fd)
+static int systemd_timer_update_schedule(int run_maintenance, int fd UNUSED)
 {
        if (run_maintenance)
                return systemd_timer_setup_units();
@@ -2606,9 +2745,12 @@ static int maintenance_start(int argc, const char **argv, const char *prefix)
        opts.scheduler = resolve_scheduler(opts.scheduler);
        validate_scheduler(opts.scheduler);
 
+       if (update_background_schedule(&opts, 1))
+               die(_("failed to set up maintenance schedule"));
+
        if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL))
                warning(_("failed to add repo to global config"));
-       return update_background_schedule(&opts, 1);
+       return 0;
 }
 
 static const char *const builtin_maintenance_stop_usage[] = {
index b71222330add858a8ae6ce0363666e85c04a5cef..fe78d4c98b13b578a09de344d6a56d2316a8cb00 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (c) 2006 Junio C Hamano
  */
 #include "builtin.h"
+#include "abspath.h"
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
@@ -812,14 +813,20 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
 {
        struct grep_opt *grep_opt = opt->value;
        int from_stdin;
+       const char *filename = arg;
        FILE *patterns;
        int lno = 0;
        struct strbuf sb = STRBUF_INIT;
 
        BUG_ON_OPT_NEG(unset);
 
-       from_stdin = !strcmp(arg, "-");
-       patterns = from_stdin ? stdin : fopen(arg, "r");
+       if (!*filename)
+               ; /* leave it as-is */
+       else
+               filename = prefix_filename_except_for_dash(grep_prefix, filename);
+
+       from_stdin = !strcmp(filename, "-");
+       patterns = from_stdin ? stdin : fopen(filename, "r");
        if (!patterns)
                die_errno(_("cannot open '%s'"), arg);
        while (strbuf_getline(&sb, patterns) == 0) {
@@ -833,6 +840,8 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
        if (!from_stdin)
                fclose(patterns);
        strbuf_release(&sb);
+       if (filename != arg)
+               free((void *)filename);
        return 0;
 }
 
index 006ffdc9c550d75a034960635f13d87b33dc57cc..dda94a9f46d9a9401c298ee304f57e55db25f217 100644 (file)
@@ -1166,6 +1166,7 @@ static void parse_pack_objects(unsigned char *hash)
        struct ofs_delta_entry *ofs_delta = ofs_deltas;
        struct object_id ref_delta_oid;
        struct stat st;
+       git_hash_ctx tmp_ctx;
 
        if (verbose)
                progress = start_progress(
@@ -1202,7 +1203,9 @@ static void parse_pack_objects(unsigned char *hash)
 
        /* Check pack integrity */
        flush();
-       the_hash_algo->final_fn(hash, &input_ctx);
+       the_hash_algo->init_fn(&tmp_ctx);
+       the_hash_algo->clone_fn(&tmp_ctx, &input_ctx);
+       the_hash_algo->final_fn(hash, &tmp_ctx);
        if (!hasheq(fill(the_hash_algo->rawsz), hash))
                die(_("pack is corrupted (SHA1 mismatch)"));
        use(the_hash_algo->rawsz);
index c5e83452654de9242f01a4045fb90f3f058ea8f7..033bd1556cf9f8d6e56c2730a3e868500388144e 100644 (file)
@@ -14,7 +14,7 @@
 
 static const char * const git_interpret_trailers_usage[] = {
        N_("git interpret-trailers [--in-place] [--trim-empty]\n"
-          "                       [(--trailer <token>[(=|:)<value>])...]\n"
+          "                       [(--trailer (<key>|<keyAlias>)[(=|:)<value>])...]\n"
           "                       [--parse] [<file>...]"),
        NULL
 };
@@ -24,21 +24,24 @@ static enum trailer_if_exists if_exists;
 static enum trailer_if_missing if_missing;
 
 static int option_parse_where(const struct option *opt,
-                             const char *arg, int unset)
+                             const char *arg, int unset UNUSED)
 {
-       return trailer_set_where(&where, arg);
+       /* unset implies NULL arg, which is handled in our helper */
+       return trailer_set_where(opt->value, arg);
 }
 
 static int option_parse_if_exists(const struct option *opt,
-                                 const char *arg, int unset)
+                                 const char *arg, int unset UNUSED)
 {
-       return trailer_set_if_exists(&if_exists, arg);
+       /* unset implies NULL arg, which is handled in our helper */
+       return trailer_set_if_exists(opt->value, arg);
 }
 
 static int option_parse_if_missing(const struct option *opt,
-                                  const char *arg, int unset)
+                                  const char *arg, int unset UNUSED)
 {
-       return trailer_set_if_missing(&if_missing, arg);
+       /* unset implies NULL arg, which is handled in our helper */
+       return trailer_set_if_missing(opt->value, arg);
 }
 
 static void new_trailers_clear(struct list_head *trailers)
@@ -97,19 +100,19 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "in-place", &opts.in_place, N_("edit files in place")),
                OPT_BOOL(0, "trim-empty", &opts.trim_empty, N_("trim empty trailers")),
 
-               OPT_CALLBACK(0, "where", NULL, N_("action"),
+               OPT_CALLBACK(0, "where", &where, N_("placement"),
                             N_("where to place the new trailer"), option_parse_where),
-               OPT_CALLBACK(0, "if-exists", NULL, N_("action"),
+               OPT_CALLBACK(0, "if-exists", &if_exists, N_("action"),
                             N_("action if trailer already exists"), option_parse_if_exists),
-               OPT_CALLBACK(0, "if-missing", NULL, N_("action"),
+               OPT_CALLBACK(0, "if-missing", &if_missing, N_("action"),
                             N_("action if trailer is missing"), option_parse_if_missing),
 
                OPT_BOOL(0, "only-trailers", &opts.only_trailers, N_("output only the trailers")),
-               OPT_BOOL(0, "only-input", &opts.only_input, N_("do not apply config rules")),
-               OPT_BOOL(0, "unfold", &opts.unfold, N_("join whitespace-continued values")),
-               OPT_CALLBACK_F(0, "parse", &opts, NULL, N_("set parsing options"),
+               OPT_BOOL(0, "only-input", &opts.only_input, N_("do not apply trailer.* configuration variables")),
+               OPT_BOOL(0, "unfold", &opts.unfold, N_("reformat multiline trailer values as single-line values")),
+               OPT_CALLBACK_F(0, "parse", &opts, NULL, N_("alias for --only-trailers --only-input --unfold"),
                        PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_parse),
-               OPT_BOOL(0, "no-divider", &opts.no_divider, N_("do not treat --- specially")),
+               OPT_BOOL(0, "no-divider", &opts.no_divider, N_("do not treat \"---\" as the end of input")),
                OPT_CALLBACK(0, "trailer", &trailers, N_("trailer"),
                                N_("trailer(s) to add"), option_parse_trailer),
                OPT_END()
index 5d808c92f441523f729e5edcdc3370d09f8bafdc..ba775d7b5cf886374bd94c9f2e54d5695a3dbaff 100644 (file)
@@ -118,16 +118,19 @@ static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
 static struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP;
 static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
 
-static int clear_decorations_callback(const struct option *opt,
-                                           const char *arg, int unset)
+static int clear_decorations_callback(const struct option *opt UNUSED,
+                                     const char *arg, int unset)
 {
+       BUG_ON_OPT_NEG(unset);
+       BUG_ON_OPT_ARG(arg);
        string_list_clear(&decorate_refs_include, 0);
        string_list_clear(&decorate_refs_exclude, 0);
        use_default_decoration_filter = 0;
        return 0;
 }
 
-static int decorate_callback(const struct option *opt, const char *arg, int unset)
+static int decorate_callback(const struct option *opt UNUSED, const char *arg,
+                            int unset)
 {
        if (unset)
                decoration_style = 0;
@@ -173,16 +176,15 @@ static void cmd_log_init_defaults(struct rev_info *rev)
        if (default_follow)
                rev->diffopt.flags.default_follow_renames = 1;
        rev->verbose_header = 1;
+       init_diffstat_widths(&rev->diffopt);
        rev->diffopt.flags.recursive = 1;
-       rev->diffopt.stat_width = -1; /* use full terminal width */
-       rev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
+       rev->diffopt.flags.allow_textconv = 1;
        rev->abbrev_commit = default_abbrev_commit;
        rev->show_root_diff = default_show_root;
        rev->subject_prefix = fmt_patch_subject_prefix;
        rev->patch_name_max = fmt_patch_name_max;
        rev->show_signature = default_show_signature;
        rev->encode_email_headers = default_encode_email_headers;
-       rev->diffopt.flags.allow_textconv = 1;
 
        if (default_date_mode)
                parse_date_format(default_date_mode, &rev->date_mode);
@@ -1253,7 +1255,15 @@ static void show_diffstat(struct rev_info *rev,
        fprintf(rev->diffopt.file, "\n");
 }
 
+static void read_desc_file(struct strbuf *buf, const char *desc_file)
+{
+       if (strbuf_read_file(buf, desc_file, 0) < 0)
+               die_errno(_("unable to read branch description file '%s'"),
+                         desc_file);
+}
+
 static void prepare_cover_text(struct pretty_print_context *pp,
+                              const char *description_file,
                               const char *branch_name,
                               struct strbuf *sb,
                               const char *encoding,
@@ -1267,7 +1277,9 @@ static void prepare_cover_text(struct pretty_print_context *pp,
        if (cover_from_description_mode == COVER_FROM_NONE)
                goto do_pp;
 
-       if (branch_name && *branch_name)
+       if (description_file && *description_file)
+               read_desc_file(&description_sb, description_file);
+       else if (branch_name && *branch_name)
                read_branch_desc(&description_sb, branch_name);
        if (!description_sb.len)
                goto do_pp;
@@ -1313,6 +1325,7 @@ static void get_notes_args(struct strvec *arg, struct rev_info *rev)
 static void make_cover_letter(struct rev_info *rev, int use_separate_file,
                              struct commit *origin,
                              int nr, struct commit **list,
+                             const char *description_file,
                              const char *branch_name,
                              int quiet)
 {
@@ -1352,7 +1365,8 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
        pp.rev = rev;
        pp.print_email_subject = 1;
        pp_user_info(&pp, NULL, &sb, committer, encoding);
-       prepare_cover_text(&pp, branch_name, &sb, encoding, need_8bit_cte);
+       prepare_cover_text(&pp, description_file, branch_name, &sb,
+                          encoding, need_8bit_cte);
        fprintf(rev->diffopt.file, "%s\n", sb.buf);
 
        strbuf_release(&sb);
@@ -1468,19 +1482,16 @@ static int subject_prefix = 0;
 static int subject_prefix_callback(const struct option *opt, const char *arg,
                            int unset)
 {
+       struct strbuf *sprefix;
+
        BUG_ON_OPT_NEG(unset);
+       sprefix = opt->value;
        subject_prefix = 1;
-       ((struct rev_info *)opt->value)->subject_prefix = arg;
+       strbuf_reset(sprefix);
+       strbuf_addstr(sprefix, arg);
        return 0;
 }
 
-static int rfc_callback(const struct option *opt, const char *arg, int unset)
-{
-       BUG_ON_OPT_NEG(unset);
-       BUG_ON_OPT_ARG(arg);
-       return subject_prefix_callback(opt, "RFC PATCH", unset);
-}
-
 static int numbered_cmdline_opt = 0;
 
 static int numbered_callback(const struct option *opt, const char *arg,
@@ -1555,7 +1566,8 @@ static int inline_callback(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
-static int header_callback(const struct option *opt, const char *arg, int unset)
+static int header_callback(const struct option *opt UNUSED, const char *arg,
+                          int unset)
 {
        if (unset) {
                string_list_clear(&extra_hdr, 0);
@@ -1567,24 +1579,6 @@ static int header_callback(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
-static int to_callback(const struct option *opt, const char *arg, int unset)
-{
-       if (unset)
-               string_list_clear(&extra_to, 0);
-       else
-               string_list_append(&extra_to, arg);
-       return 0;
-}
-
-static int cc_callback(const struct option *opt, const char *arg, int unset)
-{
-       if (unset)
-               string_list_clear(&extra_cc, 0);
-       else
-               string_list_append(&extra_cc, arg);
-       return 0;
-}
-
 static int from_callback(const struct option *opt, const char *arg, int unset)
 {
        char **from = opt->value;
@@ -1893,6 +1887,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        int quiet = 0;
        const char *reroll_count = NULL;
        char *cover_from_description_arg = NULL;
+       char *description_file = NULL;
        char *branch_name = NULL;
        char *base_commit = NULL;
        struct base_tree_info bases;
@@ -1907,6 +1902,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        struct strbuf rdiff_title = STRBUF_INIT;
        struct strbuf sprefix = STRBUF_INIT;
        int creation_factor = -1;
+       int rfc = 0;
 
        const struct option builtin_format_patch_options[] = {
                OPT_CALLBACK_F('n', "numbered", &numbered, NULL,
@@ -1930,13 +1926,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            N_("mark the series as Nth re-roll")),
                OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
                            N_("max length of output filename")),
-               OPT_CALLBACK_F(0, "rfc", &rev, NULL,
-                           N_("use [RFC PATCH] instead of [PATCH]"),
-                           PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback),
+               OPT_BOOL(0, "rfc", &rfc, N_("use [RFC PATCH] instead of [PATCH]")),
                OPT_STRING(0, "cover-from-description", &cover_from_description_arg,
                            N_("cover-from-description-mode"),
                            N_("generate parts of a cover letter based on a branch's description")),
-               OPT_CALLBACK_F(0, "subject-prefix", &rev, N_("prefix"),
+               OPT_FILENAME(0, "description-file", &description_file,
+                            N_("use branch description from file")),
+               OPT_CALLBACK_F(0, "subject-prefix", &sprefix, N_("prefix"),
                            N_("use [<prefix>] instead of [PATCH]"),
                            PARSE_OPT_NONEG, subject_prefix_callback),
                OPT_CALLBACK_F('o', "output-directory", &output_directory,
@@ -1957,8 +1953,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                OPT_GROUP(N_("Messaging")),
                OPT_CALLBACK(0, "add-header", NULL, N_("header"),
                            N_("add email header"), header_callback),
-               OPT_CALLBACK(0, "to", NULL, N_("email"), N_("add To: header"), to_callback),
-               OPT_CALLBACK(0, "cc", NULL, N_("email"), N_("add Cc: header"), cc_callback),
+               OPT_STRING_LIST(0, "to", &extra_to, N_("email"), N_("add To: header")),
+               OPT_STRING_LIST(0, "cc", &extra_cc, N_("email"), N_("add Cc: header")),
                OPT_CALLBACK_F(0, "from", &from, N_("ident"),
                            N_("set From address to <ident> (or committer ident if absent)"),
                            PARSE_OPT_OPTARG, from_callback),
@@ -2016,11 +2012,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        rev.max_parents = 1;
        rev.diffopt.flags.recursive = 1;
        rev.diffopt.no_free = 1;
-       rev.subject_prefix = fmt_patch_subject_prefix;
        memset(&s_r_opt, 0, sizeof(s_r_opt));
        s_r_opt.def = "HEAD";
        s_r_opt.revarg_opt = REVARG_COMMITTISH;
 
+       strbuf_addstr(&sprefix, fmt_patch_subject_prefix);
        if (format_no_prefix)
                diff_set_noprefix(&rev.diffopt);
 
@@ -2048,13 +2044,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        if (cover_from_description_arg)
                cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
 
+       if (rfc)
+               strbuf_insertstr(&sprefix, 0, "RFC ");
+
        if (reroll_count) {
-               strbuf_addf(&sprefix, "%s v%s",
-                           rev.subject_prefix, reroll_count);
+               strbuf_addf(&sprefix, " v%s", reroll_count);
                rev.reroll_count = reroll_count;
-               rev.subject_prefix = sprefix.buf;
        }
 
+       rev.subject_prefix = sprefix.buf;
+
        for (i = 0; i < extra_hdr.nr; i++) {
                strbuf_addstr(&buf, extra_hdr.items[i].string);
                strbuf_addch(&buf, '\n');
@@ -2321,7 +2320,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                if (thread)
                        gen_message_id(&rev, "cover");
                make_cover_letter(&rev, !!output_directory,
-                                 origin, nr, list, branch_name, quiet);
+                                 origin, nr, list, description_file, branch_name, quiet);
                print_bases(&bases, rev.diffopt.file);
                print_signature(rev.diffopt.file);
                total++;
index f558db5f3b80b3d72f5f66f008e3fa2072c2e8ed..209d2dc0d59af3d0c8860ef4eb397edb34e8b429 100644 (file)
@@ -241,7 +241,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
        return recurse;
 }
 
-static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,
+static int show_tree_name_only(const struct object_id *oid UNUSED,
+                              struct strbuf *base,
                               const char *pathname, unsigned mode,
                               void *context)
 {
index 0de42aecf4babf5d1cae19aa81e7d46676c636d1..a35e0452d6672594da29623e8934256f37784549 100644 (file)
@@ -18,6 +18,7 @@
 #include "quote.h"
 #include "tree.h"
 #include "config.h"
+#include "strvec.h"
 
 static int line_termination = '\n';
 
@@ -414,6 +415,7 @@ struct merge_tree_options {
        int show_messages;
        int name_only;
        int use_stdin;
+       struct merge_options merge_options;
 };
 
 static int real_merge(struct merge_tree_options *o,
@@ -423,10 +425,11 @@ static int real_merge(struct merge_tree_options *o,
 {
        struct commit *parent1, *parent2;
        struct commit_list *merge_bases = NULL;
-       struct merge_options opt;
        struct merge_result result = { 0 };
        int show_messages = o->show_messages;
+       struct merge_options opt;
 
+       copy_merge_options(&opt, &o->merge_options);
        parent1 = get_merge_parent(branch1);
        if (!parent1)
                help_unknown_ref(branch1, "merge-tree",
@@ -437,8 +440,6 @@ static int real_merge(struct merge_tree_options *o,
                help_unknown_ref(branch2, "merge-tree",
                                 _("not something we can merge"));
 
-       init_merge_options(&opt, the_repository);
-
        opt.show_rename_progress = 0;
 
        opt.branch1 = branch1;
@@ -507,12 +508,14 @@ static int real_merge(struct merge_tree_options *o,
        if (o->use_stdin)
                putchar(line_termination);
        merge_finalize(&opt, &result);
+       clear_merge_options(&opt);
        return !result.clean; /* result.clean < 0 handled above */
 }
 
 int cmd_merge_tree(int argc, const char **argv, const char *prefix)
 {
        struct merge_tree_options o = { .show_messages = -1 };
+       struct strvec xopts = STRVEC_INIT;
        int expected_remaining_argc;
        int original_argc;
        const char *merge_base = NULL;
@@ -548,14 +551,25 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
                           &merge_base,
                           N_("commit"),
                           N_("specify a merge-base for the merge")),
+               OPT_STRVEC('X', "strategy-option", &xopts, N_("option=value"),
+                       N_("option for selected merge strategy")),
                OPT_END()
        };
 
+       /* Init merge options */
+       init_merge_options(&o.merge_options, the_repository);
+
        /* Parse arguments */
        original_argc = argc - 1; /* ignoring argv[0] */
        argc = parse_options(argc, argv, prefix, mt_options,
                             merge_tree_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 
+       if (xopts.nr && o.mode == MODE_TRIVIAL)
+               die(_("--trivial-merge is incompatible with all other options"));
+       for (int x = 0; x < xopts.nr; x++)
+               if (parse_merge_opt(&o.merge_options, xopts.v[x]))
+                       die(_("unknown strategy option: -X%s"), xopts.v[x]);
+
        /* Handle --stdin */
        if (o.use_stdin) {
                struct strbuf buf = STRBUF_INIT;
index de68910177fbff00d19a0f8ef824776de0458636..d748d46e13517afd6908b1f7297bf448557b1a86 100644 (file)
@@ -79,8 +79,7 @@ static int overwrite_ignore = 1;
 static struct strbuf merge_msg = STRBUF_INIT;
 static struct strategy **use_strategies;
 static size_t use_strategies_nr, use_strategies_alloc;
-static const char **xopts;
-static size_t xopts_nr, xopts_alloc;
+static struct strvec xopts = STRVEC_INIT;
 static const char *branch;
 static char *branch_mergeoptions;
 static int verbosity;
@@ -232,7 +231,7 @@ static void append_strategy(struct strategy *s)
        use_strategies[use_strategies_nr++] = s;
 }
 
-static int option_parse_strategy(const struct option *opt,
+static int option_parse_strategy(const struct option *opt UNUSED,
                                 const char *name, int unset)
 {
        if (unset)
@@ -242,29 +241,9 @@ static int option_parse_strategy(const struct option *opt,
        return 0;
 }
 
-static int option_parse_x(const struct option *opt,
-                         const char *arg, int unset)
-{
-       if (unset)
-               return 0;
-
-       ALLOC_GROW(xopts, xopts_nr + 1, xopts_alloc);
-       xopts[xopts_nr++] = xstrdup(arg);
-       return 0;
-}
-
-static int option_parse_n(const struct option *opt,
-                         const char *arg, int unset)
-{
-       BUG_ON_OPT_ARG(arg);
-       show_diffstat = unset;
-       return 0;
-}
-
 static struct option builtin_merge_options[] = {
-       OPT_CALLBACK_F('n', NULL, NULL, NULL,
-               N_("do not show a diffstat at the end of the merge"),
-               PARSE_OPT_NOARG, option_parse_n),
+       OPT_SET_INT('n', NULL, &show_diffstat,
+               N_("do not show a diffstat at the end of the merge"), 0),
        OPT_BOOL(0, "stat", &show_diffstat,
                N_("show a diffstat at the end of the merge")),
        OPT_BOOL(0, "summary", &show_diffstat, N_("(synonym to --stat)")),
@@ -285,10 +264,10 @@ static struct option builtin_merge_options[] = {
        OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
        OPT_BOOL(0, "verify-signatures", &verify_signatures,
                N_("verify that the named commit has a valid GPG signature")),
-       OPT_CALLBACK('s', "strategy", &use_strategies, N_("strategy"),
+       OPT_CALLBACK('s', "strategy", NULL, N_("strategy"),
                N_("merge strategy to use"), option_parse_strategy),
-       OPT_CALLBACK('X', "strategy-option", &xopts, N_("option=value"),
-               N_("option for selected merge strategy"), option_parse_x),
+       OPT_STRVEC('X', "strategy-option", &xopts, N_("option=value"),
+               N_("option for selected merge strategy")),
        OPT_CALLBACK('m', "message", &merge_msg, N_("message"),
                N_("merge commit message (for a non-fast-forward merge)"),
                option_parse_message),
@@ -487,8 +466,7 @@ static void finish(struct commit *head_commit,
        if (new_head && show_diffstat) {
                struct diff_options opts;
                repo_diff_setup(the_repository, &opts);
-               opts.stat_width = -1; /* use full terminal width */
-               opts.stat_graph_width = -1; /* respect statGraphWidth config */
+               init_diffstat_widths(&opts);
                opts.output_format |=
                        DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
                opts.detect_rename = DIFF_DETECT_RENAME;
@@ -749,9 +727,9 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                o.show_rename_progress =
                        show_progress == -1 ? isatty(2) : show_progress;
 
-               for (x = 0; x < xopts_nr; x++)
-                       if (parse_merge_opt(&o, xopts[x]))
-                               die(_("unknown strategy option: -X%s"), xopts[x]);
+               for (x = 0; x < xopts.nr; x++)
+                       if (parse_merge_opt(&o, xopts.v[x]))
+                               die(_("unknown strategy option: -X%s"), xopts.v[x]);
 
                o.branch1 = head_arg;
                o.branch2 = merge_remote_util(remoteheads->item)->name;
@@ -777,7 +755,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                return clean ? 0 : 1;
        } else {
                return try_merge_command(the_repository,
-                                        strategy, xopts_nr, xopts,
+                                        strategy, xopts.nr, xopts.v,
                                         common, head_arg, remoteheads);
        }
 }
@@ -1654,6 +1632,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
                for (j = remoteheads; j; j = j->next) {
                        struct commit_list *common_one;
+                       struct commit *common_item;
 
                        /*
                         * Here we *have* to calculate the individual
@@ -1663,7 +1642,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        common_one = repo_get_merge_bases(the_repository,
                                                          head_commit,
                                                          j->item);
-                       if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
+                       common_item = common_one->item;
+                       free_commit_list(common_one);
+                       if (!oideq(&common_item->object.oid, &j->item->object.oid)) {
                                up_to_date = 0;
                                break;
                        }
index d2a162d52804cf7fdf1fd1a11303f2380c24c9e3..89a8b5a9768e42da3edaaddb63a663936ef70576 100644 (file)
@@ -3603,7 +3603,6 @@ static void read_cruft_objects(void)
                        string_list_append(&discard_packs, buf.buf + 1);
                else
                        string_list_append(&fresh_packs, buf.buf);
-               strbuf_reset(&buf);
        }
 
        string_list_sort(&discard_packs);
@@ -3739,7 +3738,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
        show_object(obj, name, data);
 }
 
-static int option_parse_missing_action(const struct option *opt,
+static int option_parse_missing_action(const struct option *opt UNUSED,
                                       const char *arg, int unset)
 {
        assert(arg);
@@ -4120,34 +4119,37 @@ static void add_extra_kept_packs(const struct string_list *names)
 static int option_parse_quiet(const struct option *opt, const char *arg,
                              int unset)
 {
+       int *val = opt->value;
+
        BUG_ON_OPT_ARG(arg);
 
        if (!unset)
-               progress = 0;
-       else if (!progress)
-               progress = 1;
+               *val = 0;
+       else if (!*val)
+               *val = 1;
        return 0;
 }
 
 static int option_parse_index_version(const struct option *opt,
                                      const char *arg, int unset)
 {
+       struct pack_idx_option *popts = opt->value;
        char *c;
        const char *val = arg;
 
        BUG_ON_OPT_NEG(unset);
 
-       pack_idx_opts.version = strtoul(val, &c, 10);
-       if (pack_idx_opts.version > 2)
+       popts->version = strtoul(val, &c, 10);
+       if (popts->version > 2)
                die(_("unsupported index version %s"), val);
        if (*c == ',' && c[1])
-               pack_idx_opts.off32_limit = strtoul(c+1, &c, 0);
-       if (*c || pack_idx_opts.off32_limit & 0x80000000)
+               popts->off32_limit = strtoul(c+1, &c, 0);
+       if (*c || popts->off32_limit & 0x80000000)
                die(_("bad index version '%s'"), val);
        return 0;
 }
 
-static int option_parse_unpack_unreachable(const struct option *opt,
+static int option_parse_unpack_unreachable(const struct option *opt UNUSED,
                                           const char *arg, int unset)
 {
        if (unset) {
@@ -4162,7 +4164,7 @@ static int option_parse_unpack_unreachable(const struct option *opt,
        return 0;
 }
 
-static int option_parse_cruft_expiration(const struct option *opt,
+static int option_parse_cruft_expiration(const struct option *opt UNUSED,
                                         const char *arg, int unset)
 {
        if (unset) {
@@ -4190,7 +4192,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                LIST_OBJECTS_FILTER_INIT;
 
        struct option pack_objects_options[] = {
-               OPT_CALLBACK_F('q', "quiet", NULL, NULL,
+               OPT_CALLBACK_F('q', "quiet", &progress, NULL,
                               N_("do not show progress meter"),
                               PARSE_OPT_NOARG, option_parse_quiet),
                OPT_SET_INT(0, "progress", &progress,
@@ -4200,7 +4202,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "all-progress-implied",
                         &all_progress_implied,
                         N_("similar to --all-progress when progress meter is shown")),
-               OPT_CALLBACK_F(0, "index-version", NULL, N_("<version>[,<offset>]"),
+               OPT_CALLBACK_F(0, "index-version", &pack_idx_opts, N_("<version>[,<offset>]"),
                  N_("write the pack index file in the specified idx format version"),
                  PARSE_OPT_NONEG, option_parse_index_version),
                OPT_MAGNITUDE(0, "max-pack-size", &pack_size_limit,
@@ -4383,7 +4385,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 
        if (!HAVE_THREADS && delta_search_threads != 1)
                warning(_("no threads support, ignoring --threads"));
-       if (!pack_to_stdout && !pack_size_limit && !cruft)
+       if (!pack_to_stdout && !pack_size_limit)
                pack_size_limit = pack_size_limit_cfg;
        if (pack_to_stdout && pack_size_limit)
                die(_("--max-pack-size cannot be used to build a pack for transfer"));
@@ -4400,12 +4402,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        if (!rev_list_all || !rev_list_reflog || !rev_list_index)
                unpack_unreachable_expiration = 0;
 
-       if (filter_options.choice) {
-               if (!pack_to_stdout)
-                       die(_("cannot use --filter without --stdout"));
-               if (stdin_packs)
-                       die(_("cannot use --filter with --stdin-packs"));
-       }
+       if (stdin_packs && filter_options.choice)
+               die(_("cannot use --filter with --stdin-packs"));
 
        if (stdin_packs && use_internal_rev_list)
                die(_("cannot use internal rev list with --stdin-packs"));
@@ -4415,8 +4413,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                        die(_("cannot use internal rev list with --cruft"));
                if (stdin_packs)
                        die(_("cannot use --stdin-packs with --cruft"));
-               if (pack_size_limit)
-                       die(_("cannot use --max-pack-size with --cruft"));
        }
 
        /*
index 1fec702a04fa9b9785d767c4e8b44e50d0e3a89c..8196ca9dd85828890cf5e7088d19e51990a00c66 100644 (file)
@@ -49,7 +49,7 @@ static const char * const read_tree_usage[] = {
        NULL
 };
 
-static int index_output_cb(const struct option *opt, const char *arg,
+static int index_output_cb(const struct option *opt UNUSED, const char *arg,
                                 int unset)
 {
        BUG_ON_OPT_NEG(unset);
index 50cb85751f798e81d30d631754a3aaad443c3c49..043c65dccd9f19667a1eb6af993dfb9c1f4d8669 100644 (file)
@@ -376,20 +376,6 @@ static int run_sequencer_rebase(struct rebase_options *opts)
        return ret;
 }
 
-static void imply_merge(struct rebase_options *opts, const char *option);
-static int parse_opt_keep_empty(const struct option *opt, const char *arg,
-                               int unset)
-{
-       struct rebase_options *opts = opt->value;
-
-       BUG_ON_OPT_ARG(arg);
-
-       imply_merge(opts, unset ? "--no-keep-empty" : "--keep-empty");
-       opts->keep_empty = !unset;
-       opts->type = REBASE_MERGE;
-       return 0;
-}
-
 static int is_merge(struct rebase_options *opts)
 {
        return opts->type == REBASE_MERGE;
@@ -983,6 +969,18 @@ static enum empty_type parse_empty_value(const char *value)
        die(_("unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and \"ask\"."), value);
 }
 
+static int parse_opt_keep_empty(const struct option *opt, const char *arg,
+                               int unset)
+{
+       struct rebase_options *opts = opt->value;
+
+       BUG_ON_OPT_ARG(arg);
+
+       imply_merge(opts, unset ? "--no-keep-empty" : "--keep-empty");
+       opts->keep_empty = !unset;
+       return 0;
+}
+
 static int parse_opt_empty(const struct option *opt, const char *arg, int unset)
 {
        struct rebase_options *options = opt->value;
@@ -1147,7 +1145,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                                 "instead of ignoring them"),
                              1, PARSE_OPT_HIDDEN),
                OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
-               OPT_CALLBACK_F(0, "empty", &options, "{drop,keep,ask}",
+               OPT_CALLBACK_F(0, "empty", &options, "(drop|keep|ask)",
                               N_("how to handle commits that become empty"),
                               PARSE_OPT_NONEG, parse_opt_empty),
                OPT_CALLBACK_F('k', "keep-empty", &options, NULL,
@@ -1491,23 +1489,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 
        if (options.strategy) {
                options.strategy = xstrdup(options.strategy);
-               switch (options.type) {
-               case REBASE_APPLY:
-                       die(_("--strategy requires --merge or --interactive"));
-               case REBASE_MERGE:
-                       /* compatible */
-                       break;
-               case REBASE_UNSPECIFIED:
-                       options.type = REBASE_MERGE;
-                       break;
-               default:
-                       BUG("unhandled rebase type (%d)", options.type);
-               }
+               imply_merge(&options, "--strategy");
        }
 
-       if (options.type == REBASE_MERGE)
-               imply_merge(&options, "--merge");
-
        if (options.root && !options.onto_name)
                imply_merge(&options, "--root without --onto");
 
@@ -1552,7 +1536,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 
        if (options.type == REBASE_UNSPECIFIED) {
                if (!strcmp(options.default_backend, "merge"))
-                       imply_merge(&options, "--merge");
+                       options.type = REBASE_MERGE;
                else if (!strcmp(options.default_backend, "apply"))
                        options.type = REBASE_APPLY;
                else
@@ -1803,8 +1787,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 
                /* We want color (if set), but no pager */
                repo_diff_setup(the_repository, &opts);
-               opts.stat_width = -1; /* use full terminal width */
-               opts.stat_graph_width = -1; /* respect statGraphWidth config */
+               init_diffstat_widths(&opts);
                opts.output_format |=
                        DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
                opts.detect_rename = DIFF_DETECT_RENAME;
index df63a5892e71057e342792147fe5d30e13603952..21337292f5206726a1de7b3cbbef8a9d7cb88d4a 100644 (file)
@@ -243,7 +243,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 {
        struct cmd_reflog_expire_cb cmd = { 0 };
        timestamp_t now = time(NULL);
-       int i, status, do_all, all_worktrees = 1;
+       int i, status, do_all, single_worktree = 0;
        unsigned int flags = 0;
        int verbose = 0;
        reflog_expiry_should_prune_fn *should_prune_fn = should_expire_reflog_ent;
@@ -268,7 +268,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "stale-fix", &cmd.stalefix,
                         N_("prune any reflog entries that point to broken commits")),
                OPT_BOOL(0, "all", &do_all, N_("process the reflogs of all references")),
-               OPT_BOOL(1, "single-worktree", &all_worktrees,
+               OPT_BOOL(0, "single-worktree", &single_worktree,
                         N_("limits processing to reflogs from the current worktree only")),
                OPT_END()
        };
@@ -318,7 +318,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 
                worktrees = get_worktrees();
                for (p = worktrees; *p; p++) {
-                       if (!all_worktrees && !(*p)->is_current)
+                       if (single_worktree && !(*p)->is_current)
                                continue;
                        collected.worktree = *p;
                        refs_for_each_reflog(get_worktree_ref_store(*p),
index 97051479e49bf12418dfd70ac42b9bc132b9d571..edaee4dbec7b01624b5d272a7c402c49f46dba5d 100644 (file)
 #include "pack.h"
 #include "pack-bitmap.h"
 #include "refs.h"
+#include "list-objects-filter-options.h"
 
 #define ALL_INTO_ONE 1
 #define LOOSEN_UNREACHABLE 2
 #define PACK_CRUFT 4
 
 #define DELETE_PACK 1
-#define CRUFT_PACK 2
+#define RETAIN_PACK 2
 
 static int pack_everything;
 static int delta_base_offset = 1;
@@ -52,11 +53,12 @@ struct pack_objects_args {
        const char *window_memory;
        const char *depth;
        const char *threads;
-       const char *max_pack_size;
+       unsigned long max_pack_size;
        int no_reuse_delta;
        int no_reuse_object;
        int quiet;
        int local;
+       struct list_objects_filter_options filter_options;
 };
 
 static int repack_config(const char *var, const char *value,
@@ -95,14 +97,143 @@ static int repack_config(const char *var, const char *value,
        return git_default_config(var, value, ctx, cb);
 }
 
+struct existing_packs {
+       struct string_list kept_packs;
+       struct string_list non_kept_packs;
+       struct string_list cruft_packs;
+};
+
+#define EXISTING_PACKS_INIT { \
+       .kept_packs = STRING_LIST_INIT_DUP, \
+       .non_kept_packs = STRING_LIST_INIT_DUP, \
+       .cruft_packs = STRING_LIST_INIT_DUP, \
+}
+
+static int has_existing_non_kept_packs(const struct existing_packs *existing)
+{
+       return existing->non_kept_packs.nr || existing->cruft_packs.nr;
+}
+
+static void pack_mark_for_deletion(struct string_list_item *item)
+{
+       item->util = (void*)((uintptr_t)item->util | DELETE_PACK);
+}
+
+static void pack_unmark_for_deletion(struct string_list_item *item)
+{
+       item->util = (void*)((uintptr_t)item->util & ~DELETE_PACK);
+}
+
+static int pack_is_marked_for_deletion(struct string_list_item *item)
+{
+       return (uintptr_t)item->util & DELETE_PACK;
+}
+
+static void pack_mark_retained(struct string_list_item *item)
+{
+       item->util = (void*)((uintptr_t)item->util | RETAIN_PACK);
+}
+
+static int pack_is_retained(struct string_list_item *item)
+{
+       return (uintptr_t)item->util & RETAIN_PACK;
+}
+
+static void mark_packs_for_deletion_1(struct string_list *names,
+                                     struct string_list *list)
+{
+       struct string_list_item *item;
+       const int hexsz = the_hash_algo->hexsz;
+
+       for_each_string_list_item(item, list) {
+               char *sha1;
+               size_t len = strlen(item->string);
+               if (len < hexsz)
+                       continue;
+               sha1 = item->string + len - hexsz;
+
+               if (pack_is_retained(item)) {
+                       pack_unmark_for_deletion(item);
+               } else if (!string_list_has_string(names, sha1)) {
+                       /*
+                        * Mark this pack for deletion, which ensures
+                        * that this pack won't be included in a MIDX
+                        * (if `--write-midx` was given) and that we
+                        * will actually delete this pack (if `-d` was
+                        * given).
+                        */
+                       pack_mark_for_deletion(item);
+               }
+       }
+}
+
+static void retain_cruft_pack(struct existing_packs *existing,
+                             struct packed_git *cruft)
+{
+       struct strbuf buf = STRBUF_INIT;
+       struct string_list_item *item;
+
+       strbuf_addstr(&buf, pack_basename(cruft));
+       strbuf_strip_suffix(&buf, ".pack");
+
+       item = string_list_lookup(&existing->cruft_packs, buf.buf);
+       if (!item)
+               BUG("could not find cruft pack '%s'", pack_basename(cruft));
+
+       pack_mark_retained(item);
+       strbuf_release(&buf);
+}
+
+static void mark_packs_for_deletion(struct existing_packs *existing,
+                                   struct string_list *names)
+
+{
+       mark_packs_for_deletion_1(names, &existing->non_kept_packs);
+       mark_packs_for_deletion_1(names, &existing->cruft_packs);
+}
+
+static void remove_redundant_pack(const char *dir_name, const char *base_name)
+{
+       struct strbuf buf = STRBUF_INIT;
+       struct multi_pack_index *m = get_local_multi_pack_index(the_repository);
+       strbuf_addf(&buf, "%s.pack", base_name);
+       if (m && midx_contains_pack(m, buf.buf))
+               clear_midx_file(the_repository);
+       strbuf_insertf(&buf, 0, "%s/", dir_name);
+       unlink_pack_path(buf.buf, 1);
+       strbuf_release(&buf);
+}
+
+static void remove_redundant_packs_1(struct string_list *packs)
+{
+       struct string_list_item *item;
+       for_each_string_list_item(item, packs) {
+               if (!pack_is_marked_for_deletion(item))
+                       continue;
+               remove_redundant_pack(packdir, item->string);
+       }
+}
+
+static void remove_redundant_existing_packs(struct existing_packs *existing)
+{
+       remove_redundant_packs_1(&existing->non_kept_packs);
+       remove_redundant_packs_1(&existing->cruft_packs);
+}
+
+static void existing_packs_release(struct existing_packs *existing)
+{
+       string_list_clear(&existing->kept_packs, 0);
+       string_list_clear(&existing->non_kept_packs, 0);
+       string_list_clear(&existing->cruft_packs, 0);
+}
+
 /*
- * Adds all packs hex strings (pack-$HASH) to either fname_nonkept_list
- * or fname_kept_list based on whether each pack has a corresponding
+ * Adds all packs hex strings (pack-$HASH) to either packs->non_kept
+ * or packs->kept based on whether each pack has a corresponding
  * .keep file or not.  Packs without a .keep file are not to be kept
  * if we are going to pack everything into one file.
  */
-static void collect_pack_filenames(struct string_list *fname_nonkept_list,
-                                  struct string_list *fname_kept_list,
+static void collect_pack_filenames(struct existing_packs *existing,
                                   const struct string_list *extra_keep)
 {
        struct packed_git *p;
@@ -126,28 +257,16 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,
                strbuf_strip_suffix(&buf, ".pack");
 
                if ((extra_keep->nr > 0 && i < extra_keep->nr) || p->pack_keep)
-                       string_list_append(fname_kept_list, buf.buf);
-               else {
-                       struct string_list_item *item;
-                       item = string_list_append(fname_nonkept_list, buf.buf);
-                       if (p->is_cruft)
-                               item->util = (void*)(uintptr_t)CRUFT_PACK;
-               }
+                       string_list_append(&existing->kept_packs, buf.buf);
+               else if (p->is_cruft)
+                       string_list_append(&existing->cruft_packs, buf.buf);
+               else
+                       string_list_append(&existing->non_kept_packs, buf.buf);
        }
 
-       string_list_sort(fname_kept_list);
-       strbuf_release(&buf);
-}
-
-static void remove_redundant_pack(const char *dir_name, const char *base_name)
-{
-       struct strbuf buf = STRBUF_INIT;
-       struct multi_pack_index *m = get_local_multi_pack_index(the_repository);
-       strbuf_addf(&buf, "%s.pack", base_name);
-       if (m && midx_contains_pack(m, buf.buf))
-               clear_midx_file(the_repository);
-       strbuf_insertf(&buf, 0, "%s/", dir_name);
-       unlink_pack_path(buf.buf, 1);
+       string_list_sort(&existing->kept_packs);
+       string_list_sort(&existing->non_kept_packs);
+       string_list_sort(&existing->cruft_packs);
        strbuf_release(&buf);
 }
 
@@ -165,7 +284,7 @@ static void prepare_pack_objects(struct child_process *cmd,
        if (args->threads)
                strvec_pushf(&cmd->args, "--threads=%s", args->threads);
        if (args->max_pack_size)
-               strvec_pushf(&cmd->args, "--max-pack-size=%s", args->max_pack_size);
+               strvec_pushf(&cmd->args, "--max-pack-size=%lu", args->max_pack_size);
        if (args->no_reuse_delta)
                strvec_pushf(&cmd->args, "--no-reuse-delta");
        if (args->no_reuse_object)
@@ -238,6 +357,18 @@ static struct generated_pack_data *populate_pack_exts(const char *name)
        return data;
 }
 
+static int has_pack_ext(const struct generated_pack_data *data,
+                       const char *ext)
+{
+       int i;
+       for (i = 0; i < ARRAY_SIZE(exts); i++) {
+               if (strcmp(exts[i].name, ext))
+                       continue;
+               return !!data->tempfiles[i];
+       }
+       BUG("unknown pack extension: '%s'", ext);
+}
+
 static void repack_promisor_objects(const struct pack_objects_args *args,
                                    struct string_list *names)
 {
@@ -303,6 +434,8 @@ struct pack_geometry {
        struct packed_git **pack;
        uint32_t pack_nr, pack_alloc;
        uint32_t split;
+
+       int split_factor;
 };
 
 static uint32_t geometry_pack_weight(struct packed_git *p)
@@ -324,17 +457,13 @@ static int geometry_cmp(const void *va, const void *vb)
        return 0;
 }
 
-static void init_pack_geometry(struct pack_geometry **geometry_p,
-                              struct string_list *existing_kept_packs,
+static void init_pack_geometry(struct pack_geometry *geometry,
+                              struct existing_packs *existing,
                               const struct pack_objects_args *args)
 {
        struct packed_git *p;
-       struct pack_geometry *geometry;
        struct strbuf buf = STRBUF_INIT;
 
-       *geometry_p = xcalloc(1, sizeof(struct pack_geometry));
-       geometry = *geometry_p;
-
        for (p = get_all_packs(the_repository); p; p = p->next) {
                if (args->local && !p->pack_local)
                        /*
@@ -346,23 +475,24 @@ static void init_pack_geometry(struct pack_geometry **geometry_p,
 
                if (!pack_kept_objects) {
                        /*
-                        * Any pack that has its pack_keep bit set will appear
-                        * in existing_kept_packs below, but this saves us from
-                        * doing a more expensive check.
+                        * Any pack that has its pack_keep bit set will
+                        * appear in existing->kept_packs below, but
+                        * this saves us from doing a more expensive
+                        * check.
                         */
                        if (p->pack_keep)
                                continue;
 
                        /*
-                        * The pack may be kept via the --keep-pack option;
-                        * check 'existing_kept_packs' to determine whether to
-                        * ignore it.
+                        * The pack may be kept via the --keep-pack
+                        * option; check 'existing->kept_packs' to
+                        * determine whether to ignore it.
                         */
                        strbuf_reset(&buf);
                        strbuf_addstr(&buf, pack_basename(p));
                        strbuf_strip_suffix(&buf, ".pack");
 
-                       if (string_list_has_string(existing_kept_packs, buf.buf))
+                       if (string_list_has_string(&existing->kept_packs, buf.buf))
                                continue;
                }
                if (p->is_cruft)
@@ -380,7 +510,7 @@ static void init_pack_geometry(struct pack_geometry **geometry_p,
        strbuf_release(&buf);
 }
 
-static void split_pack_geometry(struct pack_geometry *geometry, int factor)
+static void split_pack_geometry(struct pack_geometry *geometry)
 {
        uint32_t i;
        uint32_t split;
@@ -399,12 +529,14 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
                struct packed_git *ours = geometry->pack[i];
                struct packed_git *prev = geometry->pack[i - 1];
 
-               if (unsigned_mult_overflows(factor, geometry_pack_weight(prev)))
+               if (unsigned_mult_overflows(geometry->split_factor,
+                                           geometry_pack_weight(prev)))
                        die(_("pack %s too large to consider in geometric "
                              "progression"),
                            prev->pack_name);
 
-               if (geometry_pack_weight(ours) < factor * geometry_pack_weight(prev))
+               if (geometry_pack_weight(ours) <
+                   geometry->split_factor * geometry_pack_weight(prev))
                        break;
        }
 
@@ -439,10 +571,12 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
        for (i = split; i < geometry->pack_nr; i++) {
                struct packed_git *ours = geometry->pack[i];
 
-               if (unsigned_mult_overflows(factor, total_size))
+               if (unsigned_mult_overflows(geometry->split_factor,
+                                           total_size))
                        die(_("pack %s too large to roll up"), ours->pack_name);
 
-               if (geometry_pack_weight(ours) < factor * total_size) {
+               if (geometry_pack_weight(ours) <
+                   geometry->split_factor * total_size) {
                        if (unsigned_add_overflows(total_size,
                                                   geometry_pack_weight(ours)))
                                die(_("pack %s too large to roll up"),
@@ -492,13 +626,38 @@ static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)
        return NULL;
 }
 
+static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
+                                           struct string_list *names,
+                                           struct existing_packs *existing)
+{
+       struct strbuf buf = STRBUF_INIT;
+       uint32_t i;
+
+       for (i = 0; i < geometry->split; i++) {
+               struct packed_git *p = geometry->pack[i];
+               if (string_list_has_string(names, hash_to_hex(p->hash)))
+                       continue;
+
+               strbuf_reset(&buf);
+               strbuf_addstr(&buf, pack_basename(p));
+               strbuf_strip_suffix(&buf, ".pack");
+
+               if ((p->pack_keep) ||
+                   (string_list_has_string(&existing->kept_packs, buf.buf)))
+                       continue;
+
+               remove_redundant_pack(packdir, buf.buf);
+       }
+
+       strbuf_release(&buf);
+}
+
 static void free_pack_geometry(struct pack_geometry *geometry)
 {
        if (!geometry)
                return;
 
        free(geometry->pack);
-       free(geometry);
 }
 
 struct midx_snapshot_ref_data {
@@ -564,18 +723,17 @@ static void midx_snapshot_refs(struct tempfile *f)
 }
 
 static void midx_included_packs(struct string_list *include,
-                               struct string_list *existing_nonkept_packs,
-                               struct string_list *existing_kept_packs,
+                               struct existing_packs *existing,
                                struct string_list *names,
                                struct pack_geometry *geometry)
 {
        struct string_list_item *item;
 
-       for_each_string_list_item(item, existing_kept_packs)
+       for_each_string_list_item(item, &existing->kept_packs)
                string_list_insert(include, xstrfmt("%s.idx", item->string));
        for_each_string_list_item(item, names)
                string_list_insert(include, xstrfmt("pack-%s.idx", item->string));
-       if (geometry) {
+       if (geometry->split_factor) {
                struct strbuf buf = STRBUF_INIT;
                uint32_t i;
                for (i = geometry->split; i < geometry->pack_nr; i++) {
@@ -598,28 +756,37 @@ static void midx_included_packs(struct string_list *include,
 
                        string_list_insert(include, strbuf_detach(&buf, NULL));
                }
-
-               for_each_string_list_item(item, existing_nonkept_packs) {
-                       if (!((uintptr_t)item->util & CRUFT_PACK)) {
-                               /*
-                                * no need to check DELETE_PACK, since we're not
-                                * doing an ALL_INTO_ONE repack
-                                */
-                               continue;
-                       }
-                       string_list_insert(include, xstrfmt("%s.idx", item->string));
-               }
        } else {
-               for_each_string_list_item(item, existing_nonkept_packs) {
-                       if ((uintptr_t)item->util & DELETE_PACK)
+               for_each_string_list_item(item, &existing->non_kept_packs) {
+                       if (pack_is_marked_for_deletion(item))
                                continue;
                        string_list_insert(include, xstrfmt("%s.idx", item->string));
                }
        }
+
+       for_each_string_list_item(item, &existing->cruft_packs) {
+               /*
+                * When doing a --geometric repack, there is no need to check
+                * for deleted packs, since we're by definition not doing an
+                * ALL_INTO_ONE repack (hence no packs will be deleted).
+                * Otherwise we must check for and exclude any packs which are
+                * enqueued for deletion.
+                *
+                * So we could omit the conditional below in the --geometric
+                * case, but doing so is unnecessary since no packs are marked
+                * as pending deletion (since we only call
+                * `mark_packs_for_deletion()` when doing an all-into-one
+                * repack).
+                */
+               if (pack_is_marked_for_deletion(item))
+                       continue;
+               string_list_insert(include, xstrfmt("%s.idx", item->string));
+       }
 }
 
 static int write_midx_included_packs(struct string_list *include,
                                     struct pack_geometry *geometry,
+                                    struct string_list *names,
                                     const char *refs_snapshot,
                                     int show_progress, int write_bitmaps)
 {
@@ -649,6 +816,38 @@ static int write_midx_included_packs(struct string_list *include,
        if (preferred)
                strvec_pushf(&cmd.args, "--preferred-pack=%s",
                             pack_basename(preferred));
+       else if (names->nr) {
+               /* The largest pack was repacked, meaning that either
+                * one or two packs exist depending on whether the
+                * repository has a cruft pack or not.
+                *
+                * Select the non-cruft one as preferred to encourage
+                * pack-reuse among packs containing reachable objects
+                * over unreachable ones.
+                *
+                * (Note we could write multiple packs here if
+                * `--max-pack-size` was given, but any one of them
+                * will suffice, so pick the first one.)
+                */
+               for_each_string_list_item(item, names) {
+                       struct generated_pack_data *data = item->util;
+                       if (has_pack_ext(data, ".mtimes"))
+                               continue;
+
+                       strvec_pushf(&cmd.args, "--preferred-pack=pack-%s.pack",
+                                    item->string);
+                       break;
+               }
+       } else {
+               /*
+                * No packs were kept, and no packs were written. The
+                * only thing remaining are .keep packs (unless
+                * --pack-kept-objects was given).
+                *
+                * Set the `--preferred-pack` arbitrarily here.
+                */
+               ;
+       }
 
        if (refs_snapshot)
                strvec_pushf(&cmd.args, "--refs-snapshot=%s", refs_snapshot);
@@ -694,18 +893,163 @@ static void remove_redundant_bitmaps(struct string_list *include,
        strbuf_release(&path);
 }
 
+static int finish_pack_objects_cmd(struct child_process *cmd,
+                                  struct string_list *names,
+                                  int local)
+{
+       FILE *out;
+       struct strbuf line = STRBUF_INIT;
+
+       out = xfdopen(cmd->out, "r");
+       while (strbuf_getline_lf(&line, out) != EOF) {
+               struct string_list_item *item;
+
+               if (line.len != the_hash_algo->hexsz)
+                       die(_("repack: Expecting full hex object ID lines only "
+                             "from pack-objects."));
+               /*
+                * Avoid putting packs written outside of the repository in the
+                * list of names.
+                */
+               if (local) {
+                       item = string_list_append(names, line.buf);
+                       item->util = populate_pack_exts(line.buf);
+               }
+       }
+       fclose(out);
+
+       strbuf_release(&line);
+
+       return finish_command(cmd);
+}
+
+static int write_filtered_pack(const struct pack_objects_args *args,
+                              const char *destination,
+                              const char *pack_prefix,
+                              struct existing_packs *existing,
+                              struct string_list *names)
+{
+       struct child_process cmd = CHILD_PROCESS_INIT;
+       struct string_list_item *item;
+       FILE *in;
+       int ret;
+       const char *caret;
+       const char *scratch;
+       int local = skip_prefix(destination, packdir, &scratch);
+
+       prepare_pack_objects(&cmd, args, destination);
+
+       strvec_push(&cmd.args, "--stdin-packs");
+
+       if (!pack_kept_objects)
+               strvec_push(&cmd.args, "--honor-pack-keep");
+       for_each_string_list_item(item, &existing->kept_packs)
+               strvec_pushf(&cmd.args, "--keep-pack=%s", item->string);
+
+       cmd.in = -1;
+
+       ret = start_command(&cmd);
+       if (ret)
+               return ret;
+
+       /*
+        * Here 'names' contains only the pack(s) that were just
+        * written, which is exactly the packs we want to keep. Also
+        * 'existing_kept_packs' already contains the packs in
+        * 'keep_pack_list'.
+        */
+       in = xfdopen(cmd.in, "w");
+       for_each_string_list_item(item, names)
+               fprintf(in, "^%s-%s.pack\n", pack_prefix, item->string);
+       for_each_string_list_item(item, &existing->non_kept_packs)
+               fprintf(in, "%s.pack\n", item->string);
+       for_each_string_list_item(item, &existing->cruft_packs)
+               fprintf(in, "%s.pack\n", item->string);
+       caret = pack_kept_objects ? "" : "^";
+       for_each_string_list_item(item, &existing->kept_packs)
+               fprintf(in, "%s%s.pack\n", caret, item->string);
+       fclose(in);
+
+       return finish_pack_objects_cmd(&cmd, names, local);
+}
+
+static int existing_cruft_pack_cmp(const void *va, const void *vb)
+{
+       struct packed_git *a = *(struct packed_git **)va;
+       struct packed_git *b = *(struct packed_git **)vb;
+
+       if (a->pack_size < b->pack_size)
+               return -1;
+       if (a->pack_size > b->pack_size)
+               return 1;
+       return 0;
+}
+
+static void collapse_small_cruft_packs(FILE *in, size_t max_size,
+                                      struct existing_packs *existing)
+{
+       struct packed_git **existing_cruft, *p;
+       struct strbuf buf = STRBUF_INIT;
+       size_t total_size = 0;
+       size_t existing_cruft_nr = 0;
+       size_t i;
+
+       ALLOC_ARRAY(existing_cruft, existing->cruft_packs.nr);
+
+       for (p = get_all_packs(the_repository); p; p = p->next) {
+               if (!(p->is_cruft && p->pack_local))
+                       continue;
+
+               strbuf_reset(&buf);
+               strbuf_addstr(&buf, pack_basename(p));
+               strbuf_strip_suffix(&buf, ".pack");
+
+               if (!string_list_has_string(&existing->cruft_packs, buf.buf))
+                       continue;
+
+               if (existing_cruft_nr >= existing->cruft_packs.nr)
+                       BUG("too many cruft packs (found %"PRIuMAX", but knew "
+                           "of %"PRIuMAX")",
+                           (uintmax_t)existing_cruft_nr + 1,
+                           (uintmax_t)existing->cruft_packs.nr);
+               existing_cruft[existing_cruft_nr++] = p;
+       }
+
+       QSORT(existing_cruft, existing_cruft_nr, existing_cruft_pack_cmp);
+
+       for (i = 0; i < existing_cruft_nr; i++) {
+               size_t proposed;
+
+               p = existing_cruft[i];
+               proposed = st_add(total_size, p->pack_size);
+
+               if (proposed <= max_size) {
+                       total_size = proposed;
+                       fprintf(in, "-%s\n", pack_basename(p));
+               } else {
+                       retain_cruft_pack(existing, p);
+                       fprintf(in, "%s\n", pack_basename(p));
+               }
+       }
+
+       for (i = 0; i < existing->non_kept_packs.nr; i++)
+               fprintf(in, "-%s.pack\n",
+                       existing->non_kept_packs.items[i].string);
+
+       strbuf_release(&buf);
+       free(existing_cruft);
+}
+
 static int write_cruft_pack(const struct pack_objects_args *args,
                            const char *destination,
                            const char *pack_prefix,
                            const char *cruft_expiration,
                            struct string_list *names,
-                           struct string_list *existing_packs,
-                           struct string_list *existing_kept_packs)
+                           struct existing_packs *existing)
 {
        struct child_process cmd = CHILD_PROCESS_INIT;
-       struct strbuf line = STRBUF_INIT;
        struct string_list_item *item;
-       FILE *in, *out;
+       FILE *in;
        int ret;
        const char *scratch;
        int local = skip_prefix(destination, packdir, &scratch);
@@ -719,7 +1063,6 @@ static int write_cruft_pack(const struct pack_objects_args *args,
 
        strvec_push(&cmd.args, "--honor-pack-keep");
        strvec_push(&cmd.args, "--non-empty");
-       strvec_push(&cmd.args, "--max-pack-size=0");
 
        cmd.in = -1;
 
@@ -743,33 +1086,30 @@ static int write_cruft_pack(const struct pack_objects_args *args,
        in = xfdopen(cmd.in, "w");
        for_each_string_list_item(item, names)
                fprintf(in, "%s-%s.pack\n", pack_prefix, item->string);
-       for_each_string_list_item(item, existing_packs)
-               fprintf(in, "-%s.pack\n", item->string);
-       for_each_string_list_item(item, existing_kept_packs)
+       if (args->max_pack_size && !cruft_expiration) {
+               collapse_small_cruft_packs(in, args->max_pack_size, existing);
+       } else {
+               for_each_string_list_item(item, &existing->non_kept_packs)
+                       fprintf(in, "-%s.pack\n", item->string);
+               for_each_string_list_item(item, &existing->cruft_packs)
+                       fprintf(in, "-%s.pack\n", item->string);
+       }
+       for_each_string_list_item(item, &existing->kept_packs)
                fprintf(in, "%s.pack\n", item->string);
        fclose(in);
 
-       out = xfdopen(cmd.out, "r");
-       while (strbuf_getline_lf(&line, out) != EOF) {
-               struct string_list_item *item;
-
-               if (line.len != the_hash_algo->hexsz)
-                       die(_("repack: Expecting full hex object ID lines only "
-                             "from pack-objects."));
-               /*
-                * avoid putting packs written outside of the repository in the
-                * list of names
-                */
-               if (local) {
-                       item = string_list_append(names, line.buf);
-                       item->util = populate_pack_exts(line.buf);
-               }
-       }
-       fclose(out);
-
-       strbuf_release(&line);
+       return finish_pack_objects_cmd(&cmd, names, local);
+}
 
-       return finish_command(&cmd);
+static const char *find_pack_prefix(const char *packdir, const char *packtmp)
+{
+       const char *pack_prefix;
+       if (!skip_prefix(packtmp, packdir, &pack_prefix))
+               die(_("pack prefix %s does not begin with objdir %s"),
+                   packtmp, packdir);
+       if (*pack_prefix == '/')
+               pack_prefix++;
+       return pack_prefix;
 }
 
 int cmd_repack(int argc, const char **argv, const char *prefix)
@@ -777,13 +1117,10 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        struct child_process cmd = CHILD_PROCESS_INIT;
        struct string_list_item *item;
        struct string_list names = STRING_LIST_INIT_DUP;
-       struct string_list existing_nonkept_packs = STRING_LIST_INIT_DUP;
-       struct string_list existing_kept_packs = STRING_LIST_INIT_DUP;
-       struct pack_geometry *geometry = NULL;
-       struct strbuf line = STRBUF_INIT;
+       struct existing_packs existing = EXISTING_PACKS_INIT;
+       struct pack_geometry geometry = { 0 };
        struct tempfile *refs_snapshot = NULL;
        int i, ext, ret;
-       FILE *out;
        int show_progress;
 
        /* variables to be filled by option parsing */
@@ -793,10 +1130,10 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
        struct pack_objects_args po_args = {NULL};
        struct pack_objects_args cruft_po_args = {NULL};
-       int geometric_factor = 0;
        int write_midx = 0;
        const char *cruft_expiration = NULL;
        const char *expire_to = NULL;
+       const char *filter_to = NULL;
 
        struct option builtin_repack_options[] = {
                OPT_BIT('a', NULL, &pack_everything,
@@ -809,6 +1146,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                   PACK_CRUFT),
                OPT_STRING(0, "cruft-expiration", &cruft_expiration, N_("approxidate"),
                                N_("with --cruft, expire objects older than this")),
+               OPT_MAGNITUDE(0, "max-cruft-size", &cruft_po_args.max_pack_size,
+                               N_("with --cruft, limit the size of new cruft packs")),
                OPT_BOOL('d', NULL, &delete_redundant,
                                N_("remove redundant packs, and run git-prune-packed")),
                OPT_BOOL('f', NULL, &po_args.no_reuse_delta,
@@ -836,21 +1175,26 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                N_("limits the maximum delta depth")),
                OPT_STRING(0, "threads", &po_args.threads, N_("n"),
                                N_("limits the maximum number of threads")),
-               OPT_STRING(0, "max-pack-size", &po_args.max_pack_size, N_("bytes"),
+               OPT_MAGNITUDE(0, "max-pack-size", &po_args.max_pack_size,
                                N_("maximum size of each packfile")),
+               OPT_PARSE_LIST_OBJECTS_FILTER(&po_args.filter_options),
                OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
                                N_("repack objects in packs marked with .keep")),
                OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
                                N_("do not repack this pack")),
-               OPT_INTEGER('g', "geometric", &geometric_factor,
+               OPT_INTEGER('g', "geometric", &geometry.split_factor,
                            N_("find a geometric progression with factor <N>")),
                OPT_BOOL('m', "write-midx", &write_midx,
                           N_("write a multi-pack index of the resulting packs")),
                OPT_STRING(0, "expire-to", &expire_to, N_("dir"),
                           N_("pack prefix to store a pack containing pruned objects")),
+               OPT_STRING(0, "filter-to", &filter_to, N_("dir"),
+                          N_("pack prefix to store a pack containing filtered out objects")),
                OPT_END()
        };
 
+       list_objects_filter_init(&po_args.filter_options);
+
        git_config(repack_config, &cruft_po_args);
 
        argc = parse_options(argc, argv, prefix, builtin_repack_options,
@@ -915,14 +1259,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid());
        packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
 
-       collect_pack_filenames(&existing_nonkept_packs, &existing_kept_packs,
-                              &keep_pack_list);
+       collect_pack_filenames(&existing, &keep_pack_list);
 
-       if (geometric_factor) {
+       if (geometry.split_factor) {
                if (pack_everything)
                        die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
-               init_pack_geometry(&geometry, &existing_kept_packs, &po_args);
-               split_pack_geometry(geometry, geometric_factor);
+               init_pack_geometry(&geometry, &existing, &po_args);
+               split_pack_geometry(&geometry);
        }
 
        prepare_pack_objects(&cmd, &po_args, packtmp);
@@ -936,7 +1279,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                strvec_pushf(&cmd.args, "--keep-pack=%s",
                             keep_pack_list.items[i].string);
        strvec_push(&cmd.args, "--non-empty");
-       if (!geometry) {
+       if (!geometry.split_factor) {
                /*
                 * We need to grab all reachable objects, including those that
                 * are reachable from reflogs and the index.
@@ -965,7 +1308,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        if (pack_everything & ALL_INTO_ONE) {
                repack_promisor_objects(&po_args, &names);
 
-               if (existing_nonkept_packs.nr && delete_redundant &&
+               if (has_existing_non_kept_packs(&existing) &&
+                   delete_redundant &&
                    !(pack_everything & PACK_CRUFT)) {
                        for_each_string_list_item(item, &names) {
                                strvec_pushf(&cmd.args, "--keep-pack=%s-%s.pack",
@@ -983,7 +1327,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                strvec_push(&cmd.args, "--pack-loose-unreachable");
                        }
                }
-       } else if (geometry) {
+       } else if (geometry.split_factor) {
                strvec_push(&cmd.args, "--stdin-packs");
                strvec_push(&cmd.args, "--unpacked");
        } else {
@@ -991,7 +1335,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                strvec_push(&cmd.args, "--incremental");
        }
 
-       if (geometry)
+       if (po_args.filter_options.choice)
+               strvec_pushf(&cmd.args, "--filter=%s",
+                            expand_list_objects_filter_spec(&po_args.filter_options));
+       else if (filter_to)
+               die(_("option '%s' can only be used along with '%s'"), "--filter-to", "--filter");
+
+       if (geometry.split_factor)
                cmd.in = -1;
        else
                cmd.no_stdin = 1;
@@ -1000,32 +1350,21 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        if (ret)
                goto cleanup;
 
-       if (geometry) {
+       if (geometry.split_factor) {
                FILE *in = xfdopen(cmd.in, "w");
                /*
                 * The resulting pack should contain all objects in packs that
                 * are going to be rolled up, but exclude objects in packs which
                 * are being left alone.
                 */
-               for (i = 0; i < geometry->split; i++)
-                       fprintf(in, "%s\n", pack_basename(geometry->pack[i]));
-               for (i = geometry->split; i < geometry->pack_nr; i++)
-                       fprintf(in, "^%s\n", pack_basename(geometry->pack[i]));
+               for (i = 0; i < geometry.split; i++)
+                       fprintf(in, "%s\n", pack_basename(geometry.pack[i]));
+               for (i = geometry.split; i < geometry.pack_nr; i++)
+                       fprintf(in, "^%s\n", pack_basename(geometry.pack[i]));
                fclose(in);
        }
 
-       out = xfdopen(cmd.out, "r");
-       while (strbuf_getline_lf(&line, out) != EOF) {
-               struct string_list_item *item;
-
-               if (line.len != the_hash_algo->hexsz)
-                       die(_("repack: Expecting full hex object ID lines only from pack-objects."));
-               item = string_list_append(&names, line.buf);
-               item->util = populate_pack_exts(item->string);
-       }
-       strbuf_release(&line);
-       fclose(out);
-       ret = finish_command(&cmd);
+       ret = finish_pack_objects_cmd(&cmd, &names, 1);
        if (ret)
                goto cleanup;
 
@@ -1033,12 +1372,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                printf_ln(_("Nothing new to pack."));
 
        if (pack_everything & PACK_CRUFT) {
-               const char *pack_prefix;
-               if (!skip_prefix(packtmp, packdir, &pack_prefix))
-                       die(_("pack prefix %s does not begin with objdir %s"),
-                           packtmp, packdir);
-               if (*pack_prefix == '/')
-                       pack_prefix++;
+               const char *pack_prefix = find_pack_prefix(packdir, packtmp);
 
                if (!cruft_po_args.window)
                        cruft_po_args.window = po_args.window;
@@ -1048,14 +1382,15 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                        cruft_po_args.depth = po_args.depth;
                if (!cruft_po_args.threads)
                        cruft_po_args.threads = po_args.threads;
+               if (!cruft_po_args.max_pack_size)
+                       cruft_po_args.max_pack_size = po_args.max_pack_size;
 
                cruft_po_args.local = po_args.local;
                cruft_po_args.quiet = po_args.quiet;
 
                ret = write_cruft_pack(&cruft_po_args, packtmp, pack_prefix,
                                       cruft_expiration, &names,
-                                      &existing_nonkept_packs,
-                                      &existing_kept_packs);
+                                      &existing);
                if (ret)
                        goto cleanup;
 
@@ -1086,13 +1421,25 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                                               pack_prefix,
                                               NULL,
                                               &names,
-                                              &existing_nonkept_packs,
-                                              &existing_kept_packs);
+                                              &existing);
                        if (ret)
                                goto cleanup;
                }
        }
 
+       if (po_args.filter_options.choice) {
+               if (!filter_to)
+                       filter_to = packtmp;
+
+               ret = write_filtered_pack(&po_args,
+                                         filter_to,
+                                         find_pack_prefix(packdir, packtmp),
+                                         &existing,
+                                         &names);
+               if (ret)
+                       goto cleanup;
+       }
+
        string_list_sort(&names);
 
        close_object_store(the_repository->objects);
@@ -1131,31 +1478,14 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        }
        /* End of pack replacement. */
 
-       if (delete_redundant && pack_everything & ALL_INTO_ONE) {
-               const int hexsz = the_hash_algo->hexsz;
-               for_each_string_list_item(item, &existing_nonkept_packs) {
-                       char *sha1;
-                       size_t len = strlen(item->string);
-                       if (len < hexsz)
-                               continue;
-                       sha1 = item->string + len - hexsz;
-                       /*
-                        * Mark this pack for deletion, which ensures that this
-                        * pack won't be included in a MIDX (if `--write-midx`
-                        * was given) and that we will actually delete this pack
-                        * (if `-d` was given).
-                        */
-                       if (!string_list_has_string(&names, sha1))
-                               item->util = (void*)(uintptr_t)((size_t)item->util | DELETE_PACK);
-               }
-       }
+       if (delete_redundant && pack_everything & ALL_INTO_ONE)
+               mark_packs_for_deletion(&existing, &names);
 
        if (write_midx) {
                struct string_list include = STRING_LIST_INIT_NODUP;
-               midx_included_packs(&include, &existing_nonkept_packs,
-                                   &existing_kept_packs, &names, geometry);
+               midx_included_packs(&include, &existing, &names, &geometry);
 
-               ret = write_midx_included_packs(&include, geometry,
+               ret = write_midx_included_packs(&include, &geometry, &names,
                                                refs_snapshot ? get_tempfile_path(refs_snapshot) : NULL,
                                                show_progress, write_bitmaps > 0);
 
@@ -1172,35 +1502,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 
        if (delete_redundant) {
                int opts = 0;
-               for_each_string_list_item(item, &existing_nonkept_packs) {
-                       if (!((uintptr_t)item->util & DELETE_PACK))
-                               continue;
-                       remove_redundant_pack(packdir, item->string);
-               }
-
-               if (geometry) {
-                       struct strbuf buf = STRBUF_INIT;
-
-                       uint32_t i;
-                       for (i = 0; i < geometry->split; i++) {
-                               struct packed_git *p = geometry->pack[i];
-                               if (string_list_has_string(&names,
-                                                          hash_to_hex(p->hash)))
-                                       continue;
+               remove_redundant_existing_packs(&existing);
 
-                               strbuf_reset(&buf);
-                               strbuf_addstr(&buf, pack_basename(p));
-                               strbuf_strip_suffix(&buf, ".pack");
-
-                               if ((p->pack_keep) ||
-                                   (string_list_has_string(&existing_kept_packs,
-                                                           buf.buf)))
-                                       continue;
-
-                               remove_redundant_pack(packdir, buf.buf);
-                       }
-                       strbuf_release(&buf);
-               }
+               if (geometry.split_factor)
+                       geometry_remove_redundant_packs(&geometry, &names,
+                                                       &existing);
                if (show_progress)
                        opts |= PRUNE_PACKED_VERBOSE;
                prune_packed_objects(opts);
@@ -1224,9 +1530,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 
 cleanup:
        string_list_clear(&names, 1);
-       string_list_clear(&existing_nonkept_packs, 0);
-       string_list_clear(&existing_kept_packs, 0);
-       free_pack_geometry(geometry);
+       existing_packs_release(&existing);
+       free_pack_geometry(&geometry);
+       list_objects_filter_release(&po_args.filter_options);
 
        return ret;
 }
index 53e8868ba1cfd7eb9ee27c1505c61b883a9901d9..4a6771c9f4c493a5dd41df2bf285f40784fa8cff 100644 (file)
@@ -362,7 +362,7 @@ static int is_path_a_directory(const char *path)
 }
 
 static void add_diff_to_buf(struct diff_queue_struct *q,
-                           struct diff_options *options,
+                           struct diff_options *options UNUSED,
                            void *data)
 {
        int i;
@@ -989,6 +989,12 @@ usage:
 static int do_store_stash(const struct object_id *w_commit, const char *stash_msg,
                          int quiet)
 {
+       struct stash_info info;
+       char revision[GIT_MAX_HEXSZ];
+
+       oid_to_hex_r(revision, w_commit);
+       assert_stash_like(&info, revision);
+
        if (!stash_msg)
                stash_msg = "Created via \"git stash store\".";
 
index 6f3bf33e615b3162c9109c1884113497ef130809..cce46450abe95ea6a24d28026a1686cb930cb75a 100644 (file)
@@ -2889,7 +2889,7 @@ cleanup:
 
 static int module_set_url(int argc, const char **argv, const char *prefix)
 {
-       int quiet = 0;
+       int quiet = 0, ret;
        const char *newurl;
        const char *path;
        char *config_name;
@@ -2901,20 +2901,29 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
                N_("git submodule set-url [--quiet] <path> <newurl>"),
                NULL
        };
+       const struct submodule *sub;
 
        argc = parse_options(argc, argv, prefix, options, usage, 0);
 
        if (argc != 2 || !(path = argv[0]) || !(newurl = argv[1]))
                usage_with_options(usage, options);
 
-       config_name = xstrfmt("submodule.%s.url", path);
+       sub = submodule_from_path(the_repository, null_oid(), path);
 
-       config_set_in_gitmodules_file_gently(config_name, newurl);
-       sync_submodule(path, prefix, NULL, quiet ? OPT_QUIET : 0);
+       if (!sub)
+               die(_("no submodule mapping found in .gitmodules for path '%s'"),
+                   path);
 
-       free(config_name);
+       config_name = xstrfmt("submodule.%s.url", sub->name);
+       ret = config_set_in_gitmodules_file_gently(config_name, newurl);
 
-       return 0;
+       if (!ret) {
+               repo_read_gitmodules(the_repository, 0);
+               sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
+       }
+
+       free(config_name);
+       return !!ret;
 }
 
 static int module_set_branch(int argc, const char **argv, const char *prefix)
@@ -2941,6 +2950,7 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
                N_("git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>"),
                NULL
        };
+       const struct submodule *sub;
 
        argc = parse_options(argc, argv, prefix, options, usage, 0);
 
@@ -2953,7 +2963,13 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
        if (argc != 1 || !(path = argv[0]))
                usage_with_options(usage, options);
 
-       config_name = xstrfmt("submodule.%s.branch", path);
+       sub = submodule_from_path(the_repository, null_oid(), path);
+
+       if (!sub)
+               die(_("no submodule mapping found in .gitmodules for path '%s'"),
+                   path);
+
+       config_name = xstrfmt("submodule.%s.branch", sub->name);
        ret = config_set_in_gitmodules_file_gently(config_name, opt_branch);
 
        free(config_name);
index 32505255a0097b84080dd8af37454aeb01ee8001..fef7423448804006a04286ce18adedbaaf950229 100644 (file)
@@ -609,6 +609,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)
 {
        int i;
        struct object_id oid;
+       git_hash_ctx tmp_ctx;
 
        disable_replace_refs();
 
@@ -669,7 +670,9 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)
        the_hash_algo->init_fn(&ctx);
        unpack_all();
        the_hash_algo->update_fn(&ctx, buffer, offset);
-       the_hash_algo->final_oid_fn(&oid, &ctx);
+       the_hash_algo->init_fn(&tmp_ctx);
+       the_hash_algo->clone_fn(&tmp_ctx, &ctx);
+       the_hash_algo->final_oid_fn(&oid, &tmp_ctx);
        if (strict) {
                write_rest();
                if (fsck_finish(&fsck_options))
index aee3cb8cbd3a03cedaf0c3e317e8c860049dbb74..7bcaa1476c0fd5233475cac56a22db8c7714a570 100644 (file)
@@ -609,9 +609,6 @@ static const char * const update_index_usage[] = {
        NULL
 };
 
-static struct object_id head_oid;
-static struct object_id merge_head_oid;
-
 static struct cache_entry *read_one_ent(const char *which,
                                        struct object_id *ent, const char *path,
                                        int namelen, int stage)
@@ -642,84 +639,17 @@ static struct cache_entry *read_one_ent(const char *which,
 
 static int unresolve_one(const char *path)
 {
-       int namelen = strlen(path);
-       int pos;
-       int ret = 0;
-       struct cache_entry *ce_2 = NULL, *ce_3 = NULL;
-
-       /* See if there is such entry in the index. */
-       pos = index_name_pos(&the_index, path, namelen);
-       if (0 <= pos) {
-               /* already merged */
-               pos = unmerge_index_entry_at(&the_index, pos);
-               if (pos < the_index.cache_nr) {
-                       const struct cache_entry *ce = the_index.cache[pos];
-                       if (ce_stage(ce) &&
-                           ce_namelen(ce) == namelen &&
-                           !memcmp(ce->name, path, namelen))
-                               return 0;
-               }
-               /* no resolve-undo information; fall back */
-       } else {
-               /* If there isn't, either it is unmerged, or
-                * resolved as "removed" by mistake.  We do not
-                * want to do anything in the former case.
-                */
-               pos = -pos-1;
-               if (pos < the_index.cache_nr) {
-                       const struct cache_entry *ce = the_index.cache[pos];
-                       if (ce_namelen(ce) == namelen &&
-                           !memcmp(ce->name, path, namelen)) {
-                               fprintf(stderr,
-                                       "%s: skipping still unmerged path.\n",
-                                       path);
-                               goto free_return;
-                       }
-               }
-       }
-
-       /* Grab blobs from given path from HEAD and MERGE_HEAD,
-        * stuff HEAD version in stage #2,
-        * stuff MERGE_HEAD version in stage #3.
-        */
-       ce_2 = read_one_ent("our", &head_oid, path, namelen, 2);
-       ce_3 = read_one_ent("their", &merge_head_oid, path, namelen, 3);
-
-       if (!ce_2 || !ce_3) {
-               ret = -1;
-               goto free_return;
-       }
-       if (oideq(&ce_2->oid, &ce_3->oid) &&
-           ce_2->ce_mode == ce_3->ce_mode) {
-               fprintf(stderr, "%s: identical in both, skipping.\n",
-                       path);
-               goto free_return;
-       }
-
-       remove_file_from_index(&the_index, path);
-       if (add_index_entry(&the_index, ce_2, ADD_CACHE_OK_TO_ADD)) {
-               error("%s: cannot add our version to the index.", path);
-               ret = -1;
-               goto free_return;
-       }
-       if (!add_index_entry(&the_index, ce_3, ADD_CACHE_OK_TO_ADD))
-               return 0;
-       error("%s: cannot add their version to the index.", path);
-       ret = -1;
- free_return:
-       discard_cache_entry(ce_2);
-       discard_cache_entry(ce_3);
-       return ret;
-}
-
-static void read_head_pointers(void)
-{
-       if (read_ref("HEAD", &head_oid))
-               die("No HEAD -- no initial commit yet?");
-       if (read_ref("MERGE_HEAD", &merge_head_oid)) {
-               fprintf(stderr, "Not in the middle of a merge.\n");
-               exit(0);
-       }
+       struct string_list_item *item;
+       int res = 0;
+
+       if (!the_index.resolve_undo)
+               return res;
+       item = string_list_lookup(the_index.resolve_undo, path);
+       if (!item)
+               return res; /* no resolve-undo record for the path */
+       res = unmerge_index_entry(&the_index, path, item->util, 0);
+       FREE_AND_NULL(item->util);
+       return res;
 }
 
 static int do_unresolve(int ac, const char **av,
@@ -728,11 +658,6 @@ static int do_unresolve(int ac, const char **av,
        int i;
        int err = 0;
 
-       /* Read HEAD and MERGE_HEAD; if MERGE_HEAD does not exist, we
-        * are not doing a merge, so exit with success status.
-        */
-       read_head_pointers();
-
        for (i = 1; i < ac; i++) {
                const char *arg = av[i];
                char *p = prefix_path(prefix, prefix_length, arg);
@@ -751,6 +676,7 @@ static int do_reupdate(const char **paths,
        int pos;
        int has_head = 1;
        struct pathspec pathspec;
+       struct object_id head_oid;
 
        parse_pathspec(&pathspec, 0,
                       PATHSPEC_PREFER_CWD,
@@ -856,7 +782,7 @@ static int chmod_callback(const struct option *opt,
        return 0;
 }
 
-static int resolve_undo_clear_callback(const struct option *opt,
+static int resolve_undo_clear_callback(const struct option *opt UNUSED,
                                const char *arg, int unset)
 {
        BUG_ON_OPT_NEG(unset);
@@ -890,7 +816,7 @@ static int parse_new_style_cacheinfo(const char *arg,
 }
 
 static enum parse_opt_result cacheinfo_callback(
-       struct parse_opt_ctx_t *ctx, const struct option *opt,
+       struct parse_opt_ctx_t *ctx, const struct option *opt UNUSED,
        const char *arg, int unset)
 {
        struct object_id oid;
@@ -1090,6 +1016,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
                        resolve_undo_clear_callback),
                OPT_INTEGER(0, "index-version", &preferred_index_format,
                        N_("write index in this format")),
+               OPT_SET_INT(0, "show-index-version", &preferred_index_format,
+                           N_("report on-disk index format version"), -1),
                OPT_BOOL(0, "split-index", &split_index,
                        N_("enable or disable split index")),
                OPT_BOOL(0, "untracked-cache", &untracked_cache,
@@ -1182,15 +1110,20 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 
        getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
        if (preferred_index_format) {
-               if (preferred_index_format < INDEX_FORMAT_LB ||
-                   INDEX_FORMAT_UB < preferred_index_format)
+               if (preferred_index_format < 0) {
+                       printf(_("%d\n"), the_index.version);
+               } else if (preferred_index_format < INDEX_FORMAT_LB ||
+                          INDEX_FORMAT_UB < preferred_index_format) {
                        die("index-version %d not in range: %d..%d",
                            preferred_index_format,
                            INDEX_FORMAT_LB, INDEX_FORMAT_UB);
-
-               if (the_index.version != preferred_index_format)
-                       the_index.cache_changed |= SOMETHING_CHANGED;
-               the_index.version = preferred_index_format;
+               } else {
+                       if (the_index.version != preferred_index_format)
+                               the_index.cache_changed |= SOMETHING_CHANGED;
+                       report(_("index-version: was %d, set to %d"),
+                              the_index.version, preferred_index_format);
+                       the_index.version = preferred_index_format;
+               }
        }
 
        if (read_from_stdin) {
index 242102273eea02a096e7d4c31b5110d592f5d6af..c0c4e65e6fb1986fadf2e98f0d19449e95905fe6 100644 (file)
@@ -311,8 +311,8 @@ static void report_ok(const char *command)
        fflush(stdout);
 }
 
-static void parse_cmd_option(struct ref_transaction *transaction,
-                            const char *next, const char *end)
+static void parse_cmd_option(struct ref_transaction *transaction UNUSED,
+                            const char *next, const char *end UNUSED)
 {
        const char *rest;
        if (skip_prefix(next, "no-deref", &rest) && *rest == line_termination)
@@ -321,8 +321,8 @@ static void parse_cmd_option(struct ref_transaction *transaction,
                die("option unknown: %s", next);
 }
 
-static void parse_cmd_start(struct ref_transaction *transaction,
-                           const char *next, const char *end)
+static void parse_cmd_start(struct ref_transaction *transaction UNUSED,
+                           const char *next, const char *end UNUSED)
 {
        if (*next != line_termination)
                die("start: extra input: %s", next);
@@ -330,7 +330,7 @@ static void parse_cmd_start(struct ref_transaction *transaction,
 }
 
 static void parse_cmd_prepare(struct ref_transaction *transaction,
-                             const char *next, const char *end)
+                             const char *next, const char *end UNUSED)
 {
        struct strbuf error = STRBUF_INIT;
        if (*next != line_termination)
@@ -341,7 +341,7 @@ static void parse_cmd_prepare(struct ref_transaction *transaction,
 }
 
 static void parse_cmd_abort(struct ref_transaction *transaction,
-                           const char *next, const char *end)
+                           const char *next, const char *end UNUSED)
 {
        struct strbuf error = STRBUF_INIT;
        if (*next != line_termination)
@@ -352,7 +352,7 @@ static void parse_cmd_abort(struct ref_transaction *transaction,
 }
 
 static void parse_cmd_commit(struct ref_transaction *transaction,
-                            const char *next, const char *end)
+                            const char *next, const char *end UNUSED)
 {
        struct strbuf error = STRBUF_INIT;
        if (*next != line_termination)
index 10db70b7ec910753278a8506c92ae3573ec5c216..62b7e26f4bdb17f524914ab6e60143915d8f2565 100644 (file)
@@ -628,10 +628,10 @@ static void print_preparing_worktree_line(int detach,
  *
  * Returns 0 on failure and non-zero on success.
  */
-static int first_valid_ref(const char *refname,
-                          const struct object_id *oid,
-                          int flags,
-                          void *cb_data)
+static int first_valid_ref(const char *refname UNUSED,
+                          const struct object_id *oid UNUSED,
+                          int flags UNUSED,
+                          void *cb_data UNUSED)
 {
        return 1;
 }
index 73bff3a23d27bb2d9b6825bceccc9912aa2c50ce..6ce62999e58523e20a686801446daaf0d924e9be 100644 (file)
@@ -155,10 +155,10 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
  * status before calling us just in case we ask it to call us again
  * with a new pack.
  */
-static int stream_to_pack(struct bulk_checkin_packfile *state,
-                         git_hash_ctx *ctx, off_t *already_hashed_to,
-                         int fd, size_t size, enum object_type type,
-                         const char *path, unsigned flags)
+static int stream_blob_to_pack(struct bulk_checkin_packfile *state,
+                              git_hash_ctx *ctx, off_t *already_hashed_to,
+                              int fd, size_t size, const char *path,
+                              unsigned flags)
 {
        git_zstream s;
        unsigned char ibuf[16384];
@@ -170,7 +170,7 @@ static int stream_to_pack(struct bulk_checkin_packfile *state,
 
        git_deflate_init(&s, pack_compression_level);
 
-       hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), type, size);
+       hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), OBJ_BLOB, size);
        s.next_out = obuf + hdrlen;
        s.avail_out = sizeof(obuf) - hdrlen;
 
@@ -247,11 +247,10 @@ static void prepare_to_stream(struct bulk_checkin_packfile *state,
                die_errno("unable to write pack header");
 }
 
-static int deflate_to_pack(struct bulk_checkin_packfile *state,
-                          struct object_id *result_oid,
-                          int fd, size_t size,
-                          enum object_type type, const char *path,
-                          unsigned flags)
+static int deflate_blob_to_pack(struct bulk_checkin_packfile *state,
+                               struct object_id *result_oid,
+                               int fd, size_t size,
+                               const char *path, unsigned flags)
 {
        off_t seekback, already_hashed_to;
        git_hash_ctx ctx;
@@ -265,9 +264,10 @@ static int deflate_to_pack(struct bulk_checkin_packfile *state,
                return error("cannot find the current offset");
 
        header_len = format_object_header((char *)obuf, sizeof(obuf),
-                                         type, size);
+                                         OBJ_BLOB, size);
        the_hash_algo->init_fn(&ctx);
        the_hash_algo->update_fn(&ctx, obuf, header_len);
+       the_hash_algo->init_fn(&checkpoint.ctx);
 
        /* Note: idx is non-NULL when we are writing */
        if ((flags & HASH_WRITE_OBJECT) != 0)
@@ -282,8 +282,8 @@ static int deflate_to_pack(struct bulk_checkin_packfile *state,
                        idx->offset = state->offset;
                        crc32_begin(state->f);
                }
-               if (!stream_to_pack(state, &ctx, &already_hashed_to,
-                                   fd, size, type, path, flags))
+               if (!stream_blob_to_pack(state, &ctx, &already_hashed_to,
+                                        fd, size, path, flags))
                        break;
                /*
                 * Writing this object to the current pack will make
@@ -350,12 +350,12 @@ void fsync_loose_object_bulk_checkin(int fd, const char *filename)
        }
 }
 
-int index_bulk_checkin(struct object_id *oid,
-                      int fd, size_t size, enum object_type type,
-                      const char *path, unsigned flags)
+int index_blob_bulk_checkin(struct object_id *oid,
+                           int fd, size_t size,
+                           const char *path, unsigned flags)
 {
-       int status = deflate_to_pack(&bulk_checkin_packfile, oid, fd, size, type,
-                                    path, flags);
+       int status = deflate_blob_to_pack(&bulk_checkin_packfile, oid, fd, size,
+                                         path, flags);
        if (!odb_transaction_nesting)
                flush_bulk_checkin_packfile(&bulk_checkin_packfile);
        return status;
index 48fe9a6e9171e77aba4f2a3c7ab1edd79e9291b8..aa7286a7b3e127bbd4ee14cf99e3fd21f46df445 100644 (file)
@@ -9,9 +9,9 @@
 void prepare_loose_object_bulk_checkin(void);
 void fsync_loose_object_bulk_checkin(int fd, const char *filename);
 
-int index_bulk_checkin(struct object_id *oid,
-                      int fd, size_t size, enum object_type type,
-                      const char *path, unsigned flags);
+int index_blob_bulk_checkin(struct object_id *oid,
+                           int fd, size_t size,
+                           const char *path, unsigned flags);
 
 /*
  * Tell the object database to optimize for adding
index 4b5c49b93d28f080865e23688cc09a0d6dd7d70a..8492fffd2f759f97e750063c4de0eefdc0763d99 100644 (file)
@@ -20,7 +20,7 @@ static struct {
        { BUNDLE_HEURISTIC_CREATIONTOKEN, "creationToken" },
 };
 
-static int compare_bundles(const void *hashmap_cmp_fn_data,
+static int compare_bundles(const void *hashmap_cmp_fn_data UNUSED,
                           const struct hashmap_entry *he1,
                           const struct hashmap_entry *he2,
                           const void *id)
@@ -45,7 +45,7 @@ void init_bundle_list(struct bundle_list *list)
 }
 
 static int clear_remote_bundle_info(struct remote_bundle_info *bundle,
-                                   void *data)
+                                   void *data UNUSED)
 {
        FREE_AND_NULL(bundle->id);
        FREE_AND_NULL(bundle->uri);
@@ -779,7 +779,7 @@ static int unbundle_all_bundles(struct repository *r,
        return 0;
 }
 
-static int unlink_bundle(struct remote_bundle_info *info, void *data)
+static int unlink_bundle(struct remote_bundle_info *info, void *data UNUSED)
 {
        if (info->file)
                unlink_or_warn(info->file);
index 140dfa0dcc4629fec59f723d025ec36019ff29eb..cdc7f39b7039b94a14a42ec74b0e27917c43fe4f 100644 (file)
@@ -102,7 +102,8 @@ int read_table_of_contents(struct chunkfile *cf,
                           const unsigned char *mfile,
                           size_t mfile_size,
                           uint64_t toc_offset,
-                          int toc_length)
+                          int toc_length,
+                          unsigned expected_alignment)
 {
        int i;
        uint32_t chunk_id;
@@ -120,6 +121,11 @@ int read_table_of_contents(struct chunkfile *cf,
                        error(_("terminating chunk id appears earlier than expected"));
                        return 1;
                }
+               if (chunk_offset % expected_alignment != 0) {
+                       error(_("chunk id %"PRIx32" not %d-byte aligned"),
+                             chunk_id, expected_alignment);
+                       return 1;
+               }
 
                table_of_contents += CHUNK_TOC_ENTRY_SIZE;
                next_chunk_offset = get_be64(table_of_contents + 4);
@@ -154,20 +160,28 @@ int read_table_of_contents(struct chunkfile *cf,
        return 0;
 }
 
+struct pair_chunk_data {
+       const unsigned char **p;
+       size_t *size;
+};
+
 static int pair_chunk_fn(const unsigned char *chunk_start,
                         size_t chunk_size,
                         void *data)
 {
-       const unsigned char **p = data;
-       *p = chunk_start;
+       struct pair_chunk_data *pcd = data;
+       *pcd->p = chunk_start;
+       *pcd->size = chunk_size;
        return 0;
 }
 
 int pair_chunk(struct chunkfile *cf,
               uint32_t chunk_id,
-              const unsigned char **p)
+              const unsigned char **p,
+              size_t *size)
 {
-       return read_chunk(cf, chunk_id, pair_chunk_fn, p);
+       struct pair_chunk_data pcd = { .p = p, .size = size };
+       return read_chunk(cf, chunk_id, pair_chunk_fn, &pcd);
 }
 
 int read_chunk(struct chunkfile *cf,
index c7794e84adda364bc0ad14a3d1d61467d73eaadd..14b76180ef768f6b5c38aa1cda128ab87d2327ae 100644 (file)
@@ -36,20 +36,23 @@ int read_table_of_contents(struct chunkfile *cf,
                           const unsigned char *mfile,
                           size_t mfile_size,
                           uint64_t toc_offset,
-                          int toc_length);
+                          int toc_length,
+                          unsigned expected_alignment);
 
 #define CHUNK_NOT_FOUND (-2)
 
 /*
  * Find 'chunk_id' in the given chunkfile and assign the
  * given pointer to the position in the mmap'd file where
- * that chunk begins.
+ * that chunk begins. Likewise the "size" parameter is filled
+ * with the size of the chunk.
  *
  * Returns CHUNK_NOT_FOUND if the chunk does not exist.
  */
 int pair_chunk(struct chunkfile *cf,
               uint32_t chunk_id,
-              const unsigned char **p);
+              const unsigned char **p,
+              size_t *size);
 
 typedef int (*chunk_read_fn)(const unsigned char *chunk_start,
                             size_t chunk_size, void *data);
diff --git a/color.c b/color.c
index b24b19566b99eb498859ed315b74cabcf6df37c1..f663c06ac4eddc7b8085739318ddfc99a3ee7583 100644 (file)
--- a/color.c
+++ b/color.c
@@ -3,7 +3,7 @@
 #include "color.h"
 #include "editor.h"
 #include "gettext.h"
-#include "hex.h"
+#include "hex-ll.h"
 #include "pager.h"
 #include "strbuf.h"
 
index 9e6eaa8a46b3663979acc32c5b5a2d402d8771ee..c2b782af3b649fbf3deea7d90c959e10f951a003 100644 (file)
@@ -277,6 +277,8 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
 
 static int verify_commit_graph_lite(struct commit_graph *g)
 {
+       int i;
+
        /*
         * Basic validation shared between parse_commit_graph()
         * which'll be called every time the graph is used, and the
@@ -302,6 +304,30 @@ static int verify_commit_graph_lite(struct commit_graph *g)
                return 1;
        }
 
+       for (i = 0; i < 255; i++) {
+               uint32_t oid_fanout1 = ntohl(g->chunk_oid_fanout[i]);
+               uint32_t oid_fanout2 = ntohl(g->chunk_oid_fanout[i + 1]);
+
+               if (oid_fanout1 > oid_fanout2) {
+                       error("commit-graph fanout values out of order");
+                       return 1;
+               }
+       }
+       if (ntohl(g->chunk_oid_fanout[255]) != g->num_commits) {
+               error("commit-graph oid table and fanout disagree on size");
+               return 1;
+       }
+
+       return 0;
+}
+
+static int graph_read_oid_fanout(const unsigned char *chunk_start,
+                                size_t chunk_size, void *data)
+{
+       struct commit_graph *g = data;
+       if (chunk_size != 256 * sizeof(uint32_t))
+               return error("commit-graph oid fanout chunk is wrong size");
+       g->chunk_oid_fanout = (const uint32_t *)chunk_start;
        return 0;
 }
 
@@ -314,12 +340,54 @@ static int graph_read_oid_lookup(const unsigned char *chunk_start,
        return 0;
 }
 
+static int graph_read_commit_data(const unsigned char *chunk_start,
+                                 size_t chunk_size, void *data)
+{
+       struct commit_graph *g = data;
+       if (chunk_size != g->num_commits * GRAPH_DATA_WIDTH)
+               return error("commit-graph commit data chunk is wrong size");
+       g->chunk_commit_data = chunk_start;
+       return 0;
+}
+
+static int graph_read_generation_data(const unsigned char *chunk_start,
+                                     size_t chunk_size, void *data)
+{
+       struct commit_graph *g = data;
+       if (chunk_size != g->num_commits * sizeof(uint32_t))
+               return error("commit-graph generations chunk is wrong size");
+       g->chunk_generation_data = chunk_start;
+       return 0;
+}
+
+static int graph_read_bloom_index(const unsigned char *chunk_start,
+                                 size_t chunk_size, void *data)
+{
+       struct commit_graph *g = data;
+       if (chunk_size != g->num_commits * 4) {
+               warning("commit-graph changed-path index chunk is too small");
+               return -1;
+       }
+       g->chunk_bloom_indexes = chunk_start;
+       return 0;
+}
+
 static int graph_read_bloom_data(const unsigned char *chunk_start,
                                  size_t chunk_size, void *data)
 {
        struct commit_graph *g = data;
        uint32_t hash_version;
+
+       if (chunk_size < BLOOMDATA_CHUNK_HEADER_SIZE) {
+               warning("ignoring too-small changed-path chunk"
+                       " (%"PRIuMAX" < %"PRIuMAX") in commit-graph file",
+                       (uintmax_t)chunk_size,
+                       (uintmax_t)BLOOMDATA_CHUNK_HEADER_SIZE);
+               return -1;
+       }
+
        g->chunk_bloom_data = chunk_start;
+       g->chunk_bloom_data_size = chunk_size;
        hash_version = get_be32(chunk_start);
 
        if (hash_version != 1)
@@ -391,29 +459,31 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,
        cf = init_chunkfile(NULL);
 
        if (read_table_of_contents(cf, graph->data, graph_size,
-                                  GRAPH_HEADER_SIZE, graph->num_chunks))
+                                  GRAPH_HEADER_SIZE, graph->num_chunks, 1))
                goto free_and_return;
 
-       pair_chunk(cf, GRAPH_CHUNKID_OIDFANOUT,
-                  (const unsigned char **)&graph->chunk_oid_fanout);
+       read_chunk(cf, GRAPH_CHUNKID_OIDFANOUT, graph_read_oid_fanout, graph);
        read_chunk(cf, GRAPH_CHUNKID_OIDLOOKUP, graph_read_oid_lookup, graph);
-       pair_chunk(cf, GRAPH_CHUNKID_DATA, &graph->chunk_commit_data);
-       pair_chunk(cf, GRAPH_CHUNKID_EXTRAEDGES, &graph->chunk_extra_edges);
-       pair_chunk(cf, GRAPH_CHUNKID_BASE, &graph->chunk_base_graphs);
+       read_chunk(cf, GRAPH_CHUNKID_DATA, graph_read_commit_data, graph);
+       pair_chunk(cf, GRAPH_CHUNKID_EXTRAEDGES, &graph->chunk_extra_edges,
+                  &graph->chunk_extra_edges_size);
+       pair_chunk(cf, GRAPH_CHUNKID_BASE, &graph->chunk_base_graphs,
+                  &graph->chunk_base_graphs_size);
 
        if (s->commit_graph_generation_version >= 2) {
-               pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA,
-                       &graph->chunk_generation_data);
+               read_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA,
+                          graph_read_generation_data, graph);
                pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA_OVERFLOW,
-                       &graph->chunk_generation_data_overflow);
+                          &graph->chunk_generation_data_overflow,
+                          &graph->chunk_generation_data_overflow_size);
 
                if (graph->chunk_generation_data)
                        graph->read_generation_data = 1;
        }
 
        if (s->commit_graph_read_changed_paths) {
-               pair_chunk(cf, GRAPH_CHUNKID_BLOOMINDEXES,
-                          &graph->chunk_bloom_indexes);
+               read_chunk(cf, GRAPH_CHUNKID_BLOOMINDEXES,
+                          graph_read_bloom_index, graph);
                read_chunk(cf, GRAPH_CHUNKID_BLOOMDATA,
                           graph_read_bloom_data, graph);
        }
@@ -473,6 +543,31 @@ static struct commit_graph *load_commit_graph_v1(struct repository *r,
        return g;
 }
 
+/*
+ * returns 1 if and only if all graphs in the chain have
+ * corrected commit dates stored in the generation_data chunk.
+ */
+static int validate_mixed_generation_chain(struct commit_graph *g)
+{
+       int read_generation_data = 1;
+       struct commit_graph *p = g;
+
+       while (read_generation_data && p) {
+               read_generation_data = p->read_generation_data;
+               p = p->base_graph;
+       }
+
+       if (read_generation_data)
+               return 1;
+
+       while (g) {
+               g->read_generation_data = 0;
+               g = g->base_graph;
+       }
+
+       return 0;
+}
+
 static int add_graph_to_chain(struct commit_graph *g,
                              struct commit_graph *chain,
                              struct object_id *oids,
@@ -485,6 +580,11 @@ static int add_graph_to_chain(struct commit_graph *g,
                return 0;
        }
 
+       if (g->chunk_base_graphs_size / g->hash_len < n) {
+               warning(_("commit-graph base graphs chunk is too small"));
+               return 0;
+       }
+
        while (n) {
                n--;
 
@@ -498,8 +598,6 @@ static int add_graph_to_chain(struct commit_graph *g,
                cur_g = cur_g->base_graph;
        }
 
-       g->base_graph = chain;
-
        if (chain) {
                if (unsigned_add_overflows(chain->num_commits,
                                           chain->num_commits_in_base)) {
@@ -510,34 +608,46 @@ static int add_graph_to_chain(struct commit_graph *g,
                g->num_commits_in_base = chain->num_commits + chain->num_commits_in_base;
        }
 
+       g->base_graph = chain;
+
        return 1;
 }
 
-static struct commit_graph *load_commit_graph_chain(struct repository *r,
-                                                   struct object_directory *odb)
+int open_commit_graph_chain(const char *chain_file,
+                           int *fd, struct stat *st)
+{
+       *fd = git_open(chain_file);
+       if (*fd < 0)
+               return 0;
+       if (fstat(*fd, st)) {
+               close(*fd);
+               return 0;
+       }
+       if (st->st_size < the_hash_algo->hexsz) {
+               close(*fd);
+               if (!st->st_size) {
+                       /* treat empty files the same as missing */
+                       errno = ENOENT;
+               } else {
+                       warning("commit-graph chain file too small");
+                       errno = EINVAL;
+               }
+               return 0;
+       }
+       return 1;
+}
+
+struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
+                                                  int fd, struct stat *st,
+                                                  int *incomplete_chain)
 {
        struct commit_graph *graph_chain = NULL;
        struct strbuf line = STRBUF_INIT;
-       struct stat st;
        struct object_id *oids;
        int i = 0, valid = 1, count;
-       char *chain_name = get_commit_graph_chain_filename(odb);
-       FILE *fp;
-       int stat_res;
-
-       fp = fopen(chain_name, "r");
-       stat_res = stat(chain_name, &st);
-       free(chain_name);
+       FILE *fp = xfdopen(fd, "r");
 
-       if (!fp)
-               return NULL;
-       if (stat_res ||
-           st.st_size <= the_hash_algo->hexsz) {
-               fclose(fp);
-               return NULL;
-       }
-
-       count = st.st_size / (the_hash_algo->hexsz + 1);
+       count = st->st_size / (the_hash_algo->hexsz + 1);
        CALLOC_ARRAY(oids, count);
 
        prepare_alt_odb(r);
@@ -566,6 +676,8 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
                                if (add_graph_to_chain(g, graph_chain, oids, i)) {
                                        graph_chain = g;
                                        valid = 1;
+                               } else {
+                                       free_commit_graph(g);
                                }
 
                                break;
@@ -578,36 +690,32 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
                }
        }
 
+       validate_mixed_generation_chain(graph_chain);
+
        free(oids);
        fclose(fp);
        strbuf_release(&line);
 
+       *incomplete_chain = !valid;
        return graph_chain;
 }
 
-/*
- * returns 1 if and only if all graphs in the chain have
- * corrected commit dates stored in the generation_data chunk.
- */
-static int validate_mixed_generation_chain(struct commit_graph *g)
+static struct commit_graph *load_commit_graph_chain(struct repository *r,
+                                                   struct object_directory *odb)
 {
-       int read_generation_data = 1;
-       struct commit_graph *p = g;
-
-       while (read_generation_data && p) {
-               read_generation_data = p->read_generation_data;
-               p = p->base_graph;
-       }
-
-       if (read_generation_data)
-               return 1;
+       char *chain_file = get_commit_graph_chain_filename(odb);
+       struct stat st;
+       int fd;
+       struct commit_graph *g = NULL;
 
-       while (g) {
-               g->read_generation_data = 0;
-               g = g->base_graph;
+       if (open_commit_graph_chain(chain_file, &fd, &st)) {
+               int incomplete;
+               /* ownership of fd is taken over by load function */
+               g = load_commit_graph_chain_fd_st(r, fd, &st, &incomplete);
        }
 
-       return 0;
+       free(chain_file);
+       return g;
 }
 
 struct commit_graph *read_commit_graph_one(struct repository *r,
@@ -618,8 +726,6 @@ struct commit_graph *read_commit_graph_one(struct repository *r,
        if (!g)
                g = load_commit_graph_chain(r, odb);
 
-       validate_mixed_generation_chain(g);
-
        return g;
 }
 
@@ -723,19 +829,10 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)
        return NULL;
 }
 
-static void close_commit_graph_one(struct commit_graph *g)
-{
-       if (!g)
-               return;
-
-       clear_commit_graph_data_slab(&commit_graph_data_slab);
-       close_commit_graph_one(g->base_graph);
-       free_commit_graph(g);
-}
-
 void close_commit_graph(struct raw_object_store *o)
 {
-       close_commit_graph_one(o->commit_graph);
+       clear_commit_graph_data_slab(&commit_graph_data_slab);
+       free_commit_graph(o->commit_graph);
        o->commit_graph = NULL;
 }
 
@@ -815,7 +912,10 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g,
                                die(_("commit-graph requires overflow generation data but has none"));
 
                        offset_pos = offset ^ CORRECTED_COMMIT_DATE_OFFSET_OVERFLOW;
-                       graph_data->generation = item->date + get_be64(g->chunk_generation_data_overflow + st_mult(8, offset_pos));
+                       if (g->chunk_generation_data_overflow_size / sizeof(uint64_t) <= offset_pos)
+                               die(_("commit-graph overflow generation data is too small"));
+                       graph_data->generation = item->date +
+                               get_be64(g->chunk_generation_data_overflow + sizeof(uint64_t) * offset_pos);
                } else
                        graph_data->generation = item->date + offset;
        } else
@@ -835,7 +935,7 @@ static int fill_commit_in_graph(struct repository *r,
                                struct commit_graph *g, uint32_t pos)
 {
        uint32_t edge_value;
-       uint32_t *parent_data_ptr;
+       uint32_t parent_data_pos;
        struct commit_list **pptr;
        const unsigned char *commit_data;
        uint32_t lex_index;
@@ -867,14 +967,21 @@ static int fill_commit_in_graph(struct repository *r,
                return 1;
        }
 
-       parent_data_ptr = (uint32_t*)(g->chunk_extra_edges +
-                         st_mult(4, edge_value & GRAPH_EDGE_LAST_MASK));
+       parent_data_pos = edge_value & GRAPH_EDGE_LAST_MASK;
        do {
-               edge_value = get_be32(parent_data_ptr);
+               if (g->chunk_extra_edges_size / sizeof(uint32_t) <= parent_data_pos) {
+                       error("commit-graph extra-edges pointer out of bounds");
+                       free_commit_list(item->parents);
+                       item->parents = NULL;
+                       item->object.parsed = 0;
+                       return 0;
+               }
+               edge_value = get_be32(g->chunk_extra_edges +
+                                     sizeof(uint32_t) * parent_data_pos);
                pptr = insert_parent_or_die(r, g,
                                            edge_value & GRAPH_EDGE_LAST_MASK,
                                            pptr);
-               parent_data_ptr++;
+               parent_data_pos++;
        } while (!(edge_value & GRAPH_LAST_EDGE));
 
        return 1;
@@ -1578,12 +1685,14 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)
        stop_progress(&ctx->progress);
 }
 
-static timestamp_t get_generation_from_graph_data(struct commit *c, void *data)
+static timestamp_t get_generation_from_graph_data(struct commit *c,
+                                                 void *data UNUSED)
 {
        return commit_graph_data_at(c)->generation;
 }
 
-static void set_generation_v2(struct commit *c, timestamp_t t, void *data)
+static void set_generation_v2(struct commit *c, timestamp_t t,
+                             void *data UNUSED)
 {
        struct commit_graph_data *g = commit_graph_data_at(c);
        g->generation = t;
@@ -1597,7 +1706,6 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
                .commits = &ctx->commits,
                .get_generation = get_generation_from_graph_data,
                .set_generation = set_generation_v2,
-               .data = ctx,
        };
 
        if (ctx->report_progress)
@@ -1626,7 +1734,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
 }
 
 static void set_generation_in_graph_data(struct commit *c, timestamp_t t,
-                                        void *data)
+                                        void *data UNUSED)
 {
        commit_graph_data_at(c)->generation = t;
 }
@@ -2071,9 +2179,11 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
                        free(graph_name);
                }
 
+               free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
                ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));
                final_graph_name = get_split_graph_filename(ctx->odb,
                                        ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
+               free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);
                ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;
 
                result = rename(ctx->graph_name, final_graph_name);
@@ -2522,6 +2632,7 @@ int write_commit_graph(struct object_directory *odb,
 
 cleanup:
        free(ctx->graph_name);
+       free(ctx->base_graph_name);
        free(ctx->commits.list);
        oid_array_clear(&ctx->oids);
        clear_topo_level_slab(&topo_levels);
@@ -2752,15 +2863,17 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 
 void free_commit_graph(struct commit_graph *g)
 {
-       if (!g)
-               return;
-       if (g->data) {
-               munmap((void *)g->data, g->data_len);
-               g->data = NULL;
+       while (g) {
+               struct commit_graph *next = g->base_graph;
+
+               if (g->data)
+                       munmap((void *)g->data, g->data_len);
+               free(g->filename);
+               free(g->bloom_filter_settings);
+               free(g);
+
+               g = next;
        }
-       free(g->filename);
-       free(g->bloom_filter_settings);
-       free(g);
 }
 
 void disable_commit_graph(struct repository *r)
index 5e534f0fcc8d131a6e759ed1658b0e0984123a6e..c6870274c5ab7e8821e65a1eb35b514c889ffa95 100644 (file)
@@ -26,6 +26,7 @@ struct string_list;
 char *get_commit_graph_filename(struct object_directory *odb);
 char *get_commit_graph_chain_filename(struct object_directory *odb);
 int open_commit_graph(const char *graph_file, int *fd, struct stat *st);
+int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st);
 
 /*
  * Given a commit struct, try to fill the commit struct info, including:
@@ -93,10 +94,14 @@ struct commit_graph {
        const unsigned char *chunk_commit_data;
        const unsigned char *chunk_generation_data;
        const unsigned char *chunk_generation_data_overflow;
+       size_t chunk_generation_data_overflow_size;
        const unsigned char *chunk_extra_edges;
+       size_t chunk_extra_edges_size;
        const unsigned char *chunk_base_graphs;
+       size_t chunk_base_graphs_size;
        const unsigned char *chunk_bloom_indexes;
        const unsigned char *chunk_bloom_data;
+       size_t chunk_bloom_data_size;
 
        struct topo_level_slab *topo_levels;
        struct bloom_filter_settings *bloom_filter_settings;
@@ -105,6 +110,9 @@ struct commit_graph {
 struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
                                                 int fd, struct stat *st,
                                                 struct object_directory *odb);
+struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
+                                                  int fd, struct stat *st,
+                                                  int *incomplete_chain);
 struct commit_graph *read_commit_graph_one(struct repository *r,
                                           struct object_directory *odb);
 
index 4b7c233fd468f9ad2a60abf5b9202f5c4fbad3c4..a868a575ea1cf8e7ccd331610b9d309a065ad135 100644 (file)
@@ -173,6 +173,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
                        for (k = bases; k; k = k->next)
                                end = k;
                }
+               free_commit_list(ret);
                ret = new_commits;
        }
        return ret;
index 5b1709d63f729b173d89152e37567dcb3459117a..c2afcbe6c89d9ab2f279b5ac7cb4c9a3e6ae01ea 100644 (file)
@@ -4,21 +4,21 @@
 #include "fsm-health.h"
 #include "fsmonitor--daemon.h"
 
-int fsm_health__ctor(struct fsmonitor_daemon_state *state)
+int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED)
 {
        return 0;
 }
 
-void fsm_health__dtor(struct fsmonitor_daemon_state *state)
+void fsm_health__dtor(struct fsmonitor_daemon_state *state UNUSED)
 {
        return;
 }
 
-void fsm_health__loop(struct fsmonitor_daemon_state *state)
+void fsm_health__loop(struct fsmonitor_daemon_state *state UNUSED)
 {
        return;
 }
 
-void fsm_health__stop_async(struct fsmonitor_daemon_state *state)
+void fsm_health__stop_async(struct fsmonitor_daemon_state *state UNUSED)
 {
 }
index 8928fa93ce223968ab59279ddac50a3dd2b15239..41984ea48e26b8c5fc9cf8ed9bc6851957a230d9 100644 (file)
@@ -6,6 +6,6 @@
 const char *fsmonitor_ipc__get_path(struct repository *r) {
        static char *ret;
        if (!ret)
-               ret = git_pathdup("fsmonitor--daemon.ipc");
+               ret = repo_git_path(r, "fsmonitor--daemon.ipc");
        return ret;
 }
index 36c7e13281c675cba46d7a219f31f238f361c17c..11b56d3ef12ffb52ef291e95e2b8e39823e77f0f 100644 (file)
@@ -191,12 +191,12 @@ static void my_add_path(struct fsmonitor_batch *batch, const char *path)
 }
 
 
-static void fsevent_callback(ConstFSEventStreamRef streamRef,
+static void fsevent_callback(ConstFSEventStreamRef streamRef UNUSED,
                             void *ctx,
                             size_t num_of_events,
                             void *event_paths,
                             const FSEventStreamEventFlags event_flags[],
-                            const FSEventStreamEventId event_ids[])
+                            const FSEventStreamEventId event_ids[] UNUSED)
 {
        struct fsmonitor_daemon_state *state = ctx;
        struct fsm_listen_data *data = state->listen_data;
index a361a7db20edbf406219922acebf2291f315b22c..90a2412284414e0675bc7603e4d13850d640a695 100644 (file)
@@ -289,8 +289,7 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
        SetEvent(state->listen_data->hListener[LISTENER_SHUTDOWN]);
 }
 
-static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
-                                     const char *path)
+static struct one_watch *create_watch(const char *path)
 {
        struct one_watch *watch = NULL;
        DWORD desired_access = FILE_LIST_DIRECTORY;
@@ -361,8 +360,7 @@ static void destroy_watch(struct one_watch *watch)
        free(watch);
 }
 
-static int start_rdcw_watch(struct fsm_listen_data *data,
-                           struct one_watch *watch)
+static int start_rdcw_watch(struct one_watch *watch)
 {
        DWORD dwNotifyFilter =
                FILE_NOTIFY_CHANGE_FILE_NAME |
@@ -735,11 +733,11 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
 
        state->listen_error_code = 0;
 
-       if (start_rdcw_watch(data, data->watch_worktree) == -1)
+       if (start_rdcw_watch(data->watch_worktree) == -1)
                goto force_error_stop;
 
        if (data->watch_gitdir &&
-           start_rdcw_watch(data, data->watch_gitdir) == -1)
+           start_rdcw_watch(data->watch_gitdir) == -1)
                goto force_error_stop;
 
        for (;;) {
@@ -755,7 +753,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
                        }
                        if (result == -2) {
                                /* retryable error */
-                               if (start_rdcw_watch(data, data->watch_worktree) == -1)
+                               if (start_rdcw_watch(data->watch_worktree) == -1)
                                        goto force_error_stop;
                                continue;
                        }
@@ -763,7 +761,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
                        /* have data */
                        if (process_worktree_events(state) == LISTENER_SHUTDOWN)
                                goto force_shutdown;
-                       if (start_rdcw_watch(data, data->watch_worktree) == -1)
+                       if (start_rdcw_watch(data->watch_worktree) == -1)
                                goto force_error_stop;
                        continue;
                }
@@ -776,7 +774,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
                        }
                        if (result == -2) {
                                /* retryable error */
-                               if (start_rdcw_watch(data, data->watch_gitdir) == -1)
+                               if (start_rdcw_watch(data->watch_gitdir) == -1)
                                        goto force_error_stop;
                                continue;
                        }
@@ -784,7 +782,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
                        /* have data */
                        if (process_gitdir_events(state) == LISTENER_SHUTDOWN)
                                goto force_shutdown;
-                       if (start_rdcw_watch(data, data->watch_gitdir) == -1)
+                       if (start_rdcw_watch(data->watch_gitdir) == -1)
                                goto force_error_stop;
                        continue;
                }
@@ -821,16 +819,14 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
 
        data->hEventShutdown = CreateEvent(NULL, TRUE, FALSE, NULL);
 
-       data->watch_worktree = create_watch(state,
-                                           state->path_worktree_watch.buf);
+       data->watch_worktree = create_watch(state->path_worktree_watch.buf);
        if (!data->watch_worktree)
                goto failed;
 
        check_for_shortnames(data->watch_worktree);
 
        if (state->nr_paths_watching > 1) {
-               data->watch_gitdir = create_watch(state,
-                                                 state->path_gitdir_watch.buf);
+               data->watch_gitdir = create_watch(state->path_gitdir_watch.buf);
                if (!data->watch_gitdir)
                        goto failed;
        }
index c8a3e9dcdbb655eab0fbea2d42c1973ee67e16f7..f4f9cc1f336720614bcbb77d1ea908419801f9ab 100644 (file)
@@ -132,7 +132,8 @@ int fsmonitor__is_fs_remote(const char *path)
 /*
  * No-op for now.
  */
-int fsmonitor__get_alias(const char *path, struct alias_info *info)
+int fsmonitor__get_alias(const char *path UNUSED,
+                        struct alias_info *info UNUSED)
 {
        return 0;
 }
@@ -140,8 +141,8 @@ int fsmonitor__get_alias(const char *path, struct alias_info *info)
 /*
  * No-op for now.
  */
-char *fsmonitor__resolve_alias(const char *path,
-       const struct alias_info *info)
+char *fsmonitor__resolve_alias(const char *path UNUSED,
+                              const struct alias_info *info UNUSED)
 {
        return NULL;
 }
index b6f67444944b5ff60ed3823dc64fc10d36f2a778..0f2aa321f6e15f729aef67d4012fea6513cacfa4 100644 (file)
@@ -25,7 +25,7 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r)
        return FSMONITOR_REASON_OK;
 }
 
-enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)
+enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc UNUSED)
 {
        enum fsmonitor_reason reason;
 
index 3846a37be971c92153eb1ceeb65c6e612c8e173c..b330c7adb4a5efc3cac898391d4c722b019d95a1 100644 (file)
--- a/config.c
+++ b/config.c
@@ -11,6 +11,7 @@
 #include "date.h"
 #include "branch.h"
 #include "config.h"
+#include "parse.h"
 #include "convert.h"
 #include "environment.h"
 #include "gettext.h"
@@ -18,6 +19,7 @@
 #include "repository.h"
 #include "lockfile.h"
 #include "mailmap.h"
+#include "attr.h"
 #include "exec-cmd.h"
 #include "strbuf.h"
 #include "quote.h"
@@ -1165,129 +1167,6 @@ static int git_parse_source(struct config_source *cs, config_fn_t fn,
        return error_return;
 }
 
-static uintmax_t get_unit_factor(const char *end)
-{
-       if (!*end)
-               return 1;
-       else if (!strcasecmp(end, "k"))
-               return 1024;
-       else if (!strcasecmp(end, "m"))
-               return 1024 * 1024;
-       else if (!strcasecmp(end, "g"))
-               return 1024 * 1024 * 1024;
-       return 0;
-}
-
-static int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)
-{
-       if (value && *value) {
-               char *end;
-               intmax_t val;
-               intmax_t factor;
-
-               if (max < 0)
-                       BUG("max must be a positive integer");
-
-               errno = 0;
-               val = strtoimax(value, &end, 0);
-               if (errno == ERANGE)
-                       return 0;
-               if (end == value) {
-                       errno = EINVAL;
-                       return 0;
-               }
-               factor = get_unit_factor(end);
-               if (!factor) {
-                       errno = EINVAL;
-                       return 0;
-               }
-               if ((val < 0 && -max / factor > val) ||
-                   (val > 0 && max / factor < val)) {
-                       errno = ERANGE;
-                       return 0;
-               }
-               val *= factor;
-               *ret = val;
-               return 1;
-       }
-       errno = EINVAL;
-       return 0;
-}
-
-static int git_parse_unsigned(const char *value, uintmax_t *ret, uintmax_t max)
-{
-       if (value && *value) {
-               char *end;
-               uintmax_t val;
-               uintmax_t factor;
-
-               /* negative values would be accepted by strtoumax */
-               if (strchr(value, '-')) {
-                       errno = EINVAL;
-                       return 0;
-               }
-               errno = 0;
-               val = strtoumax(value, &end, 0);
-               if (errno == ERANGE)
-                       return 0;
-               if (end == value) {
-                       errno = EINVAL;
-                       return 0;
-               }
-               factor = get_unit_factor(end);
-               if (!factor) {
-                       errno = EINVAL;
-                       return 0;
-               }
-               if (unsigned_mult_overflows(factor, val) ||
-                   factor * val > max) {
-                       errno = ERANGE;
-                       return 0;
-               }
-               val *= factor;
-               *ret = val;
-               return 1;
-       }
-       errno = EINVAL;
-       return 0;
-}
-
-int git_parse_int(const char *value, int *ret)
-{
-       intmax_t tmp;
-       if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(int)))
-               return 0;
-       *ret = tmp;
-       return 1;
-}
-
-static int git_parse_int64(const char *value, int64_t *ret)
-{
-       intmax_t tmp;
-       if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(int64_t)))
-               return 0;
-       *ret = tmp;
-       return 1;
-}
-
-int git_parse_ulong(const char *value, unsigned long *ret)
-{
-       uintmax_t tmp;
-       if (!git_parse_unsigned(value, &tmp, maximum_unsigned_value_of_type(long)))
-               return 0;
-       *ret = tmp;
-       return 1;
-}
-
-int git_parse_ssize_t(const char *value, ssize_t *ret)
-{
-       intmax_t tmp;
-       if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(ssize_t)))
-               return 0;
-       *ret = tmp;
-       return 1;
-}
-
 NORETURN
 static void die_bad_number(const char *name, const char *value,
                           const struct key_value_info *kvi)
@@ -1363,23 +1242,6 @@ ssize_t git_config_ssize_t(const char *name, const char *value,
        return ret;
 }
 
-static int git_parse_maybe_bool_text(const char *value)
-{
-       if (!value)
-               return 1;
-       if (!*value)
-               return 0;
-       if (!strcasecmp(value, "true")
-           || !strcasecmp(value, "yes")
-           || !strcasecmp(value, "on"))
-               return 1;
-       if (!strcasecmp(value, "false")
-           || !strcasecmp(value, "no")
-           || !strcasecmp(value, "off"))
-               return 0;
-       return -1;
-}
-
 static const struct fsync_component_name {
        const char *name;
        enum fsync_component component_bits;
@@ -1454,16 +1316,6 @@ next_name:
        return (current & ~negative) | positive;
 }
 
-int git_parse_maybe_bool(const char *value)
-{
-       int v = git_parse_maybe_bool_text(value);
-       if (0 <= v)
-               return v;
-       if (git_parse_int(value, &v))
-               return !!v;
-       return -1;
-}
-
 int git_config_bool_or_int(const char *name, const char *value,
                           const struct key_value_info *kvi, int *is_bool)
 {
@@ -1801,6 +1653,11 @@ static int git_default_core_config(const char *var, const char *value,
                return 0;
        }
 
+       if (!strcmp(var, "core.maxtreedepth")) {
+               max_allowed_tree_depth = git_config_int(var, value, ctx->kvi);
+               return 0;
+       }
+
        /* Add other config variables here and to Documentation/config.txt. */
        return platform_core_config(var, value, ctx, cb);
 }
@@ -1904,6 +1761,18 @@ static int git_default_mailmap_config(const char *var, const char *value)
        return 0;
 }
 
+static int git_default_attr_config(const char *var, const char *value)
+{
+       if (!strcmp(var, "attr.tree"))
+               return git_config_string(&git_attr_tree, var, value);
+
+       /*
+        * Add other attribute related config variables here and to
+        * Documentation/config/attr.txt.
+        */
+       return 0;
+}
+
 int git_default_config(const char *var, const char *value,
                       const struct config_context *ctx, void *cb)
 {
@@ -1927,6 +1796,9 @@ int git_default_config(const char *var, const char *value,
        if (starts_with(var, "mailmap."))
                return git_default_mailmap_config(var, value);
 
+       if (starts_with(var, "attr."))
+               return git_default_attr_config(var, value);
+
        if (starts_with(var, "advice.") || starts_with(var, "color.advice"))
                return git_default_advice_config(var, value);
 
@@ -2126,28 +1998,6 @@ void git_global_config(char **user_out, char **xdg_out)
        *xdg_out = xdg_config;
 }
 
-/*
- * Parse environment variable 'k' as a boolean (in various
- * possible spellings); if missing, use the default value 'def'.
- */
-int git_env_bool(const char *k, int def)
-{
-       const char *v = getenv(k);
-       return v ? git_config_bool(k, v) : def;
-}
-
-/*
- * Parse environment variable 'k' as ulong with possibly a unit
- * suffix; if missing, use the default value 'val'.
- */
-unsigned long git_env_ulong(const char *k, unsigned long val)
-{
-       const char *v = getenv(k);
-       if (v && !git_parse_ulong(v, &val))
-               die(_("failed to parse %s"), k);
-       return val;
-}
-
 int git_config_system(void)
 {
        return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
index 6332d749047764aff33000d01fc78f75ddfe03b1..14f881ecfaf6b264b6d120205ab509f2ee5930f2 100644 (file)
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
 #include "hashmap.h"
 #include "string-list.h"
 #include "repository.h"
-
+#include "parse.h"
 
 /**
  * The config API gives callers a way to access Git configuration files
@@ -243,16 +243,6 @@ int config_with_options(config_fn_t fn, void *,
  * The following helper functions aid in parsing string values
  */
 
-int git_parse_ssize_t(const char *, ssize_t *);
-int git_parse_ulong(const char *, unsigned long *);
-int git_parse_int(const char *value, int *ret);
-
-/**
- * Same as `git_config_bool`, except that it returns -1 on error rather
- * than dying.
- */
-int git_parse_maybe_bool(const char *);
-
 /**
  * Parse the string to an integer, including unit factors. Dies on error;
  * otherwise, returns the parsed result.
@@ -385,8 +375,6 @@ int git_config_rename_section(const char *, const char *);
 int git_config_rename_section_in_file(const char *, const char *, const char *);
 int git_config_copy_section(const char *, const char *);
 int git_config_copy_section_in_file(const char *, const char *, const char *);
-int git_env_bool(const char *, int);
-unsigned long git_env_ulong(const char *, unsigned long);
 int git_config_system(void);
 int config_error_nonbool(const char *);
 #if defined(__GNUC__)
index 05f291c1f1d3d1018f390618816f94d0cd58951b..21d3d0e7dee46de8ee07ae69d9735b76643693db 100644 (file)
@@ -23,7 +23,7 @@ This is the same way as how I have been treating gitk, and to a
 lesser degree various foreign SCM interfaces, so you know the
 drill.
 
-I expect that things that start their life in the contrib/ area
+I expect things that start their life in the contrib/ area
 to graduate out of contrib/ once they mature, either by becoming
 projects on their own, or moving to the toplevel directory.  On
 the other hand, I expect I'll be proposing removal of disused
@@ -31,7 +31,7 @@ and inactive ones from time to time.
 
 If you have new things to add to this area, please first propose
 it on the git mailing list, and after a list discussion proves
-there are some general interests (it does not have to be a
+there is general interest (it does not have to be a
 list-wide consensus for a tool targeted to a relatively narrow
 audience -- for example I do not work with projects whose
 upstream is svn, so I have no use for git-svn myself, but it is
index 55950057c8debd6519282ba98db1c8fa678dc4a3..13a39ebd2e73f9b34de743b797577a5e8e98cbae 100644 (file)
@@ -28,7 +28,8 @@
 # completion style.  For example '!f() { : git commit ; ... }; f' will
 # tell the completion to use commit completion.  This also works with aliases
 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
-# Be sure to add a space between the command name and the ';'.
+# Note that "git" is optional --- '!f() { : commit; ...}; f' would complete
+# just like the 'git commit' command.
 #
 # If you have a command that is not part of git, but you would still
 # like completion, you can use __git_complete:
@@ -1183,7 +1184,7 @@ __git_aliased_command ()
                        :)      : skip null command ;;
                        \'*)    : skip opening quote after sh -c ;;
                        *)
-                               cur="$word"
+                               cur="${word%;}"
                                break
                        esac
                done
@@ -1678,6 +1679,11 @@ _git_clone ()
 
 __git_untracked_file_modes="all no normal"
 
+__git_trailer_tokens ()
+{
+       __git config --name-only --get-regexp '^trailer\..*\.key$' | cut -d. -f 2- | rev | cut -d. -f2- | rev
+}
+
 _git_commit ()
 {
        case "$prev" in
@@ -1702,6 +1708,10 @@ _git_commit ()
                __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
                return
                ;;
+       --trailer=*)
+               __gitcomp_nl "$(__git_trailer_tokens)" "" "${cur##--trailer=}" ":"
+               return
+               ;;
        --*)
                __gitcomp_builtin commit
                return
@@ -2043,7 +2053,7 @@ __git_log_shortlog_options="
 "
 # Options accepted by log and show
 __git_log_show_options="
-       --diff-merges --diff-merges= --no-diff-merges --remerge-diff
+       --diff-merges --diff-merges= --no-diff-merges --dd --remerge-diff
 "
 
 __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-combined cc remerge r"
index ef681f29d5ba12dd5c6f7f11baa42cb1e6aab7d5..215a81d8bae59ca2364eb762c72089ff8b6b51d7 100644 (file)
@@ -39,6 +39,8 @@ struct credential {
        char *path;
        char *username;
        char *password;
+       char *password_expiry_utc;
+       char *oauth_refresh_token;
 };
 
 #define CREDENTIAL_INIT { 0 }
@@ -52,8 +54,29 @@ struct credential_operation {
 
 #define CREDENTIAL_OP_END { NULL, NULL }
 
+static void credential_clear(struct credential *c);
+
 /* ----------------- Secret Service functions ----------------- */
 
+static const SecretSchema schema = {
+       "org.git.Password",
+       /* Ignore schema name during search for backwards compatibility */
+       SECRET_SCHEMA_DONT_MATCH_NAME,
+       {
+               /*
+                * libsecret assumes attribute values are non-confidential and
+                * unchanging, so we can't include oauth_refresh_token or
+                * password_expiry_utc.
+                */
+               {  "user", SECRET_SCHEMA_ATTRIBUTE_STRING },
+               {  "object", SECRET_SCHEMA_ATTRIBUTE_STRING },
+               {  "protocol", SECRET_SCHEMA_ATTRIBUTE_STRING },
+               {  "port", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
+               {  "server", SECRET_SCHEMA_ATTRIBUTE_STRING },
+               {  NULL, 0 },
+       }
+};
+
 static char *make_label(struct credential *c)
 {
        if (c->port)
@@ -101,7 +124,7 @@ static int keyring_get(struct credential *c)
 
        attributes = make_attr_list(c);
        items = secret_service_search_sync(service,
-                                          SECRET_SCHEMA_COMPAT_NETWORK,
+                                          &schema,
                                           attributes,
                                           SECRET_SEARCH_LOAD_SECRETS | SECRET_SEARCH_UNLOCK,
                                           NULL,
@@ -117,6 +140,7 @@ static int keyring_get(struct credential *c)
                SecretItem *item;
                SecretValue *secret;
                const char *s;
+               gchar **parts;
 
                item = items->data;
                secret = secret_item_get_secret(item);
@@ -130,8 +154,27 @@ static int keyring_get(struct credential *c)
 
                s = secret_value_get_text(secret);
                if (s) {
-                       g_free(c->password);
-                       c->password = g_strdup(s);
+                       /*
+                        * Passwords and other attributes encoded in following format:
+                        *   hunter2
+                        *   password_expiry_utc=1684189401
+                        *   oauth_refresh_token=xyzzy
+                        */
+                       parts = g_strsplit(s, "\n", 0);
+                       if (g_strv_length(parts) >= 1) {
+                               g_free(c->password);
+                               c->password = g_strdup(parts[0]);
+                       }
+                       for (int i = 1; i < g_strv_length(parts); i++) {
+                               if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {
+                                       g_free(c->password_expiry_utc);
+                                       c->password_expiry_utc = g_strdup(&parts[i][20]);
+                               } else if (g_str_has_prefix(parts[i], "oauth_refresh_token=")) {
+                                       g_free(c->oauth_refresh_token);
+                                       c->oauth_refresh_token = g_strdup(&parts[i][20]);
+                               }
+                       }
+                       g_strfreev(parts);
                }
 
                g_hash_table_unref(attributes);
@@ -148,6 +191,7 @@ static int keyring_store(struct credential *c)
        char *label = NULL;
        GHashTable *attributes = NULL;
        GError *error = NULL;
+       GString *secret = NULL;
 
        /*
         * Sanity check that what we are storing is actually sensible.
@@ -162,13 +206,23 @@ static int keyring_store(struct credential *c)
 
        label = make_label(c);
        attributes = make_attr_list(c);
-       secret_password_storev_sync(SECRET_SCHEMA_COMPAT_NETWORK,
+       secret = g_string_new(c->password);
+       if (c->password_expiry_utc) {
+               g_string_append_printf(secret, "\npassword_expiry_utc=%s",
+                       c->password_expiry_utc);
+       }
+       if (c->oauth_refresh_token) {
+               g_string_append_printf(secret, "\noauth_refresh_token=%s",
+                       c->oauth_refresh_token);
+       }
+       secret_password_storev_sync(&schema,
                                    attributes,
                                    NULL,
                                    label,
-                                   c->password,
+                                   secret->str,
                                    NULL,
                                    &error);
+       g_string_free(secret, TRUE);
        g_free(label);
        g_hash_table_unref(attributes);
 
@@ -185,6 +239,7 @@ static int keyring_erase(struct credential *c)
 {
        GHashTable *attributes = NULL;
        GError *error = NULL;
+       struct credential existing = CREDENTIAL_INIT;
 
        /*
         * Sanity check that we actually have something to match
@@ -197,8 +252,22 @@ static int keyring_erase(struct credential *c)
        if (!c->protocol && !c->host && !c->path && !c->username)
                return EXIT_FAILURE;
 
+       if (c->password) {
+               existing.host = g_strdup(c->host);
+               existing.path = g_strdup(c->path);
+               existing.port = c->port;
+               existing.protocol = g_strdup(c->protocol);
+               existing.username = g_strdup(c->username);
+               keyring_get(&existing);
+               if (existing.password && strcmp(c->password, existing.password)) {
+                       credential_clear(&existing);
+                       return EXIT_SUCCESS;
+               }
+               credential_clear(&existing);
+       }
+
        attributes = make_attr_list(c);
-       secret_password_clearv_sync(SECRET_SCHEMA_COMPAT_NETWORK,
+       secret_password_clearv_sync(&schema,
                                    attributes,
                                    NULL,
                                    &error);
@@ -238,6 +307,8 @@ static void credential_clear(struct credential *c)
        g_free(c->path);
        g_free(c->username);
        g_free(c->password);
+       g_free(c->password_expiry_utc);
+       g_free(c->oauth_refresh_token);
 
        credential_init(c);
 }
@@ -284,11 +355,19 @@ static int credential_read(struct credential *c)
                } else if (!strcmp(key, "username")) {
                        g_free(c->username);
                        c->username = g_strdup(value);
+               } else if (!strcmp(key, "password_expiry_utc")) {
+                       g_free(c->password_expiry_utc);
+                       c->password_expiry_utc = g_strdup(value);
                } else if (!strcmp(key, "password")) {
                        g_free(c->password);
                        c->password = g_strdup(value);
                        while (*value)
                                *value++ = '\0';
+               } else if (!strcmp(key, "oauth_refresh_token")) {
+                       g_free(c->oauth_refresh_token);
+                       c->oauth_refresh_token = g_strdup(value);
+                       while (*value)
+                               *value++ = '\0';
                }
                /*
                 * Ignore other lines; we don't know what they mean, but
@@ -314,6 +393,10 @@ static void credential_write(const struct credential *c)
        /* only write username/password, if set */
        credential_write_item(stdout, "username", c->username);
        credential_write_item(stdout, "password", c->password);
+       credential_write_item(stdout, "password_expiry_utc",
+               c->password_expiry_utc);
+       credential_write_item(stdout, "oauth_refresh_token",
+               c->oauth_refresh_token);
 }
 
 static void usage(const char *name)
index 96f10613aee29b7c360b25308927564df1551388..4cd56c42e24469a48a40e7b02de4b4921ff8662c 100644 (file)
@@ -109,7 +109,18 @@ static int match_part_last(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
        return match_part_with_last(ptarget, want, delim, 1);
 }
 
-static int match_cred(const CREDENTIALW *cred)
+static int match_cred_password(const CREDENTIALW *cred) {
+       int ret;
+       WCHAR *cred_password = xmalloc(cred->CredentialBlobSize);
+       wcsncpy_s(cred_password, cred->CredentialBlobSize,
+               (LPCWSTR)cred->CredentialBlob,
+               cred->CredentialBlobSize / sizeof(WCHAR));
+       ret = !wcscmp(cred_password, password);
+       free(cred_password);
+       return ret;
+}
+
+static int match_cred(const CREDENTIALW *cred, int match_password)
 {
        LPCWSTR target = cred->TargetName;
        if (wusername && wcscmp(wusername, cred->UserName ? cred->UserName : L""))
@@ -119,7 +130,8 @@ static int match_cred(const CREDENTIALW *cred)
                match_part(&target, protocol, L"://") &&
                match_part_last(&target, wusername, L"@") &&
                match_part(&target, host, L"/") &&
-               match_part(&target, path, L"");
+               match_part(&target, path, L"") &&
+               (!match_password || match_cred_password(cred));
 }
 
 static void get_credential(void)
@@ -134,7 +146,7 @@ static void get_credential(void)
 
        /* search for the first credential that matches username */
        for (i = 0; i < num_creds; ++i)
-               if (match_cred(creds[i])) {
+               if (match_cred(creds[i], 0)) {
                        write_item("username", creds[i]->UserName,
                                creds[i]->UserName ? wcslen(creds[i]->UserName) : 0);
                        write_item("password",
@@ -196,7 +208,7 @@ static void erase_credential(void)
                return;
 
        for (i = 0; i < num_creds; ++i) {
-               if (match_cred(creds[i]))
+               if (match_cred(creds[i], password != NULL))
                        CredDeleteW(creds[i]->TargetName, creds[i]->Type, 0);
        }
 
index 40c4b0d111071676c278651f49669036e90f079a..47e0c557e63f1b236a3ad763e03ac086f1842d23 100755 (executable)
@@ -9,7 +9,7 @@ The <mode> parameter is one of:
 
 diff: elements are diff hunks. Arguments are given to diff.
 
-merge: elements are merge conflicts. Arguments are ignored.
+merge: elements are merge conflicts. Arguments are given to ls-files -u.
 
 grep: elements are grep hits. Arguments are given to git grep or, if
       configured, to the command in `jump.grepCmd`.
index 7db4c45676d304869bba126bd57e7f553aec2008..e0c5d3b0de63483113edbcc09003e70aaa0a3d2d 100755 (executable)
@@ -33,19 +33,19 @@ git subtree split --prefix=<prefix> [<commit>]
 git subtree pull  --prefix=<prefix> <repository> <ref>
 git subtree push  --prefix=<prefix> <repository> <refspec>
 --
-h,help        show the help
-q,quiet       quiet
-d,debug       show debug messages
+h,help!       show the help
+q,quiet!      quiet
+d,debug!      show debug messages
 P,prefix=     the name of the subdir to split out
  options for 'split' (also: 'push')
 annotate=     add a prefix to commit message of new commits
-b,branch    create a new branch from the split subtree
+b,branch!=    create a new branch from the split subtree
 ignore-joins  ignore prior --rejoin commits
 onto=         try connecting new tree to an existing one
 rejoin        merge the new branch back into HEAD
  options for 'add' and 'merge' (also: 'pull', 'split --rejoin', and 'push --rejoin')
 squash        merge subtree changes as a single commit
-m,message   use the given message as the commit message for the merge commit
+m,message!=   use the given message as the commit message for the merge commit
 "
 
 indent=0
index 341c169eca7e6c0f02ac43f0e1844605abddf24d..49a21dd7c9c553f80a905ca8333b93fbe05fcc67 100755 (executable)
@@ -71,7 +71,7 @@ test_expect_success 'shows short help text for -h' '
        test_expect_code 129 git subtree -h >out 2>err &&
        test_must_be_empty err &&
        grep -e "^ *or: git subtree pull" out &&
-       grep -e --annotate out
+       grep -F -e "--[no-]annotate" out
 '
 
 #
index d6647541634f3850ea147cebc681a5944d8e5ee9..18098bd35ebab9683ae0046c1712b111eaeb3fe1 100644 (file)
@@ -88,8 +88,8 @@ static int proto_is_http(const char *s)
 static void credential_describe(struct credential *c, struct strbuf *out);
 static void credential_format(struct credential *c, struct strbuf *out);
 
-static int select_all(const struct urlmatch_item *a,
-                     const struct urlmatch_item *b)
+static int select_all(const struct urlmatch_item *a UNUSED,
+                     const struct urlmatch_item *b UNUSED)
 {
        return 0;
 }
index cd017132448d1ec340f137d6b882ee9bc420509a..870748e01695f865e1e4d587cdb38f769367a5c6 100644 (file)
@@ -207,7 +207,7 @@ int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint
            lseek(f->fd, offset, SEEK_SET) != offset)
                return -1;
        f->total = offset;
-       f->ctx = checkpoint->ctx;
+       the_hash_algo->clone_fn(&f->ctx, &checkpoint->ctx);
        f->offset = 0; /* hashflush() was called in checkpoint */
        return 0;
 }
index 8430064000bcba96506e4b9c99c9efe60ba072f4..4d096c857f1e669a44bc2e43375889ce2952083c 100644 (file)
@@ -71,42 +71,6 @@ static int dir_file_stats(struct object_directory *object_dir, void *data)
        return 0;
 }
 
-/*
- * Get the d_type of a dirent. If the d_type is unknown, derive it from
- * stat.st_mode.
- *
- * Note that 'path' is assumed to have a trailing slash. It is also modified
- * in-place during the execution of the function, but is then reverted to its
- * original value before returning.
- */
-static unsigned char get_dtype(struct dirent *e, struct strbuf *path)
-{
-       struct stat st;
-       unsigned char dtype = DTYPE(e);
-       size_t base_path_len;
-
-       if (dtype != DT_UNKNOWN)
-               return dtype;
-
-       /* d_type unknown in dirent, try to fall back on lstat results */
-       base_path_len = path->len;
-       strbuf_addstr(path, e->d_name);
-       if (lstat(path->buf, &st))
-               goto cleanup;
-
-       /* determine d_type from st_mode */
-       if (S_ISREG(st.st_mode))
-               dtype = DT_REG;
-       else if (S_ISDIR(st.st_mode))
-               dtype = DT_DIR;
-       else if (S_ISLNK(st.st_mode))
-               dtype = DT_LNK;
-
-cleanup:
-       strbuf_setlen(path, base_path_len);
-       return dtype;
-}
-
 static int count_files(struct strbuf *path)
 {
        DIR *dir = opendir(path->buf);
@@ -117,7 +81,7 @@ static int count_files(struct strbuf *path)
                return 0;
 
        while ((e = readdir_skip_dot_and_dotdot(dir)) != NULL)
-               if (get_dtype(e, path) == DT_REG)
+               if (get_dtype(e, path, 0) == DT_REG)
                        count++;
 
        closedir(dir);
@@ -146,7 +110,7 @@ static void loose_objs_stats(struct strbuf *buf, const char *path)
        base_path_len = count_path.len;
 
        while ((e = readdir_skip_dot_and_dotdot(dir)) != NULL)
-               if (get_dtype(e, &count_path) == DT_DIR &&
+               if (get_dtype(e, &count_path, 0) == DT_DIR &&
                    strlen(e->d_name) == 2 &&
                    !hex_to_bytes(&c, e->d_name, 1)) {
                        strbuf_setlen(&count_path, base_path_len);
@@ -191,7 +155,7 @@ static int add_directory_to_archiver(struct strvec *archiver_args,
 
                strbuf_add_absolute_path(&abspath, at_root ? "." : path);
                strbuf_addch(&abspath, '/');
-               dtype = get_dtype(e, &abspath);
+               dtype = get_dtype(e, &abspath, 0);
 
                strbuf_setlen(&buf, len);
                strbuf_addstr(&buf, e->d_name);
index 5848e4f9ca294052b0e06c7e4d038ebd462ade92..0e9ec4f68afb01f23d9b9a0142d2ffb2cd1cc79b 100644 (file)
@@ -571,8 +571,6 @@ void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)
                struct object *obj = revs->pending.objects[i].item;
                if (obj->flags)
                        die(_("--merge-base does not work with ranges"));
-               if (obj->type != OBJ_COMMIT)
-                       die(_("--merge-base only works with commits"));
        }
 
        /*
index ec97616db1dfaa0673945bb08a9f364b2d570db1..45507588a2797b8d3618e3a19a2854d12051157b 100644 (file)
@@ -131,6 +131,9 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
        } else if (!strcmp(arg, "--cc")) {
                set_dense_combined(revs);
                revs->merges_imply_patch = 1;
+       } else if (!strcmp(arg, "--dd")) {
+               set_first_parent(revs);
+               revs->merges_imply_patch = 1;
        } else if (!strcmp(arg, "--remerge-diff")) {
                set_remerge_diff(revs);
                revs->merges_imply_patch = 1;
diff --git a/diff.c b/diff.c
index bccb018da468480615c04d858909891ac59b69e5..2c602df10a372c7e99402ca5a2dc9cf7aa673c09 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -65,6 +65,7 @@ int diff_auto_refresh_index = 1;
 static int diff_mnemonic_prefix;
 static int diff_no_prefix;
 static int diff_relative;
+static int diff_stat_name_width;
 static int diff_stat_graph_width;
 static int diff_dirstat_permille_default = 30;
 static struct diff_options default_diff_options;
@@ -410,6 +411,10 @@ int git_diff_ui_config(const char *var, const char *value,
                diff_relative = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "diff.statnamewidth")) {
+               diff_stat_name_width = git_config_int(var, value, ctx->kvi);
+               return 0;
+       }
        if (!strcmp(var, "diff.statgraphwidth")) {
                diff_stat_graph_width = git_config_int(var, value, ctx->kvi);
                return 0;
@@ -2704,12 +2709,14 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
        number_width = decimal_width(max_change) > number_width ?
                decimal_width(max_change) : number_width;
 
+       if (options->stat_name_width == -1)
+               options->stat_name_width = diff_stat_name_width;
        if (options->stat_graph_width == -1)
                options->stat_graph_width = diff_stat_graph_width;
 
        /*
-        * Guarantee 3/8*16==6 for the graph part
-        * and 5/8*16==10 for the filename part
+        * Guarantee 3/8*16 == 6 for the graph part
+        * and 5/8*16 == 10 for the filename part
         */
        if (width < 16 + 6 + number_width)
                width = 16 + 6 + number_width;
@@ -6929,6 +6936,13 @@ void diff_queued_diff_prefetch(void *repository)
        oid_array_clear(&to_fetch);
 }
 
+void init_diffstat_widths(struct diff_options *options)
+{
+       options->stat_width = -1;        /* use full terminal width */
+       options->stat_name_width = -1;   /* respect diff.statNameWidth config */
+       options->stat_graph_width = -1;  /* respect diff.statGraphWidth config */
+}
+
 void diffcore_std(struct diff_options *options)
 {
        int output_formats_to_prefetch = DIFF_FORMAT_DIFFSTAT |
diff --git a/diff.h b/diff.h
index caf1528bf077cda0be89882b5ef856fe34dd3999..66bd8aeb2936fbe9d6610f7dc1202e31e1450ebb 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -573,6 +573,7 @@ int git_config_rename(const char *var, const char *value);
 
 #define DIFF_PICKAXE_IGNORE_CASE       32
 
+void init_diffstat_widths(struct diff_options *);
 void diffcore_std(struct diff_options *);
 void diffcore_fix_diff_index(void);
 
diff --git a/dir.c b/dir.c
index 8486e4d56ff50cafd14aa3ef00ee89c069d87269..16fdb03f2a51c9505b3cc9da2d9a908f3e4ae119 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -2235,6 +2235,39 @@ static int get_index_dtype(struct index_state *istate,
        return DT_UNKNOWN;
 }
 
+unsigned char get_dtype(struct dirent *e, struct strbuf *path,
+                       int follow_symlink)
+{
+       struct stat st;
+       unsigned char dtype = DTYPE(e);
+       size_t base_path_len;
+
+       if (dtype != DT_UNKNOWN && !(follow_symlink && dtype == DT_LNK))
+               return dtype;
+
+       /*
+        * d_type unknown or unfollowed symlink, try to fall back on [l]stat
+        * results. If [l]stat fails, explicitly set DT_UNKNOWN.
+        */
+       base_path_len = path->len;
+       strbuf_addstr(path, e->d_name);
+       if ((follow_symlink && stat(path->buf, &st)) ||
+           (!follow_symlink && lstat(path->buf, &st)))
+               goto cleanup;
+
+       /* determine d_type from st_mode */
+       if (S_ISREG(st.st_mode))
+               dtype = DT_REG;
+       else if (S_ISDIR(st.st_mode))
+               dtype = DT_DIR;
+       else if (S_ISLNK(st.st_mode))
+               dtype = DT_LNK;
+
+cleanup:
+       strbuf_setlen(path, base_path_len);
+       return dtype;
+}
+
 static int resolve_dtype(int dtype, struct index_state *istate,
                         const char *path, int len)
 {
diff --git a/dir.h b/dir.h
index ad06682fd54b3e7ae47d6f8a8d80048da0324f01..98aa85fcc0ee357a2df50014008c3e5ec12acb25 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -363,6 +363,22 @@ struct dir_struct {
 
 struct dirent *readdir_skip_dot_and_dotdot(DIR *dirp);
 
+/*
+ * Get the d_type of a dirent. If the d_type is unknown, derive it from
+ * stat.st_mode using the path to the dirent's containing directory (path) and
+ * the name of the dirent itself.
+ *
+ * If 'follow_symlink' is 1, this function will attempt to follow DT_LNK types
+ * using 'stat'. Links are *not* followed recursively, so a symlink pointing
+ * to another symlink will still resolve to 'DT_LNK'.
+ *
+ * Note that 'path' is assumed to have a trailing slash. It is also modified
+ * in-place during the execution of the function, but is then reverted to its
+ * original value before returning.
+ */
+unsigned char get_dtype(struct dirent *e, struct strbuf *path,
+                       int follow_symlink);
+
 /*Count the number of slashes for string s*/
 int count_slashes(const char *s);
 
diff --git a/entry.c b/entry.c
index 43767f9043c0cbb97ec3257fd78b0a985e5a8f77..076e97eb89ce15e312b6ff08eebd3c1389245997 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -581,3 +581,8 @@ void unlink_entry(const struct cache_entry *ce, const char *super_prefix)
                return;
        schedule_dir_for_removal(ce->name, ce_namelen(ce));
 }
+
+int remove_or_warn(unsigned int mode, const char *file)
+{
+       return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
+}
diff --git a/entry.h b/entry.h
index 7329f918a97ee3f80aeeaff07e4236143fcf3cbf..ca3ed35bc08654ee47bc6c9331c1fad2804bfd32 100644 (file)
--- a/entry.h
+++ b/entry.h
@@ -62,4 +62,10 @@ int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st)
 void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
                           struct stat *st);
 
+/*
+ * Calls the correct function out of {unlink,rmdir}_or_warn based on
+ * the supplied file mode.
+ */
+int remove_or_warn(unsigned int mode, const char *path);
+
 #endif /* ENTRY_H */
index f98d76f08047f14f49e9d3c3d1a4232c500efbf1..9e37bf58c0c6822f48152e5ab59c25a0cf39a874 100644 (file)
@@ -81,6 +81,20 @@ int merge_log_config = -1;
 int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 unsigned long pack_size_limit_cfg;
 enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET;
+int max_allowed_tree_depth =
+#ifdef _MSC_VER
+       /*
+        * When traversing into too-deep trees, Visual C-compiled Git seems to
+        * run into some internal stack overflow detection in the
+        * `RtlpAllocateHeap()` function that is called from within
+        * `git_inflate_init()`'s call tree. The following value seems to be
+        * low enough to avoid that by letting Git exit with an error before
+        * the stack overflow can occur.
+        */
+       512;
+#else
+       2048;
+#endif
 
 #ifndef PROTECT_HFS_DEFAULT
 #define PROTECT_HFS_DEFAULT 0
index c5377473c683390992315f69a63c557b25c655bb..e5351c9dd95ea6e7afe77b1db466d6ab30310491 100644 (file)
@@ -132,6 +132,7 @@ extern size_t packed_git_limit;
 extern size_t delta_base_cache_limit;
 extern unsigned long big_file_threshold;
 extern unsigned long pack_size_limit_cfg;
+extern int max_allowed_tree_depth;
 
 /*
  * Accessors for the core.sharedrepository config which lazy-load the value
diff --git a/fsck.c b/fsck.c
index 2b1e348005b7bcc7f27bc08e126c93260cda81e4..6a0bbc50877710ff22db33adec48f4a469143c37 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -24,6 +24,8 @@
 #include "credential.h"
 #include "help.h"
 
+static ssize_t max_tree_entry_len = 4096;
+
 #define STR(x) #x
 #define MSG_ID(id, msg_type) { STR(id), NULL, NULL, FSCK_##msg_type },
 static struct {
@@ -154,15 +156,29 @@ void fsck_set_msg_type(struct fsck_options *options,
                       const char *msg_id_str, const char *msg_type_str)
 {
        int msg_id = parse_msg_id(msg_id_str);
-       enum fsck_msg_type msg_type = parse_msg_type(msg_type_str);
+       char *to_free = NULL;
+       enum fsck_msg_type msg_type;
 
        if (msg_id < 0)
                die("Unhandled message id: %s", msg_id_str);
 
+       if (msg_id == FSCK_MSG_LARGE_PATHNAME) {
+               const char *colon = strchr(msg_type_str, ':');
+               if (colon) {
+                       msg_type_str = to_free =
+                               xmemdupz(msg_type_str, colon - msg_type_str);
+                       colon++;
+                       if (!git_parse_ssize_t(colon, &max_tree_entry_len))
+                               die("unable to parse max tree entry len: %s", colon);
+               }
+       }
+       msg_type = parse_msg_type(msg_type_str);
+
        if (msg_type != FSCK_ERROR && msg_id_info[msg_id].msg_type == FSCK_FATAL)
                die("Cannot demote %s to %s", msg_id_str, msg_type_str);
 
        fsck_set_msg_type_from_ids(options, msg_id, msg_type);
+       free(to_free);
 }
 
 void fsck_set_msg_types(struct fsck_options *options, const char *values)
@@ -578,6 +594,7 @@ static int fsck_tree(const struct object_id *tree_oid,
        int has_bad_modes = 0;
        int has_dup_entries = 0;
        int not_properly_sorted = 0;
+       int has_large_name = 0;
        struct tree_desc desc;
        unsigned o_mode;
        const char *o_name;
@@ -607,6 +624,7 @@ static int fsck_tree(const struct object_id *tree_oid,
                has_dotdot |= !strcmp(name, "..");
                has_dotgit |= is_hfs_dotgit(name) || is_ntfs_dotgit(name);
                has_zero_pad |= *(char *)desc.buffer == '0';
+               has_large_name |= tree_entry_len(&desc.entry) > max_tree_entry_len;
 
                if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name)) {
                        if (!S_ISLNK(mode))
@@ -749,6 +767,10 @@ static int fsck_tree(const struct object_id *tree_oid,
                retval += report(options, tree_oid, OBJ_TREE,
                                 FSCK_MSG_TREE_NOT_SORTED,
                                 "not properly sorted");
+       if (has_large_name)
+               retval += report(options, tree_oid, OBJ_TREE,
+                                FSCK_MSG_LARGE_PATHNAME,
+                                "contains excessively large pathname");
        return retval;
 }
 
diff --git a/fsck.h b/fsck.h
index 6359ba359bd24a5ece2fa4752d55f703af32388e..e3adf9d91159878ae09b35a9fe12370fdbf85f98 100644 (file)
--- a/fsck.h
+++ b/fsck.h
@@ -73,6 +73,7 @@ enum fsck_msg_type {
        FUNC(NULL_SHA1, WARN) \
        FUNC(ZERO_PADDED_FILEMODE, WARN) \
        FUNC(NUL_IN_COMMIT, WARN) \
+       FUNC(LARGE_PATHNAME, WARN) \
        /* infos (reported as warnings, but ignored by default) */ \
        FUNC(BAD_FILEMODE, INFO) \
        FUNC(GITMODULES_PARSE, INFO) \
index 70d776c54f6d142c2efd931cec140afaa91479f4..673f80d2aad0d4a2e0dff1f7f114f2fc7b5b653c 100644 (file)
@@ -99,7 +99,7 @@ struct fsmonitor_daemon_state {
  * to only mean an external GITDIR referenced by a ".git" file.
  *
  * The platform FS event backends will receive watch-specific
- * relative paths (except for those OS's that always emit absolute
+ * relative paths (except for those OSes that always emit absolute
  * paths).  We use the following enum and routines to classify each
  * path so that we know how to handle it.  There is a slight asymmetry
  * here because ".git/" is inside the working directory and the
index 88575aa54cad07312b2aa3dab3a87cfe0ebb3693..153918cf768c48f4b9cad799cd728c45a152a8ad 100644 (file)
@@ -20,7 +20,7 @@ int fsmonitor_ipc__is_supported(void)
        return 0;
 }
 
-const char *fsmonitor_ipc__get_path(struct repository *r)
+const char *fsmonitor_ipc__get_path(struct repository *r UNUSED)
 {
        return NULL;
 }
@@ -30,14 +30,14 @@ enum ipc_active_state fsmonitor_ipc__get_state(void)
        return IPC_STATE__OTHER_ERROR;
 }
 
-int fsmonitor_ipc__send_query(const char *since_token,
-                             struct strbuf *answer)
+int fsmonitor_ipc__send_query(const char *since_token UNUSED,
+                             struct strbuf *answer UNUSED)
 {
        return -1;
 }
 
-int fsmonitor_ipc__send_command(const char *command,
-                               struct strbuf *answer)
+int fsmonitor_ipc__send_command(const char *command UNUSED,
+                               struct strbuf *answer UNUSED)
 {
        return -1;
 }
index b62acf44aee2b9c029fac4389f6af7e4c4df6dab..a6a9e6bc199ec2ea0b608212da2f5b4a6edd94ed 100644 (file)
@@ -62,7 +62,8 @@ static enum fsmonitor_reason check_remote(struct repository *r)
 }
 #endif
 
-static enum fsmonitor_reason check_for_incompatible(struct repository *r, int ipc)
+static enum fsmonitor_reason check_for_incompatible(struct repository *r,
+                                                   int ipc MAYBE_UNUSED)
 {
        if (!r->worktree) {
                /*
index a0d5a4b28e171542a0bfca2a3e833607aa47d409..3f80435436c11d2f36ee626450ae72697570ca8e 100644 (file)
@@ -138,25 +138,10 @@ GITGUI_SCRIPT   := $$0
 GITGUI_RELATIVE :=
 GITGUI_MACOSXAPP :=
 
-ifeq ($(uname_O),Cygwin)
-       GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"`
-
-       # Is this a Cygwin Tcl/Tk binary?  If so it knows how to do
-       # POSIX path translation just like cygpath does and we must
-       # keep libdir in POSIX format so Cygwin packages of git-gui
-       # work no matter where the user installs them.
-       #
-       ifeq ($(shell echo 'puts [file normalize /]' | '$(TCL_PATH_SQ)'),$(shell cygpath --mixed --absolute /))
-               gg_libdir_sed_in := $(gg_libdir)
-       else
-               gg_libdir_sed_in := $(shell cygpath --windows --absolute "$(gg_libdir)")
-       endif
-else
-       ifeq ($(exedir),$(gg_libdir))
-               GITGUI_RELATIVE := 1
-       endif
-       gg_libdir_sed_in := $(gg_libdir)
+ifeq ($(exedir),$(gg_libdir))
+       GITGUI_RELATIVE := 1
 endif
+gg_libdir_sed_in := $(gg_libdir)
 ifeq ($(uname_S),Darwin)
        ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
                GITGUI_MACOSXAPP := YesPlease
index 5ce2122fbc618384f66f4e1f08f98bca047db1c0..b460b649a8ccfec587dab03fb3c516007ab1a060 100644 (file)
@@ -88,7 +88,7 @@ that you first use `git-format-patch` to generate the emails, audit them, and
 then send them via `git-send-email`.
 
 A pretty good guide to configuring and using `git-send-email` can be found
-[here](https://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/)
+[here](https://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/).
 
 ### Using your email client
 
index 201524c34edac053f908c927a00270a7b1fdc09a..3e5907a4609b1510aef71ab54f56a82eeb36e071 100755 (executable)
@@ -44,6 +44,132 @@ if {[catch {package require Tcl 8.5} err]
 
 catch {rename send {}} ; # What an evil concept...
 
+######################################################################
+##
+## Enabling platform-specific code paths
+
+proc is_MacOSX {} {
+       if {[tk windowingsystem] eq {aqua}} {
+               return 1
+       }
+       return 0
+}
+
+proc is_Windows {} {
+       if {$::tcl_platform(platform) eq {windows}} {
+               return 1
+       }
+       return 0
+}
+
+set _iscygwin {}
+proc is_Cygwin {} {
+       global _iscygwin
+       if {$_iscygwin eq {}} {
+               if {[string match "CYGWIN_*" $::tcl_platform(os)]} {
+                       set _iscygwin 1
+               } else {
+                       set _iscygwin 0
+               }
+       }
+       return $_iscygwin
+}
+
+######################################################################
+##
+## PATH lookup
+
+set _search_path {}
+proc _which {what args} {
+       global env _search_exe _search_path
+
+       if {$_search_path eq {}} {
+               if {[is_Windows]} {
+                       set gitguidir [file dirname [info script]]
+                       regsub -all ";" $gitguidir "\\;" gitguidir
+                       set env(PATH) "$gitguidir;$env(PATH)"
+                       set _search_path [split $env(PATH) {;}]
+                       # Skip empty `PATH` elements
+                       set _search_path [lsearch -all -inline -not -exact \
+                               $_search_path ""]
+                       set _search_exe .exe
+               } else {
+                       set _search_path [split $env(PATH) :]
+                       set _search_exe {}
+               }
+       }
+
+       if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
+               set suffix {}
+       } else {
+               set suffix $_search_exe
+       }
+
+       foreach p $_search_path {
+               set p [file join $p $what$suffix]
+               if {[file exists $p]} {
+                       return [file normalize $p]
+               }
+       }
+       return {}
+}
+
+proc sanitize_command_line {command_line from_index} {
+       set i $from_index
+       while {$i < [llength $command_line]} {
+               set cmd [lindex $command_line $i]
+               if {[llength [file split $cmd]] < 2} {
+                       set fullpath [_which $cmd]
+                       if {$fullpath eq ""} {
+                               throw {NOT-FOUND} "$cmd not found in PATH"
+                       }
+                       lset command_line $i $fullpath
+               }
+
+               # handle piped commands, e.g. `exec A | B`
+               for {incr i} {$i < [llength $command_line]} {incr i} {
+                       if {[lindex $command_line $i] eq "|"} {
+                               incr i
+                               break
+                       }
+               }
+       }
+       return $command_line
+}
+
+# Override `exec` to avoid unsafe PATH lookup
+
+rename exec real_exec
+
+proc exec {args} {
+       # skip options
+       for {set i 0} {$i < [llength $args]} {incr i} {
+               set arg [lindex $args $i]
+               if {$arg eq "--"} {
+                       incr i
+                       break
+               }
+               if {[string range $arg 0 0] ne "-"} {
+                       break
+               }
+       }
+       set args [sanitize_command_line $args $i]
+       uplevel 1 real_exec $args
+}
+
+# Override `open` to avoid unsafe PATH lookup
+
+rename open real_open
+
+proc open {args} {
+       set arg0 [lindex $args 0]
+       if {[string range $arg0 0 0] eq "|"} {
+               set command_line [string trim [string range $arg0 1 end]]
+               lset args 0 "| [sanitize_command_line $command_line 0]"
+       }
+       uplevel 1 real_open $args
+}
+
 ######################################################################
 ##
 ## locate our library
@@ -163,8 +289,6 @@ set _isbare {}
 set _gitexec {}
 set _githtmldir {}
 set _reponame {}
-set _iscygwin {}
-set _search_path {}
 set _shellpath {@@SHELL_PATH@@}
 
 set _trace [lsearch -exact $argv --trace]
@@ -211,14 +335,7 @@ proc gitexec {args} {
                if {[catch {set _gitexec [git --exec-path]} err]} {
                        error "Git not installed?\n\n$err"
                }
-               if {[is_Cygwin]} {
-                       set _gitexec [exec cygpath \
-                               --windows \
-                               --absolute \
-                               $_gitexec]
-               } else {
-                       set _gitexec [file normalize $_gitexec]
-               }
+               set _gitexec [file normalize $_gitexec]
        }
        if {$args eq {}} {
                return $_gitexec
@@ -233,14 +350,7 @@ proc githtmldir {args} {
                        # Git not installed or option not yet supported
                        return {}
                }
-               if {[is_Cygwin]} {
-                       set _githtmldir [exec cygpath \
-                               --windows \
-                               --absolute \
-                               $_githtmldir]
-               } else {
-                       set _githtmldir [file normalize $_githtmldir]
-               }
+               set _githtmldir [file normalize $_githtmldir]
        }
        if {$args eq {}} {
                return $_githtmldir
@@ -252,40 +362,6 @@ proc reponame {} {
        return $::_reponame
 }
 
-proc is_MacOSX {} {
-       if {[tk windowingsystem] eq {aqua}} {
-               return 1
-       }
-       return 0
-}
-
-proc is_Windows {} {
-       if {$::tcl_platform(platform) eq {windows}} {
-               return 1
-       }
-       return 0
-}
-
-proc is_Cygwin {} {
-       global _iscygwin
-       if {$_iscygwin eq {}} {
-               if {$::tcl_platform(platform) eq {windows}} {
-                       if {[catch {set p [exec cygpath --windir]} err]} {
-                               set _iscygwin 0
-                       } else {
-                               set _iscygwin 1
-                               # Handle MSys2 which is only cygwin when MSYSTEM is MSYS.
-                               if {[info exists ::env(MSYSTEM)] && $::env(MSYSTEM) ne "MSYS"} {
-                                       set _iscygwin 0
-                               }
-                       }
-               } else {
-                       set _iscygwin 0
-               }
-       }
-       return $_iscygwin
-}
-
 proc is_enabled {option} {
        global enabled_options
        if {[catch {set on $enabled_options($option)}]} {return 0}
@@ -448,44 +524,6 @@ proc _git_cmd {name} {
        return $v
 }
 
-proc _which {what args} {
-       global env _search_exe _search_path
-
-       if {$_search_path eq {}} {
-               if {[is_Cygwin] && [regexp {^(/|\.:)} $env(PATH)]} {
-                       set _search_path [split [exec cygpath \
-                               --windows \
-                               --path \
-                               --absolute \
-                               $env(PATH)] {;}]
-                       set _search_exe .exe
-               } elseif {[is_Windows]} {
-                       set gitguidir [file dirname [info script]]
-                       regsub -all ";" $gitguidir "\\;" gitguidir
-                       set env(PATH) "$gitguidir;$env(PATH)"
-                       set _search_path [split $env(PATH) {;}]
-                       set _search_exe .exe
-               } else {
-                       set _search_path [split $env(PATH) :]
-                       set _search_exe {}
-               }
-       }
-
-       if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
-               set suffix {}
-       } else {
-               set suffix $_search_exe
-       }
-
-       foreach p $_search_path {
-               set p [file join $p $what$suffix]
-               if {[file exists $p]} {
-                       return [file normalize $p]
-               }
-       }
-       return {}
-}
-
 # Test a file for a hashbang to identify executable scripts on Windows.
 proc is_shellscript {filename} {
        if {![file exists $filename]} {return 0}
@@ -623,31 +661,8 @@ proc git_write {args} {
 }
 
 proc githook_read {hook_name args} {
-       set pchook [gitdir hooks $hook_name]
-       lappend args 2>@1
-
-       # On Windows [file executable] might lie so we need to ask
-       # the shell if the hook is executable.  Yes that's annoying.
-       #
-       if {[is_Windows]} {
-               upvar #0 _sh interp
-               if {![info exists interp]} {
-                       set interp [_which sh]
-               }
-               if {$interp eq {}} {
-                       error "hook execution requires sh (not in PATH)"
-               }
-
-               set scr {if test -x "$1";then exec "$@";fi}
-               set sh_c [list $interp -c $scr $interp $pchook]
-               return [_open_stdout_stderr [concat $sh_c $args]]
-       }
-
-       if {[file executable $pchook]} {
-               return [_open_stdout_stderr [concat [list $pchook] $args]]
-       }
-
-       return {}
+       set cmd [concat git hook run --ignore-missing $hook_name -- $args 2>@1]
+       return [_open_stdout_stderr $cmd]
 }
 
 proc kill_file_process {fd} {
@@ -1259,9 +1274,6 @@ if {$_gitdir eq "."} {
        set _gitdir [pwd]
 }
 
-if {![file isdirectory $_gitdir] && [is_Cygwin]} {
-       catch {set _gitdir [exec cygpath --windows $_gitdir]}
-}
 if {![file isdirectory $_gitdir]} {
        catch {wm withdraw .}
        error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"]
@@ -1273,11 +1285,7 @@ apply_config
 
 # v1.7.0 introduced --show-toplevel to return the canonical work-tree
 if {[package vcompare $_git_version 1.7.0] >= 0} {
-       if { [is_Cygwin] } {
-               catch {set _gitworktree [exec cygpath --windows [git rev-parse --show-toplevel]]}
-       } else {
-               set _gitworktree [git rev-parse --show-toplevel]
-       }
+       set _gitworktree [git rev-parse --show-toplevel]
 } else {
        # try to set work tree from environment, core.worktree or use
        # cdup to obtain a relative path to the top of the worktree. If
@@ -1502,24 +1510,8 @@ proc rescan {after {honor_trustmtime 1}} {
        }
 }
 
-if {[is_Cygwin]} {
-       set is_git_info_exclude {}
-       proc have_info_exclude {} {
-               global is_git_info_exclude
-
-               if {$is_git_info_exclude eq {}} {
-                       if {[catch {exec test -f [gitdir info exclude]}]} {
-                               set is_git_info_exclude 0
-                       } else {
-                               set is_git_info_exclude 1
-                       }
-               }
-               return $is_git_info_exclude
-       }
-} else {
-       proc have_info_exclude {} {
-               return [file readable [gitdir info exclude]]
-       }
+proc have_info_exclude {} {
+       return [file readable [gitdir info exclude]]
 }
 
 proc rescan_stage2 {fd after} {
@@ -2259,7 +2251,9 @@ proc do_git_gui {} {
 
 # Get the system-specific explorer app/command.
 proc get_explorer {} {
-       if {[is_Cygwin] || [is_Windows]} {
+       if {[is_Cygwin]} {
+               set explorer "/bin/cygstart.exe --explore"
+       } elseif {[is_Windows]} {
                set explorer "explorer.exe"
        } elseif {[is_MacOSX]} {
                set explorer "open"
@@ -3053,10 +3047,6 @@ if {[is_MacOSX]} {
 set doc_path [githtmldir]
 if {$doc_path ne {}} {
        set doc_path [file join $doc_path index.html]
-
-       if {[is_Cygwin]} {
-               set doc_path [exec cygpath --mixed $doc_path]
-       }
 }
 
 if {[file isfile $doc_path]} {
@@ -4028,60 +4018,6 @@ set file_lists($ui_workdir) [list]
 wm title . "[appname] ([reponame]) [file normalize $_gitworktree]"
 focus -force $ui_comm
 
-# -- Warn the user about environmental problems.  Cygwin's Tcl
-#    does *not* pass its env array onto any processes it spawns.
-#    This means that git processes get none of our environment.
-#
-if {[is_Cygwin]} {
-       set ignored_env 0
-       set suggest_user {}
-       set msg [mc "Possible environment issues exist.
-
-The following environment variables are probably
-going to be ignored by any Git subprocess run
-by %s:
-
-" [appname]]
-       foreach name [array names env] {
-               switch -regexp -- $name {
-               {^GIT_INDEX_FILE$} -
-               {^GIT_OBJECT_DIRECTORY$} -
-               {^GIT_ALTERNATE_OBJECT_DIRECTORIES$} -
-               {^GIT_DIFF_OPTS$} -
-               {^GIT_EXTERNAL_DIFF$} -
-               {^GIT_PAGER$} -
-               {^GIT_TRACE$} -
-               {^GIT_CONFIG$} -
-               {^GIT_(AUTHOR|COMMITTER)_DATE$} {
-                       append msg " - $name\n"
-                       incr ignored_env
-               }
-               {^GIT_(AUTHOR|COMMITTER)_(NAME|EMAIL)$} {
-                       append msg " - $name\n"
-                       incr ignored_env
-                       set suggest_user $name
-               }
-               }
-       }
-       if {$ignored_env > 0} {
-               append msg [mc "
-This is due to a known issue with the
-Tcl binary distributed by Cygwin."]
-
-               if {$suggest_user ne {}} {
-                       append msg [mc "
-
-A good replacement for %s
-is placing values for the user.name and
-user.email settings into your personal
-~/.gitconfig file.
-" $suggest_user]
-               }
-               warn_popup $msg
-       }
-       unset ignored_env msg suggest_user name
-}
-
 # -- Only initialize complex UI if we are going to stay running.
 #
 if {[is_enabled transport]} {
index af1fee7c751dc635bcc9c621161dc3558f297cb8..d23abedcb36fd93ab3f12694d607bf354d6cf208 100644 (file)
@@ -174,9 +174,6 @@ constructor pick {} {
                        -foreground blue \
                        -underline 1
                set home $::env(HOME)
-               if {[is_Cygwin]} {
-                       set home [exec cygpath --windows --absolute $home]
-               }
                set home "[file normalize $home]/"
                set hlen [string length $home]
                foreach p $sorted_recent {
@@ -374,18 +371,6 @@ proc _objdir {path} {
                return $objdir
        }
 
-       if {[is_Cygwin]} {
-               set objdir [file join $path .git objects.lnk]
-               if {[file isfile $objdir]} {
-                       return [win32_read_lnk $objdir]
-               }
-
-               set objdir [file join $path objects.lnk]
-               if {[file isfile $objdir]} {
-                       return [win32_read_lnk $objdir]
-               }
-       }
-
        return {}
 }
 
@@ -623,12 +608,6 @@ method _do_clone2 {} {
        }
 
        set giturl $origin_url
-       if {[is_Cygwin] && [file isdirectory $giturl]} {
-               set giturl [exec cygpath --unix --absolute $giturl]
-               if {$clone_type eq {shared}} {
-                       set objdir [exec cygpath --unix --absolute $objdir]
-               }
-       }
 
        if {[file exists $local_path]} {
                error_popup [mc "Location %s already exists." $local_path]
@@ -668,11 +647,7 @@ method _do_clone2 {} {
                                fconfigure $f_cp -translation binary -encoding binary
                                cd $objdir
                                while {[gets $f_in line] >= 0} {
-                                       if {[is_Cygwin]} {
-                                               puts $f_cp [exec cygpath --unix --absolute $line]
-                                       } else {
-                                               puts $f_cp [file normalize $line]
-                                       }
+                                       puts $f_cp [file normalize $line]
                                }
                                close $f_in
                                close $f_cp
index 97d1d7aa02686606912dd5ff7b512343083a17c0..674a41f5e0c868b70d84202381fec8b5919f962f 100644 (file)
@@ -27,13 +27,10 @@ proc do_windows_shortcut {} {
 }
 
 proc do_cygwin_shortcut {} {
-       global argv0 _gitworktree
+       global argv0 _gitworktree oguilib
 
        if {[catch {
                set desktop [exec cygpath \
-                       --windows \
-                       --absolute \
-                       --long-name \
                        --desktop]
                }]} {
                        set desktop .
@@ -48,19 +45,19 @@ proc do_cygwin_shortcut {} {
                        set fn ${fn}.lnk
                }
                if {[catch {
-                               set sh [exec cygpath \
-                                       --windows \
-                                       --absolute \
-                                       /bin/sh.exe]
-                               set me [exec cygpath \
-                                       --unix \
-                                       --absolute \
-                                       $argv0]
-                               win32_create_lnk $fn [list \
-                                       $sh -c \
-                                       "CHERE_INVOKING=1 source /etc/profile;[sq $me] &" \
-                                       ] \
-                                       [file normalize $_gitworktree]
+                               set repodir [file normalize $_gitworktree]
+                               set shargs {-c \
+                                       "CHERE_INVOKING=1 \
+                                       source /etc/profile; \
+                                       git gui"}
+                               exec /bin/mkshortcut.exe \
+                                       --arguments $shargs \
+                                       --desc "git-gui on $repodir" \
+                                       --icon $oguilib/git-gui.ico \
+                                       --name $fn \
+                                       --show min \
+                                       --workingdir $repodir \
+                                       /bin/sh.exe
                        } err]} {
                        error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
                }
index d26a980e5acb66eda31d32e075d90736bcac4e3a..0eb3bb4c47dcf12a9f1d98e1b76a3681197ac52e 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -1522,6 +1522,10 @@ class LargeFileSystem(object):
            file is stored in the large file system and handles all necessary
            steps.
            """
+        # symlinks aren't processed by smudge/clean filters
+        if git_mode == "120000":
+            return (git_mode, contents)
+
         if self.exceedsLargeFileThreshold(relPath, contents) or self.hasLargeFileExtension(relPath):
             contentTempFile = self.generateTempFile(contents)
             pointer_git_mode, contents, localLargeFile = self.generatePointer(contentTempFile)
index 288ea1ae802dcb88c582085de5a046178b6fbf5e..cacdbd6bb2e41823994071fc936148dab806f7c2 100755 (executable)
@@ -799,30 +799,6 @@ $sender = sanitize_address($sender);
 
 $time = time - scalar $#files;
 
-if ($validate) {
-       # FIFOs can only be read once, exclude them from validation.
-       my @real_files = ();
-       foreach my $f (@files) {
-               unless (-p $f) {
-                       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";
-               pre_process_file($r, 1);
-               validate_patch($r, $target_xfer_encoding);
-               $num += 1;
-       }
-       delete $ENV{GIT_SENDEMAIL_FILE_COUNTER};
-       delete $ENV{GIT_SENDEMAIL_FILE_TOTAL};
-}
-
 @files = handle_backup_files(@files);
 
 if (@files) {
@@ -861,6 +837,9 @@ if ($compose) {
        my $tpl_subject = $initial_subject || '';
        my $tpl_in_reply_to = $initial_in_reply_to || '';
        my $tpl_reply_to = $reply_to || '';
+       my $tpl_to = join(',', @initial_to);
+       my $tpl_cc = join(',', @initial_cc);
+       my $tpl_bcc = join(', ', @initial_bcc);
 
        print $c <<EOT1, Git::prefix_lines("GIT: ", __(<<EOT2)), <<EOT3;
 From $tpl_sender # This line is ignored.
@@ -872,6 +851,9 @@ for the patch you are writing.
 Clear the body content if you don't wish to send a summary.
 EOT2
 From: $tpl_sender
+To: $tpl_to
+Cc: $tpl_cc
+Bcc: $tpl_bcc
 Reply-To: $tpl_reply_to
 Subject: $tpl_subject
 In-Reply-To: $tpl_in_reply_to
@@ -888,73 +870,65 @@ EOT3
                do_edit($compose_filename);
        }
 
+       open my $c2, ">", $compose_filename . ".final"
+               or die sprintf(__("Failed to open %s.final: %s"), $compose_filename, $!);
+
        open $c, "<", $compose_filename
                or die sprintf(__("Failed to open %s: %s"), $compose_filename, $!);
 
+       my $need_8bit_cte = file_has_nonascii($compose_filename);
+       my $in_body = 0;
+       my $summary_empty = 1;
        if (!defined $compose_encoding) {
                $compose_encoding = "UTF-8";
        }
-
-       my %parsed_email;
-       while (my $line = <$c>) {
-               next if $line =~ m/^GIT:/;
-               parse_header_line($line, \%parsed_email);
-               if ($line =~ /^$/) {
-                       $parsed_email{'body'} = filter_body($c);
+       while(<$c>) {
+               next if m/^GIT:/;
+               if ($in_body) {
+                       $summary_empty = 0 unless (/^\n$/);
+               } elsif (/^\n$/) {
+                       $in_body = 1;
+                       if ($need_8bit_cte) {
+                               print $c2 "MIME-Version: 1.0\n",
+                                        "Content-Type: text/plain; ",
+                                          "charset=$compose_encoding\n",
+                                        "Content-Transfer-Encoding: 8bit\n";
+                       }
+               } elsif (/^MIME-Version:/i) {
+                       $need_8bit_cte = 0;
+               } elsif (/^Subject:\s*(.+)\s*$/i) {
+                       $initial_subject = $1;
+                       my $subject = $initial_subject;
+                       $_ = "Subject: " .
+                               quote_subject($subject, $compose_encoding) .
+                               "\n";
+               } elsif (/^In-Reply-To:\s*(.+)\s*$/i) {
+                       $initial_in_reply_to = $1;
+                       next;
+               } elsif (/^Reply-To:\s*(.+)\s*$/i) {
+                       $reply_to = $1;
+               } elsif (/^From:\s*(.+)\s*$/i) {
+                       $sender = $1;
+                       next;
+               } elsif (/^To:\s*(.+)\s*$/i) {
+                       @initial_to = parse_address_line($1);
+                       next;
+               } elsif (/^Cc:\s*(.+)\s*$/i) {
+                       @initial_cc = parse_address_line($1);
+                       next;
+               } elsif (/^Bcc:/i) {
+                       @initial_bcc = parse_address_line($1);
+                       next;
                }
+               print $c2 $_;
        }
        close $c;
+       close $c2;
 
-       open my $c2, ">", $compose_filename . ".final"
-       or die sprintf(__("Failed to open %s.final: %s"), $compose_filename, $!);
-
-
-       if ($parsed_email{'From'}) {
-               $sender = delete($parsed_email{'From'});
-       }
-       if ($parsed_email{'In-Reply-To'}) {
-               $initial_in_reply_to = delete($parsed_email{'In-Reply-To'});
-       }
-       if ($parsed_email{'Reply-To'}) {
-               $reply_to = delete($parsed_email{'Reply-To'});
-       }
-       if ($parsed_email{'Subject'}) {
-               $initial_subject = delete($parsed_email{'Subject'});
-               print $c2 "Subject: " .
-                       quote_subject($initial_subject, $compose_encoding) .
-                       "\n";
-       }
-
-       if ($parsed_email{'MIME-Version'}) {
-               print $c2 "MIME-Version: $parsed_email{'MIME-Version'}\n",
-                               "Content-Type: $parsed_email{'Content-Type'};\n",
-                               "Content-Transfer-Encoding: $parsed_email{'Content-Transfer-Encoding'}\n";
-               delete($parsed_email{'MIME-Version'});
-               delete($parsed_email{'Content-Type'});
-               delete($parsed_email{'Content-Transfer-Encoding'});
-       } elsif (file_has_nonascii($compose_filename)) {
-               my $content_type = (delete($parsed_email{'Content-Type'}) or
-                       "text/plain; charset=$compose_encoding");
-               print $c2 "MIME-Version: 1.0\n",
-                       "Content-Type: $content_type\n",
-                       "Content-Transfer-Encoding: 8bit\n";
-       }
-       # Preserve unknown headers
-       foreach my $key (keys %parsed_email) {
-               next if $key eq 'body';
-               print $c2 "$key: $parsed_email{$key}";
-       }
-
-       if ($parsed_email{'body'}) {
-               print $c2 "\n$parsed_email{'body'}\n";
-               delete($parsed_email{'body'});
-       } else {
+       if ($summary_empty) {
                print __("Summary email is empty, skipping it\n");
                $compose = -1;
        }
-
-       close $c2;
-
 } elsif ($annotate) {
        do_edit(@files);
 }
@@ -1009,32 +983,6 @@ sub ask {
        return;
 }
 
-sub parse_header_line {
-       my $lines = shift;
-       my $parsed_line = shift;
-       my $addr_pat = join "|", qw(To Cc Bcc);
-
-       foreach (split(/\n/, $lines)) {
-               if (/^($addr_pat):\s*(.+)$/i) {
-                       $parsed_line->{$1} = [ parse_address_line($2) ];
-               } elsif (/^([^:]*):\s*(.+)\s*$/i) {
-                       $parsed_line->{$1} = $2;
-               }
-       }
-}
-
-sub filter_body {
-       my $c = shift;
-       my $body = "";
-       while (my $body_line = <$c>) {
-               if ($body_line !~ m/^GIT:/) {
-                       $body .= $body_line;
-               }
-       }
-       return $body;
-}
-
-
 my %broken_encoding;
 
 sub file_declares_8bit_cte {
@@ -1754,10 +1702,6 @@ EOF
        return 1;
 }
 
-$in_reply_to = $initial_in_reply_to;
-$references = $initial_in_reply_to || '';
-$message_num = 0;
-
 sub pre_process_file {
        my ($t, $quiet) = @_;
 
@@ -2023,6 +1967,38 @@ sub process_file {
        return 1;
 }
 
+sub initialize_modified_loop_vars {
+       $in_reply_to = $initial_in_reply_to;
+       $references = $initial_in_reply_to || '';
+       $message_num = 0;
+}
+
+if ($validate) {
+       # FIFOs can only be read once, exclude them from validation.
+       my @real_files = ();
+       foreach my $f (@files) {
+               unless (-p $f) {
+                       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";
+       initialize_modified_loop_vars();
+       foreach my $r (@real_files) {
+               $ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num";
+               pre_process_file($r, 1);
+               validate_patch($r, $target_xfer_encoding);
+               $num += 1;
+       }
+       delete $ENV{GIT_SENDEMAIL_FILE_COUNTER};
+       delete $ENV{GIT_SENDEMAIL_FILE_TOTAL};
+}
+
+initialize_modified_loop_vars();
 foreach my $t (@files) {
        while (!process_file($t)) {
                # user edited the file
diff --git a/graph.c b/graph.c
index 2a9dc430fae105c8d6fb5a8763320ae40fb1e5c8..1ca34770ee8139f25e0a2476c5aa3cd8b06fb89c 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -339,7 +339,6 @@ void graph_setup_line_prefix(struct diff_options *diffopt)
                diffopt->output_prefix = diff_output_prefix_callback;
 }
 
-
 struct git_graph *graph_init(struct rev_info *opt)
 {
        struct git_graph *graph = xmalloc(sizeof(struct git_graph));
diff --git a/grep.c b/grep.c
index 0904d55b244fb6f0e1b859cdd87be330c606d9e7..fc2d0c837a378d6a14da32fad69c0f3620447a21 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -17,7 +17,7 @@ static int grep_source_load(struct grep_source *gs);
 static int grep_source_is_binary(struct grep_source *gs,
                                 struct index_state *istate);
 
-static void std_output(struct grep_opt *opt, const void *buf, size_t size)
+static void std_output(struct grep_opt *opt UNUSED, const void *buf, size_t size)
 {
        fwrite(buf, size, 1, stdout);
 }
@@ -452,18 +452,20 @@ static void free_pcre2_pattern(struct grep_pat *p)
        pcre2_general_context_free(p->pcre2_general_context);
 }
 #else /* !USE_LIBPCRE2 */
-static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
+static void compile_pcre2_pattern(struct grep_pat *p UNUSED,
+                                 const struct grep_opt *opt UNUSED)
 {
        die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
 }
 
-static int pcre2match(struct grep_pat *p, const char *line, const char *eol,
-               regmatch_t *match, int eflags)
+static int pcre2match(struct grep_pat *p UNUSED, const char *line UNUSED,
+                     const char *eol UNUSED, regmatch_t *match UNUSED,
+                     int eflags UNUSED)
 {
        return 1;
 }
 
-static void free_pcre2_pattern(struct grep_pat *p)
+static void free_pcre2_pattern(struct grep_pat *p UNUSED)
 {
 }
 
diff --git a/hex-ll.c b/hex-ll.c
new file mode 100644 (file)
index 0000000..4d7ece1
--- /dev/null
+++ b/hex-ll.c
@@ -0,0 +1,49 @@
+#include "git-compat-util.h"
+#include "hex-ll.h"
+
+const signed char hexval_table[256] = {
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 00-07 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 08-0f */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 10-17 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 18-1f */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 20-27 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 28-2f */
+         0,  1,  2,  3,  4,  5,  6,  7,                /* 30-37 */
+         8,  9, -1, -1, -1, -1, -1, -1,                /* 38-3f */
+        -1, 10, 11, 12, 13, 14, 15, -1,                /* 40-47 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 48-4f */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 50-57 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 58-5f */
+        -1, 10, 11, 12, 13, 14, 15, -1,                /* 60-67 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 68-67 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 70-77 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 78-7f */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 80-87 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 88-8f */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 90-97 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* 98-9f */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* a0-a7 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* a8-af */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* b0-b7 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* b8-bf */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* c0-c7 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* c8-cf */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* d0-d7 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* d8-df */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* e0-e7 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* e8-ef */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* f0-f7 */
+        -1, -1, -1, -1, -1, -1, -1, -1,                /* f8-ff */
+};
+
+int hex_to_bytes(unsigned char *binary, const char *hex, size_t len)
+{
+       for (; len; len--, hex += 2) {
+               unsigned int val = (hexval(hex[0]) << 4) | hexval(hex[1]);
+
+               if (val & ~0xff)
+                       return -1;
+               *binary++ = val;
+       }
+       return 0;
+}
diff --git a/hex-ll.h b/hex-ll.h
new file mode 100644 (file)
index 0000000..a381fa8
--- /dev/null
+++ b/hex-ll.h
@@ -0,0 +1,27 @@
+#ifndef HEX_LL_H
+#define HEX_LL_H
+
+extern const signed char hexval_table[256];
+static inline unsigned int hexval(unsigned char c)
+{
+       return hexval_table[c];
+}
+
+/*
+ * Convert two consecutive hexadecimal digits into a char.  Return a
+ * negative value on error.  Don't run over the end of short strings.
+ */
+static inline int hex2chr(const char *s)
+{
+       unsigned int val = hexval(s[0]);
+       return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
+}
+
+/*
+ * Read `len` pairs of hexadecimal digits from `hex` and write the
+ * values to `binary` as `len` bytes. Return 0 on success, or -1 if
+ * the input does not consist of hex digits).
+ */
+int hex_to_bytes(unsigned char *binary, const char *hex, size_t len);
+
+#endif
diff --git a/hex.c b/hex.c
index 01f17fe5c906e6f8dd225b7c07bfb725a54a48a8..d42262bdca71a8703ce191393f0217f0c589a75e 100644 (file)
--- a/hex.c
+++ b/hex.c
@@ -2,53 +2,6 @@
 #include "hash.h"
 #include "hex.h"
 
-const signed char hexval_table[256] = {
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 00-07 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 08-0f */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 10-17 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 18-1f */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 20-27 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 28-2f */
-         0,  1,  2,  3,  4,  5,  6,  7,                /* 30-37 */
-         8,  9, -1, -1, -1, -1, -1, -1,                /* 38-3f */
-        -1, 10, 11, 12, 13, 14, 15, -1,                /* 40-47 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 48-4f */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 50-57 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 58-5f */
-        -1, 10, 11, 12, 13, 14, 15, -1,                /* 60-67 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 68-67 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 70-77 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 78-7f */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 80-87 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 88-8f */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 90-97 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* 98-9f */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* a0-a7 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* a8-af */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* b0-b7 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* b8-bf */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* c0-c7 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* c8-cf */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* d0-d7 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* d8-df */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* e0-e7 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* e8-ef */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* f0-f7 */
-        -1, -1, -1, -1, -1, -1, -1, -1,                /* f8-ff */
-};
-
-int hex_to_bytes(unsigned char *binary, const char *hex, size_t len)
-{
-       for (; len; len--, hex += 2) {
-               unsigned int val = (hexval(hex[0]) << 4) | hexval(hex[1]);
-
-               if (val & ~0xff)
-                       return -1;
-               *binary++ = val;
-       }
-       return 0;
-}
-
 static int get_hash_hex_algop(const char *hex, unsigned char *hash,
                              const struct git_hash_algo *algop)
 {
diff --git a/hex.h b/hex.h
index 87abf6660214151a50f45197572b6749c10944cc..e0b83f776f1a8cc62ab1694be4faf579051396b4 100644 (file)
--- a/hex.h
+++ b/hex.h
@@ -2,22 +2,7 @@
 #define HEX_H
 
 #include "hash-ll.h"
-
-extern const signed char hexval_table[256];
-static inline unsigned int hexval(unsigned char c)
-{
-       return hexval_table[c];
-}
-
-/*
- * Convert two consecutive hexadecimal digits into a char.  Return a
- * negative value on error.  Don't run over the end of short strings.
- */
-static inline int hex2chr(const char *s)
-{
-       unsigned int val = hexval(s[0]);
-       return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
-}
+#include "hex-ll.h"
 
 /*
  * Try to read a hash (specified by the_hash_algo) in hexadecimal
@@ -34,13 +19,6 @@ int get_oid_hex(const char *hex, struct object_id *oid);
 /* Like get_oid_hex, but for an arbitrary hash algorithm. */
 int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop);
 
-/*
- * Read `len` pairs of hexadecimal digits from `hex` and write the
- * values to `binary` as `len` bytes. Return 0 on success, or -1 if
- * the input does not consist of hex digits).
- */
-int hex_to_bytes(unsigned char *binary, const char *hex, size_t len);
-
 /*
  * Convert a binary hash in "unsigned char []" or an object name in
  * "struct object_id *" to its hex equivalent. The `_r` variant is reentrant,
index 06386e0b3bd878b163624f49e953686d4d49f8d1..996651e4f80abd5fa2daf570f9d981934d328aeb 100644 (file)
@@ -206,10 +206,14 @@ static void socket_perror(const char *func, struct imap_socket *sock, int ret)
                else
                        fprintf(stderr, "%s: unexpected EOF\n", func);
        }
+       /* mark as used to appease -Wunused-parameter with NO_OPENSSL */
+       (void)sock;
 }
 
 #ifdef NO_OPENSSL
-static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int verify)
+static int ssl_socket_connect(struct imap_socket *sock UNUSED,
+                             int use_tls_only UNUSED,
+                             int verify UNUSED)
 {
        fprintf(stderr, "SSL requested but SSL support not compiled in\n");
        return -1;
@@ -904,7 +908,9 @@ static char *cram(const char *challenge_64, const char *user, const char *pass)
 
 #else
 
-static char *cram(const char *challenge_64, const char *user, const char *pass)
+static char *cram(const char *challenge_64 UNUSED,
+                 const char *user UNUSED,
+                 const char *pass UNUSED)
 {
        die("If you want to use CRAM-MD5 authenticate method, "
            "you have to build git-imap-send with OpenSSL library.");
index e60a6cd5b46ef8ded2dfbbe86d75cd8d107f548d..c25c72b32c323c18da214fb7c0f5935556bb97a4 100644 (file)
@@ -14,6 +14,7 @@
 #include "packfile.h"
 #include "object-store-ll.h"
 #include "trace.h"
+#include "environment.h"
 
 struct traversal_context {
        struct rev_info *revs;
@@ -21,6 +22,7 @@ struct traversal_context {
        show_commit_fn show_commit;
        void *show_data;
        struct filter *filter;
+       int depth;
 };
 
 static void show_commit(struct traversal_context *ctx,
@@ -118,7 +120,9 @@ static void process_tree_contents(struct traversal_context *ctx,
                                    entry.path, oid_to_hex(&tree->object.oid));
                        }
                        t->object.flags |= NOT_USER_GIVEN;
+                       ctx->depth++;
                        process_tree(ctx, t, base, entry.path);
+                       ctx->depth--;
                }
                else if (S_ISGITLINK(entry.mode))
                        ; /* ignore gitlink */
@@ -156,6 +160,9 @@ static void process_tree(struct traversal_context *ctx,
            !revs->include_check_obj(&tree->object, revs->include_check_data))
                return;
 
+       if (ctx->depth > max_allowed_tree_depth)
+               die("exceeded maximum allowed tree depth");
+
        failed_parse = parse_tree_gently(tree, 1);
        if (failed_parse) {
                if (revs->ignore_missing_links)
@@ -349,6 +356,7 @@ static void traverse_non_commits(struct traversal_context *ctx,
                if (!path)
                        path = "";
                if (obj->type == OBJ_TREE) {
+                       ctx->depth = 0;
                        process_tree(ctx, (struct tree *)obj, base, path);
                        continue;
                }
index 208c69cbb79021ad471467292572c5587b103a6d..504da6b519edff523bd542d07684a4c27a6c10bb 100644 (file)
@@ -303,26 +303,43 @@ static void show_name(struct strbuf *sb, const struct name_decoration *decoratio
 
 /*
  * The caller makes sure there is no funny color before calling.
- * format_decorations_extended makes sure the same after return.
+ * format_decorations ensures the same after return.
  */
-void format_decorations_extended(struct strbuf *sb,
+void format_decorations(struct strbuf *sb,
                        const struct commit *commit,
                        int use_color,
-                       const char *prefix,
-                       const char *separator,
-                       const char *suffix)
+                       const struct decoration_options *opts)
 {
        const struct name_decoration *decoration;
        const struct name_decoration *current_and_HEAD;
-       const char *color_commit =
-               diff_get_color(use_color, DIFF_COMMIT);
-       const char *color_reset =
-               decorate_get_color(use_color, DECORATION_NONE);
+       const char *color_commit, *color_reset;
+
+       const char *prefix = " (";
+       const char *suffix = ")";
+       const char *separator = ", ";
+       const char *pointer = " -> ";
+       const char *tag = "tag: ";
 
        decoration = get_name_decoration(&commit->object);
        if (!decoration)
                return;
 
+       if (opts) {
+               if (opts->prefix)
+                       prefix = opts->prefix;
+               if (opts->suffix)
+                       suffix = opts->suffix;
+               if (opts->separator)
+                       separator = opts->separator;
+               if (opts->pointer)
+                       pointer = opts->pointer;
+               if (opts->tag)
+                       tag = opts->tag;
+       }
+
+       color_commit = diff_get_color(use_color, DIFF_COMMIT);
+       color_reset = decorate_get_color(use_color, DECORATION_NONE);
+
        current_and_HEAD = current_pointed_by_HEAD(decoration);
        while (decoration) {
                /*
@@ -331,31 +348,44 @@ void format_decorations_extended(struct strbuf *sb,
                 * appeared, skipping the entry for current.
                 */
                if (decoration != current_and_HEAD) {
-                       strbuf_addstr(sb, color_commit);
-                       strbuf_addstr(sb, prefix);
-                       strbuf_addstr(sb, color_reset);
-                       strbuf_addstr(sb, decorate_get_color(use_color, decoration->type));
-                       if (decoration->type == DECORATION_REF_TAG)
-                               strbuf_addstr(sb, "tag: ");
+                       const char *color =
+                               decorate_get_color(use_color, decoration->type);
+
+                       if (*prefix) {
+                               strbuf_addstr(sb, color_commit);
+                               strbuf_addstr(sb, prefix);
+                               strbuf_addstr(sb, color_reset);
+                       }
 
+                       if (*tag && decoration->type == DECORATION_REF_TAG) {
+                               strbuf_addstr(sb, color);
+                               strbuf_addstr(sb, tag);
+                               strbuf_addstr(sb, color_reset);
+                       }
+
+                       strbuf_addstr(sb, color);
                        show_name(sb, decoration);
+                       strbuf_addstr(sb, color_reset);
 
                        if (current_and_HEAD &&
                            decoration->type == DECORATION_REF_HEAD) {
-                               strbuf_addstr(sb, " -> ");
+                               strbuf_addstr(sb, color_commit);
+                               strbuf_addstr(sb, pointer);
                                strbuf_addstr(sb, color_reset);
                                strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type));
                                show_name(sb, current_and_HEAD);
+                               strbuf_addstr(sb, color_reset);
                        }
-                       strbuf_addstr(sb, color_reset);
 
                        prefix = separator;
                }
                decoration = decoration->next;
        }
-       strbuf_addstr(sb, color_commit);
-       strbuf_addstr(sb, suffix);
-       strbuf_addstr(sb, color_reset);
+       if (*suffix) {
+               strbuf_addstr(sb, color_commit);
+               strbuf_addstr(sb, suffix);
+               strbuf_addstr(sb, color_reset);
+       }
 }
 
 void show_decorations(struct rev_info *opt, struct commit *commit)
@@ -370,7 +400,7 @@ void show_decorations(struct rev_info *opt, struct commit *commit)
        }
        if (!opt->show_decorations)
                return;
-       format_decorations(&sb, commit, opt->diffopt.use_color);
+       format_decorations(&sb, commit, opt->diffopt.use_color, NULL);
        fputs(sb.buf, opt->diffopt.file);
        strbuf_release(&sb);
 }
index bdb64328154e519ceaa4138045ee4124c0fb3381..41c776fea52e6867800caf2eb919379fc6e54218 100644 (file)
@@ -13,17 +13,20 @@ struct decoration_filter {
        struct string_list *exclude_ref_config_pattern;
 };
 
+struct decoration_options {
+       char *prefix;
+       char *suffix;
+       char *separator;
+       char *pointer;
+       char *tag;
+};
+
 int parse_decorate_color_config(const char *var, const char *slot_name, const char *value);
 int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
 void show_log(struct rev_info *opt);
-void format_decorations_extended(struct strbuf *sb, const struct commit *commit,
-                            int use_color,
-                            const char *prefix,
-                            const char *separator,
-                            const char *suffix);
-#define format_decorations(strbuf, commit, color) \
-                            format_decorations_extended((strbuf), (commit), (color), " (", ", ", ")")
+void format_decorations(struct strbuf *sb, const struct commit *commit,
+                       int use_color, const struct decoration_options *opts);
 void show_decorations(struct rev_info *opt, struct commit *commit);
 void log_write_email_headers(struct rev_info *opt, struct commit *commit,
                             const char **extra_headers_p,
index 931505363cde08b0475f200e9c60fd3c034413b7..a07d2da16dedb2779a9797cfa185ec29d9321491 100644 (file)
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
-#include "hex.h"
+#include "hex-ll.h"
 #include "utf8.h"
 #include "strbuf.h"
 #include "mailinfo.h"
index e5e22e3583fddf2fcebcd01326f8a8a26c4f6864..6491070d965835f9202b68fbdae72cb6cd6c987f 100644 (file)
@@ -721,23 +721,6 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
        renames->callback_data_nr = renames->callback_data_alloc = 0;
 }
 
-__attribute__((format (printf, 2, 3)))
-static int err(struct merge_options *opt, const char *err, ...)
-{
-       va_list params;
-       struct strbuf sb = STRBUF_INIT;
-
-       strbuf_addstr(&sb, "error: ");
-       va_start(params, err);
-       strbuf_vaddf(&sb, err, params);
-       va_end(params);
-
-       error("%s", sb.buf);
-       strbuf_release(&sb);
-
-       return -1;
-}
-
 static void format_commit(struct strbuf *sb,
                          int indent,
                          struct repository *repo,
@@ -1919,6 +1902,7 @@ static void initialize_attr_index(struct merge_options *opt)
        struct index_state *attr_index = &opt->priv->attr_index;
        struct cache_entry *ce;
 
+       attr_index->repo = opt->repo;
        attr_index->initialized = 1;
 
        if (!opt->renormalize)
@@ -2122,13 +2106,12 @@ static int handle_content_merge(struct merge_options *opt,
                                          &result_buf);
 
                if ((merge_status < 0) || !result_buf.ptr)
-                       ret = err(opt, _("Failed to execute internal merge"));
+                       ret = error(_("failed to execute internal merge"));
 
                if (!ret &&
                    write_object_file(result_buf.ptr, result_buf.size,
                                      OBJ_BLOB, &result->oid))
-                       ret = err(opt, _("Unable to add %s to database"),
-                                 path);
+                       ret = error(_("unable to add %s to database"), path);
 
                free(result_buf.ptr);
                if (ret)
@@ -3342,10 +3325,7 @@ static int collect_renames(struct merge_options *opt,
        return clean;
 }
 
-static int detect_and_process_renames(struct merge_options *opt,
-                                     struct tree *merge_base,
-                                     struct tree *side1,
-                                     struct tree *side2)
+static int detect_and_process_renames(struct merge_options *opt)
 {
        struct diff_queue_struct combined = { 0 };
        struct rename_info *renames = &opt->priv->renames;
@@ -3509,8 +3489,7 @@ static int sort_dirs_next_to_their_children(const char *one, const char *two)
                return c1 - c2;
 }
 
-static int read_oid_strbuf(struct merge_options *opt,
-                          const struct object_id *oid,
+static int read_oid_strbuf(const struct object_id *oid,
                           struct strbuf *dst)
 {
        void *buf;
@@ -3518,10 +3497,10 @@ static int read_oid_strbuf(struct merge_options *opt,
        unsigned long size;
        buf = repo_read_object_file(the_repository, oid, &type, &size);
        if (!buf)
-               return err(opt, _("cannot read object %s"), oid_to_hex(oid));
+               return error(_("cannot read object %s"), oid_to_hex(oid));
        if (type != OBJ_BLOB) {
                free(buf);
-               return err(opt, _("object %s is not a blob"), oid_to_hex(oid));
+               return error(_("object %s is not a blob"), oid_to_hex(oid));
        }
        strbuf_attach(dst, buf, size, size + 1);
        return 0;
@@ -3545,8 +3524,8 @@ static int blob_unchanged(struct merge_options *opt,
        if (oideq(&base->oid, &side->oid))
                return 1;
 
-       if (read_oid_strbuf(opt, &base->oid, &basebuf) ||
-           read_oid_strbuf(opt, &side->oid, &sidebuf))
+       if (read_oid_strbuf(&base->oid, &basebuf) ||
+           read_oid_strbuf(&side->oid, &sidebuf))
                goto error_return;
        /*
         * Note: binary | is used so that both renormalizations are
@@ -4902,8 +4881,7 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
        trace2_region_leave("merge", "allocate/init", opt->repo);
 }
 
-static void merge_check_renames_reusable(struct merge_options *opt,
-                                        struct merge_result *result,
+static void merge_check_renames_reusable(struct merge_result *result,
                                         struct tree *merge_base,
                                         struct tree *side1,
                                         struct tree *side2)
@@ -4973,7 +4951,7 @@ redo:
                 * TRANSLATORS: The %s arguments are: 1) tree hash of a merge
                 * base, and 2-3) the trees for the two trees we're merging.
                 */
-               err(opt, _("collecting merge info failed for trees %s, %s, %s"),
+               error(_("collecting merge info failed for trees %s, %s, %s"),
                    oid_to_hex(&merge_base->object.oid),
                    oid_to_hex(&side1->object.oid),
                    oid_to_hex(&side2->object.oid));
@@ -4983,8 +4961,7 @@ redo:
        trace2_region_leave("merge", "collect_merge_info", opt->repo);
 
        trace2_region_enter("merge", "renames", opt->repo);
-       result->clean = detect_and_process_renames(opt, merge_base,
-                                                  side1, side2);
+       result->clean = detect_and_process_renames(opt);
        trace2_region_leave("merge", "renames", opt->repo);
        if (opt->priv->renames.redo_after_renames == 2) {
                trace2_region_enter("merge", "reset_maps", opt->repo);
@@ -5106,7 +5083,7 @@ void merge_incore_nonrecursive(struct merge_options *opt,
 
        trace2_region_enter("merge", "merge_start", opt->repo);
        assert(opt->ancestor != NULL);
-       merge_check_renames_reusable(opt, result, merge_base, side1, side2);
+       merge_check_renames_reusable(result, merge_base, side1, side2);
        merge_start(opt, result);
        /*
         * Record the trees used in this merge, so if there's a next merge in
index 6a4081bb0f522bf556610fa0e11239b5c7fcddb9..e3beb0801b115691d84b5da3403bc52abcb97336 100644 (file)
@@ -1383,12 +1383,12 @@ static int merge_mode_and_contents(struct merge_options *opt,
                                                  extra_marker_size);
 
                        if ((merge_status < 0) || !result_buf.ptr)
-                               ret = err(opt, _("Failed to execute internal merge"));
+                               ret = err(opt, _("failed to execute internal merge"));
 
                        if (!ret &&
                            write_object_file(result_buf.ptr, result_buf.size,
                                              OBJ_BLOB, &result->blob.oid))
-                               ret = err(opt, _("Unable to add %s to database"),
+                               ret = err(opt, _("unable to add %s to database"),
                                          a->path);
 
                        free(result_buf.ptr);
@@ -3912,6 +3912,22 @@ void init_merge_options(struct merge_options *opt,
                opt->buffer_output = 0;
 }
 
+/*
+ * For now, members of merge_options do not need deep copying, but
+ * it may change in the future, in which case we would need to update
+ * this, and also make a matching change to clear_merge_options() to
+ * release the resources held by a copied instance.
+ */
+void copy_merge_options(struct merge_options *dst, struct merge_options *src)
+{
+       *dst = *src;
+}
+
+void clear_merge_options(struct merge_options *opt UNUSED)
+{
+       ; /* no-op as our copy is shallow right now */
+}
+
 int parse_merge_opt(struct merge_options *opt, const char *s)
 {
        const char *arg;
index b88000e3c25277d07d20b7ba29755b9670cd28ff..3d3b3e3c295deb0dc8470958d01f8ed1e6ef0611 100644 (file)
@@ -55,6 +55,9 @@ struct merge_options {
 
 void init_merge_options(struct merge_options *opt, struct repository *repo);
 
+void copy_merge_options(struct merge_options *dst, struct merge_options *src);
+void clear_merge_options(struct merge_options *opt);
+
 /* parse the option in s and update the relevant field of opt */
 int parse_merge_opt(struct merge_options *opt, const char *s);
 
diff --git a/midx.c b/midx.c
index 931f55735037fcc4de53005ef0970e9ed3781885..2f3863c936a4c1c9035f90ae28b73887cf8f24b2 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -71,6 +71,33 @@ static int midx_read_oid_fanout(const unsigned char *chunk_start,
                error(_("multi-pack-index OID fanout is of the wrong size"));
                return 1;
        }
+       m->num_objects = ntohl(m->chunk_oid_fanout[255]);
+       return 0;
+}
+
+static int midx_read_oid_lookup(const unsigned char *chunk_start,
+                               size_t chunk_size, void *data)
+{
+       struct multi_pack_index *m = data;
+       m->chunk_oid_lookup = chunk_start;
+
+       if (chunk_size != st_mult(m->hash_len, m->num_objects)) {
+               error(_("multi-pack-index OID lookup chunk is the wrong size"));
+               return 1;
+       }
+       return 0;
+}
+
+static int midx_read_object_offsets(const unsigned char *chunk_start,
+                                   size_t chunk_size, void *data)
+{
+       struct multi_pack_index *m = data;
+       m->chunk_object_offsets = chunk_start;
+
+       if (chunk_size != st_mult(m->num_objects, MIDX_CHUNK_OFFSET_WIDTH)) {
+               error(_("multi-pack-index object offset chunk is the wrong size"));
+               return 1;
+       }
        return 0;
 }
 
@@ -140,33 +167,41 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
        cf = init_chunkfile(NULL);
 
        if (read_table_of_contents(cf, m->data, midx_size,
-                                  MIDX_HEADER_SIZE, m->num_chunks))
+                                  MIDX_HEADER_SIZE, m->num_chunks,
+                                  MIDX_CHUNK_ALIGNMENT))
                goto cleanup_fail;
 
-       if (pair_chunk(cf, MIDX_CHUNKID_PACKNAMES, &m->chunk_pack_names) == CHUNK_NOT_FOUND)
-               die(_("multi-pack-index missing required pack-name chunk"));
-       if (read_chunk(cf, MIDX_CHUNKID_OIDFANOUT, midx_read_oid_fanout, m) == CHUNK_NOT_FOUND)
-               die(_("multi-pack-index missing required OID fanout chunk"));
-       if (pair_chunk(cf, MIDX_CHUNKID_OIDLOOKUP, &m->chunk_oid_lookup) == CHUNK_NOT_FOUND)
-               die(_("multi-pack-index missing required OID lookup chunk"));
-       if (pair_chunk(cf, MIDX_CHUNKID_OBJECTOFFSETS, &m->chunk_object_offsets) == CHUNK_NOT_FOUND)
-               die(_("multi-pack-index missing required object offsets chunk"));
+       if (pair_chunk(cf, MIDX_CHUNKID_PACKNAMES, &m->chunk_pack_names, &m->chunk_pack_names_len))
+               die(_("multi-pack-index required pack-name chunk missing or corrupted"));
+       if (read_chunk(cf, MIDX_CHUNKID_OIDFANOUT, midx_read_oid_fanout, m))
+               die(_("multi-pack-index required OID fanout chunk missing or corrupted"));
+       if (read_chunk(cf, MIDX_CHUNKID_OIDLOOKUP, midx_read_oid_lookup, m))
+               die(_("multi-pack-index required OID lookup chunk missing or corrupted"));
+       if (read_chunk(cf, MIDX_CHUNKID_OBJECTOFFSETS, midx_read_object_offsets, m))
+               die(_("multi-pack-index required object offsets chunk missing or corrupted"));
 
-       pair_chunk(cf, MIDX_CHUNKID_LARGEOFFSETS, &m->chunk_large_offsets);
+       pair_chunk(cf, MIDX_CHUNKID_LARGEOFFSETS, &m->chunk_large_offsets,
+                  &m->chunk_large_offsets_len);
 
        if (git_env_bool("GIT_TEST_MIDX_READ_RIDX", 1))
-               pair_chunk(cf, MIDX_CHUNKID_REVINDEX, &m->chunk_revindex);
-
-       m->num_objects = ntohl(m->chunk_oid_fanout[255]);
+               pair_chunk(cf, MIDX_CHUNKID_REVINDEX, &m->chunk_revindex,
+                          &m->chunk_revindex_len);
 
        CALLOC_ARRAY(m->pack_names, m->num_packs);
        CALLOC_ARRAY(m->packs, m->num_packs);
 
        cur_pack_name = (const char *)m->chunk_pack_names;
        for (i = 0; i < m->num_packs; i++) {
+               const char *end;
+               size_t avail = m->chunk_pack_names_len -
+                               (cur_pack_name - (const char *)m->chunk_pack_names);
+
                m->pack_names[i] = cur_pack_name;
 
-               cur_pack_name += strlen(cur_pack_name) + 1;
+               end = memchr(cur_pack_name, '\0', avail);
+               if (!end)
+                       die(_("multi-pack-index pack-name chunk is too short"));
+               cur_pack_name = end + 1;
 
                if (i && strcmp(m->pack_names[i], m->pack_names[i - 1]) <= 0)
                        die(_("multi-pack-index pack names out of order: '%s' before '%s'"),
@@ -270,8 +305,9 @@ off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos)
                        die(_("multi-pack-index stores a 64-bit offset, but off_t is too small"));
 
                offset32 ^= MIDX_LARGE_OFFSET_NEEDED;
-               return get_be64(m->chunk_large_offsets +
-                               st_mult(sizeof(uint64_t), offset32));
+               if (offset32 >= m->chunk_large_offsets_len / sizeof(uint64_t))
+                       die(_("multi-pack-index large offset out of bounds"));
+               return get_be64(m->chunk_large_offsets + sizeof(uint64_t) * offset32);
        }
 
        return offset32;
diff --git a/midx.h b/midx.h
index 5578cd7b835e2b396e502e8abaf4560ab765c850..a5d98919c857b812789f44d86fb6ad13fb7e0560 100644 (file)
--- a/midx.h
+++ b/midx.h
@@ -32,11 +32,14 @@ struct multi_pack_index {
        int local;
 
        const unsigned char *chunk_pack_names;
+       size_t chunk_pack_names_len;
        const uint32_t *chunk_oid_fanout;
        const unsigned char *chunk_oid_lookup;
        const unsigned char *chunk_object_offsets;
        const unsigned char *chunk_large_offsets;
+       size_t chunk_large_offsets_len;
        const unsigned char *chunk_revindex;
+       size_t chunk_revindex_len;
 
        const char **pack_names;
        struct packed_git **packs;
index 7b729376867afee47c76aaf74901aa19f3615804..de39028ab7f88058c87f735a79185da2f3b5e749 100644 (file)
@@ -3,22 +3,24 @@
 #include "../commit.h"
 #include "../fetch-negotiator.h"
 
-static void known_common(struct fetch_negotiator *n, struct commit *c)
+static void known_common(struct fetch_negotiator *n UNUSED,
+                        struct commit *c UNUSED)
 {
        /* do nothing */
 }
 
-static void add_tip(struct fetch_negotiator *n, struct commit *c)
+static void add_tip(struct fetch_negotiator *n UNUSED,
+                   struct commit *c UNUSED)
 {
        /* do nothing */
 }
 
-static const struct object_id *next(struct fetch_negotiator *n)
+static const struct object_id *next(struct fetch_negotiator *n UNUSED)
 {
        return NULL;
 }
 
-static int ack(struct fetch_negotiator *n, struct commit *c)
+static int ack(struct fetch_negotiator *n UNUSED, struct commit *c UNUSED)
 {
        /*
         * This negotiator does not emit any commits, so there is no commit to
@@ -28,7 +30,7 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
        return 0;
 }
 
-static void release(struct fetch_negotiator *n)
+static void release(struct fetch_negotiator *n UNUSED)
 {
        /* nothing to release */
 }
index 7dc0c4bfbba87d1a9f42e3274764f7e07cc74c52..7c7afe5793641c06b10dee6f1f6735a1a476c7d9 100644 (file)
@@ -2446,11 +2446,11 @@ static int index_core(struct index_state *istate,
  * binary blobs, they generally do not want to get any conversion, and
  * callers should avoid this code path when filters are requested.
  */
-static int index_stream(struct object_id *oid, int fd, size_t size,
-                       enum object_type type, const char *path,
-                       unsigned flags)
+static int index_blob_stream(struct object_id *oid, int fd, size_t size,
+                            const char *path,
+                            unsigned flags)
 {
-       return index_bulk_checkin(oid, fd, size, type, path, flags);
+       return index_blob_bulk_checkin(oid, fd, size, path, flags);
 }
 
 int index_fd(struct index_state *istate, struct object_id *oid,
@@ -2472,8 +2472,8 @@ int index_fd(struct index_state *istate, struct object_id *oid,
                ret = index_core(istate, oid, fd, xsize_t(st->st_size),
                                 type, path, flags);
        else
-               ret = index_stream(oid, fd, xsize_t(st->st_size), type, path,
-                                  flags);
+               ret = index_blob_stream(oid, fd, xsize_t(st->st_size), path,
+                                       flags);
        close(fd);
        return ret;
 }
index f6757c3cbf2019b7cf41b3d82e0861138c92c075..f4ecdf8b0e3581cb6d92d0b88832c37adf749dc1 100644 (file)
@@ -413,15 +413,19 @@ static int fill_bitmap_commit(struct bb_commit *ent,
 
                if (old_bitmap && mapping) {
                        struct ewah_bitmap *old = bitmap_for_commit(old_bitmap, c);
+                       struct bitmap *remapped = bitmap_new();
                        /*
                         * If this commit has an old bitmap, then translate that
                         * bitmap and add its bits to this one. No need to walk
                         * parents or the tree for this commit.
                         */
-                       if (old && !rebuild_bitmap(mapping, old, ent->bitmap)) {
+                       if (old && !rebuild_bitmap(mapping, old, remapped)) {
+                               bitmap_or(ent->bitmap, remapped);
+                               bitmap_free(remapped);
                                reused_bitmaps_nr++;
                                continue;
                        }
+                       bitmap_free(remapped);
                }
 
                /*
index 6afc03d1e4c39e53c1c48deb51c16d65667979e8..ca8319b87c66f75941b43ab029d69e6eda19e3be 100644 (file)
@@ -1101,8 +1101,9 @@ static void show_boundary_commit(struct commit *commit, void *_data)
        }
 }
 
-static void show_boundary_object(struct object *object,
-                                const char *name, void *data)
+static void show_boundary_object(struct object *object UNUSED,
+                                const char *name UNUSED,
+                                void *data UNUSED)
 {
        BUG("should not be called");
 }
index 1b8052bececc1f9b0a2ef53f04d70334c1b57314..f403ca6986a9d4c68715c1e1b24462d462fb8aa9 100644 (file)
@@ -3,7 +3,7 @@
 #include "pack.h"
 #include "pack-objects.h"
 #include "packfile.h"
-#include "config.h"
+#include "parse.h"
 
 static uint32_t locate_object_entry_hash(struct packing_data *pdata,
                                         const struct object_id *oid,
index 7fffcad9125610cb05a5823b03b86d3e28eeabdb..acf1dd9786cd3c2a0cb410804721488b6d1d92b4 100644 (file)
@@ -6,7 +6,7 @@
 #include "packfile.h"
 #include "strbuf.h"
 #include "trace2.h"
-#include "config.h"
+#include "parse.h"
 #include "midx.h"
 #include "csum-file.h"
 
@@ -343,6 +343,17 @@ int verify_pack_revindex(struct packed_git *p)
        return res;
 }
 
+static int can_use_midx_ridx_chunk(struct multi_pack_index *m)
+{
+       if (!m->chunk_revindex)
+               return 0;
+       if (m->chunk_revindex_len != st_mult(sizeof(uint32_t), m->num_objects)) {
+               error(_("multi-pack-index reverse-index chunk is the wrong size"));
+               return 0;
+       }
+       return 1;
+}
+
 int load_midx_revindex(struct multi_pack_index *m)
 {
        struct strbuf revindex_name = STRBUF_INIT;
@@ -351,7 +362,7 @@ int load_midx_revindex(struct multi_pack_index *m)
        if (m->revindex_data)
                return 0;
 
-       if (m->chunk_revindex) {
+       if (can_use_midx_ridx_chunk(m)) {
                /*
                 * If the MIDX `m` has a `RIDX` chunk, then use its contents for
                 * the reverse index instead of trying to load a separate `.rev`
index a24521dee0fca3de6284a9c59cd3bd8cefdb4942..bdc7fae49719dfef060739854ae7491045afb6f2 100644 (file)
@@ -227,7 +227,9 @@ int parse_opt_strvec(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
-int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)
+int parse_opt_noop_cb(const struct option *opt UNUSED,
+                     const char *arg UNUSED,
+                     int unset UNUSED)
 {
        return 0;
 }
index 60224cf8d03fb1764ad26da422f7158898b631ea..e0c94b0546b5487c5b324c4c2b76d668289e8b10 100644 (file)
@@ -1,11 +1,12 @@
 #include "git-compat-util.h"
 #include "parse-options.h"
 #include "abspath.h"
-#include "config.h"
+#include "parse.h"
 #include "commit.h"
 #include "color.h"
 #include "gettext.h"
 #include "strbuf.h"
+#include "string-list.h"
 #include "utf8.h"
 
 static int disallow_abbreviated_options;
@@ -69,42 +70,10 @@ static void fix_filename(const char *prefix, char **file)
                *file = prefix_filename_except_for_dash(prefix, *file);
 }
 
-static enum parse_opt_result opt_command_mode_error(
-       const struct option *opt,
-       const struct option *all_opts,
-       enum opt_parsed flags)
-{
-       const struct option *that;
-       struct strbuf that_name = STRBUF_INIT;
-
-       /*
-        * Find the other option that was used to set the variable
-        * already, and report that this is not compatible with it.
-        */
-       for (that = all_opts; that->type != OPTION_END; that++) {
-               if (that == opt ||
-                   !(that->flags & PARSE_OPT_CMDMODE) ||
-                   that->value != opt->value ||
-                   that->defval != *(int *)opt->value)
-                       continue;
-
-               if (that->long_name)
-                       strbuf_addf(&that_name, "--%s", that->long_name);
-               else
-                       strbuf_addf(&that_name, "-%c", that->short_name);
-               error(_("%s is incompatible with %s"),
-                     optname(opt, flags), that_name.buf);
-               strbuf_release(&that_name);
-               return PARSE_OPT_ERROR;
-       }
-       return error(_("%s : incompatible with something else"),
-                    optname(opt, flags));
-}
-
-static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
-                                      const struct option *opt,
-                                      const struct option *all_opts,
-                                      enum opt_parsed flags)
+static enum parse_opt_result do_get_value(struct parse_opt_ctx_t *p,
+                                         const struct option *opt,
+                                         enum opt_parsed flags,
+                                         const char **argp)
 {
        const char *s, *arg;
        const int unset = flags & OPT_UNSET;
@@ -117,14 +86,6 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
        if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
                return error(_("%s takes no value"), optname(opt, flags));
 
-       /*
-        * Giving the same mode option twice, although unnecessary,
-        * is not a grave error, so let it pass.
-        */
-       if ((opt->flags & PARSE_OPT_CMDMODE) &&
-           *(int *)opt->value && *(int *)opt->value != opt->defval)
-               return opt_command_mode_error(opt, all_opts, flags);
-
        switch (opt->type) {
        case OPTION_LOWLEVEL_CALLBACK:
                return opt->ll_callback(p, opt, NULL, unset);
@@ -199,6 +160,8 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
                        p_unset = 0;
                        p_arg = arg;
                }
+               if (opt->flags & PARSE_OPT_CMDMODE)
+                       *argp = p_arg;
                if (opt->callback)
                        return (*opt->callback)(opt, p_arg, p_unset) ? (-1) : 0;
                else
@@ -246,16 +209,91 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
        }
 }
 
+struct parse_opt_cmdmode_list {
+       int value, *value_ptr;
+       const struct option *opt;
+       const char *arg;
+       enum opt_parsed flags;
+       struct parse_opt_cmdmode_list *next;
+};
+
+static void build_cmdmode_list(struct parse_opt_ctx_t *ctx,
+                              const struct option *opts)
+{
+       ctx->cmdmode_list = NULL;
+
+       for (; opts->type != OPTION_END; opts++) {
+               struct parse_opt_cmdmode_list *elem = ctx->cmdmode_list;
+               int *value_ptr = opts->value;
+
+               if (!(opts->flags & PARSE_OPT_CMDMODE) || !value_ptr)
+                       continue;
+
+               while (elem && elem->value_ptr != value_ptr)
+                       elem = elem->next;
+               if (elem)
+                       continue;
+
+               CALLOC_ARRAY(elem, 1);
+               elem->value_ptr = value_ptr;
+               elem->value = *value_ptr;
+               elem->next = ctx->cmdmode_list;
+               ctx->cmdmode_list = elem;
+       }
+}
+
+static char *optnamearg(const struct option *opt, const char *arg,
+                       enum opt_parsed flags)
+{
+       if (flags & OPT_SHORT)
+               return xstrfmt("-%c%s", opt->short_name, arg ? arg : "");
+       return xstrfmt("--%s%s%s%s", flags & OPT_UNSET ? "no-" : "",
+                      opt->long_name, arg ? "=" : "", arg ? arg : "");
+}
+
+static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
+                                      const struct option *opt,
+                                      enum opt_parsed flags)
+{
+       const char *arg = NULL;
+       enum parse_opt_result result = do_get_value(p, opt, flags, &arg);
+       struct parse_opt_cmdmode_list *elem = p->cmdmode_list;
+       char *opt_name, *other_opt_name;
+
+       for (; elem; elem = elem->next) {
+               if (*elem->value_ptr == elem->value)
+                       continue;
+
+               if (elem->opt &&
+                   (elem->opt->flags | opt->flags) & PARSE_OPT_CMDMODE)
+                       break;
+
+               elem->opt = opt;
+               elem->arg = arg;
+               elem->flags = flags;
+               elem->value = *elem->value_ptr;
+       }
+
+       if (result || !elem)
+               return result;
+
+       opt_name = optnamearg(opt, arg, flags);
+       other_opt_name = optnamearg(elem->opt, elem->arg, elem->flags);
+       error(_("%s is incompatible with %s"), opt_name, other_opt_name);
+       free(opt_name);
+       free(other_opt_name);
+       return -1;
+}
+
 static enum parse_opt_result parse_short_opt(struct parse_opt_ctx_t *p,
                                             const struct option *options)
 {
-       const struct option *all_opts = options;
        const struct option *numopt = NULL;
 
        for (; options->type != OPTION_END; options++) {
                if (options->short_name == *p->opt) {
                        p->opt = p->opt[1] ? p->opt + 1 : NULL;
-                       return get_value(p, options, all_opts, OPT_SHORT);
+                       return get_value(p, options, OPT_SHORT);
                }
 
                /*
@@ -317,7 +355,6 @@ static enum parse_opt_result parse_long_opt(
        struct parse_opt_ctx_t *p, const char *arg,
        const struct option *options)
 {
-       const struct option *all_opts = options;
        const char *arg_end = strchrnul(arg, '=');
        const struct option *abbrev_option = NULL, *ambiguous_option = NULL;
        enum opt_parsed abbrev_flags = OPT_LONG, ambiguous_flags = OPT_LONG;
@@ -386,7 +423,7 @@ is_abbreviated:
                                continue;
                        p->opt = rest + 1;
                }
-               return get_value(p, options, all_opts, flags ^ opt_flags);
+               return get_value(p, options, flags ^ opt_flags);
        }
 
        if (disallow_abbreviated_options && (ambiguous_option || abbrev_option))
@@ -404,7 +441,7 @@ is_abbreviated:
                return PARSE_OPT_HELP;
        }
        if (abbrev_option)
-               return get_value(p, abbrev_option, all_opts, abbrev_flags);
+               return get_value(p, abbrev_option, abbrev_flags);
        return PARSE_OPT_UNKNOWN;
 }
 
@@ -412,13 +449,11 @@ static enum parse_opt_result parse_nodash_opt(struct parse_opt_ctx_t *p,
                                              const char *arg,
                                              const struct option *options)
 {
-       const struct option *all_opts = options;
-
        for (; options->type != OPTION_END; options++) {
                if (!(options->flags & PARSE_OPT_NODASH))
                        continue;
                if (options->short_name == arg[0] && arg[1] == '\0')
-                       return get_value(p, options, all_opts, OPT_SHORT);
+                       return get_value(p, options, OPT_SHORT);
        }
        return PARSE_OPT_ERROR;
 }
@@ -573,6 +608,7 @@ static void parse_options_start_1(struct parse_opt_ctx_t *ctx,
            (flags & PARSE_OPT_KEEP_ARGV0))
                BUG("Can't keep argv0 if you don't have it");
        parse_options_check(options);
+       build_cmdmode_list(ctx, options);
 }
 
 void parse_options_start(struct parse_opt_ctx_t *ctx,
@@ -1005,6 +1041,11 @@ int parse_options(int argc, const char **argv,
        precompose_argv_prefix(argc, argv, NULL);
        free_preprocessed_options(real_options);
        free(ctx.alias_groups);
+       for (struct parse_opt_cmdmode_list *elem = ctx.cmdmode_list; elem;) {
+               struct parse_opt_cmdmode_list *next = elem->next;
+               free(elem);
+               elem = next;
+       }
        return parse_options_end(&ctx);
 }
 
@@ -1023,14 +1064,37 @@ static int usage_argh(const struct option *opts, FILE *outfile)
        return utf8_fprintf(outfile, s, opts->argh ? _(opts->argh) : _("..."));
 }
 
-#define USAGE_OPTS_WIDTH 24
-#define USAGE_GAP         2
+static int usage_indent(FILE *outfile)
+{
+       return fprintf(outfile, "    ");
+}
+
+#define USAGE_OPTS_WIDTH 26
+
+static void usage_padding(FILE *outfile, size_t pos)
+{
+       if (pos < USAGE_OPTS_WIDTH)
+               fprintf(outfile, "%*s", USAGE_OPTS_WIDTH - (int)pos, "");
+       else
+               fprintf(outfile, "\n%*s", USAGE_OPTS_WIDTH, "");
+}
+
+static const struct option *find_option_by_long_name(const struct option *opts,
+                                                    const char *long_name)
+{
+       for (; opts->type != OPTION_END; opts++) {
+               if (opts->long_name && !strcmp(opts->long_name, long_name))
+                       return opts;
+       }
+       return NULL;
+}
 
 static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t *ctx,
                                                         const char * const *usagestr,
                                                         const struct option *opts,
                                                         int full, int err)
 {
+       const struct option *all_opts = opts;
        FILE *outfile = err ? stderr : stdout;
        int need_newline;
 
@@ -1111,8 +1175,8 @@ static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t
 
        for (; opts->type != OPTION_END; opts++) {
                size_t pos;
-               int pad;
                const char *cp, *np;
+               const char *positive_name = NULL;
 
                if (opts->type == OPTION_SUBCOMMAND)
                        continue;
@@ -1131,7 +1195,7 @@ static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t
                        need_newline = 0;
                }
 
-               pos = fprintf(outfile, "    ");
+               pos = usage_indent(outfile);
                if (opts->short_name) {
                        if (opts->flags & PARSE_OPT_NODASH)
                                pos += fprintf(outfile, "%c", opts->short_name);
@@ -1140,8 +1204,15 @@ static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t
                }
                if (opts->long_name && opts->short_name)
                        pos += fprintf(outfile, ", ");
-               if (opts->long_name)
-                       pos += fprintf(outfile, "--%s", opts->long_name);
+               if (opts->long_name) {
+                       const char *long_name = opts->long_name;
+                       if ((opts->flags & PARSE_OPT_NONEG) ||
+                           skip_prefix(long_name, "no-", &positive_name))
+                               pos += fprintf(outfile, "--%s", long_name);
+                       else
+                               pos += fprintf(outfile, "--[no-]%s", long_name);
+               }
+
                if (opts->type == OPTION_NUMBER)
                        pos += utf8_fprintf(outfile, _("-NUM"));
 
@@ -1149,29 +1220,31 @@ static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t
                    !(opts->flags & PARSE_OPT_NOARG))
                        pos += usage_argh(opts, outfile);
 
-               if (pos == USAGE_OPTS_WIDTH + 1)
-                       pad = -1;
-               else if (pos <= USAGE_OPTS_WIDTH)
-                       pad = USAGE_OPTS_WIDTH - pos;
-               else {
-                       fputc('\n', outfile);
-                       pad = USAGE_OPTS_WIDTH;
-               }
                if (opts->type == OPTION_ALIAS) {
-                       fprintf(outfile, "%*s", pad + USAGE_GAP, "");
+                       usage_padding(outfile, pos);
                        fprintf_ln(outfile, _("alias of --%s"),
                                   (const char *)opts->value);
                        continue;
                }
 
-               for (cp = _(opts->help); *cp; cp = np) {
+               for (cp = opts->help ? _(opts->help) : ""; *cp; cp = np) {
                        np = strchrnul(cp, '\n');
-                       fprintf(outfile,
-                               "%*s%.*s\n", pad + USAGE_GAP, "",
-                               (int)(np - cp), cp);
                        if (*np)
                                np++;
-                       pad = USAGE_OPTS_WIDTH;
+                       usage_padding(outfile, pos);
+                       fwrite(cp, 1, np - cp, outfile);
+                       pos = 0;
+               }
+               fputc('\n', outfile);
+
+               if (positive_name) {
+                       if (find_option_by_long_name(all_opts, positive_name))
+                               continue;
+                       pos = usage_indent(outfile);
+                       pos += fprintf(outfile, "--%s", positive_name);
+                       usage_padding(outfile, pos);
+                       fprintf_ln(outfile, _("opposite of --no-%s"),
+                                  positive_name);
                }
        }
        fputc('\n', outfile);
index 4a66ec3bf5f4bfcae08297f4799bdd51222b3b81..bd62e20268d01d0e9d7afbcb300c440bb3adaa9f 100644 (file)
@@ -445,6 +445,8 @@ static inline void die_for_incompatible_opt3(int opt1, const char *opt1_name,
 
 /*----- incremental advanced APIs -----*/
 
+struct parse_opt_cmdmode_list;
+
 /*
  * It's okay for the caller to consume argv/argc in the usual way.
  * Other fields of that structure are private to parse-options and should not
@@ -459,6 +461,7 @@ struct parse_opt_ctx_t {
        unsigned has_subcommands;
        const char *prefix;
        const char **alias_groups; /* must be in groups of 3 elements! */
+       struct parse_opt_cmdmode_list *cmdmode_list;
 };
 
 void parse_options_start(struct parse_opt_ctx_t *ctx,
diff --git a/parse.c b/parse.c
new file mode 100644 (file)
index 0000000..42d691a
--- /dev/null
+++ b/parse.c
@@ -0,0 +1,182 @@
+#include "git-compat-util.h"
+#include "gettext.h"
+#include "parse.h"
+
+static uintmax_t get_unit_factor(const char *end)
+{
+       if (!*end)
+               return 1;
+       else if (!strcasecmp(end, "k"))
+               return 1024;
+       else if (!strcasecmp(end, "m"))
+               return 1024 * 1024;
+       else if (!strcasecmp(end, "g"))
+               return 1024 * 1024 * 1024;
+       return 0;
+}
+
+int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)
+{
+       if (value && *value) {
+               char *end;
+               intmax_t val;
+               intmax_t factor;
+
+               if (max < 0)
+                       BUG("max must be a positive integer");
+
+               errno = 0;
+               val = strtoimax(value, &end, 0);
+               if (errno == ERANGE)
+                       return 0;
+               if (end == value) {
+                       errno = EINVAL;
+                       return 0;
+               }
+               factor = get_unit_factor(end);
+               if (!factor) {
+                       errno = EINVAL;
+                       return 0;
+               }
+               if ((val < 0 && -max / factor > val) ||
+                   (val > 0 && max / factor < val)) {
+                       errno = ERANGE;
+                       return 0;
+               }
+               val *= factor;
+               *ret = val;
+               return 1;
+       }
+       errno = EINVAL;
+       return 0;
+}
+
+static int git_parse_unsigned(const char *value, uintmax_t *ret, uintmax_t max)
+{
+       if (value && *value) {
+               char *end;
+               uintmax_t val;
+               uintmax_t factor;
+
+               /* negative values would be accepted by strtoumax */
+               if (strchr(value, '-')) {
+                       errno = EINVAL;
+                       return 0;
+               }
+               errno = 0;
+               val = strtoumax(value, &end, 0);
+               if (errno == ERANGE)
+                       return 0;
+               if (end == value) {
+                       errno = EINVAL;
+                       return 0;
+               }
+               factor = get_unit_factor(end);
+               if (!factor) {
+                       errno = EINVAL;
+                       return 0;
+               }
+               if (unsigned_mult_overflows(factor, val) ||
+                   factor * val > max) {
+                       errno = ERANGE;
+                       return 0;
+               }
+               val *= factor;
+               *ret = val;
+               return 1;
+       }
+       errno = EINVAL;
+       return 0;
+}
+
+int git_parse_int(const char *value, int *ret)
+{
+       intmax_t tmp;
+       if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(int)))
+               return 0;
+       *ret = tmp;
+       return 1;
+}
+
+int git_parse_int64(const char *value, int64_t *ret)
+{
+       intmax_t tmp;
+       if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(int64_t)))
+               return 0;
+       *ret = tmp;
+       return 1;
+}
+
+int git_parse_ulong(const char *value, unsigned long *ret)
+{
+       uintmax_t tmp;
+       if (!git_parse_unsigned(value, &tmp, maximum_unsigned_value_of_type(long)))
+               return 0;
+       *ret = tmp;
+       return 1;
+}
+
+int git_parse_ssize_t(const char *value, ssize_t *ret)
+{
+       intmax_t tmp;
+       if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(ssize_t)))
+               return 0;
+       *ret = tmp;
+       return 1;
+}
+
+int git_parse_maybe_bool_text(const char *value)
+{
+       if (!value)
+               return 1;
+       if (!*value)
+               return 0;
+       if (!strcasecmp(value, "true")
+           || !strcasecmp(value, "yes")
+           || !strcasecmp(value, "on"))
+               return 1;
+       if (!strcasecmp(value, "false")
+           || !strcasecmp(value, "no")
+           || !strcasecmp(value, "off"))
+               return 0;
+       return -1;
+}
+
+int git_parse_maybe_bool(const char *value)
+{
+       int v = git_parse_maybe_bool_text(value);
+       if (0 <= v)
+               return v;
+       if (git_parse_int(value, &v))
+               return !!v;
+       return -1;
+}
+
+/*
+ * Parse environment variable 'k' as a boolean (in various
+ * possible spellings); if missing, use the default value 'def'.
+ */
+int git_env_bool(const char *k, int def)
+{
+       const char *v = getenv(k);
+       int val;
+       if (!v)
+               return def;
+       val = git_parse_maybe_bool(v);
+       if (val < 0)
+               die(_("bad boolean environment value '%s' for '%s'"),
+                   v, k);
+       return val;
+}
+
+/*
+ * Parse environment variable 'k' as ulong with possibly a unit
+ * suffix; if missing, use the default value 'val'.
+ */
+unsigned long git_env_ulong(const char *k, unsigned long val)
+{
+       const char *v = getenv(k);
+       if (v && !git_parse_ulong(v, &val))
+               die(_("failed to parse %s"), k);
+       return val;
+}
diff --git a/parse.h b/parse.h
new file mode 100644 (file)
index 0000000..07d2193
--- /dev/null
+++ b/parse.h
@@ -0,0 +1,20 @@
+#ifndef PARSE_H
+#define PARSE_H
+
+int git_parse_signed(const char *value, intmax_t *ret, intmax_t max);
+int git_parse_ssize_t(const char *, ssize_t *);
+int git_parse_ulong(const char *, unsigned long *);
+int git_parse_int(const char *value, int *ret);
+int git_parse_int64(const char *value, int64_t *ret);
+
+/**
+ * Same as `git_config_bool`, except that it returns -1 on error rather
+ * than dying.
+ */
+int git_parse_maybe_bool(const char *);
+int git_parse_maybe_bool_text(const char *value);
+
+int git_env_bool(const char *, int);
+unsigned long git_env_ulong(const char *, unsigned long);
+
+#endif /* PARSE_H */
index 3a3a5724c44bcb7b53d10ddce6f0f9f9f397512b..bb1efe1f3929f116a216de5cae6fa6b83227569e 100644 (file)
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "parse.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
@@ -467,7 +467,12 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
                match = prefix_path_gently(prefix, prefixlen,
                                           &prefixlen, copyfrom);
                if (!match) {
-                       const char *hint_path = get_git_work_tree();
+                       const char *hint_path;
+
+                       if (!have_git_dir())
+                               die(_("'%s' is outside the directory tree"),
+                                   copyfrom);
+                       hint_path = get_git_work_tree();
                        if (!hint_path)
                                hint_path = get_git_dir();
                        die(_("%s: '%s' is outside repository at '%s'"), elt,
index 3e4f897d935918092f3dfd1a05637b7176bd9fe1..ec08aa24add4e3da7c02b990ba1851665825c2b0 100644 (file)
@@ -412,7 +412,7 @@ There are some conventions that l10n contributors must follow:
 - Do not use non-ASCII characters in the subject of a commit.
 
 - The length of commit subject (first line of the commit log) should
-  be less than 50 characters, and the length of other lines of the
+  be no more than 50 characters, and the length of other lines of the
   commit log should be no more than 72 characters.
 
 - Add "Signed-off-by" trailer to your commit log, like other commits
index e44530c80cf51edfdff846ed476a16c9bae0047a..63fd35d64b141f6f1488c40c4fb34b1fe1e53ae0 100644 (file)
@@ -7,7 +7,7 @@
 #include "environment.h"
 #include "fsmonitor.h"
 #include "gettext.h"
-#include "config.h"
+#include "parse.h"
 #include "preload-index.h"
 #include "progress.h"
 #include "read-cache.h"
index 718530bbab5204b88972849abb95eabd0d3bedaf..cf964b060cd128e2bc271c07ed8bb8b4c28bfe29 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1252,8 +1252,8 @@ static int format_trailer_match_cb(const struct strbuf *key, void *ud)
        return 0;
 }
 
-static struct strbuf *expand_separator(struct strbuf *sb,
-                                      const char *argval, size_t arglen)
+static struct strbuf *expand_string_arg(struct strbuf *sb,
+                                       const char *argval, size_t arglen)
 {
        char *fmt = xstrndup(argval, arglen);
        const char *format = fmt;
@@ -1301,9 +1301,9 @@ int format_set_trailers_options(struct process_trailer_options *opts,
                        opts->filter_data = filter_list;
                        opts->only_trailers = 1;
                } else if (match_placeholder_arg_value(*arg, "separator", arg, &argval, &arglen)) {
-                       opts->separator = expand_separator(sepbuf, argval, arglen);
+                       opts->separator = expand_string_arg(sepbuf, argval, arglen);
                } else if (match_placeholder_arg_value(*arg, "key_value_separator", arg, &argval, &arglen)) {
-                       opts->key_value_separator = expand_separator(kvsepbuf, argval, arglen);
+                       opts->key_value_separator = expand_string_arg(kvsepbuf, argval, arglen);
                } else if (!match_placeholder_bool_arg(*arg, "only", arg, &opts->only_trailers) &&
                           !match_placeholder_bool_arg(*arg, "unfold", arg, &opts->unfold) &&
                           !match_placeholder_bool_arg(*arg, "keyonly", arg, &opts->key_only) &&
@@ -1384,6 +1384,44 @@ static size_t parse_describe_args(const char *start, struct strvec *args)
        return arg - start;
 }
 
+
+static int parse_decoration_option(const char **arg,
+                                  const char *name,
+                                  char **opt)
+{
+       const char *argval;
+       size_t arglen;
+
+       if (match_placeholder_arg_value(*arg, name, arg, &argval, &arglen)) {
+               struct strbuf sb = STRBUF_INIT;
+
+               expand_string_arg(&sb, argval, arglen);
+               *opt = strbuf_detach(&sb, NULL);
+               return 1;
+       }
+       return 0;
+}
+
+static void parse_decoration_options(const char **arg,
+                                    struct decoration_options *opts)
+{
+       while (parse_decoration_option(arg, "prefix", &opts->prefix) ||
+              parse_decoration_option(arg, "suffix", &opts->suffix) ||
+              parse_decoration_option(arg, "separator", &opts->separator) ||
+              parse_decoration_option(arg, "pointer", &opts->pointer) ||
+              parse_decoration_option(arg, "tag", &opts->tag))
+               ;
+}
+
+static void free_decoration_options(const struct decoration_options *opts)
+{
+       free(opts->prefix);
+       free(opts->suffix);
+       free(opts->separator);
+       free(opts->pointer);
+       free(opts->tag);
+}
+
 static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                                const char *placeholder,
                                void *context)
@@ -1537,11 +1575,18 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                strbuf_addstr(sb, get_revision_mark(NULL, commit));
                return 1;
        case 'd':
-               format_decorations(sb, commit, c->auto_color);
+               format_decorations(sb, commit, c->auto_color, NULL);
                return 1;
        case 'D':
-               format_decorations_extended(sb, commit, c->auto_color, "", ", ", "");
-               return 1;
+               {
+                       const struct decoration_options opts = {
+                               .prefix = "",
+                               .suffix = ""
+                       };
+
+                       format_decorations(sb, commit, c->auto_color, &opts);
+                       return 1;
+               }
        case 'S':               /* tag/branch like --source */
                if (!(c->pretty_ctx->rev && c->pretty_ctx->rev->sources))
                        return 0;
@@ -1638,6 +1683,23 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                return 2;
        }
 
+       if (skip_prefix(placeholder, "(decorate", &arg)) {
+               struct decoration_options opts = { NULL };
+               size_t ret = 0;
+
+               if (*arg == ':') {
+                       arg++;
+                       parse_decoration_options(&arg, &opts);
+               }
+               if (*arg == ')') {
+                       format_decorations(sb, commit, c->auto_color, &opts);
+                       ret = arg - placeholder + 1;
+               }
+
+               free_decoration_options(&opts);
+               return ret;
+       }
+
        /* For the rest we have to parse the commit header. */
        if (!c->commit_header_parsed) {
                msg = c->message =
@@ -1899,6 +1961,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
                case 'D':
                        w->decorate = 1;
                        break;
+               case '(':
+                       if (starts_with(fmt + 1, "decorate"))
+                               w->decorate = 1;
+                       break;
                }
        }
 }
index f695798acac72bd703dfacc59f83054fd761b619..c83cb60bf17eb490ccc3abc97a1b6f6679196e07 100644 (file)
@@ -17,7 +17,7 @@
 #include "trace.h"
 #include "trace2.h"
 #include "utf8.h"
-#include "config.h"
+#include "parse.h"
 
 #define TP_IDX_MAX      8
 
index 3baa33f63d87a675947bafcdfe3a798b02410de2..8935fe4dfb9414f101bf603aaf866ac6a1f6e027 100644 (file)
--- a/prompt.c
+++ b/prompt.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "parse.h"
 #include "environment.h"
 #include "run-command.h"
 #include "strbuf.h"
index ca5493984a59c8e067b420241091cb919f8e71c9..c45b6d849cbf4f97ec3d6eb893259837d25d9052 100644 (file)
@@ -60,7 +60,7 @@ static int read_patches(const char *range, struct string_list *list,
                     "--output-indicator-context=#",
                     "--no-abbrev-commit",
                     "--pretty=medium",
-                    "--notes",
+                    "--show-notes-by-default",
                     NULL);
        strvec_push(&cp.args, range);
        if (other_arg)
index 17a570f1ff97fab8e789d2960ae54894b1c42a80..69a1822da34ce7b5877c7aace0a770ef51c655fd 100644 (file)
--- a/rebase.c
+++ b/rebase.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "rebase.h"
-#include "config.h"
+#include "parse.h"
 #include "gettext.h"
 
 /*
index 9dbc4f71bd272a25423f131bbbbb23152a248be8..e4d3510e28e15a7ff967737f08a8c1acadb588e1 100644 (file)
@@ -13,6 +13,8 @@
 #include "oid-array.h"
 #include "repository.h"
 #include "commit.h"
+#include "mailmap.h"
+#include "ident.h"
 #include "remote.h"
 #include "color.h"
 #include "tag.h"
@@ -215,8 +217,16 @@ static struct used_atom {
                struct {
                        enum { O_SIZE, O_SIZE_DISK } option;
                } objectsize;
-               struct email_option {
-                       enum { EO_RAW, EO_TRIM, EO_LOCALPART } option;
+               struct {
+                       enum { N_RAW, N_MAILMAP } option;
+               } name_option;
+               struct {
+                       enum {
+                               EO_RAW = 0,
+                               EO_TRIM = 1<<0,
+                               EO_LOCALPART = 1<<1,
+                               EO_MAILMAP = 1<<2,
+                       } option;
                } email_option;
                struct {
                        enum { S_BARE, S_GRADE, S_SIGNER, S_KEY,
@@ -549,7 +559,8 @@ static int signature_atom_parser(struct ref_format *format UNUSED,
        return 0;
 }
 
-static int trailers_atom_parser(struct ref_format *format, struct used_atom *atom,
+static int trailers_atom_parser(struct ref_format *format UNUSED,
+                               struct used_atom *atom,
                                const char *arg, struct strbuf *err)
 {
        atom->u.contents.trailer_opts.no_divider = 1;
@@ -719,21 +730,55 @@ static int oid_atom_parser(struct ref_format *format UNUSED,
        return 0;
 }
 
-static int person_email_atom_parser(struct ref_format *format UNUSED,
-                                   struct used_atom *atom,
-                                   const char *arg, struct strbuf *err)
+static int person_name_atom_parser(struct ref_format *format UNUSED,
+                                  struct used_atom *atom,
+                                  const char *arg, struct strbuf *err)
 {
        if (!arg)
-               atom->u.email_option.option = EO_RAW;
-       else if (!strcmp(arg, "trim"))
-               atom->u.email_option.option = EO_TRIM;
-       else if (!strcmp(arg, "localpart"))
-               atom->u.email_option.option = EO_LOCALPART;
+               atom->u.name_option.option = N_RAW;
+       else if (!strcmp(arg, "mailmap"))
+               atom->u.name_option.option = N_MAILMAP;
        else
                return err_bad_arg(err, atom->name, arg);
        return 0;
 }
 
+static int email_atom_option_parser(struct used_atom *atom,
+                                   const char **arg, struct strbuf *err)
+{
+       if (!*arg)
+               return EO_RAW;
+       if (skip_prefix(*arg, "trim", arg))
+               return EO_TRIM;
+       if (skip_prefix(*arg, "localpart", arg))
+               return EO_LOCALPART;
+       if (skip_prefix(*arg, "mailmap", arg))
+               return EO_MAILMAP;
+       return -1;
+}
+
+static int person_email_atom_parser(struct ref_format *format UNUSED,
+                                   struct used_atom *atom,
+                                   const char *arg, struct strbuf *err)
+{
+       for (;;) {
+               int opt = email_atom_option_parser(atom, &arg, err);
+               const char *bad_arg = arg;
+
+               if (opt < 0)
+                       return err_bad_arg(err, atom->name, bad_arg);
+               atom->u.email_option.option |= opt;
+
+               if (!arg || !*arg)
+                       break;
+               if (*arg == ',')
+                       arg++;
+               else
+                       return err_bad_arg(err, atom->name, bad_arg);
+       }
+       return 0;
+}
+
 static int refname_atom_parser(struct ref_format *format UNUSED,
                               struct used_atom *atom,
                               const char *arg, struct strbuf *err)
@@ -821,7 +866,7 @@ static int if_atom_parser(struct ref_format *format UNUSED,
        return 0;
 }
 
-static int rest_atom_parser(struct ref_format *format,
+static int rest_atom_parser(struct ref_format *format UNUSED,
                            struct used_atom *atom UNUSED,
                            const char *arg, struct strbuf *err)
 {
@@ -830,7 +875,8 @@ static int rest_atom_parser(struct ref_format *format,
        return 0;
 }
 
-static int ahead_behind_atom_parser(struct ref_format *format, struct used_atom *atom,
+static int ahead_behind_atom_parser(struct ref_format *format,
+                                   struct used_atom *atom UNUSED,
                                    const char *arg, struct strbuf *err)
 {
        struct string_list_item *item;
@@ -875,15 +921,15 @@ static struct {
        [ATOM_TYPE] = { "type", SOURCE_OBJ },
        [ATOM_TAG] = { "tag", SOURCE_OBJ },
        [ATOM_AUTHOR] = { "author", SOURCE_OBJ },
-       [ATOM_AUTHORNAME] = { "authorname", SOURCE_OBJ },
+       [ATOM_AUTHORNAME] = { "authorname", SOURCE_OBJ, FIELD_STR, person_name_atom_parser },
        [ATOM_AUTHOREMAIL] = { "authoremail", SOURCE_OBJ, FIELD_STR, person_email_atom_parser },
        [ATOM_AUTHORDATE] = { "authordate", SOURCE_OBJ, FIELD_TIME },
        [ATOM_COMMITTER] = { "committer", SOURCE_OBJ },
-       [ATOM_COMMITTERNAME] = { "committername", SOURCE_OBJ },
+       [ATOM_COMMITTERNAME] = { "committername", SOURCE_OBJ, FIELD_STR, person_name_atom_parser },
        [ATOM_COMMITTEREMAIL] = { "committeremail", SOURCE_OBJ, FIELD_STR, person_email_atom_parser },
        [ATOM_COMMITTERDATE] = { "committerdate", SOURCE_OBJ, FIELD_TIME },
        [ATOM_TAGGER] = { "tagger", SOURCE_OBJ },
-       [ATOM_TAGGERNAME] = { "taggername", SOURCE_OBJ },
+       [ATOM_TAGGERNAME] = { "taggername", SOURCE_OBJ, FIELD_STR, person_name_atom_parser },
        [ATOM_TAGGEREMAIL] = { "taggeremail", SOURCE_OBJ, FIELD_STR, person_email_atom_parser },
        [ATOM_TAGGERDATE] = { "taggerdate", SOURCE_OBJ, FIELD_TIME },
        [ATOM_CREATOR] = { "creator", SOURCE_OBJ },
@@ -1484,32 +1530,49 @@ static const char *copy_name(const char *buf)
        return xstrdup("");
 }
 
+static const char *find_end_of_email(const char *email, int opt)
+{
+       const char *eoemail;
+
+       if (opt & EO_LOCALPART) {
+               eoemail = strchr(email, '@');
+               if (eoemail)
+                       return eoemail;
+               return strchr(email, '>');
+       }
+
+       if (opt & EO_TRIM)
+               return strchr(email, '>');
+
+       /*
+        * The option here is either the raw email option or the raw
+        * mailmap option (that is EO_RAW or EO_MAILMAP). In such cases,
+        * we directly grab the whole email including the closing
+        * angle brackets.
+        *
+        * If EO_MAILMAP was set with any other option (that is either
+        * EO_TRIM or EO_LOCALPART), we already grab the end of email
+        * above.
+        */
+       eoemail = strchr(email, '>');
+       if (eoemail)
+               eoemail++;
+       return eoemail;
+}
+
 static const char *copy_email(const char *buf, struct used_atom *atom)
 {
        const char *email = strchr(buf, '<');
        const char *eoemail;
+       int opt = atom->u.email_option.option;
+
        if (!email)
                return xstrdup("");
-       switch (atom->u.email_option.option) {
-       case EO_RAW:
-               eoemail = strchr(email, '>');
-               if (eoemail)
-                       eoemail++;
-               break;
-       case EO_TRIM:
-               email++;
-               eoemail = strchr(email, '>');
-               break;
-       case EO_LOCALPART:
+
+       if (opt & (EO_LOCALPART | EO_TRIM))
                email++;
-               eoemail = strchr(email, '@');
-               if (!eoemail)
-                       eoemail = strchr(email, '>');
-               break;
-       default:
-               BUG("unknown email option");
-       }
 
+       eoemail = find_end_of_email(email, opt);
        if (!eoemail)
                return xstrdup("");
        return xmemdupz(email, eoemail - email);
@@ -1570,16 +1633,23 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
        v->value = 0;
 }
 
+static struct string_list mailmap = STRING_LIST_INIT_NODUP;
+
 /* See grab_values */
 static void grab_person(const char *who, struct atom_value *val, int deref, void *buf)
 {
        int i;
        int wholen = strlen(who);
        const char *wholine = NULL;
+       const char *headers[] = { "author ", "committer ",
+                                 "tagger ", NULL };
 
        for (i = 0; i < used_atom_cnt; i++) {
-               const char *name = used_atom[i].name;
+               struct used_atom *atom = &used_atom[i];
+               const char *name = atom->name;
                struct atom_value *v = &val[i];
+               struct strbuf mailmap_buf = STRBUF_INIT;
+
                if (!!deref != (*name == '*'))
                        continue;
                if (deref)
@@ -1587,22 +1657,36 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void
                if (strncmp(who, name, wholen))
                        continue;
                if (name[wholen] != 0 &&
-                   strcmp(name + wholen, "name") &&
+                   !starts_with(name + wholen, "name") &&
                    !starts_with(name + wholen, "email") &&
                    !starts_with(name + wholen, "date"))
                        continue;
-               if (!wholine)
+
+               if ((starts_with(name + wholen, "name") &&
+                   (atom->u.name_option.option == N_MAILMAP)) ||
+                   (starts_with(name + wholen, "email") &&
+                   (atom->u.email_option.option & EO_MAILMAP))) {
+                       if (!mailmap.items)
+                               read_mailmap(&mailmap);
+                       strbuf_addstr(&mailmap_buf, buf);
+                       apply_mailmap_to_header(&mailmap_buf, headers, &mailmap);
+                       wholine = find_wholine(who, wholen, mailmap_buf.buf);
+               } else {
                        wholine = find_wholine(who, wholen, buf);
+               }
+
                if (!wholine)
                        return; /* no point looking for it */
                if (name[wholen] == 0)
                        v->s = copy_line(wholine);
-               else if (!strcmp(name + wholen, "name"))
+               else if (starts_with(name + wholen, "name"))
                        v->s = copy_name(wholine);
                else if (starts_with(name + wholen, "email"))
                        v->s = copy_email(wholine, &used_atom[i]);
                else if (starts_with(name + wholen, "date"))
                        grab_date(wholine, v, name);
+
+               strbuf_release(&mailmap_buf);
        }
 
        /*
index 341354182bbf10937dffc9de2c56645027f5cfcd..db5c0c7a724d57ad67250cb0be996ae5cfbc0372 100644 (file)
@@ -246,10 +246,8 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
        int dirnamelen = strlen(dirname);
        struct strbuf refname;
        struct strbuf path = STRBUF_INIT;
-       size_t path_baselen;
 
        files_ref_path(refs, &path, dirname);
-       path_baselen = path.len;
 
        d = opendir(path.buf);
        if (!d) {
@@ -262,23 +260,22 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
 
        while ((de = readdir(d)) != NULL) {
                struct object_id oid;
-               struct stat st;
                int flag;
+               unsigned char dtype;
 
                if (de->d_name[0] == '.')
                        continue;
                if (ends_with(de->d_name, ".lock"))
                        continue;
                strbuf_addstr(&refname, de->d_name);
-               strbuf_addstr(&path, de->d_name);
-               if (stat(path.buf, &st) < 0) {
-                       ; /* silently ignore */
-               } else if (S_ISDIR(st.st_mode)) {
+
+               dtype = get_dtype(de, &path, 1);
+               if (dtype == DT_DIR) {
                        strbuf_addch(&refname, '/');
                        add_entry_to_dir(dir,
                                         create_dir_entry(dir->cache, refname.buf,
                                                          refname.len));
-               } else {
+               } else if (dtype == DT_REG) {
                        if (!refs_resolve_ref_unsafe(&refs->base,
                                                     refname.buf,
                                                     RESOLVE_REF_READING,
@@ -308,7 +305,6 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
                                         create_ref_entry(refname.buf, &oid, flag));
                }
                strbuf_setlen(&refname, dirnamelen);
-               strbuf_setlen(&path, path_baselen);
        }
        strbuf_release(&refname);
        strbuf_release(&path);
index 2294c4564fba3e171334314a5623928c5f27c14a..6e3b725245c3e8df1ec666cc23ab51b718be1d1f 100644 (file)
@@ -412,7 +412,8 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
 
                if (level->prefix_state == PREFIX_WITHIN_DIR) {
                        entry_prefix_state = overlaps_prefix(entry->name, iter->prefix);
-                       if (entry_prefix_state == PREFIX_EXCLUDES_DIR)
+                       if (entry_prefix_state == PREFIX_EXCLUDES_DIR ||
+                           (entry_prefix_state == PREFIX_WITHIN_DIR && !(entry->flag & REF_DIR)))
                                continue;
                } else {
                        entry_prefix_state = level->prefix_state;
index 725c1b6a95cdedd89152a0f80b8fe2477751458e..09e19412859b3edb7be4142947d3967fc76520cc 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -1112,7 +1112,7 @@ int rerere_forget(struct repository *r, struct pathspec *pathspec)
         * recover the original conflicted state and then
         * find the conflicted paths.
         */
-       unmerge_index(r->index, pathspec);
+       unmerge_index(r->index, pathspec, 0);
        find_conflict(r, &conflict);
        for (i = 0; i < conflict.nr; i++) {
                struct string_list_item *it = &conflict.items[i];
index 7817f5d6db178519c23b4eea66785820cb4315ca..cd02dc99289997e5bf3ac57da3a0c5d482a8301d 100644 (file)
@@ -117,86 +117,59 @@ void resolve_undo_clear_index(struct index_state *istate)
        istate->cache_changed |= RESOLVE_UNDO_CHANGED;
 }
 
-int unmerge_index_entry_at(struct index_state *istate, int pos)
+int unmerge_index_entry(struct index_state *istate, const char *path,
+                       struct resolve_undo_info *ru, unsigned ce_flags)
 {
-       const struct cache_entry *ce;
-       struct string_list_item *item;
-       struct resolve_undo_info *ru;
-       int i, err = 0, matched;
-       char *name;
-
-       if (!istate->resolve_undo)
-               return pos;
-
-       ce = istate->cache[pos];
-       if (ce_stage(ce)) {
-               /* already unmerged */
-               while ((pos < istate->cache_nr) &&
-                      ! strcmp(istate->cache[pos]->name, ce->name))
-                       pos++;
-               return pos - 1; /* return the last entry processed */
+       int i = index_name_pos(istate, path, strlen(path));
+
+       if (i < 0) {
+               /* unmerged? */
+               i = -i - 1;
+               if (i < istate->cache_nr &&
+                   !strcmp(istate->cache[i]->name, path))
+                       /* yes, it is already unmerged */
+                       return 0;
+               /* fallthru: resolved to removal */
+       } else {
+               /* merged - remove it to replace it with unmerged entries */
+               remove_index_entry_at(istate, i);
        }
-       item = string_list_lookup(istate->resolve_undo, ce->name);
-       if (!item)
-               return pos;
-       ru = item->util;
-       if (!ru)
-               return pos;
-       matched = ce->ce_flags & CE_MATCHED;
-       name = xstrdup(ce->name);
-       remove_index_entry_at(istate, pos);
+
        for (i = 0; i < 3; i++) {
-               struct cache_entry *nce;
+               struct cache_entry *ce;
                if (!ru->mode[i])
                        continue;
-               nce = make_cache_entry(istate,
-                                      ru->mode[i],
-                                      &ru->oid[i],
-                                      name, i + 1, 0);
-               if (matched)
-                       nce->ce_flags |= CE_MATCHED;
-               if (add_index_entry(istate, nce, ADD_CACHE_OK_TO_ADD)) {
-                       err = 1;
-                       error("cannot unmerge '%s'", name);
-               }
+               ce = make_cache_entry(istate, ru->mode[i], &ru->oid[i],
+                                     path, i + 1, 0);
+               ce->ce_flags |= ce_flags;
+               if (add_index_entry(istate, ce, ADD_CACHE_OK_TO_ADD))
+                       return error("cannot unmerge '%s'", path);
        }
-       free(name);
-       if (err)
-               return pos;
-       free(ru);
-       item->util = NULL;
-       return unmerge_index_entry_at(istate, pos);
+       return 0;
 }
 
-void unmerge_marked_index(struct index_state *istate)
+void unmerge_index(struct index_state *istate, const struct pathspec *pathspec,
+                  unsigned ce_flags)
 {
-       int i;
+       struct string_list_item *item;
 
        if (!istate->resolve_undo)
                return;
 
        /* TODO: audit for interaction with sparse-index. */
        ensure_full_index(istate);
-       for (i = 0; i < istate->cache_nr; i++) {
-               const struct cache_entry *ce = istate->cache[i];
-               if (ce->ce_flags & CE_MATCHED)
-                       i = unmerge_index_entry_at(istate, i);
-       }
-}
 
-void unmerge_index(struct index_state *istate, const struct pathspec *pathspec)
-{
-       int i;
-
-       if (!istate->resolve_undo)
-               return;
-
-       /* TODO: audit for interaction with sparse-index. */
-       ensure_full_index(istate);
-       for (i = 0; i < istate->cache_nr; i++) {
-               const struct cache_entry *ce = istate->cache[i];
-               if (!ce_path_match(istate, ce, pathspec, NULL))
+       for_each_string_list_item(item, istate->resolve_undo) {
+               const char *path = item->string;
+               struct resolve_undo_info *ru = item->util;
+               if (!item->util)
+                       continue;
+               if (!match_pathspec(istate, pathspec,
+                                   item->string, strlen(item->string),
+                                   0, NULL, 0))
                        continue;
-               i = unmerge_index_entry_at(istate, i);
+               unmerge_index_entry(istate, path, ru, ce_flags);
+               free(ru);
+               item->util = NULL;
        }
 }
index c5deafc92fe7751532162ec308cf2bd62d97cf1b..f3f8462751bfd2e7fb2ab38b2632f059b8f07013 100644 (file)
@@ -17,8 +17,7 @@ void record_resolve_undo(struct index_state *, struct cache_entry *);
 void resolve_undo_write(struct strbuf *, struct string_list *);
 struct string_list *resolve_undo_read(const char *, unsigned long);
 void resolve_undo_clear_index(struct index_state *);
-int unmerge_index_entry_at(struct index_state *, int);
-void unmerge_index(struct index_state *, const struct pathspec *);
-void unmerge_marked_index(struct index_state *);
+int unmerge_index_entry(struct index_state *, const char *, struct resolve_undo_info *, unsigned);
+void unmerge_index(struct index_state *, const struct pathspec *, unsigned);
 
 #endif
index 0ae1c76db3e7c991e8333d81db874d072b7c8073..219dc76716fb0611ae8e7eb3dc10522d8779b213 100644 (file)
@@ -2484,6 +2484,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->break_bar = xstrdup(optarg);
                revs->track_linear = 1;
                revs->track_first_time = 1;
+       } else if (!strcmp(arg, "--show-notes-by-default")) {
+               revs->show_notes_by_default = 1;
        } else if (skip_prefix(arg, "--show-notes=", &optarg) ||
                   skip_prefix(arg, "--notes=", &optarg)) {
                if (starts_with(arg, "--show-notes=") &&
@@ -2788,13 +2790,13 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
 }
 
 static void read_revisions_from_stdin(struct rev_info *revs,
-                                     struct strvec *prune,
-                                     int *flags)
+                                     struct strvec *prune)
 {
        struct strbuf sb;
        int seen_dashdash = 0;
        int seen_end_of_options = 0;
        int save_warning;
+       int flags = 0;
 
        save_warning = warn_on_object_refname_ambiguity;
        warn_on_object_refname_ambiguity = 0;
@@ -2817,13 +2819,13 @@ static void read_revisions_from_stdin(struct rev_info *revs,
                                continue;
                        }
 
-                       if (handle_revision_pseudo_opt(revs, argv, flags) > 0)
+                       if (handle_revision_pseudo_opt(revs, argv, &flags) > 0)
                                continue;
 
                        die(_("invalid option '%s' in --stdin mode"), sb.buf);
                }
 
-               if (handle_revision_arg(sb.buf, revs, 0,
+               if (handle_revision_arg(sb.buf, revs, flags,
                                        REVARG_CANNOT_BE_FILENAME))
                        die("bad revision '%s'", sb.buf);
        }
@@ -2906,7 +2908,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                                }
                                if (revs->read_from_stdin++)
                                        die("--stdin given twice?");
-                               read_revisions_from_stdin(revs, &prune_data, &flags);
+                               read_revisions_from_stdin(revs, &prune_data);
                                continue;
                        }
 
@@ -3054,6 +3056,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
        if (revs->expand_tabs_in_log < 0)
                revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;
 
+       if (!revs->show_notes_given && revs->show_notes_by_default) {
+               enable_default_display_notes(&revs->notes_opt, &revs->show_notes);
+               revs->show_notes_given = 1;
+       }
+
        return left;
 }
 
index 82ab400139de30fd6af5e00f2047c51a62a8ed7d..50091bbd13f07ffd633446c6e0c392c01bd4152f 100644 (file)
@@ -253,6 +253,7 @@ struct rev_info {
                        shown_dashes:1,
                        show_merge:1,
                        show_notes_given:1,
+                       show_notes_by_default:1,
                        show_signature:1,
                        pretty_given:1,
                        abbrev_commit:1,
index 42f495c4b42fb152429ca596e0007fd53b774477..d584cac8ed9307caad0f8a9ede98d1f57ceab874 100644 (file)
@@ -438,10 +438,9 @@ struct commit_message {
        const char *message;
 };
 
-static const char *short_commit_name(struct commit *commit)
+static const char *short_commit_name(struct repository *r, struct commit *commit)
 {
-       return repo_find_unique_abbrev(the_repository, &commit->object.oid,
-                                      DEFAULT_ABBREV);
+       return repo_find_unique_abbrev(r, &commit->object.oid, DEFAULT_ABBREV);
 }
 
 static int get_message(struct commit *commit, struct commit_message *out)
@@ -451,7 +450,7 @@ static int get_message(struct commit *commit, struct commit_message *out)
 
        out->message = repo_logmsg_reencode(the_repository, commit, NULL,
                                            get_commit_output_encoding());
-       abbrev = short_commit_name(commit);
+       abbrev = short_commit_name(the_repository, commit);
 
        subject_len = find_commit_subject(out->message, &subject);
 
@@ -2263,6 +2262,8 @@ static int do_pick_commit(struct repository *r,
         */
 
        if (command == TODO_REVERT) {
+               const char *orig_subject;
+
                base = commit;
                base_label = msg.label;
                next = parent;
@@ -2270,6 +2271,15 @@ static int do_pick_commit(struct repository *r,
                if (opts->commit_use_reference) {
                        strbuf_addstr(&msgbuf,
                                "# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
+               } else if (skip_prefix(msg.subject, "Revert \"", &orig_subject) &&
+                          /*
+                           * We don't touch pre-existing repeated reverts, because
+                           * theoretically these can be nested arbitrarily deeply,
+                           * thus requiring excessive complexity to deal with.
+                           */
+                          !starts_with(orig_subject, "Revert \"")) {
+                       strbuf_addstr(&msgbuf, "Reapply \"");
+                       strbuf_addstr(&msgbuf, orig_subject);
                } else {
                        strbuf_addstr(&msgbuf, "Revert \"");
                        strbuf_addstr(&msgbuf, msg.subject);
@@ -2388,7 +2398,7 @@ static int do_pick_commit(struct repository *r,
                error(command == TODO_REVERT
                      ? _("could not revert %s... %s")
                      : _("could not apply %s... %s"),
-                     short_commit_name(commit), msg.subject);
+                     short_commit_name(r, commit), msg.subject);
                print_advice(r, res == 1, opts);
                repo_rerere(r, opts->allow_rerere_auto);
                goto leave;
@@ -2655,7 +2665,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
        return item->commit ? 0 : -1;
 }
 
-int sequencer_get_last_command(struct repository *r, enum replay_action *action)
+int sequencer_get_last_command(struct repository *r UNUSED, enum replay_action *action)
 {
        const char *todo_file, *bol;
        struct strbuf buf = STRBUF_INIT;
@@ -3177,7 +3187,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
                item->offset_in_buf = todo_list->buf.len;
                subject_len = find_commit_subject(commit_buffer, &subject);
                strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string,
-                       short_commit_name(commit), subject_len, subject);
+                       short_commit_name(the_repository, commit),
+                       subject_len, subject);
                repo_unuse_commit_buffer(the_repository, commit,
                                         commit_buffer);
        }
@@ -3598,7 +3609,7 @@ static int error_with_patch(struct repository *r,
        } else if (exit_code) {
                if (commit)
                        fprintf_ln(stderr, _("Could not apply %s... %.*s"),
-                                  short_commit_name(commit), subject_len, subject);
+                                  short_commit_name(r, commit), subject_len, subject);
                else
                        /*
                         * We don't have the hash of the parent so
@@ -4681,7 +4692,7 @@ static int pick_one_commit(struct repository *r,
                        if (!opts->verbose)
                                term_clear_line();
                        fprintf(stderr, _("Stopped at %s...  %.*s\n"),
-                               short_commit_name(commit), item->arg_len, arg);
+                               short_commit_name(r, commit), item->arg_len, arg);
                }
                return error_with_patch(r, commit,
                                        arg, item->arg_len, opts, res, !res);
@@ -5576,7 +5587,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
                if (!is_empty && (commit->object.flags & PATCHSAME)) {
                        if (flags & TODO_LIST_WARN_SKIPPED_CHERRY_PICKS)
                                warning(_("skipped previously applied commit %s"),
-                                       short_commit_name(commit));
+                                       short_commit_name(the_repository, commit));
                        skipped_commit = 1;
                        continue;
                }
@@ -5812,7 +5823,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
                if (!is_empty && (commit->object.flags & PATCHSAME)) {
                        if (flags & TODO_LIST_WARN_SKIPPED_CHERRY_PICKS)
                                warning(_("skipped previously applied commit %s"),
-                                       short_commit_name(commit));
+                                       short_commit_name(r, commit));
                        skipped_commit = 1;
                        continue;
                }
@@ -5904,7 +5915,8 @@ static void todo_list_add_exec_commands(struct todo_list *todo_list,
        todo_list->alloc = alloc;
 }
 
-static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_list,
+static void todo_list_to_strbuf(struct repository *r,
+                               struct todo_list *todo_list,
                                struct strbuf *buf, int num, unsigned flags)
 {
        struct todo_item *item;
@@ -5933,7 +5945,7 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
                /* add commit id */
                if (item->commit) {
                        const char *oid = flags & TODO_LIST_SHORTEN_IDS ?
-                                         short_commit_name(item->commit) :
+                                         short_commit_name(r, item->commit) :
                                          oid_to_hex(&item->commit->object.oid);
 
                        if (item->command == TODO_FIXUP) {
@@ -6292,7 +6304,7 @@ static int skip_fixupish(const char *subject, const char **p) {
 int todo_list_rearrange_squash(struct todo_list *todo_list)
 {
        struct hashmap subject2item;
-       int rearranged = 0, *next, *tail, i, nr = 0, alloc = 0;
+       int rearranged = 0, *next, *tail, i, nr = 0;
        char **subjects;
        struct commit_todo_item commit_todo;
        struct todo_item *items = NULL;
@@ -6404,6 +6416,8 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
        }
 
        if (rearranged) {
+               ALLOC_ARRAY(items, todo_list->nr);
+
                for (i = 0; i < todo_list->nr; i++) {
                        enum todo_command command = todo_list->items[i].command;
                        int cur = i;
@@ -6416,16 +6430,15 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
                                continue;
 
                        while (cur >= 0) {
-                               ALLOC_GROW(items, nr + 1, alloc);
                                items[nr++] = todo_list->items[cur];
                                cur = next[cur];
                        }
                }
 
+               assert(nr == todo_list->nr);
+               todo_list->alloc = nr;
                FREE_AND_NULL(todo_list->items);
                todo_list->items = items;
-               todo_list->nr = nr;
-               todo_list->alloc = alloc;
        }
 
        free(next);
index 1fdb07a9e69be2db0b03d283f0f100a1d2842ad2..3578feb28376e308ebb1ab1adc069c6860bbe72b 100644 (file)
@@ -391,7 +391,7 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
                strbuf_setlen(&base, 0);
                strbuf_add(&base, ce->name, strlen(ce->name));
 
-               read_tree_at(istate->repo, tree, &base, &ps,
+               read_tree_at(istate->repo, tree, &base, 0, &ps,
                             add_path_to_index, &ctx);
 
                /* free directory entries. full entries are re-used */
index 17bb8966c33d6d01644e237288491a77e1575c51..9367ca099cd114d56d7b2103b0e56fa4933f5781 100644 (file)
@@ -2,6 +2,22 @@
 #include "environment.h"
 #include "statinfo.h"
 
+/*
+ * Munge st_size into an unsigned int.
+ */
+static unsigned int munge_st_size(off_t st_size) {
+       unsigned int sd_size = st_size;
+
+       /*
+        * If the file is an exact multiple of 4 GiB, modify the value so it
+        * doesn't get marked as racily clean (zero).
+        */
+       if (!sd_size && st_size)
+               return 0x80000000;
+       else
+               return sd_size;
+}
+
 void fill_stat_data(struct stat_data *sd, struct stat *st)
 {
        sd->sd_ctime.sec = (unsigned int)st->st_ctime;
@@ -12,7 +28,7 @@ void fill_stat_data(struct stat_data *sd, struct stat *st)
        sd->sd_ino = st->st_ino;
        sd->sd_uid = st->st_uid;
        sd->sd_gid = st->st_gid;
-       sd->sd_size = st->st_size;
+       sd->sd_size = munge_st_size(st->st_size);
 }
 
 int match_stat_data(const struct stat_data *sd, struct stat *st)
@@ -51,7 +67,7 @@ int match_stat_data(const struct stat_data *sd, struct stat *st)
                        changed |= INODE_CHANGED;
 #endif
 
-       if (sd->sd_size != (unsigned int) st->st_size)
+       if (sd->sd_size != munge_st_size(st->st_size))
                changed |= DATA_CHANGED;
 
        return changed;
index 4c9ac6dc5e3cd34fd059ca3a20f8e98bd08b2d4a..7827178d8e5e374582357f48a14a77bb15d98320 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "hex.h"
+#include "hex-ll.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "utf8.h"
index fd43c46433a4b938f3c46a634db740b4c352a475..e959caca876ac759debb0c77cd7c6d1046cbc25d 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -12,9 +12,9 @@
 struct string_list;
 
 /**
- * strbuf's are meant to be used with all the usual C string and memory
+ * strbufs are meant to be used with all the usual C string and memory
  * APIs. Given that the length of the buffer is known, it's often better to
- * use the mem* functions than a str* one (memchr vs. strchr e.g.).
+ * use the mem* functions than a str* one (e.g., memchr vs. strchr).
  * Though, one has to be careful about the fact that str* functions often
  * stop on NULs and that strbufs may have embedded NULs.
  *
@@ -24,7 +24,7 @@ struct string_list;
  * strbufs have some invariants that are very important to keep in mind:
  *
  *  - The `buf` member is never NULL, so it can be used in any usual C
- *    string operations safely. strbuf's _have_ to be initialized either by
+ *    string operations safely. strbufs _have_ to be initialized either by
  *    `strbuf_init()` or by `= STRBUF_INIT` before the invariants, though.
  *
  *    Do *not* assume anything on what `buf` really is (e.g. if it is
@@ -37,7 +37,7 @@ struct string_list;
  *
  *  - The `buf` member is a byte array that has at least `len + 1` bytes
  *    allocated. The extra byte is used to store a `'\0'`, allowing the
- *    `buf` member to be a valid C-string. Every strbuf function ensure this
+ *    `buf` member to be a valid C-string. All strbuf functions ensure this
  *    invariant is preserved.
  *
  *    NOTE: It is OK to "play" with the buffer directly if you work it this
index 61080859899bef0de95e04070ab54484bf591345..a0ebe294848ddc3ea6abdd7b9308edce34f7a876 100644 (file)
--- a/t/README
+++ b/t/README
@@ -262,8 +262,8 @@ The argument for --run, <test-selector>, is a list of description
 substrings or globs or individual test numbers or ranges with an
 optional negation prefix (of '!') that define what tests in a test
 suite to include (or exclude, if negated) in the run.  A range is two
-numbers separated with a dash and matches a range of tests with both
-ends been included.  You may omit the first or the second number to
+numbers separated with a dash and specifies an inclusive range of tests
+to run.  You may omit the first or the second number to
 mean "from the first test" or "up to the very last test" respectively.
 
 The argument to --run is split on commas into separate strings,
@@ -274,10 +274,10 @@ text that you want to match includes a comma, use the glob character
 on all tests that match either the glob *rebase* or the glob
 *merge?cherry-pick*.
 
-If --run starts with an unprefixed number or range the initial
-set of tests to run is empty. If the first item starts with '!'
+If --run starts with an unprefixed number or range, the initial
+set of tests to run is empty.  If the first item starts with '!',
 all the tests are added to the initial set.  After initial set is
-determined every test number or range is added or excluded from
+determined, every test number or range is added or excluded from
 the set one by one, from left to right.
 
 For example, to run only tests up to a specific test (21), one
@@ -579,11 +579,11 @@ This test harness library does the following things:
 
 Recommended style
 -----------------
-Here are some recommented styles when writing test case.
 
- - Keep test title the same line with test helper function itself.
+ - Keep the test_expect_* function call and test title on
+   the same line.
 
-   Take test_expect_success helper for example, write it like:
+   For example, with test_expect_success, write it like:
 
   test_expect_success 'test title' '
       ... test body ...
@@ -595,10 +595,9 @@ Here are some recommented styles when writing test case.
       'test title' \
       '... test body ...'
 
+ - End the line with an opening single quote.
 
- - End the line with a single quote.
-
- - Indent the body of here-document, and use "<<-" instead of "<<"
+ - Indent here-document bodies, and use "<<-" instead of "<<"
    to strip leading TABs used for indentation:
 
   test_expect_success 'test something' '
@@ -624,7 +623,7 @@ Here are some recommented styles when writing test case.
   '
 
  - Quote or escape the EOF delimiter that begins a here-document if
-   there is no parameter and other expansion in it, to signal readers
+   there is no parameter or other expansion in it, to signal readers
    that they can skim it more casually:
 
   cmd <<-\EOF
@@ -638,7 +637,7 @@ Do's & don'ts
 Here are a few examples of things you probably should and shouldn't do
 when writing tests.
 
-Here are the "do's:"
+The "do's:"
 
  - Put all code inside test_expect_success and other assertions.
 
@@ -888,7 +887,7 @@ see test-lib-functions.sh for the full list and their options.
    rare case where your test depends on more than one:
 
        test_expect_success PERL,PYTHON 'yo dawg' \
-           ' test $(perl -E 'print eval "1 +" . qx[python -c "print 2"]') == "4" '
+           ' test $(perl -E '\''print eval "1 +" . qx[python -c "print(2)"]'\'') = "4" '
 
  - test_expect_failure [<prereq>] <message> <script>
 
@@ -1237,8 +1236,8 @@ and it knows that the object ID of an empty tree is a certain
 because the things the very basic core test tries to achieve is
 to serve as a basis for people who are changing the Git internals
 drastically.  For these people, after making certain changes,
-not seeing failures from the basic test _is_ a failure.  And
-such drastic changes to the core Git that even changes these
+not seeing failures from the basic test _is_ a failure.  Any
+Git core changes so drastic that they change even these
 otherwise supposedly stable object IDs should be accompanied by
 an update to t0000-basic.sh.
 
@@ -1248,7 +1247,7 @@ knowledge of the core Git internals.  If all the test scripts
 hardcoded the object IDs like t0000-basic.sh does, that defeats
 the purpose of t0000-basic.sh, which is to isolate that level of
 validation in one place.  Your test also ends up needing
-updating when such a change to the internal happens, so do _not_
+an update whenever the internals change, so do _not_
 do it and leave the low level of validation to t0000-basic.sh.
 
 Test coverage
index 66c88b8ff3d311573db482035aa143a0c1ad136f..1c486888a42d0da490f6b9a4d90941b09eda754b 100644 (file)
@@ -1,5 +1,5 @@
 #include "test-tool.h"
-#include "config.h"
+#include "parse.h"
 #include "parse-options.h"
 
 static char const * const env__helper_usage[] = {
diff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c
new file mode 100644 (file)
index 0000000..e8bd793
--- /dev/null
@@ -0,0 +1,50 @@
+#include "test-tool.h"
+#include "object-name.h"
+#include "object-store.h"
+#include "packfile.h"
+#include "parse-options.h"
+#include "setup.h"
+
+/*
+ * Display the path(s), one per line, of the packfile(s) containing
+ * the given object.
+ *
+ * If '--check-count <n>' is passed, then error out if the number of
+ * packfiles containing the object is not <n>.
+ */
+
+static const char *find_pack_usage[] = {
+       "test-tool find-pack [--check-count <n>] <object>",
+       NULL
+};
+
+int cmd__find_pack(int argc, const char **argv)
+{
+       struct object_id oid;
+       struct packed_git *p;
+       int count = -1, actual_count = 0;
+       const char *prefix = setup_git_directory();
+
+       struct option options[] = {
+               OPT_INTEGER('c', "check-count", &count, "expected number of packs"),
+               OPT_END(),
+       };
+
+       argc = parse_options(argc, argv, prefix, options, find_pack_usage, 0);
+       if (argc != 1)
+               usage(find_pack_usage[0]);
+
+       if (repo_get_oid(the_repository, argv[0], &oid))
+               die("cannot parse %s as an object name", argv[0]);
+
+       for (p = get_all_packs(the_repository); p; p = p->next)
+               if (find_pack_entry_one(oid.hash, p)) {
+                       printf("%s\n", p->pack_name);
+                       actual_count++;
+               }
+
+       if (count > -1 && count != actual_count)
+               die("bad packfile count %d instead of %d", actual_count, count);
+
+       return 0;
+}
diff --git a/t/helper/test-index-version.c b/t/helper/test-index-version.c
deleted file mode 100644 (file)
index f3c2dbe..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "test-tool.h"
-#include "read-cache-ll.h"
-
-int cmd__index_version(int argc UNUSED, const char **argv UNUSED)
-{
-       struct cache_header hdr;
-       int version;
-
-       memset(&hdr,0,sizeof(hdr));
-       if (read(0, &hdr, sizeof(hdr)) != sizeof(hdr))
-               return 0;
-       version = ntohl(hdr.hdr_version);
-       printf("%d\n", version);
-       return 0;
-}
index a4f6e24b0c6e1bf6557803921b5e9b21853791a3..ded8116cc5119f9d22d2d083cb8fa189e3783904 100644 (file)
@@ -21,6 +21,19 @@ static struct {
        int unset;
 } length_cb;
 
+static int mode34_callback(const struct option *opt, const char *arg, int unset)
+{
+       if (unset)
+               *(int *)opt->value = 0;
+       else if (!strcmp(arg, "3"))
+               *(int *)opt->value = 3;
+       else if (!strcmp(arg, "4"))
+               *(int *)opt->value = 4;
+       else
+               return error("invalid value for '%s': '%s'", "--mode34", arg);
+       return 0;
+}
+
 static int length_callback(const struct option *opt, const char *arg, int unset)
 {
        length_cb.called = 1;
@@ -124,6 +137,9 @@ int cmd__parse_options(int argc, const char **argv)
                OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
                OPT_CMDMODE(0, "mode1", &integer, "set integer to 1 (cmdmode option)", 1),
                OPT_CMDMODE(0, "mode2", &integer, "set integer to 2 (cmdmode option)", 2),
+               OPT_CALLBACK_F(0, "mode34", &integer, "(3|4)",
+                       "set integer to 3 or 4 (cmdmode option)",
+                       PARSE_OPT_CMDMODE, mode34_callback),
                OPT_CALLBACK('L', "length", &integer, "str",
                        "get length of <str>", length_callback),
                OPT_FILENAME('F', "file", &file, "set file to <file>"),
index 3d1436da59872fcfe7551a5586c7720893221ddb..941ae7e3bcf3eda6e88148d9ff9d923aea707ada 100644 (file)
@@ -278,7 +278,8 @@ static int daemon__run_server(void)
 
 static start_bg_wait_cb bg_wait_cb;
 
-static int bg_wait_cb(const struct child_process *cp, void *cb_data)
+static int bg_wait_cb(const struct child_process *cp UNUSED,
+                     void *cb_data UNUSED)
 {
        int s = ipc_get_active_state(cl_args.path);
 
index abe8a785eb651017ce2336eed7fa3bda06d4658c..876cd2dc313a73e48b55ba79488dbf2ea5887fa1 100644 (file)
@@ -31,6 +31,7 @@ static struct test_cmd cmds[] = {
        { "env-helper", cmd__env_helper },
        { "example-decorate", cmd__example_decorate },
        { "fast-rebase", cmd__fast_rebase },
+       { "find-pack", cmd__find_pack },
        { "fsmonitor-client", cmd__fsmonitor_client },
        { "genrandom", cmd__genrandom },
        { "genzeros", cmd__genzeros },
@@ -38,7 +39,6 @@ static struct test_cmd cmds[] = {
        { "hashmap", cmd__hashmap },
        { "hash-speed", cmd__hash_speed },
        { "hexdump", cmd__hexdump },
-       { "index-version", cmd__index_version },
        { "json-writer", cmd__json_writer },
        { "lazy-init-name-hash", cmd__lazy_init_name_hash },
        { "match-trees", cmd__match_trees },
@@ -86,6 +86,7 @@ static struct test_cmd cmds[] = {
        { "submodule-nested-repo-config", cmd__submodule_nested_repo_config },
        { "subprocess", cmd__subprocess },
        { "trace2", cmd__trace2 },
+       { "truncate", cmd__truncate },
        { "userdiff", cmd__userdiff },
        { "urlmatch-normalization", cmd__urlmatch_normalization },
        { "xml-encode", cmd__xml_encode },
index ea2672436c9ab56ed544d0a3ff414c366de5fdc0..70dd4eba11905083f325409955b1b0f8ec18a883 100644 (file)
@@ -25,6 +25,7 @@ int cmd__dump_reftable(int argc, const char **argv);
 int cmd__env_helper(int argc, const char **argv);
 int cmd__example_decorate(int argc, const char **argv);
 int cmd__fast_rebase(int argc, const char **argv);
+int cmd__find_pack(int argc, const char **argv);
 int cmd__fsmonitor_client(int argc, const char **argv);
 int cmd__genrandom(int argc, const char **argv);
 int cmd__genzeros(int argc, const char **argv);
@@ -32,7 +33,6 @@ int cmd__getcwd(int argc, const char **argv);
 int cmd__hashmap(int argc, const char **argv);
 int cmd__hash_speed(int argc, const char **argv);
 int cmd__hexdump(int argc, const char **argv);
-int cmd__index_version(int argc, const char **argv);
 int cmd__json_writer(int argc, const char **argv);
 int cmd__lazy_init_name_hash(int argc, const char **argv);
 int cmd__match_trees(int argc, const char **argv);
@@ -79,6 +79,7 @@ int cmd__submodule_config(int argc, const char **argv);
 int cmd__submodule_nested_repo_config(int argc, const char **argv);
 int cmd__subprocess(int argc, const char **argv);
 int cmd__trace2(int argc, const char **argv);
+int cmd__truncate(int argc, const char **argv);
 int cmd__userdiff(int argc, const char **argv);
 int cmd__urlmatch_normalization(int argc, const char **argv);
 int cmd__xml_encode(int argc, const char **argv);
index 20c7495f38593550a8a4dd35a957cc62cf3a2ded..d5ca0046c89fd434e5b4c5c4f28cb24d6a076bd2 100644 (file)
@@ -45,7 +45,7 @@ static int get_i(int *p_value, const char *data)
  * [] "def_param" events for all of the "interesting" pre-defined
  * config settings.
  */
-static int ut_001return(int argc, const char **argv)
+static int ut_001return(int argc UNUSED, const char **argv)
 {
        int rc;
 
@@ -65,7 +65,7 @@ static int ut_001return(int argc, const char **argv)
  * [] "def_param" events for all of the "interesting" pre-defined
  * config settings.
  */
-static int ut_002exit(int argc, const char **argv)
+static int ut_002exit(int argc UNUSED, const char **argv)
 {
        int rc;
 
@@ -201,7 +201,7 @@ static int ut_006data(int argc, const char **argv)
        return 0;
 }
 
-static int ut_007BUG(int argc, const char **argv)
+static int ut_007BUG(int argc UNUSED, const char **argv UNUSED)
 {
        /*
         * Exercise BUG() to ensure that the message is printed to trace2.
diff --git a/t/helper/test-truncate.c b/t/helper/test-truncate.c
new file mode 100644 (file)
index 0000000..3931dea
--- /dev/null
@@ -0,0 +1,25 @@
+#include "test-tool.h"
+#include "git-compat-util.h"
+
+/*
+ * Truncate a file to the given size.
+ */
+int cmd__truncate(int argc, const char **argv)
+{
+       char *p = NULL;
+       uintmax_t sz = 0;
+       int fd = -1;
+
+       if (argc != 3)
+               die("expected filename and size");
+
+       sz = strtoumax(argv[2], &p, 0);
+       if (*p)
+               die("invalid size");
+
+       fd = xopen(argv[1], O_WRONLY | O_CREAT, 0600);
+
+       if (ftruncate(fd, (off_t) sz) < 0)
+               die_errno("failed to truncate file");
+       return 0;
+}
diff --git a/t/lib-chunk.sh b/t/lib-chunk.sh
new file mode 100644 (file)
index 0000000..a7cd9c3
--- /dev/null
@@ -0,0 +1,17 @@
+# Shell library for working with "chunk" files (commit-graph, midx, etc).
+
+# corrupt_chunk_file <fn> <chunk> <offset> <bytes>
+#
+# Corrupt a chunk-based file (like a commit-graph) by overwriting the bytes
+# found in the chunk specified by the 4-byte <chunk> identifier. If <offset> is
+# "clear", replace the chunk entirely. Otherwise, overwrite data <offset> bytes
+# into the chunk.
+#
+# The <bytes> are interpreted as pairs of hex digits (so "000000FE" would be
+# big-endian 254).
+corrupt_chunk_file () {
+       fn=$1; shift
+       perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \
+               "$@" <"$fn" >"$fn.tmp" &&
+       mv "$fn.tmp" "$fn"
+}
diff --git a/t/lib-chunk/corrupt-chunk-file.pl b/t/lib-chunk/corrupt-chunk-file.pl
new file mode 100644 (file)
index 0000000..0e11aad
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+
+my ($chunk, $seek, $bytes) = @ARGV;
+$bytes =~ s/../chr(hex($&))/ge;
+
+binmode STDIN;
+binmode STDOUT;
+
+# A few helpers to read bytes, or read and copy them to the
+# output.
+sub get {
+       my $n = shift;
+       return unless $n;
+       read(STDIN, my $buf, $n)
+               or die "read error or eof: $!\n";
+       return $buf;
+}
+sub copy {
+       my $buf = get(@_);
+       print $buf;
+       return $buf;
+}
+
+# Some platforms' perl builds don't support 64-bit integers, and hence do not
+# allow packing/unpacking quadwords with "Q". The chunk format uses 64-bit file
+# offsets to support files of any size, but in practice our test suite will
+# only use small files. So we can fake it by asking for two 32-bit values and
+# discarding the first (most significant) one, which is equivalent as long as
+# it's just zero.
+sub unpack_quad {
+       my $bytes = shift;
+       my ($n1, $n2) = unpack("NN", $bytes);
+       die "quad value exceeds 32 bits" if $n1;
+       return $n2;
+}
+sub pack_quad {
+       my $n = shift;
+       my $ret = pack("NN", 0, $n);
+       # double check that our original $n did not exceed the 32-bit limit.
+       # This is presumably impossible on a 32-bit system (which would have
+       # truncated much earlier), but would still alert us on a 64-bit build
+       # of a new test that would fail on a 32-bit build (though we'd
+       # presumably see the die() from unpack_quad() in such a case).
+       die "quad round-trip failed" if unpack_quad($ret) != $n;
+       return $ret;
+}
+
+# read until we find table-of-contents entry for chunk;
+# note that we cheat a bit by assuming 4-byte alignment and
+# that no ToC entry will accidentally look like a header.
+#
+# If we don't find the entry, copy() will hit EOF and exit
+# (which should cause the caller to fail the test).
+while (copy(4) ne $chunk) { }
+my $offset = unpack_quad(copy(8));
+
+# In clear mode, our length will change. So figure out
+# the length by comparing to the offset of the next chunk, and
+# then adjust that offset (and all subsequent) ones.
+my $len;
+if ($seek eq "clear") {
+       my $id;
+       do {
+               $id = copy(4);
+               my $next = unpack_quad(get(8));
+               if (!defined $len) {
+                       $len = $next - $offset;
+               }
+               print pack_quad($next - $len + length($bytes));
+       } while (unpack("N", $id));
+}
+
+# and now copy up to our existing chunk data
+copy($offset - tell(STDIN));
+if ($seek eq "clear") {
+       # if clearing, skip past existing data
+       get($len);
+} else {
+       # otherwise, copy up to the requested offset,
+       # and skip past the overwritten bytes
+       copy($seek);
+       get(length($bytes));
+}
+
+# now write out the requested bytes, along
+# with any other remaining data
+print $bytes;
+while (read(STDIN, my $buf, 4096)) {
+       print $buf;
+}
index 032b2d8fcc48aa2cd72c60fa05f9b1299680f92c..15fc9a31e2cc03689e76876693e39367626784ff 100644 (file)
@@ -43,6 +43,8 @@ helper_test_clean() {
        reject $1 https example.com store-user
        reject $1 https example.com user1
        reject $1 https example.com user2
+       reject $1 https example.com user-expiry
+       reject $1 https example.com user-expiry-overwrite
        reject $1 https example.com user4
        reject $1 https example.com user-distinct-pass
        reject $1 https example.com user-overwrite
@@ -431,6 +433,81 @@ helper_test_timeout() {
        '
 }
 
+helper_test_password_expiry_utc() {
+       HELPER=$1
+
+       test_expect_success "helper ($HELPER) stores password_expiry_utc" '
+               check approve $HELPER <<-\EOF
+               protocol=https
+               host=example.com
+               username=user-expiry
+               password=pass
+               password_expiry_utc=9999999999
+               EOF
+       '
+
+       test_expect_success "helper ($HELPER) gets password_expiry_utc" '
+               check fill $HELPER <<-\EOF
+               protocol=https
+               host=example.com
+               username=user-expiry
+               --
+               protocol=https
+               host=example.com
+               username=user-expiry
+               password=pass
+               password_expiry_utc=9999999999
+               --
+               EOF
+       '
+
+       test_expect_success "helper ($HELPER) overwrites when password_expiry_utc changes" '
+               check approve $HELPER <<-\EOF &&
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               password=pass1
+               password_expiry_utc=9999999998
+               EOF
+               check approve $HELPER <<-\EOF &&
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               password=pass2
+               password_expiry_utc=9999999999
+               EOF
+               check fill $HELPER <<-\EOF &&
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               --
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               password=pass2
+               password_expiry_utc=9999999999
+               EOF
+               check reject $HELPER <<-\EOF &&
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               password=pass2
+               EOF
+               check fill $HELPER <<-\EOF
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               --
+               protocol=https
+               host=example.com
+               username=user-expiry-overwrite
+               password=askpass-password
+               --
+               askpass: Password for '\''https://user-expiry-overwrite@example.com'\'':
+               EOF
+       '
+}
+
 helper_test_oauth_refresh_token() {
        HELPER=$1
 
index 7ca5b918f0445cbb3097e531883861f5574e29a1..11d2dc9fe341b61d22c467ea8ae6a9d13ff1ac18 100644 (file)
@@ -8,18 +8,21 @@
 # - check that non-commit messages have a certain line count with $EXPECT_COUNT
 # - check the commit count in the commit message header with $EXPECT_HEADER_COUNT
 # - rewrite a rebase -i script as directed by $FAKE_LINES.
-#   $FAKE_LINES consists of a sequence of words separated by spaces.
-#   The following word combinations are possible:
+#   $FAKE_LINES consists of a sequence of words separated by spaces;
+#   spaces inside the words are encoded as underscores.
+#   The following words are possible:
 #
-#   "<lineno>" -- add a "pick" line with the SHA1 taken from the
-#       specified line.
+#   "<cmd>" -- override the command for the next line specification. Can be
+#       "pick", "squash", "fixup[_-(c|C)]", "edit", "reword", "drop",
+#       "merge[_-(c|C)_<rev>]", or "bad" for an invalid command.
 #
-#   "<cmd> <lineno>" -- add a line with the specified command
-#       ("pick", "squash", "fixup"|"fixup_-C"|"fixup_-c", "edit", "reword" or "drop")
-#       and the SHA1 taken from the specified line.
+#   "<lineno>" -- add a command, using the specified line as a template.
+#       If the command has not been overridden, the line will be copied
+#       verbatim, usually resulting in a "pick" line.
 #
-#   "_" -- add a space, like "fixup_-C" implies "fixup -C" and
-#       "exec_cmd_with_args" add an "exec cmd with args" line.
+#   "fakesha" -- add a command ("pick" by default), using a fake SHA1.
+#
+#   "exec_[command...]", "break" -- add the specified command.
 #
 #   "#" -- Add a comment line.
 #
@@ -49,7 +52,7 @@ set_fake_editor () {
        action=\&
        for line in $FAKE_LINES; do
                case $line in
-               pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d|label|l|reset|r|merge|m)
+               pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d|label|l|reset|t|merge|m)
                        action="$line";;
                exec_*|x_*|break|b)
                        echo "$line" | sed 's/_/ /g' >> "$1";;
@@ -64,7 +67,7 @@ set_fake_editor () {
                fakesha)
                        test \& != "$action" || action=pick
                        echo "$action XXXXXXX False commit" >> "$1"
-                       action=pick;;
+                       action=\&;;
                *)
                        sed -n "${line}s/^[a-z][a-z]*/$action/p" < "$1".tmp >> "$1"
                        action=\&;;
index 96ed3e1d69881541c82bdaf8c7f6b6fd8af97ef5..39e92b0841437bee9cbd939de6e216fae81a7ff2 100755 (executable)
@@ -134,5 +134,6 @@ test_perf_on_all git diff-files -- $SPARSE_CONE/a
 test_perf_on_all git diff-tree HEAD
 test_perf_on_all git diff-tree HEAD -- $SPARSE_CONE/a
 test_perf_on_all "git worktree add ../temp && git worktree remove ../temp"
+test_perf_on_all git check-attr -a -- $SPARSE_CONE/a
 
 test_done
index 26e082f05b4473a553b4de9b7747b928179439cd..ecf43ab54545a22ad52495af7cd728b04ac245bb 100755 (executable)
@@ -40,6 +40,10 @@ attr_check_source () {
        test_cmp expect actual &&
        test_must_be_empty err
 
+       git $git_opts -c "attr.tree=$source" check-attr test -- "$path" >actual 2>err &&
+       test_cmp expect actual &&
+       test_must_be_empty err
+
        GIT_ATTR_SOURCE="$source" git $git_opts check-attr test -- "$path" >actual 2>err &&
        test_cmp expect actual &&
        test_must_be_empty err
@@ -342,6 +346,74 @@ test_expect_success 'bare repository: check that .gitattribute is ignored' '
        )
 '
 
+bad_attr_source_err="fatal: bad --attr-source or GIT_ATTR_SOURCE"
+
+test_expect_success '--attr-source is bad' '
+       test_when_finished rm -rf empty &&
+       git init empty &&
+       (
+               cd empty &&
+               echo "$bad_attr_source_err" >expect_err &&
+               test_must_fail git --attr-source=HEAD check-attr test -- f/path 2>err &&
+               test_cmp expect_err err
+       )
+'
+
+test_expect_success 'attr.tree when HEAD is unborn' '
+       test_when_finished rm -rf empty &&
+       git init empty &&
+       (
+               cd empty &&
+               echo "f/path: test: unspecified" >expect &&
+               git -c attr.tree=HEAD check-attr test -- f/path >actual 2>err &&
+               test_must_be_empty err &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'bad attr source defaults to reading .gitattributes file' '
+       test_when_finished rm -rf empty &&
+       git init empty &&
+       (
+               cd empty &&
+               echo "f/path test=val" >.gitattributes &&
+               echo "f/path: test: val" >expect &&
+               git -c attr.tree=HEAD check-attr test -- f/path >actual 2>err &&
+               test_must_be_empty err &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'bare repo defaults to reading .gitattributes from HEAD' '
+       test_when_finished rm -rf test bare_with_gitattribute &&
+       git init test &&
+       test_commit -C test gitattributes .gitattributes "f/path test=val" &&
+       git clone --bare test bare_with_gitattribute &&
+       echo "f/path: test: val" >expect &&
+       git -C bare_with_gitattribute check-attr test -- f/path >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'precedence of --attr-source, GIT_ATTR_SOURCE, then attr.tree' '
+       test_when_finished rm -rf empty &&
+       git init empty &&
+       (
+               cd empty &&
+               git checkout -b attr-source &&
+               test_commit "val1" .gitattributes "f/path test=val1" &&
+               git checkout -b attr-tree &&
+               test_commit "val2" .gitattributes "f/path test=val2" &&
+               git checkout attr-source &&
+               echo "f/path: test: val1" >expect &&
+               GIT_ATTR_SOURCE=attr-source git -c attr.tree=attr-tree --attr-source=attr-source \
+               check-attr test -- f/path >actual &&
+               test_cmp expect actual &&
+               GIT_ATTR_SOURCE=attr-source git -c attr.tree=attr-tree \
+               check-attr test -- f/path >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_expect_success 'bare repository: with --source' '
        (
                cd bare.git &&
index e19a19963697a08255bb1b933631cdc90d57340d..06fb9e64576de8fa4c44a20cb86c4cf690569afd 100755 (executable)
@@ -13,30 +13,36 @@ usage: test-tool parse-options <options>
 
     A helper function for the parse-options API.
 
-    --yes                 get a boolean
+    --[no-]yes            get a boolean
     -D, --no-doubt        begins with 'no-'
+    --doubt               opposite of --no-doubt
     -B, --no-fear         be brave
-    -b, --boolean         increment by one
-    -4, --or4             bitwise-or boolean with ...0100
-    --neg-or4             same as --no-or4
+    -b, --[no-]boolean    increment by one
+    -4, --[no-]or4        bitwise-or boolean with ...0100
+    --[no-]neg-or4        same as --no-or4
 
-    -i, --integer <n>     get a integer
+    -i, --[no-]integer <n>
+                          get a integer
     -j <n>                get a integer, too
     -m, --magnitude <n>   get a magnitude
-    --set23               set integer to 23
+    --[no-]set23          set integer to 23
     --mode1               set integer to 1 (cmdmode option)
     --mode2               set integer to 2 (cmdmode option)
-    -L, --length <str>    get length of <str>
-    -F, --file <file>     set file to <file>
+    --[no-]mode34 (3|4)   set integer to 3 or 4 (cmdmode option)
+    -L, --[no-]length <str>
+                          get length of <str>
+    -F, --[no-]file <file>
+                          set file to <file>
 
 String options
-    -s, --string <string> get a string
-    --string2 <str>       get another string
-    --st <st>             get another string (pervert ordering)
+    -s, --[no-]string <string>
+                          get a string
+    --[no-]string2 <str>  get another string
+    --[no-]st <st>        get another string (pervert ordering)
     -o <str>              get another string
     --longhelp            help text of this entry
                           spans multiple lines
-    --list <str>          add str to list
+    --[no-]list <str>     add str to list
 
 Magic arguments
     -NUM                  set integer to NUM
@@ -45,16 +51,17 @@ Magic arguments
     --no-ambiguous        negative ambiguity
 
 Standard options
-    --abbrev[=<n>]        use <n> digits to display object names
-    -v, --verbose         be verbose
-    -n, --dry-run         dry run
-    -q, --quiet           be quiet
-    --expect <string>     expected output in the variable dump
+    --[no-]abbrev[=<n>]   use <n> digits to display object names
+    -v, --[no-]verbose    be verbose
+    -n, --[no-]dry-run    dry run
+    -q, --[no-]quiet      be quiet
+    --[no-]expect <string>
+                          expected output in the variable dump
 
 Alias
-    -A, --alias-source <string>
+    -A, --[no-]alias-source <string>
                           get a string
-    -Z, --alias-target <string>
+    -Z, --[no-]alias-target <string>
                           alias of --alias-source
 
 EOF
@@ -360,19 +367,41 @@ test_expect_success 'OPT_NEGBIT() works' '
 '
 
 test_expect_success 'OPT_CMDMODE() works' '
-       test-tool parse-options --expect="integer: 1" --mode1
+       test-tool parse-options --expect="integer: 1" --mode1 &&
+       test-tool parse-options --expect="integer: 3" --mode34=3
 '
 
-test_expect_success 'OPT_CMDMODE() detects incompatibility' '
+test_expect_success 'OPT_CMDMODE() detects incompatibility (1)' '
        test_must_fail test-tool parse-options --mode1 --mode2 >output 2>output.err &&
        test_must_be_empty output &&
-       test_i18ngrep "incompatible with --mode" output.err
+       test_i18ngrep "mode1" output.err &&
+       test_i18ngrep "mode2" output.err &&
+       test_i18ngrep "is incompatible with" output.err
 '
 
-test_expect_success 'OPT_CMDMODE() detects incompatibility with something else' '
+test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '
        test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err &&
        test_must_be_empty output &&
-       test_i18ngrep "incompatible with something else" output.err
+       test_i18ngrep "mode2" output.err &&
+       test_i18ngrep "set23" output.err &&
+       test_i18ngrep "is incompatible with" output.err
+'
+
+test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '
+       test_must_fail test-tool parse-options --mode2 --set23 >output 2>output.err &&
+       test_must_be_empty output &&
+       test_i18ngrep "mode2" output.err &&
+       test_i18ngrep "set23" output.err &&
+       test_i18ngrep "is incompatible with" output.err
+'
+
+test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
+       test_must_fail test-tool parse-options --mode2 --mode34=3 \
+               >output 2>output.err &&
+       test_must_be_empty output &&
+       test_i18ngrep "mode2" output.err &&
+       test_i18ngrep "mode34.3" output.err &&
+       test_i18ngrep "is incompatible with" output.err
 '
 
 test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '
diff --git a/t/t0081-find-pack.sh b/t/t0081-find-pack.sh
new file mode 100755 (executable)
index 0000000..67b1121
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+test_description='test `test-tool find-pack`'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       test_commit one &&
+       test_commit two &&
+       test_commit three &&
+       test_commit four &&
+       test_commit five
+'
+
+test_expect_success 'repack everything into a single packfile' '
+       git repack -a -d --no-write-bitmap-index &&
+
+       head_commit_pack=$(test-tool find-pack HEAD) &&
+       head_tree_pack=$(test-tool find-pack HEAD^{tree}) &&
+       one_pack=$(test-tool find-pack HEAD:one.t) &&
+       three_pack=$(test-tool find-pack HEAD:three.t) &&
+       old_commit_pack=$(test-tool find-pack HEAD~4) &&
+
+       test-tool find-pack --check-count 1 HEAD &&
+       test-tool find-pack --check-count=1 HEAD^{tree} &&
+       ! test-tool find-pack --check-count=0 HEAD:one.t &&
+       ! test-tool find-pack -c 2 HEAD:one.t &&
+       test-tool find-pack -c 1 HEAD:three.t &&
+
+       # Packfile exists at the right path
+       case "$head_commit_pack" in
+               ".git/objects/pack/pack-"*".pack") true ;;
+               *) false ;;
+       esac &&
+       test -f "$head_commit_pack" &&
+
+       # Everything is in the same pack
+       test "$head_commit_pack" = "$head_tree_pack" &&
+       test "$head_commit_pack" = "$one_pack" &&
+       test "$head_commit_pack" = "$three_pack" &&
+       test "$head_commit_pack" = "$old_commit_pack"
+'
+
+test_expect_success 'add more packfiles' '
+       git rev-parse HEAD^{tree} HEAD:two.t HEAD:four.t >objects &&
+       git pack-objects .git/objects/pack/mypackname1 >packhash1 <objects &&
+
+       git rev-parse HEAD~ HEAD~^{tree} HEAD:five.t >objects &&
+       git pack-objects .git/objects/pack/mypackname2 >packhash2 <objects &&
+
+       head_commit_pack=$(test-tool find-pack HEAD) &&
+
+       # HEAD^{tree} is in 2 packfiles
+       test-tool find-pack HEAD^{tree} >head_tree_packs &&
+       grep "$head_commit_pack" head_tree_packs &&
+       grep mypackname1 head_tree_packs &&
+       ! grep mypackname2 head_tree_packs &&
+       test-tool find-pack --check-count 2 HEAD^{tree} &&
+       ! test-tool find-pack --check-count 1 HEAD^{tree} &&
+
+       # HEAD:five.t is also in 2 packfiles
+       test-tool find-pack HEAD:five.t >five_packs &&
+       grep "$head_commit_pack" five_packs &&
+       ! grep mypackname1 five_packs &&
+       grep mypackname2 five_packs &&
+       test-tool find-pack -c 2 HEAD:five.t &&
+       ! test-tool find-pack --check-count=0 HEAD:five.t
+'
+
+test_expect_success 'add more commits (as loose objects)' '
+       test_commit six &&
+       test_commit seven &&
+
+       test -z "$(test-tool find-pack HEAD)" &&
+       test -z "$(test-tool find-pack HEAD:six.t)" &&
+       test-tool find-pack --check-count 0 HEAD &&
+       test-tool find-pack -c 0 HEAD:six.t &&
+       ! test-tool find-pack -c 1 HEAD:seven.t
+'
+
+test_done
index f6998269beb4fea3f68f14ffae22b541a066e6b3..ae5b7dc31ffd6719226b2921d1c5f08b6f9758f6 100755 (executable)
@@ -65,7 +65,14 @@ test_expect_success '--output-directory puts the report in the provided dir' '
 
 test_expect_success 'incorrect arguments abort with usage' '
        test_must_fail git bugreport --false 2>output &&
-       test_i18ngrep usage output &&
+       grep usage output &&
+       test_path_is_missing git-bugreport-*
+'
+
+test_expect_success 'incorrect positional arguments abort with usage and hint' '
+       test_must_fail git bugreport false 2>output &&
+       grep usage output &&
+       grep false output &&
        test_path_is_missing git-bugreport-*
 '
 
index c02a3b5969c3d2265d1552132464df7135cd522b..8300faadea9a76f19e3d2c82f5ff600f38bfe18f 100755 (executable)
@@ -29,6 +29,7 @@ test_atexit 'git credential-cache exit'
 
 # test that the daemon works with no special setup
 helper_test cache
+helper_test_password_expiry_utc cache
 helper_test_oauth_refresh_token cache
 
 test_expect_success 'socket defaults to ~/.cache/git/credential/socket' '
index f028fd1418285107a90e170a6ea1cd7657e31bb8..095574bfc6edf2aaf835b2ff43bb8cd35f792591 100755 (executable)
@@ -45,6 +45,8 @@ test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
 helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
 
 helper_test "$GIT_TEST_CREDENTIAL_HELPER"
+helper_test_password_expiry_utc "$GIT_TEST_CREDENTIAL_HELPER"
+helper_test_oauth_refresh_token "$GIT_TEST_CREDENTIAL_HELPER"
 
 if test -z "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"; then
        say "# skipping timeout tests (GIT_TEST_CREDENTIAL_HELPER_TIMEOUT not set)"
index 8a95adf4b50de6b543598ceac84f8515d9442f4d..2a4f35e98450f8ab499f11a1bafa777a82101136 100755 (executable)
@@ -2259,4 +2259,76 @@ test_expect_success 'worktree is not expanded' '
        ensure_not_expanded worktree remove .worktrees/hotfix
 '
 
+test_expect_success 'check-attr with pathspec inside sparse definition' '
+       init_repos &&
+
+       echo "a -crlf myAttr" >>.gitattributes &&
+       run_on_all cp ../.gitattributes ./deep &&
+
+       test_all_match git check-attr -a -- deep/a &&
+
+       test_all_match git add deep/.gitattributes &&
+       test_all_match git check-attr -a --cached -- deep/a
+'
+
+test_expect_success 'check-attr with pathspec outside sparse definition' '
+       init_repos &&
+
+       echo "a -crlf myAttr" >>.gitattributes &&
+       run_on_sparse mkdir folder1 &&
+       run_on_all cp ../.gitattributes ./folder1 &&
+       run_on_all cp a folder1/a &&
+
+       test_all_match git check-attr -a -- folder1/a &&
+
+       git -C full-checkout add folder1/.gitattributes &&
+       test_sparse_match git add --sparse folder1/.gitattributes &&
+       test_all_match git commit -m "add .gitattributes" &&
+       test_sparse_match git sparse-checkout reapply &&
+       test_all_match git check-attr -a --cached -- folder1/a
+'
+
+# NEEDSWORK: The 'diff --check' test is left as 'test_expect_failure' due
+# to an underlying issue in oneway_diff() within diff-lib.c.
+# 'do_oneway_diff()' is not called as expected for paths that could match
+# inside of a sparse directory. Specifically, the 'ce_path_match()' function
+# fails to recognize files inside a sparse directory (e.g., when 'folder1/'
+# is a sparse directory, 'folder1/a' cannot be recognized). The goal is to
+# proceed with 'do_oneway_diff()' if the pathspec could match inside of a
+# sparse directory.
+test_expect_failure 'diff --check with pathspec outside sparse definition' '
+       init_repos &&
+
+       write_script edit-contents <<-\EOF &&
+       echo "a " >"$1"
+       EOF
+
+       test_all_match git config core.whitespace -trailing-space,-space-before-tab &&
+
+       echo "a whitespace=trailing-space,space-before-tab" >>.gitattributes &&
+       run_on_all mkdir -p folder1 &&
+       run_on_all cp ../.gitattributes ./folder1 &&
+       test_all_match git add --sparse folder1/.gitattributes &&
+       run_on_all ../edit-contents folder1/a &&
+       test_all_match git add --sparse folder1/a &&
+
+       test_sparse_match git sparse-checkout reapply &&
+       test_all_match test_must_fail git diff --check --cached -- folder1/a
+'
+
+test_expect_success 'sparse-index is not expanded: check-attr' '
+       init_repos &&
+
+       echo "a -crlf myAttr" >>.gitattributes &&
+       mkdir ./sparse-index/folder1 &&
+       cp ./sparse-index/a ./sparse-index/folder1/a &&
+       cp .gitattributes ./sparse-index/deep &&
+       cp .gitattributes ./sparse-index/folder1 &&
+
+       git -C sparse-index add deep/.gitattributes &&
+       git -C sparse-index add --sparse folder1/.gitattributes &&
+       ensure_not_expanded check-attr -a --cached -- deep/a &&
+       ensure_not_expanded check-attr -a --cached -- folder1/a
+'
+
 test_done
index 6c45965b1e4bef9652a1bc876f28605ad213b261..09e7f3cdac8afcfebdf0558cd12159b7e367e26f 100755 (executable)
@@ -446,6 +446,29 @@ test_expect_success 'expire with multiple worktrees' '
        )
 '
 
+test_expect_success 'expire one of multiple worktrees' '
+       git init main-wt2 &&
+       (
+               cd main-wt2 &&
+               test_tick &&
+               test_commit foo &&
+               git worktree add link-wt &&
+               test_tick &&
+               test_commit -C link-wt foobar &&
+               test_tick &&
+               test-tool ref-store worktree:link-wt for-each-reflog-ent HEAD \
+                       >expect-link-wt &&
+               git reflog expire --verbose --all --expire=$test_tick \
+                       --single-worktree &&
+               test-tool ref-store worktree:main for-each-reflog-ent HEAD \
+                       >actual-main &&
+               test-tool ref-store worktree:link-wt for-each-reflog-ent HEAD \
+                       >actual-link-wt &&
+               test_must_be_empty actual-main &&
+               test_cmp expect-link-wt actual-link-wt
+       )
+'
+
 test_expect_success REFFILES 'empty reflog' '
        test_when_finished "rm -rf empty" &&
        git init empty &&
index 5805d47eb96c1eb72c761e50a8ba4670f5d7947a..10a539158c42ef7d5a7cdf0d602b0c92f43b7d6a 100755 (executable)
@@ -589,6 +589,16 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
        )
 '
 
+test_expect_success 'fsck notices excessively large tree entry name' '
+       git init large-name &&
+       (
+               cd large-name &&
+               test_commit a-long-name &&
+               git -c fsck.largePathname=warn:10 fsck 2>out &&
+               grep "warning.*large pathname" out
+       )
+'
+
 while read name path pretty; do
        while read mode type; do
                : ${pretty:=$path}
index 37ee5091b5caa7c087663cbb51f701084227c414..3f9e7f62e458c4db06a686700a15c5e08f47fad9 100755 (executable)
@@ -264,4 +264,27 @@ test_expect_success 'rev-parse --since= unsqueezed ordering' '
        test_cmp expect actual
 '
 
+test_expect_success 'rev-parse --bisect includes bad, excludes good' '
+       test_commit_bulk 6 &&
+
+       git update-ref refs/bisect/bad-1 HEAD~1 &&
+       git update-ref refs/bisect/b HEAD~2 &&
+       git update-ref refs/bisect/bad-3 HEAD~3 &&
+       git update-ref refs/bisect/good-3 HEAD~3 &&
+       git update-ref refs/bisect/bad-4 HEAD~4 &&
+       git update-ref refs/bisect/go HEAD~4 &&
+
+       # Note: refs/bisect/b and refs/bisect/go should be ignored because they
+       # do not match the refs/bisect/bad or refs/bisect/good prefixes.
+       cat >expect <<-EOF &&
+       refs/bisect/bad-1
+       refs/bisect/bad-3
+       refs/bisect/bad-4
+       ^refs/bisect/good-3
+       EOF
+
+       git rev-parse --symbolic-full-name --bisect >actual &&
+       test_cmp expect actual
+'
+
 test_done
index dd811b7fb467c4f3f27ef1be14427e022f73caeb..f0737593c3fda734060fa9509d1b9561086a7376 100755 (executable)
@@ -3,13 +3,29 @@
 test_description='test git rev-parse --parseopt'
 . ./test-lib.sh
 
+check_invalid_long_option () {
+       spec="$1"
+       opt="$2"
+       test_expect_success "test --parseopt invalid switch $opt help output for $spec" '
+               {
+                       cat <<-\EOF &&
+                       error: unknown option `'${opt#--}\''
+                       EOF
+                       sed -e 1d -e \$d <"$TEST_DIRECTORY/t1502/$spec.help"
+               } >expect &&
+               test_expect_code 129 git rev-parse --parseopt -- $opt \
+                       2>output <"$TEST_DIRECTORY/t1502/$spec" &&
+               test_cmp expect output
+       '
+}
+
 test_expect_success 'setup optionspec' '
        sed -e "s/^|//" >optionspec <<\EOF
 |some-command [options] <args>...
 |
 |some-command does foo and bar!
 |--
-|h,help    show the help
+|h,help!   show the help
 |
 |foo       some nifty option --foo
 |bar=      some cool option --bar with an argument
@@ -58,44 +74,8 @@ EOF
 '
 
 test_expect_success 'test --parseopt help output' '
-       sed -e "s/^|//" >expect <<\END_EXPECT &&
-|cat <<\EOF
-|usage: some-command [options] <args>...
-|
-|    some-command does foo and bar!
-|
-|    -h, --help            show the help
-|    --foo                 some nifty option --foo
-|    --bar ...             some cool option --bar with an argument
-|    -b, --baz             a short and long option
-|
-|An option group Header
-|    -C[...]               option C with an optional argument
-|    -d, --data[=...]      short and long option with an optional argument
-|
-|Argument hints
-|    -B <arg>              short option required argument
-|    --bar2 <arg>          long option required argument
-|    -e, --fuz <with-space>
-|                          short and long option required argument
-|    -s[<some>]            short option optional argument
-|    --long[=<data>]       long option optional argument
-|    -g, --fluf[=<path>]   short and long option optional argument
-|    --longest <very-long-argument-hint>
-|                          a very long argument hint
-|    --pair <key=value>    with an equals sign in the hint
-|    --aswitch             help te=t contains? fl*g characters!`
-|    --bswitch <hint>      hint has trailing tab character
-|    --cswitch             switch has trailing tab character
-|    --short-hint <a>      with a one symbol hint
-|
-|Extras
-|    --extra1              line above used to cause a segfault but no longer does
-|
-|EOF
-END_EXPECT
        test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec &&
-       test_cmp expect output
+       test_cmp "$TEST_DIRECTORY/t1502/optionspec.help" output
 '
 
 test_expect_success 'test --parseopt help output no switches' '
@@ -131,7 +111,7 @@ test_expect_success 'test --parseopt help-all output hidden switches' '
 |
 |    some-command does foo and bar!
 |
-|    --hidden1             A hidden switch
+|    --[no-]hidden1        A hidden switch
 |
 |EOF
 END_EXPECT
@@ -140,41 +120,12 @@ END_EXPECT
 '
 
 test_expect_success 'test --parseopt invalid switch help output' '
-       sed -e "s/^|//" >expect <<\END_EXPECT &&
-|error: unknown option `does-not-exist'\''
-|usage: some-command [options] <args>...
-|
-|    some-command does foo and bar!
-|
-|    -h, --help            show the help
-|    --foo                 some nifty option --foo
-|    --bar ...             some cool option --bar with an argument
-|    -b, --baz             a short and long option
-|
-|An option group Header
-|    -C[...]               option C with an optional argument
-|    -d, --data[=...]      short and long option with an optional argument
-|
-|Argument hints
-|    -B <arg>              short option required argument
-|    --bar2 <arg>          long option required argument
-|    -e, --fuz <with-space>
-|                          short and long option required argument
-|    -s[<some>]            short option optional argument
-|    --long[=<data>]       long option optional argument
-|    -g, --fluf[=<path>]   short and long option optional argument
-|    --longest <very-long-argument-hint>
-|                          a very long argument hint
-|    --pair <key=value>    with an equals sign in the hint
-|    --aswitch             help te=t contains? fl*g characters!`
-|    --bswitch <hint>      hint has trailing tab character
-|    --cswitch             switch has trailing tab character
-|    --short-hint <a>      with a one symbol hint
-|
-|Extras
-|    --extra1              line above used to cause a segfault but no longer does
-|
-END_EXPECT
+       {
+               cat <<-\EOF &&
+               error: unknown option `does-not-exist'\''
+               EOF
+               sed -e 1d -e \$d <"$TEST_DIRECTORY/t1502/optionspec.help"
+       } >expect &&
        test_expect_code 129 git rev-parse --parseopt -- --does-not-exist 1>/dev/null 2>output < optionspec &&
        test_cmp expect output
 '
@@ -288,7 +239,7 @@ test_expect_success 'test --parseopt help output: "wrapped" options normal "or:"
        |    [--another-option]
        |cmd [--yet-another-option]
        |--
-       |h,help    show the help
+       |h,help!   show the help
        EOF
 
        sed -e "s/^|//" >expect <<-\END_EXPECT &&
@@ -322,7 +273,7 @@ test_expect_success 'test --parseopt help output: multi-line blurb after empty l
        |line
        |blurb
        |--
-       |h,help    show the help
+       |h,help!   show the help
        EOF
 
        sed -e "s/^|//" >expect <<-\END_EXPECT &&
@@ -343,4 +294,32 @@ test_expect_success 'test --parseopt help output: multi-line blurb after empty l
        test_cmp expect actual
 '
 
+test_expect_success 'test --parseopt help output for optionspec-neg' '
+       test_expect_code 129 git rev-parse --parseopt -- \
+               -h >output <"$TEST_DIRECTORY/t1502/optionspec-neg" &&
+       test_cmp "$TEST_DIRECTORY/t1502/optionspec-neg.help" output
+'
+
+test_expect_success 'test --parseopt valid options for optionspec-neg' '
+       cat >expect <<-\EOF &&
+       set -- --foo --no-foo --no-bar --positive-only --no-negative --
+       EOF
+       git rev-parse --parseopt -- <"$TEST_DIRECTORY/t1502/optionspec-neg" >output \
+              --foo --no-foo --no-bar --positive-only --no-negative &&
+       test_cmp expect output
+'
+
+test_expect_success 'test --parseopt positivated option for optionspec-neg' '
+       cat >expect <<-\EOF &&
+       set -- --no-no-bar --no-no-bar --
+       EOF
+       git rev-parse --parseopt -- <"$TEST_DIRECTORY/t1502/optionspec-neg" >output \
+              --no-no-bar --bar &&
+       test_cmp expect output
+'
+
+check_invalid_long_option optionspec-neg --no-positive-only
+check_invalid_long_option optionspec-neg --negative
+check_invalid_long_option optionspec-neg --no-no-negative
+
 test_done
diff --git a/t/t1502/.gitattributes b/t/t1502/.gitattributes
new file mode 100644 (file)
index 0000000..562b12e
--- /dev/null
@@ -0,0 +1 @@
+* -whitespace
diff --git a/t/t1502/optionspec-neg b/t/t1502/optionspec-neg
new file mode 100644 (file)
index 0000000..392f43e
--- /dev/null
@@ -0,0 +1,8 @@
+some-command [options] <args>...
+
+some-command does foo and bar!
+--
+foo            can be negated
+no-bar         can be positivated
+positive-only! cannot be negated
+no-negative!   cannot be positivated
diff --git a/t/t1502/optionspec-neg.help b/t/t1502/optionspec-neg.help
new file mode 100644 (file)
index 0000000..7a29f8c
--- /dev/null
@@ -0,0 +1,12 @@
+cat <<\EOF
+usage: some-command [options] <args>...
+
+    some-command does foo and bar!
+
+    --[no-]foo            can be negated
+    --no-bar              can be positivated
+    --bar                 opposite of --no-bar
+    --positive-only       cannot be negated
+    --no-negative         cannot be positivated
+
+EOF
diff --git a/t/t1502/optionspec.help b/t/t1502/optionspec.help
new file mode 100755 (executable)
index 0000000..cbdd54d
--- /dev/null
@@ -0,0 +1,36 @@
+cat <<\EOF
+usage: some-command [options] <args>...
+
+    some-command does foo and bar!
+
+    -h, --help            show the help
+    --[no-]foo            some nifty option --foo
+    --[no-]bar ...        some cool option --bar with an argument
+    -b, --[no-]baz        a short and long option
+
+An option group Header
+    -C[...]               option C with an optional argument
+    -d, --[no-]data[=...] short and long option with an optional argument
+
+Argument hints
+    -B <arg>              short option required argument
+    --[no-]bar2 <arg>     long option required argument
+    -e, --[no-]fuz <with-space>
+                          short and long option required argument
+    -s[<some>]            short option optional argument
+    --[no-]long[=<data>]  long option optional argument
+    -g, --[no-]fluf[=<path>]
+                          short and long option optional argument
+    --[no-]longest <very-long-argument-hint>
+                          a very long argument hint
+    --[no-]pair <key=value>
+                          with an equals sign in the hint
+    --[no-]aswitch        help te=t contains? fl*g characters!`
+    --[no-]bswitch <hint> hint has trailing tab character
+    --[no-]cswitch        switch has trailing tab character
+    --[no-]short-hint <a> with a one symbol hint
+
+Extras
+    --[no-]extra1         line above used to cause a segfault but no longer does
+
+EOF
index 9368d82f7d70ca8133616ed40f167ae4344266c4..62e7fd15964bba7cbc8904471879027219368951 100755 (executable)
@@ -118,7 +118,7 @@ test_index_version () {
                fi &&
                git add a &&
                echo $EXPECTED_OUTPUT_VERSION >expect &&
-               test-tool index-version <.git/index >actual &&
+               git update-index --show-index-version >actual &&
                test_cmp expect actual
        )
 }
index b4ab166369ec06c69add33eb240d69531459276c..a7b7263b35d1d8f142eec5311c9e42c25e398878 100755 (executable)
@@ -43,7 +43,7 @@ test_expect_success 'enable split index' '
        git config splitIndex.maxPercentChange 100 &&
        git update-index --split-index &&
        test-tool dump-split-index .git/index >actual &&
-       indexversion=$(test-tool index-version <.git/index) &&
+       indexversion=$(git update-index --show-index-version) &&
 
        # NEEDSWORK: Stop hard-coding checksums.
        if test "$indexversion" = "4"
index b16d69ca4ae0e8b61ce00a085273d8ad6f40f104..45dd1bc8582142db6d35c7e1d708c8a27c243a34 100755 (executable)
@@ -117,6 +117,26 @@ test_expect_success 'checkout all stages/one file to temporary files' '
        test $(cat $s3) = tree3path1)
 '
 
+test_expect_success '--stage=all implies --temp' '
+       rm -f path* .merge_* actual &&
+       git checkout-index --stage=all -- path1 &&
+       test_path_is_missing path1
+'
+
+test_expect_success 'overriding --stage=all resets implied --temp' '
+       rm -f path* .merge_* actual &&
+       git checkout-index --stage=all --stage=2 -- path1 &&
+       echo tree2path1 >expect &&
+       test_cmp expect path1
+'
+
+test_expect_success '--stage=all --no-temp is rejected' '
+       rm -f path* .merge_* actual &&
+       test_must_fail git checkout-index --stage=all --no-temp -- path1 2>err &&
+       grep -v "already exists" err &&
+       grep "options .--stage=all. and .--no-temp. cannot be used together" err
+'
+
 test_expect_success 'checkout some stages/one file to temporary files' '
        rm -f path* .merge_* actual &&
        git checkout-index --stage=all --temp -- path2 >actual &&
index 2d8c70b03a50e9ca082f7343d78dbcf6ad456159..3eda385ca207578996164500a8ee168342682376 100755 (executable)
@@ -37,11 +37,17 @@ prime_resolve_undo () {
        git checkout second^0 &&
        test_tick &&
        test_must_fail git merge third^0 &&
-       echo merge does not leave anything &&
        check_resolve_undo empty &&
-       echo different >fi/le &&
-       git add fi/le &&
-       echo resolving records &&
+
+       # how should the conflict be resolved?
+       case "$1" in
+       remove)
+               rm -f file/le && git rm fi/le
+               ;;
+       *) # modify
+               echo different >fi/le && git add fi/le
+               ;;
+       esac
        check_resolve_undo recorded fi/le initial:fi/le second:fi/le third:fi/le
 }
 
@@ -122,6 +128,37 @@ test_expect_success 'add records checkout -m undoes' '
 test_expect_success 'unmerge with plumbing' '
        prime_resolve_undo &&
        git update-index --unresolve fi/le &&
+       git ls-files --resolve-undo fi/le >actual &&
+       test_must_be_empty actual &&
+       git ls-files -u >actual &&
+       test_line_count = 3 actual
+'
+
+test_expect_success 'unmerge can be done even after committing' '
+       prime_resolve_undo &&
+       git commit -m "record to nuke MERGE_HEAD" &&
+       git update-index --unresolve fi/le &&
+       git ls-files --resolve-undo fi/le >actual &&
+       test_must_be_empty actual &&
+       git ls-files -u >actual &&
+       test_line_count = 3 actual
+'
+
+test_expect_success 'unmerge removal' '
+       prime_resolve_undo remove &&
+       git update-index --unresolve fi/le &&
+       git ls-files --resolve-undo fi/le >actual &&
+       test_must_be_empty actual &&
+       git ls-files -u >actual &&
+       test_line_count = 3 actual
+'
+
+test_expect_success 'unmerge removal after committing' '
+       prime_resolve_undo remove &&
+       git commit -m "record to nuke MERGE_HEAD" &&
+       git update-index --unresolve fi/le &&
+       git ls-files --resolve-undo fi/le >actual &&
+       test_must_be_empty actual &&
        git ls-files -u >actual &&
        test_line_count = 3 actual
 '
index c5d19dd973d7f4ea7a3a496d7df92a5c74fa667d..16d6348b692806ab25faf89d77a73cd62fab4d93 100755 (executable)
@@ -137,11 +137,78 @@ test_expect_success 'restore --staged invalidates cache tree for deletions' '
        test_must_fail git rev-parse HEAD:new1
 '
 
-test_expect_success 'restore with merge options rejects --staged' '
+test_expect_success 'restore --merge to unresolve' '
+       O=$(echo original | git hash-object -w --stdin) &&
+       A=$(echo ourside | git hash-object -w --stdin) &&
+       B=$(echo theirside | git hash-object -w --stdin) &&
+       {
+               echo "100644 $O 1       file" &&
+               echo "100644 $A 2       file" &&
+               echo "100644 $B 3       file"
+       } | git update-index --index-info &&
+       echo nothing >file &&
+       git restore --worktree --merge file &&
+       cat >expect <<-\EOF &&
+       <<<<<<< ours
+       ourside
+       =======
+       theirside
+       >>>>>>> theirs
+       EOF
+       test_cmp expect file
+'
+
+test_expect_success 'restore --merge to unresolve after (mistaken) resolution' '
+       O=$(echo original | git hash-object -w --stdin) &&
+       A=$(echo ourside | git hash-object -w --stdin) &&
+       B=$(echo theirside | git hash-object -w --stdin) &&
+       {
+               echo "100644 $O 1       file" &&
+               echo "100644 $A 2       file" &&
+               echo "100644 $B 3       file"
+       } | git update-index --index-info &&
+       echo nothing >file &&
+       git add file &&
+       git restore --worktree --merge file &&
+       cat >expect <<-\EOF &&
+       <<<<<<< ours
+       ourside
+       =======
+       theirside
+       >>>>>>> theirs
+       EOF
+       test_cmp expect file
+'
+
+test_expect_success 'restore --merge to unresolve after (mistaken) resolution' '
+       O=$(echo original | git hash-object -w --stdin) &&
+       A=$(echo ourside | git hash-object -w --stdin) &&
+       B=$(echo theirside | git hash-object -w --stdin) &&
+       {
+               echo "100644 $O 1       file" &&
+               echo "100644 $A 2       file" &&
+               echo "100644 $B 3       file"
+       } | git update-index --index-info &&
+       git rm -f file &&
+       git restore --worktree --merge file &&
+       cat >expect <<-\EOF &&
+       <<<<<<< ours
+       ourside
+       =======
+       theirside
+       >>>>>>> theirs
+       EOF
+       test_cmp expect file
+'
+
+test_expect_success 'restore with merge options are incompatible with certain options' '
        for opts in \
                "--staged --ours" \
                "--staged --theirs" \
                "--staged --merge" \
+               "--source=HEAD --ours" \
+               "--source=HEAD --theirs" \
+               "--source=HEAD --merge" \
                "--staged --conflict=diff3" \
                "--staged --worktree --ours" \
                "--staged --worktree --theirs" \
@@ -149,7 +216,7 @@ test_expect_success 'restore with merge options rejects --staged' '
                "--staged --worktree --conflict=zdiff3"
        do
                test_must_fail git restore $opts . 2>err &&
-               grep "cannot be used with --staged" err || return
+               grep "cannot be used" err || return
        done
 '
 
index b8686aabd38b5ac8a60753bff80fddd4e91a5102..0bab134d71d3e785194562779ef63085de4e6545 100755 (executable)
@@ -39,7 +39,7 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'index is at version 2' '
-       test "$(test-tool index-version < .git/index)" = 2
+       test "$(git update-index --show-index-version)" = 2
 '
 
 test_expect_success 'update-index --skip-worktree' '
@@ -48,7 +48,7 @@ test_expect_success 'update-index --skip-worktree' '
 '
 
 test_expect_success 'index is at version 3 after having some skip-worktree entries' '
-       test "$(test-tool index-version < .git/index)" = 3
+       test "$(git update-index --show-index-version)" = 3
 '
 
 test_expect_success 'ls-files -t' '
@@ -61,7 +61,7 @@ test_expect_success 'update-index --no-skip-worktree' '
 '
 
 test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
-       test "$(test-tool index-version < .git/index)" = 2
+       test "$(git update-index --show-index-version)" = 2
 '
 
 test_done
index 89b285fa3a608f917a269c56ee2f44fa51f5d01f..22f4c923998619f8ebd5f1dc85e0ffa917dbb4d3 100755 (executable)
@@ -111,4 +111,35 @@ test_expect_success '--chmod=+x and chmod=-x in the same argument list' '
        test_cmp expect actual
 '
 
+test_expect_success '--index-version' '
+       git commit --allow-empty -m snap &&
+       git reset --hard &&
+       git rm -f -r --cached . &&
+
+       # The default index version is 2 --- update this test
+       # when you change it in the code
+       git update-index --show-index-version >actual &&
+       echo 2 >expect &&
+       test_cmp expect actual &&
+
+       # The next test wants us to be using version 2
+       git update-index --index-version 2 &&
+
+       git update-index --index-version 4 --verbose >actual &&
+       echo "index-version: was 2, set to 4" >expect &&
+       test_cmp expect actual &&
+
+       git update-index --index-version 4 --verbose >actual &&
+       echo "index-version: was 4, set to 4" >expect &&
+       test_cmp expect actual &&
+
+       git update-index --index-version 2 --verbose >actual &&
+       echo "index-version: was 4, set to 2" >expect &&
+       test_cmp expect actual &&
+
+       # non-verbose should be silent
+       git update-index --index-version 4 >actual &&
+       test_must_be_empty actual
+'
+
 test_done
index 051363acbbc784ec5b2cc3d0c6ddfc3af87cdd6c..df4aff7825c9f8430d7449d1bdf2b0d5045d397a 100755 (executable)
@@ -121,7 +121,8 @@ test_expect_success '"add" worktree creating new branch' '
 test_expect_success 'die the same branch is already checked out' '
        (
                cd here &&
-               test_must_fail git checkout newmain
+               test_must_fail git checkout newmain 2>actual &&
+               grep "already used by worktree at" actual
        )
 '
 
index 469443d8ae8c44483c7dbea8dd3c3fc2baef0745..f6835c91dcc49cfeb23881fe0ef7a96629bfb2e6 100755 (executable)
@@ -45,7 +45,7 @@ test_expect_success 'refuse to overwrite: checked out in worktree' '
                grep "cannot force update the branch" err &&
 
                test_must_fail git branch -D wt-$i 2>err &&
-               grep "Cannot delete branch" err || return 1
+               grep "cannot delete branch" err || return 1
        done
 '
 
index daf1666df7adb9594c50445764440ad339f43645..3182abde27f45e35e93bf25d5b079f6901c298fb 100755 (executable)
@@ -291,10 +291,10 @@ test_expect_success 'git branch -M topic topic should work when main is checked
 test_expect_success 'git branch -M and -C fail on detached HEAD' '
        git checkout HEAD^{} &&
        test_when_finished git checkout - &&
-       echo "fatal: cannot rename the current branch while not on any." >expect &&
+       echo "fatal: cannot rename the current branch while not on any" >expect &&
        test_must_fail git branch -M must-fail 2>err &&
        test_cmp expect err &&
-       echo "fatal: cannot copy the current branch while not on any." >expect &&
+       echo "fatal: cannot copy the current branch while not on any" >expect &&
        test_must_fail git branch -C must-fail 2>err &&
        test_cmp expect err
 '
@@ -942,7 +942,19 @@ test_expect_success 'test deleting branch without config' '
 test_expect_success 'deleting currently checked out branch fails' '
        git worktree add -b my7 my7 &&
        test_must_fail git -C my7 branch -d my7 &&
-       test_must_fail git branch -d my7 &&
+       test_must_fail git branch -d my7 2>actual &&
+       grep "^error: cannot delete branch .my7. used by worktree at " actual &&
+       rm -r my7 &&
+       git worktree prune
+'
+
+test_expect_success 'deleting in-use branch fails' '
+       git worktree add my7 &&
+       test_commit -C my7 bt7 &&
+       git -C my7 bisect start HEAD HEAD~2 &&
+       test_must_fail git -C my7 branch -d my7 &&
+       test_must_fail git branch -d my7 2>actual &&
+       grep "^error: cannot delete branch .my7. used by worktree at " actual &&
        rm -r my7 &&
        git worktree prune
 '
@@ -1012,7 +1024,7 @@ test_expect_success '--set-upstream-to fails on multiple branches' '
 test_expect_success '--set-upstream-to fails on detached HEAD' '
        git checkout HEAD^{} &&
        test_when_finished git checkout - &&
-       echo "fatal: could not set upstream of HEAD to main when it does not point to any branch." >expect &&
+       echo "fatal: could not set upstream of HEAD to main when it does not point to any branch" >expect &&
        test_must_fail git branch --set-upstream-to main 2>err &&
        test_cmp expect err
 '
@@ -1060,7 +1072,7 @@ test_expect_success 'use --set-upstream-to modify a particular branch' '
 '
 
 test_expect_success '--unset-upstream should fail if given a non-existent branch' '
-       echo "fatal: Branch '"'"'i-dont-exist'"'"' has no upstream information" >expect &&
+       echo "fatal: branch '"'"'i-dont-exist'"'"' has no upstream information" >expect &&
        test_must_fail git branch --unset-upstream i-dont-exist 2>err &&
        test_cmp expect err
 '
@@ -1082,7 +1094,7 @@ test_expect_success 'test --unset-upstream on HEAD' '
        test_must_fail git config branch.main.remote &&
        test_must_fail git config branch.main.merge &&
        # fail for a branch without upstream set
-       echo "fatal: Branch '"'"'main'"'"' has no upstream information" >expect &&
+       echo "fatal: branch '"'"'main'"'"' has no upstream information" >expect &&
        test_must_fail git branch --unset-upstream 2>err &&
        test_cmp expect err
 '
@@ -1096,7 +1108,7 @@ test_expect_success '--unset-upstream should fail on multiple branches' '
 test_expect_success '--unset-upstream should fail on detached HEAD' '
        git checkout HEAD^{} &&
        test_when_finished git checkout - &&
-       echo "fatal: could not unset upstream of HEAD when it does not point to any branch." >expect &&
+       echo "fatal: could not unset upstream of HEAD when it does not point to any branch" >expect &&
        test_must_fail git branch --unset-upstream 2>err &&
        test_cmp expect err
 '
index b17f388f56dfea819e70a04cf25000f0fb4b3658..2cdb834b37e65bdc0d1bf74109def557dc3bb675 100755 (executable)
@@ -10,7 +10,7 @@ GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
 test_expect_success 'error descriptions on empty repository' '
        current=$(git branch --show-current) &&
        cat >expect <<-EOF &&
-       error: No commit on branch '\''$current'\'' yet.
+       error: no commit on branch '\''$current'\'' yet
        EOF
        test_must_fail git branch --edit-description 2>actual &&
        test_cmp expect actual &&
@@ -21,7 +21,7 @@ test_expect_success 'error descriptions on empty repository' '
 test_expect_success 'fatal descriptions on empty repository' '
        current=$(git branch --show-current) &&
        cat >expect <<-EOF &&
-       fatal: No commit on branch '\''$current'\'' yet.
+       fatal: no commit on branch '\''$current'\'' yet
        EOF
        test_must_fail git branch --set-upstream-to=non-existent 2>actual &&
        test_cmp expect actual &&
@@ -224,7 +224,7 @@ done
 
 test_expect_success 'error descriptions on non-existent branch' '
        cat >expect <<-EOF &&
-       error: No branch named '\''non-existent'\'.'
+       error: no branch named '\''non-existent'\''
        EOF
        test_must_fail git branch --edit-description non-existent 2>actual &&
        test_cmp expect actual
@@ -238,7 +238,7 @@ test_expect_success 'fatal descriptions on non-existent branch' '
        test_cmp expect actual &&
 
        cat >expect <<-EOF &&
-       fatal: No branch named '\''non-existent'\''.
+       fatal: no branch named '\''non-existent'\''
        EOF
        test_must_fail git branch -c non-existent new-branch 2>actual &&
        test_cmp expect actual &&
@@ -253,7 +253,7 @@ test_expect_success 'error descriptions on orphan branch' '
        test_branch_op_in_wt() {
                test_orphan_error() {
                        test_must_fail git $* 2>actual &&
-                       test_i18ngrep "No commit on branch .orphan-branch. yet.$" actual
+                       test_i18ngrep "no commit on branch .orphan-branch. yet$" actual
                } &&
                test_orphan_error -C wt branch $1 $2 &&                # implicit branch
                test_orphan_error -C wt branch $1 orphan-branch $2 &&  # explicit branch
index b5f4d6a653045dafa7c2317036196866f78b9ca5..b33afa1c6aa9bcc33faaa117780bc45e91525a19 100755 (executable)
@@ -662,6 +662,20 @@ test_expect_success 'range-diff with multiple --notes' '
        test_cmp expect actual
 '
 
+# `range-diff` should act like `log` with regards to notes
+test_expect_success 'range-diff with --notes=custom does not show default notes' '
+       git notes add -m "topic note" topic &&
+       git notes add -m "unmodified note" unmodified &&
+       git notes --ref=custom add -m "topic note" topic &&
+       git notes --ref=custom add -m "unmodified note" unmodified &&
+       test_when_finished git notes remove topic unmodified &&
+       test_when_finished git notes --ref=custom remove topic unmodified &&
+       git range-diff --notes=custom main..topic main..unmodified \
+               >actual &&
+       ! grep "## Notes ##" actual &&
+       grep "## Notes (custom) ##" actual
+'
+
 test_expect_success 'format-patch --range-diff does not compare notes by default' '
        git notes add -m "topic note" topic &&
        git notes add -m "unmodified note" unmodified &&
@@ -679,6 +693,20 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
        ! grep "note" 0000-*
 '
 
+test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' '
+       git notes add -m "topic note" topic &&
+       git notes --ref=custom add -m "topic note (custom)" topic &&
+       git notes add -m "unmodified note" unmodified &&
+       git notes --ref=custom add -m "unmodified note (custom)" unmodified &&
+       test_when_finished git notes remove topic unmodified &&
+       test_when_finished git notes --ref=custom remove topic unmodified &&
+       git format-patch --notes=custom --cover-letter --range-diff=$prev \
+               main..unmodified >actual &&
+       test_when_finished "rm 000?-*" &&
+       grep "## Notes (custom) ##" 0000-* &&
+       ! grep "## Notes ##" 0000-*
+'
+
 test_expect_success 'format-patch --range-diff with --no-notes' '
        git notes add -m "topic note" topic &&
        git notes add -m "unmodified note" unmodified &&
index 3ce918fdb8062fc5f720bb890ad58a2676547218..d3df19a51f83a9193916c3812d1ca152644b470f 100755 (executable)
@@ -421,7 +421,7 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
        git checkout main &&
        git worktree add wt &&
        test_must_fail git -C wt rebase main main 2>err &&
-       test_i18ngrep "already checked out" err
+       test_i18ngrep "already used by worktree at" err
 '
 
 test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
index e2ef6193233dd0b7a2341c391695aabd73d03200..4158590322321742dcc0fef90d43591db3c0ab09 100755 (executable)
@@ -176,6 +176,29 @@ test_expect_success 'advice from failed revert' '
        test_cmp expected actual
 '
 
+test_expect_subject () {
+       echo "$1" >expect &&
+       git log -1 --pretty=%s >actual &&
+       test_cmp expect actual
+}
+
+test_expect_success 'titles of fresh reverts' '
+       test_commit --no-tag A file1 &&
+       test_commit --no-tag B file1 &&
+       git revert --no-edit HEAD &&
+       test_expect_subject "Revert \"B\"" &&
+       git revert --no-edit HEAD &&
+       test_expect_subject "Reapply \"B\"" &&
+       git revert --no-edit HEAD &&
+       test_expect_subject "Revert \"Reapply \"B\"\""
+'
+
+test_expect_success 'title of legacy double revert' '
+       test_commit --no-tag "Revert \"Revert \"B\"\"" file1 &&
+       git revert --no-edit HEAD &&
+       test_expect_subject "Revert \"Revert \"Revert \"B\"\"\""
+'
+
 test_expect_success 'identification of reverted commit (default)' '
        test_commit to-ident &&
        test_when_finished "git reset --hard to-ident" &&
index 0b3dfeaea20048426be4d032dd6dc7e66359dc67..30b64260a8a943305d6d798deda056ec6b9617c2 100755 (executable)
@@ -931,6 +931,10 @@ test_expect_success 'store called with invalid commit' '
        test_must_fail git stash store foo
 '
 
+test_expect_success 'store called with non-stash commit' '
+       test_must_fail git stash store HEAD
+'
+
 test_expect_success 'store updates stash ref and reflog' '
        git stash clear &&
        git reset --hard &&
index 5de1d190759f958f8c3c0319f7b4cca34f39d83c..4b474808311e3e654258445128acaacb7b988240 100755 (executable)
@@ -473,6 +473,14 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' '
        test_cmp expected actual
 '
 
+test_expect_success 'log --dd matches --diff-merges=1 -p' '
+       git log --diff-merges=1 -p master >result &&
+       process_diffs result >expected &&
+       git log --dd master >result &&
+       process_diffs result >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'deny wrong log.diffMerges config' '
        test_config log.diffMerges wrong-value &&
        test_expect_code 128 git log
index 3cf2b7a7fb70ec272d9f12294a26e2a1685c5999..0a4ab36c3aff97bc4fac0a38df9f6222ad50a0ce 100755 (executable)
@@ -1373,7 +1373,27 @@ test_expect_success '--rfc' '
        Subject: [RFC PATCH 1/1] header with . in it
        EOF
        git format-patch -n -1 --stdout --rfc >patch &&
-       grep ^Subject: patch >actual &&
+       grep "^Subject:" patch >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '--rfc does not overwrite prefix' '
+       cat >expect <<-\EOF &&
+       Subject: [RFC PATCH foobar 1/1] header with . in it
+       EOF
+       git -c format.subjectPrefix="PATCH foobar" \
+               format-patch -n -1 --stdout --rfc >patch &&
+       grep "^Subject:" patch >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '--rfc is argument order independent' '
+       cat >expect <<-\EOF &&
+       Subject: [RFC PATCH foobar 1/1] header with . in it
+       EOF
+       git format-patch -n -1 --stdout --rfc \
+               --subject-prefix="PATCH foobar" >patch &&
+       grep "^Subject:" patch >actual &&
        test_cmp expect actual
 '
 
@@ -1991,6 +2011,20 @@ test_expect_success 'cover letter using branch description (6)' '
        grep hello actual
 '
 
+test_expect_success 'cover letter with --description-file' '
+       test_when_finished "rm -f description.txt" &&
+       cat >description.txt <<-\EOF &&
+       subject from file
+
+       body from file
+       EOF
+       git checkout rebuild-1 &&
+       git format-patch --stdout --cover-letter --cover-from-description auto \
+               --description-file description.txt main >actual &&
+       grep "^Subject: \[PATCH 0/2\] subject from file$" actual &&
+       grep "^body from file$" actual
+'
+
 test_expect_success 'cover letter with nothing' '
        git format-patch --stdout --cover-letter >actual &&
        test_line_count = 0 actual
index 3ee27e277dca1cd95484ec9ef3b1251e38b22dde..7badd72488d664ff776e1004f620df1fbc774cdc 100755 (executable)
@@ -12,7 +12,7 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
-# 120 character name
+# 120-character name
 name=aaaaaaaaaa
 name=$name$name$name$name$name$name$name$name$name$name$name$name
 test_expect_success 'preparation' '
@@ -49,12 +49,41 @@ log -1 --stat
 EOF
 
 cat >expect.60 <<-'EOF'
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
 EOF
 cat >expect.6030 <<-'EOF'
  ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
 EOF
-cat >expect2.60 <<-'EOF'
+while read verb expect cmd args
+do
+       # No width limit applied when statNameWidth is ignored
+       case "$expect" in expect72|expect.6030)
+               test_expect_success "$cmd $verb diff.statNameWidth with long name" '
+                       git -c diff.statNameWidth=30 $cmd $args >output &&
+                       grep " | " output >actual &&
+                       test_cmp $expect actual
+               ';;
+       esac
+       # Maximum width limit still applied when statNameWidth is ignored
+       case "$expect" in expect.60|expect.6030)
+               test_expect_success "$cmd --stat=width $verb diff.statNameWidth with long name" '
+                       git -c diff.statNameWidth=30 $cmd $args --stat=60 >output &&
+                       grep " | " output >actual &&
+                       test_cmp $expect actual
+               ';;
+       esac
+done <<\EOF
+ignores expect72 format-patch -1 --stdout
+ignores expect.60 format-patch -1 --stdout
+respects expect.6030 diff HEAD^ HEAD --stat
+respects expect.6030 show --stat
+respects expect.6030 log -1 --stat
+EOF
+
+cat >expect.40 <<-'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
+EOF
+cat >expect2.40 <<-'EOF'
  ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
  ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
 EOF
@@ -67,22 +96,22 @@ do
        test_expect_success "$cmd --stat=width: a long name is given more room when the bar is short" '
                git $cmd $args --stat=40 >output &&
                grep " | " output >actual &&
-               test_cmp $expect.60 actual
+               test_cmp $expect.40 actual
        '
 
        test_expect_success "$cmd --stat-width=width with long name" '
                git $cmd $args --stat-width=40 >output &&
                grep " | " output >actual &&
-               test_cmp $expect.60 actual
+               test_cmp $expect.40 actual
        '
 
-       test_expect_success "$cmd --stat=...,name-width with long name" '
+       test_expect_success "$cmd --stat=width,name-width with long name" '
                git $cmd $args --stat=60,30 >output &&
                grep " | " output >actual &&
                test_cmp $expect.6030 actual
        '
 
-       test_expect_success "$cmd --stat-name-width with long name" '
+       test_expect_success "$cmd --stat-name-width=width with long name" '
                git $cmd $args --stat-name-width=30 >output &&
                grep " | " output >actual &&
                test_cmp $expect.6030 actual
@@ -94,8 +123,7 @@ expect show --stat
 expect log -1 --stat
 EOF
 
-
-test_expect_success 'preparation for big change tests' '
+test_expect_success 'preparation for big-change tests' '
        >abcd &&
        git add abcd &&
        git commit -m message &&
@@ -111,7 +139,7 @@ cat >expect72 <<'EOF'
  abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 EOF
-test_expect_success "format-patch --cover-letter ignores COLUMNS (big change)" '
+test_expect_success "format-patch --cover-letter ignores COLUMNS with big change" '
        COLUMNS=200 git format-patch -1 --stdout --cover-letter >output &&
        grep " | " output >actual &&
        test_cmp expect72 actual
@@ -131,7 +159,7 @@ cat >expect200-graph <<'EOF'
 EOF
 while read verb expect cmd args
 do
-       test_expect_success "$cmd $verb COLUMNS (big change)" '
+       test_expect_success "$cmd $verb COLUMNS with big change" '
                COLUMNS=200 git $cmd $args >output &&
                grep " | " output >actual &&
                test_cmp "$expect" actual
@@ -139,7 +167,7 @@ do
 
        case "$cmd" in diff|show) continue;; esac
 
-       test_expect_success "$cmd --graph $verb COLUMNS (big change)" '
+       test_expect_success "$cmd --graph $verb COLUMNS with big change" '
                COLUMNS=200 git $cmd $args --graph >output &&
                grep " | " output >actual &&
                test_cmp "$expect-graph" actual
@@ -159,7 +187,7 @@ cat >expect40-graph <<'EOF'
 EOF
 while read verb expect cmd args
 do
-       test_expect_success "$cmd $verb not enough COLUMNS (big change)" '
+       test_expect_success "$cmd $verb not enough COLUMNS with big change" '
                COLUMNS=40 git $cmd $args >output &&
                grep " | " output >actual &&
                test_cmp "$expect" actual
@@ -167,7 +195,7 @@ do
 
        case "$cmd" in diff|show) continue;; esac
 
-       test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" '
+       test_expect_success "$cmd --graph $verb not enough COLUMNS with big change" '
                COLUMNS=40 git $cmd $args --graph >output &&
                grep " | " output >actual &&
                test_cmp "$expect-graph" actual
@@ -187,7 +215,7 @@ cat >expect40-graph <<'EOF'
 EOF
 while read verb expect cmd args
 do
-       test_expect_success "$cmd $verb statGraphWidth config" '
+       test_expect_success "$cmd $verb diff.statGraphWidth" '
                git -c diff.statGraphWidth=26 $cmd $args >output &&
                grep " | " output >actual &&
                test_cmp "$expect" actual
@@ -195,7 +223,7 @@ do
 
        case "$cmd" in diff|show) continue;; esac
 
-       test_expect_success "$cmd --graph $verb statGraphWidth config" '
+       test_expect_success "$cmd --graph $verb diff.statGraphWidth" '
                git -c diff.statGraphWidth=26 $cmd $args --graph >output &&
                grep " | " output >actual &&
                test_cmp "$expect-graph" actual
@@ -207,7 +235,6 @@ respects expect40 show --stat
 respects expect40 log -1 --stat
 EOF
 
-
 cat >expect <<'EOF'
  abcd | 1000 ++++++++++++++++++++++++++
 EOF
@@ -228,7 +255,7 @@ do
                test_cmp expect actual
        '
 
-       test_expect_success "$cmd --stat-graph-width with big change" '
+       test_expect_success "$cmd --stat-graph-width=width with big change" '
                git $cmd $args --stat-graph-width=26 >output &&
                grep " | " output >actual &&
                test_cmp expect actual
@@ -242,7 +269,7 @@ do
                test_cmp expect-graph actual
        '
 
-       test_expect_success "$cmd --stat-graph-width --graph with big change" '
+       test_expect_success "$cmd --stat-graph-width=width --graph with big change" '
                git $cmd $args --stat-graph-width=26 --graph >output &&
                grep " | " output >actual &&
                test_cmp expect-graph actual
@@ -254,7 +281,7 @@ show --stat
 log -1 --stat
 EOF
 
-test_expect_success 'preparation for long filename tests' '
+test_expect_success 'preparation for long-name tests' '
        cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
        git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
        git commit -m message
@@ -302,7 +329,7 @@ cat >expect200-graph <<'EOF'
 EOF
 while read verb expect cmd args
 do
-       test_expect_success "$cmd $verb COLUMNS (long filename)" '
+       test_expect_success "$cmd $verb COLUMNS with long name" '
                COLUMNS=200 git $cmd $args >output &&
                grep " | " output >actual &&
                test_cmp "$expect" actual
@@ -310,7 +337,7 @@ do
 
        case "$cmd" in diff|show) continue;; esac
 
-       test_expect_success "$cmd --graph $verb COLUMNS (long filename)" '
+       test_expect_success "$cmd --graph $verb COLUMNS with long name" '
                COLUMNS=200 git $cmd $args --graph >output &&
                grep " | " output >actual &&
                test_cmp "$expect-graph" actual
@@ -331,7 +358,7 @@ EOF
 while read verb expect cmd args
 do
        test_expect_success COLUMNS_CAN_BE_1 \
-               "$cmd $verb prefix greater than COLUMNS (big change)" '
+               "$cmd $verb prefix greater than COLUMNS with big change" '
                COLUMNS=1 git $cmd $args >output &&
                grep " | " output >actual &&
                test_cmp "$expect" actual
@@ -340,7 +367,7 @@ do
        case "$cmd" in diff|show) continue;; esac
 
        test_expect_success COLUMNS_CAN_BE_1 \
-               "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
+               "$cmd --graph $verb prefix greater than COLUMNS with big change" '
                COLUMNS=1 git $cmd $args --graph >output &&
                grep " | " output >actual &&
                test_cmp "$expect-graph" actual
@@ -355,8 +382,14 @@ EOF
 cat >expect <<'EOF'
  abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 EOF
-test_expect_success 'merge --stat respects COLUMNS (big change)' '
-       git checkout -b branch HEAD^^ &&
+test_expect_success 'merge --stat respects diff.statGraphWidth with big change' '
+       git checkout -b branch1 HEAD^^ &&
+       git -c diff.statGraphWidth=26 merge --stat --no-ff main^ >output &&
+       grep " | " output >actual &&
+       test_cmp expect40 actual
+'
+test_expect_success 'merge --stat respects COLUMNS with big change' '
+       git checkout -b branch2 HEAD^^ &&
        COLUMNS=100 git merge --stat --no-ff main^ >output &&
        grep " | " output >actual &&
        test_cmp expect actual
@@ -365,7 +398,17 @@ test_expect_success 'merge --stat respects COLUMNS (big change)' '
 cat >expect <<'EOF'
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
 EOF
-test_expect_success 'merge --stat respects COLUMNS (long filename)' '
+cat >expect.30 <<'EOF'
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++++++++++++++++++++++
+EOF
+test_expect_success 'merge --stat respects diff.statNameWidth with long name' '
+       git switch branch1 &&
+       git -c diff.statNameWidth=30 merge --stat --no-ff main >output &&
+       grep " | " output >actual &&
+       test_cmp expect.30 actual
+'
+test_expect_success 'merge --stat respects COLUMNS with long name' '
+       git switch branch2 &&
        COLUMNS=100 git merge --stat --no-ff main >output &&
        grep " | " output >actual &&
        test_cmp expect actual
index 2d650d8f1032ca7c113fa0f48c72719fb08ab245..541642650f533816ae8ea6490141893cbc111ce4 100755 (executable)
@@ -34,7 +34,7 @@ test_expect_success setup '
        echo c >c &&
        git add c &&
        git commit -m C &&
-       git tag commit-C &&
+       git tag -m commit-C commit-C &&
        git merge -m D main &&
        git tag commit-D &&
        git checkout main &&
@@ -109,6 +109,13 @@ do
                test_cmp expect actual
        '
 
+       test_expect_success "$cmd --merge-base with annotated tag" '
+               git checkout main &&
+               git $cmd commit-C >expect &&
+               git $cmd --merge-base commit-C >actual &&
+               test_cmp expect actual
+       '
+
        test_expect_success "$cmd --merge-base with one commit and unstaged changes" '
                git checkout main &&
                test_when_finished git reset --hard &&
@@ -143,7 +150,7 @@ do
        test_expect_success "$cmd --merge-base with non-commit" '
                git checkout main &&
                test_must_fail git $cmd --merge-base main^{tree} 2>err &&
-               test_i18ngrep "fatal: --merge-base only works with commits" err
+               test_i18ngrep "is a tree, not a commit" err
        '
 
        test_expect_success "$cmd --merge-base with no merge bases and one commit" '
@@ -169,7 +176,7 @@ do
 
        test_expect_success "$cmd --merge-base commit and non-commit" '
                test_must_fail git $cmd --merge-base br2 main^{tree} 2>err &&
-               test_i18ngrep "fatal: --merge-base only works with commits" err
+               test_i18ngrep "is a tree, not a commit" err
        '
 
        test_expect_success "$cmd --merge-base with no merge bases and two commits" '
index dd9035aa384937bfec5793fe2f591032282837ac..e3d655e6b8b5565d619298b16da010ee671667a2 100755 (executable)
@@ -576,6 +576,38 @@ test_expect_success 'clean log decoration' '
        test_cmp expected actual1
 '
 
+test_expect_success 'pretty format %decorate' '
+       git checkout -b foo &&
+       git commit --allow-empty -m "new commit" &&
+       git tag bar &&
+       git branch qux &&
+
+       echo " (HEAD -> foo, tag: bar, qux)" >expect1 &&
+       git log --format="%(decorate)" -1 >actual1 &&
+       test_cmp expect1 actual1 &&
+
+       echo "HEAD -> foo, tag: bar, qux" >expect2 &&
+       git log --format="%(decorate:prefix=,suffix=)" -1 >actual2 &&
+       test_cmp expect2 actual2 &&
+
+       echo "[ bar; qux; foo ]" >expect3 &&
+       git log --format="%(decorate:prefix=[ ,suffix= ],separator=%x3B ,tag=)" \
+               --decorate-refs=refs/ -1 >actual3 &&
+       test_cmp expect3 actual3 &&
+
+       # Try with a typo (in "separator"), in which case the placeholder should
+       # not be replaced.
+       echo "%(decorate:prefix=[ ,suffix= ],separater=; )" >expect4 &&
+       git log --format="%(decorate:prefix=[ ,suffix= ],separater=%x3B )" \
+               -1 >actual4 &&
+       test_cmp expect4 actual4 &&
+
+       echo "HEAD->foo bar qux" >expect5 &&
+       git log --format="%(decorate:prefix=,suffix=,separator= ,tag=,pointer=->)" \
+               -1 >actual5 &&
+       test_cmp expect5 actual5
+'
+
 cat >trailers <<EOF
 Signed-off-by: A U Thor <author@example.com>
 Acked-by: A U Thor <author@example.com>
@@ -924,6 +956,36 @@ test_expect_success '%S in git log --format works with other placeholders (part
        test_cmp expect actual
 '
 
+test_expect_success 'setup more commits for %S with --bisect' '
+       test_commit four &&
+       test_commit five &&
+
+       head1=$(git rev-parse --verify HEAD~0) &&
+       head2=$(git rev-parse --verify HEAD~1) &&
+       head3=$(git rev-parse --verify HEAD~2) &&
+       head4=$(git rev-parse --verify HEAD~3)
+'
+
+test_expect_success '%S with --bisect labels commits with refs/bisect/bad ref' '
+       git update-ref refs/bisect/bad-$head1 $head1 &&
+       git update-ref refs/bisect/go $head1 &&
+       git update-ref refs/bisect/bad-$head2 $head2 &&
+       git update-ref refs/bisect/b $head3 &&
+       git update-ref refs/bisect/bad-$head4 $head4 &&
+       git update-ref refs/bisect/good-$head4 $head4 &&
+
+       # We expect to see the range of commits betwee refs/bisect/good-$head4
+       # and refs/bisect/bad-$head1. The "source" ref is the nearest bisect ref
+       # from which the commit is reachable.
+       cat >expect <<-EOF &&
+       $head1 refs/bisect/bad-$head1
+       $head2 refs/bisect/bad-$head2
+       $head3 refs/bisect/bad-$head2
+       EOF
+       git log --bisect --format="%H %S" >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'log --pretty=reference' '
        git log --pretty="tformat:%h (%s, %as)" >expect &&
        git log --pretty=reference >actual &&
index ded33a82e2c94cd4f44c1df4c9fe93ce9bf5f148..21986a866df65c9ed9025f7ab48dc596e6df81ca 100755 (executable)
@@ -53,15 +53,17 @@ cmp_filtered_decorations () {
 # to this test since it does not contain any decoration, hence --first-parent
 test_expect_success 'commit decorations colored correctly' '
        cat >expect <<-EOF &&
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
-${c_reset}${c_branch}main${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit}, \
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\
+${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
+${c_reset}${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \
+${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_tag}tag: ${c_reset}${c_tag}A1${c_reset}${c_commit}, \
 ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset} \
-On main: Changes to A.t
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_stash}refs/stash${c_reset}${c_commit})${c_reset} On main: Changes to A.t
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
        EOF
 
        git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual &&
@@ -76,12 +78,14 @@ test_expect_success 'test coloring with replace-objects' '
        git replace HEAD~1 HEAD~2 &&
 
        cat >expect <<-EOF &&
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
-${c_reset}${c_branch}main${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: D${c_reset}${c_commit})${c_reset} D
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: C${c_reset}${c_commit}, \
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\
+${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
+${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit})${c_reset} D
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_tag}tag: ${c_reset}${c_tag}C${c_reset}${c_commit}, \
 ${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} B
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
 EOF
 
        git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual &&
@@ -100,13 +104,15 @@ test_expect_success 'test coloring with grafted commit' '
        git replace --graft HEAD HEAD~2 &&
 
        cat >expect <<-EOF &&
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
-${c_reset}${c_branch}main${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: D${c_reset}${c_commit}, \
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\
+${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
+${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit}, \
 ${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
-       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \
+${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B
+       ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
        EOF
 
        git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual &&
index f70c46bbbfa2c8fc9cc5ca1b620c9a80f29e382e..79055978690962fc3b58cd754a9383a88148f0f9 100755 (executable)
@@ -5,6 +5,7 @@ test_description='git log --graph of skewed left octopus merge.'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-log-graph.sh
 
index 28d0779a8c599ee9eab9b0b31afe1a57bb558c28..b877ac723516dc710fd42c17b65877d795d874ff 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='git log --graph of skewed merges'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-log-graph.sh
 
index fa9d32facfb0ddca6c001d78c1011cf0b3568f19..2ba0324a693731412242cf9603826736a3c9279a 100755 (executable)
@@ -5,6 +5,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-chunk.sh
 
 GIT_TEST_COMMIT_GRAPH=0
 GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
@@ -404,4 +405,53 @@ test_expect_success 'Bloom generation backfills empty commits' '
        )
 '
 
+corrupt_graph () {
+       graph=.git/objects/info/commit-graph &&
+       test_when_finished "rm -rf $graph" &&
+       git commit-graph write --reachable --changed-paths &&
+       corrupt_chunk_file $graph "$@"
+}
+
+check_corrupt_graph () {
+       corrupt_graph "$@" &&
+       git -c core.commitGraph=false log -- A/B/file2 >expect.out &&
+       git -c core.commitGraph=true log -- A/B/file2 >out 2>err &&
+       test_cmp expect.out out
+}
+
+test_expect_success 'Bloom reader notices too-small data chunk' '
+       check_corrupt_graph BDAT clear 00000000 &&
+       echo "warning: ignoring too-small changed-path chunk" \
+               "(4 < 12) in commit-graph file" >expect.err &&
+       test_cmp expect.err err
+'
+
+test_expect_success 'Bloom reader notices out-of-bounds filter offsets' '
+       check_corrupt_graph BIDX 12 FFFFFFFF &&
+       # use grep to avoid depending on exact chunk size
+       grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err
+'
+
+test_expect_success 'Bloom reader notices too-small index chunk' '
+       # replace the index with a single entry, making most
+       # lookups out-of-bounds
+       check_corrupt_graph BIDX clear 00000000 &&
+       echo "warning: commit-graph changed-path index chunk" \
+               "is too small" >expect.err &&
+       test_cmp expect.err err
+'
+
+test_expect_success 'Bloom reader notices out-of-order index offsets' '
+       # we do not know any real offsets, but we can pick
+       # something plausible; we should not get to the point of
+       # actually reading from the bogus offsets anyway.
+       corrupt_graph BIDX 4 0000000c00000005 &&
+       echo "warning: ignoring decreasing changed-path index offsets" \
+               "(12 > 5) for positions 1 and 2 of .git/objects/info/commit-graph" >expect.err &&
+       git -c core.commitGraph=false log -- A/B/file2 >expect.out &&
+       git -c core.commitGraph=true log -- A/B/file2 >out 2>err &&
+       test_cmp expect.out out &&
+       test_cmp expect.err err
+'
+
 test_done
index 57c4f26e4613a97644ad5822b1f6a0c4572a33a4..9c197260d5bbf54d3ad578c27f54e278d88ab97b 100755 (executable)
@@ -86,6 +86,33 @@ EXPECTED
        test_cmp expected actual
 '
 
+test_expect_success '3-way merge with --attr-source' '
+       test_when_finished rm -rf 3-way &&
+       git init 3-way &&
+       (
+               cd 3-way &&
+               test_commit initial file1 foo &&
+               base=$(git rev-parse HEAD) &&
+               git checkout -b brancha &&
+               echo bar >>file1 &&
+               git commit -am "adding bar" &&
+               source=$(git rev-parse HEAD) &&
+               git checkout @{-1} &&
+               git checkout -b branchb &&
+               echo baz >>file1 &&
+               git commit -am "adding baz" &&
+               merge=$(git rev-parse HEAD) &&
+               git checkout -b gitattributes &&
+               test_commit "gitattributes" .gitattributes "file1 merge=union" &&
+               git checkout @{-1} &&
+               tree=$(git --attr-source=gitattributes merge-tree --write-tree \
+               --merge-base "$base" --end-of-options "$source" "$merge") &&
+               test_write_lines foo bar baz >expect &&
+               git cat-file -p "$tree:file1" >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_expect_success 'file change A, B (same)' '
        git reset --hard initial &&
        test_commit "change-a-b-same-A" "initial-file" "AAA" &&
index 250f721795b5bd2ecba3090b7e181c50673540aa..b2c8a43fce311570e358d77a3b062228adcbbf68 100755 (executable)
@@ -22,6 +22,7 @@ test_expect_success setup '
        git branch side1 &&
        git branch side2 &&
        git branch side3 &&
+       git branch side4 &&
 
        git checkout side1 &&
        test_write_lines 1 2 3 4 5 6 >numbers &&
@@ -46,6 +47,13 @@ test_expect_success setup '
        test_tick &&
        git commit -m rename-numbers &&
 
+       git checkout side4 &&
+       test_write_lines 0 1 2 3 4 5 >numbers &&
+       echo yo >greeting &&
+       git add numbers greeting &&
+       test_tick &&
+       git commit -m other-content-modifications &&
+
        git switch --orphan unrelated &&
        >something-else &&
        git add something-else &&
@@ -97,6 +105,21 @@ test_expect_success 'Content merge and a few conflicts' '
        test_cmp expect actual
 '
 
+test_expect_success 'Auto resolve conflicts by "ours" strategy option' '
+       git checkout side1^0 &&
+
+       # make sure merge conflict exists
+       test_must_fail git merge side4 &&
+       git merge --abort &&
+
+       git merge -X ours side4 &&
+       git rev-parse HEAD^{tree} >expected &&
+
+       git merge-tree -X ours side1 side4 >actual &&
+
+       test_cmp expected actual
+'
+
 test_expect_success 'Barf on misspelled option, with exit code other than 0 or 1' '
        # Mis-spell with single "s" instead of double "s"
        test_expect_code 129 git merge-tree --write-tree --mesages FOOBAR side1 side2 2>expect &&
index 0ff47a239db905eb5c3e65de53994b0ac81cbd86..eaf959d8f63f158651609a7c5b0c2eb6592b4926 100755 (executable)
@@ -138,7 +138,7 @@ test_expect_success 'git archive with worktree attributes, bare' '
 '
 
 test_expect_missing    bare-worktree/ignored
-test_expect_exists     bare-worktree/ignored-by-tree
+test_expect_missing    bare-worktree/ignored-by-tree
 test_expect_exists     bare-worktree/ignored-by-worktree
 
 test_expect_success 'export-subst' '
index b26d476c646fdb63a9569d98bc9d2792dd6f3426..2ff3eef9a3b8cad7f95253c79283d3ac542802fd 100755 (executable)
@@ -53,6 +53,14 @@ test_expect_success 'verify blob:none packfile has no blobs' '
        ! grep blob verify_result
 '
 
+test_expect_success 'verify blob:none packfile without --stdout' '
+       git -C r1 pack-objects --revs --filter=blob:none mypackname >packhash <<-EOF &&
+       HEAD
+       EOF
+       git -C r1 verify-pack -v "mypackname-$(cat packhash).pack" >verify_result &&
+       ! grep blob verify_result
+'
+
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
        git -C r1 verify-pack -v ../all.pack >verify_result &&
        grep -E "commit|tree" verify_result |
index ba65f17dd9cc863a9a92ae90393af3ffdd2309de..6505ff595a389afa7d79fe31305d214046c376f2 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='commit graph'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-chunk.sh
 
 GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
 
@@ -559,7 +560,7 @@ test_expect_success 'detect incorrect fanout' '
 
 test_expect_success 'detect incorrect fanout final value' '
        corrupt_graph_and_verify $GRAPH_BYTE_FANOUT2 "\01" \
-               "fanout value"
+               "oid table and fanout disagree on size"
 '
 
 test_expect_success 'detect incorrect OID order' '
@@ -821,4 +822,77 @@ test_expect_success 'overflow during generation version upgrade' '
        )
 '
 
+corrupt_chunk () {
+       graph=full/.git/objects/info/commit-graph &&
+       test_when_finished "rm -rf $graph" &&
+       git -C full commit-graph write --reachable &&
+       corrupt_chunk_file $graph "$@"
+}
+
+check_corrupt_chunk () {
+       corrupt_chunk "$@" &&
+       git -C full -c core.commitGraph=false log >expect.out &&
+       git -C full -c core.commitGraph=true log >out 2>err &&
+       test_cmp expect.out out
+}
+
+test_expect_success 'reader notices too-small oid fanout chunk' '
+       # make it big enough that the graph file is plausible,
+       # otherwise we hit an earlier check
+       check_corrupt_chunk OIDF clear $(printf "000000%02x" $(test_seq 250)) &&
+       cat >expect.err <<-\EOF &&
+       error: commit-graph oid fanout chunk is wrong size
+       error: commit-graph is missing the OID Fanout chunk
+       EOF
+       test_cmp expect.err err
+'
+
+test_expect_success 'reader notices fanout/lookup table mismatch' '
+       check_corrupt_chunk OIDF 1020 "FFFFFFFF" &&
+       cat >expect.err <<-\EOF &&
+       error: commit-graph oid table and fanout disagree on size
+       EOF
+       test_cmp expect.err err
+'
+
+test_expect_success 'reader notices out-of-bounds fanout' '
+       # Rather than try to corrupt a specific hash, we will just
+       # wreck them all. But we cannot just set them all to 0xFFFFFFFF or
+       # similar, as they are used for hi/lo starts in a binary search (so if
+       # they are identical, that indicates that the search should abort
+       # immediately). Instead, we will give them high values that differ by
+       # 2^24, ensuring that any that are used would cause an out-of-bounds
+       # read.
+       check_corrupt_chunk OIDF 0 $(printf "%02x000000" $(test_seq 0 254)) &&
+       cat >expect.err <<-\EOF &&
+       error: commit-graph fanout values out of order
+       EOF
+       test_cmp expect.err err
+'
+
+test_expect_success 'reader notices too-small commit data chunk' '
+       check_corrupt_chunk CDAT clear 00000000 &&
+       cat >expect.err <<-\EOF &&
+       error: commit-graph commit data chunk is wrong size
+       error: commit-graph is missing the Commit Data chunk
+       EOF
+       test_cmp expect.err err
+'
+
+test_expect_success 'reader notices out-of-bounds extra edge' '
+       check_corrupt_chunk EDGE clear &&
+       cat >expect.err <<-\EOF &&
+       error: commit-graph extra-edges pointer out of bounds
+       EOF
+       test_cmp expect.err err
+'
+
+test_expect_success 'reader notices too-small generations chunk' '
+       check_corrupt_chunk GDA2 clear 00000000 &&
+       cat >expect.err <<-\EOF &&
+       error: commit-graph generations chunk is wrong size
+       EOF
+       test_cmp expect.err err
+'
+
 test_done
index 1bcc02004d7d1acbce8306bdeb5439f4da689ccb..d3c9e97feb12b7d80a1c74189a0da04c438152c5 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='multi-pack-indexes'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-chunk.sh
 
 GIT_TEST_MULTI_PACK_INDEX=0
 objdir=.git/objects
@@ -438,7 +439,7 @@ test_expect_success 'verify extended chunk count' '
 
 test_expect_success 'verify missing required chunk' '
        corrupt_midx_and_verify $MIDX_BYTE_CHUNK_ID "\01" $objdir \
-               "missing required"
+               "required pack-name chunk missing"
 '
 
 test_expect_success 'verify invalid chunk offset' '
@@ -1055,4 +1056,105 @@ test_expect_success 'repack with delta islands' '
        )
 '
 
+corrupt_chunk () {
+       midx=.git/objects/pack/multi-pack-index &&
+       test_when_finished "rm -rf $midx" &&
+       git repack -ad --write-midx &&
+       corrupt_chunk_file $midx "$@"
+}
+
+test_expect_success 'reader notices too-small oid fanout chunk' '
+       corrupt_chunk OIDF clear 00000000 &&
+       test_must_fail git log 2>err &&
+       cat >expect <<-\EOF &&
+       error: multi-pack-index OID fanout is of the wrong size
+       fatal: multi-pack-index required OID fanout chunk missing or corrupted
+       EOF
+       test_cmp expect err
+'
+
+test_expect_success 'reader notices too-small oid lookup chunk' '
+       corrupt_chunk OIDL clear 00000000 &&
+       test_must_fail git log 2>err &&
+       cat >expect <<-\EOF &&
+       error: multi-pack-index OID lookup chunk is the wrong size
+       fatal: multi-pack-index required OID lookup chunk missing or corrupted
+       EOF
+       test_cmp expect err
+'
+
+test_expect_success 'reader notices too-small pack names chunk' '
+       # There is no NUL to terminate the name here, so the
+       # chunk is too short.
+       corrupt_chunk PNAM clear 70656666 &&
+       test_must_fail git log 2>err &&
+       cat >expect <<-\EOF &&
+       fatal: multi-pack-index pack-name chunk is too short
+       EOF
+       test_cmp expect err
+'
+
+test_expect_success 'reader handles unaligned chunks' '
+       # A 9-byte PNAM means all of the subsequent chunks
+       # will no longer be 4-byte aligned, but it is still
+       # a valid one-pack chunk on its own (it is "foo.pack\0").
+       corrupt_chunk PNAM clear 666f6f2e7061636b00 &&
+       git -c core.multipackindex=false log >expect.out &&
+       git -c core.multipackindex=true log >out 2>err &&
+       test_cmp expect.out out &&
+       cat >expect.err <<-\EOF &&
+       error: chunk id 4f494446 not 4-byte aligned
+       EOF
+       test_cmp expect.err err
+'
+
+test_expect_success 'reader notices too-small object offset chunk' '
+       corrupt_chunk OOFF clear 00000000 &&
+       test_must_fail git log 2>err &&
+       cat >expect <<-\EOF &&
+       error: multi-pack-index object offset chunk is the wrong size
+       fatal: multi-pack-index required object offsets chunk missing or corrupted
+       EOF
+       test_cmp expect err
+'
+
+test_expect_success 'reader bounds-checks large offset table' '
+       # re-use the objects64 dir here to cheaply get access to a midx
+       # with large offsets.
+       git init repo &&
+       test_when_finished "rm -rf repo" &&
+       (
+               cd repo &&
+               (cd ../objects64 && pwd) >.git/objects/info/alternates &&
+               git multi-pack-index --object-dir=../objects64 write &&
+               midx=../objects64/pack/multi-pack-index &&
+               corrupt_chunk_file $midx LOFF clear &&
+               # using only %(objectsize) is important here; see the commit
+               # message for more details
+               test_must_fail git cat-file --batch-all-objects \
+                       --batch-check="%(objectsize)" 2>err &&
+               cat >expect <<-\EOF &&
+               fatal: multi-pack-index large offset out of bounds
+               EOF
+               test_cmp expect err
+       )
+'
+
+test_expect_success 'reader notices too-small revindex chunk' '
+       # We only get a revindex with bitmaps (and likewise only
+       # load it when they are asked for).
+       test_config repack.writeBitmaps true &&
+       corrupt_chunk RIDX clear 00000000 &&
+       git -c core.multipackIndex=false rev-list \
+               --all --use-bitmap-index >expect.out &&
+       git -c core.multipackIndex=true rev-list \
+               --all --use-bitmap-index >out 2>err &&
+       test_cmp expect.out out &&
+       cat >expect.err <<-\EOF &&
+       error: multi-pack-index reverse-index chunk is the wrong size
+       warning: multi-pack bitmap is missing required reverse index
+       EOF
+       test_cmp expect.err err
+'
+
 test_done
index 36c4141e67b8f0f5aaf87443ab0c00f2bbd67836..97eb6d2e72bac5c3936965c269ff9bfa56d87568 100755 (executable)
@@ -1,7 +1,10 @@
 #!/bin/sh
 
 test_description='split commit graph'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-chunk.sh
 
 GIT_TEST_COMMIT_GRAPH=0
 GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
@@ -285,13 +288,39 @@ test_expect_success 'verify hashes along chain, even in shallow' '
        )
 '
 
+test_expect_success 'verify notices chain slice which is bogus (base)' '
+       git clone --no-hardlinks . verify-chain-bogus-base &&
+       (
+               cd verify-chain-bogus-base &&
+               git commit-graph verify &&
+               base_file=$graphdir/graph-$(sed -n 1p $graphdir/commit-graph-chain).graph &&
+               echo "garbage" >$base_file &&
+               test_must_fail git commit-graph verify 2>test_err &&
+               grep -v "^+" test_err >err &&
+               grep "commit-graph file is too small" err
+       )
+'
+
+test_expect_success 'verify notices chain slice which is bogus (tip)' '
+       git clone --no-hardlinks . verify-chain-bogus-tip &&
+       (
+               cd verify-chain-bogus-tip &&
+               git commit-graph verify &&
+               tip_file=$graphdir/graph-$(sed -n 2p $graphdir/commit-graph-chain).graph &&
+               echo "garbage" >$tip_file &&
+               test_must_fail git commit-graph verify 2>test_err &&
+               grep -v "^+" test_err >err &&
+               grep "commit-graph file is too small" err
+       )
+'
+
 test_expect_success 'verify --shallow does not check base contents' '
        git clone --no-hardlinks . verify-shallow &&
        (
                cd verify-shallow &&
                git commit-graph verify &&
                base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
-               corrupt_file "$base_file" 1000 "\01" &&
+               corrupt_file "$base_file" 1500 "\01" &&
                git commit-graph verify --shallow &&
                test_must_fail git commit-graph verify 2>test_err &&
                grep -v "^+" test_err >err &&
@@ -306,27 +335,54 @@ test_expect_success 'warn on base graph chunk incorrect' '
                git commit-graph verify &&
                base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
                corrupt_file "$base_file" $(test_oid base) "\01" &&
-               git commit-graph verify --shallow 2>test_err &&
+               test_must_fail git commit-graph verify --shallow 2>test_err &&
                grep -v "^+" test_err >err &&
                test_i18ngrep "commit-graph chain does not match" err
        )
 '
 
-test_expect_success 'verify after commit-graph-chain corruption' '
-       git clone --no-hardlinks . verify-chain &&
+test_expect_success 'verify after commit-graph-chain corruption (base)' '
+       git clone --no-hardlinks . verify-chain-base &&
        (
-               cd verify-chain &&
-               corrupt_file "$graphdir/commit-graph-chain" 60 "G" &&
-               git commit-graph verify 2>test_err &&
+               cd verify-chain-base &&
+               corrupt_file "$graphdir/commit-graph-chain" 30 "G" &&
+               test_must_fail git commit-graph verify 2>test_err &&
                grep -v "^+" test_err >err &&
                test_i18ngrep "invalid commit-graph chain" err &&
-               corrupt_file "$graphdir/commit-graph-chain" 60 "A" &&
-               git commit-graph verify 2>test_err &&
+               corrupt_file "$graphdir/commit-graph-chain" 30 "A" &&
+               test_must_fail git commit-graph verify 2>test_err &&
                grep -v "^+" test_err >err &&
                test_i18ngrep "unable to find all commit-graph files" err
        )
 '
 
+test_expect_success 'verify after commit-graph-chain corruption (tip)' '
+       git clone --no-hardlinks . verify-chain-tip &&
+       (
+               cd verify-chain-tip &&
+               corrupt_file "$graphdir/commit-graph-chain" 70 "G" &&
+               test_must_fail git commit-graph verify 2>test_err &&
+               grep -v "^+" test_err >err &&
+               test_i18ngrep "invalid commit-graph chain" err &&
+               corrupt_file "$graphdir/commit-graph-chain" 70 "A" &&
+               test_must_fail git commit-graph verify 2>test_err &&
+               grep -v "^+" test_err >err &&
+               test_i18ngrep "unable to find all commit-graph files" err
+       )
+'
+
+test_expect_success 'verify notices too-short chain file' '
+       git clone --no-hardlinks . verify-chain-short &&
+       (
+               cd verify-chain-short &&
+               git commit-graph verify &&
+               echo "garbage" >$graphdir/commit-graph-chain &&
+               test_must_fail git commit-graph verify 2>test_err &&
+               grep -v "^+" test_err >err &&
+               grep "commit-graph chain file too small" err
+       )
+'
+
 test_expect_success 'verify across alternates' '
        git clone --no-hardlinks . verify-alt &&
        (
@@ -338,10 +394,23 @@ test_expect_success 'verify across alternates' '
                test_commit extra &&
                git commit-graph write --reachable --split &&
                tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
-               corrupt_file "$tip_file" 100 "\01" &&
+               corrupt_file "$tip_file" 1500 "\01" &&
                test_must_fail git commit-graph verify --shallow 2>test_err &&
                grep -v "^+" test_err >err &&
-               test_i18ngrep "commit-graph has incorrect fanout value" err
+               test_i18ngrep "incorrect checksum" err
+       )
+'
+
+test_expect_success 'reader bounds-checks base-graph chunk' '
+       git clone --no-hardlinks . corrupt-base-chunk &&
+       (
+               cd corrupt-base-chunk &&
+               tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
+               corrupt_chunk_file "$tip_file" BASE clear 01020304 &&
+               git -c core.commitGraph=false log >expect.out &&
+               git -c core.commitGraph=true log >out 2>err &&
+               test_cmp expect.out out &&
+               grep "commit-graph base graphs chunk is too small" err
        )
 '
 
index e9c521c061c3eae86619f4eb931d40f5e3127d35..fc6a242b56d88686036ff019003352ee806ef8ce 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='commit graph with 64-bit timestamps'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 if ! test_have_prereq TIME_IS_64BIT || ! test_have_prereq TIME_T_IS_64BIT
@@ -10,6 +12,7 @@ then
 fi
 
 . "$TEST_DIRECTORY"/lib-commit-graph.sh
+. "$TEST_DIRECTORY/lib-chunk.sh"
 
 UNIX_EPOCH_ZERO="@0 +0000"
 FUTURE_DATE="@4147483646 +0000"
@@ -72,4 +75,13 @@ test_expect_success 'single commit with generation data exceeding UINT32_MAX' '
        git -C repo-uint32-max commit-graph verify
 '
 
+test_expect_success 'reader notices out-of-bounds generation overflow' '
+       graph=.git/objects/info/commit-graph &&
+       test_when_finished "rm -rf $graph" &&
+       git commit-graph write --reachable &&
+       corrupt_chunk_file $graph GDO2 clear &&
+       test_must_fail git log 2>err &&
+       grep "commit-graph overflow generation data is too small" err
+'
+
 test_done
index 45667d4999a97f7ec3221a89bcba579ef3871b3d..fc5fedbe9b0c4dd5b59a429a4a877c422f46e602 100755 (executable)
@@ -573,23 +573,54 @@ test_expect_success 'cruft repack with no reachable objects' '
        )
 '
 
-test_expect_success 'cruft repack ignores --max-pack-size' '
+write_blob () {
+       test-tool genrandom "$@" >in &&
+       git hash-object -w -t blob in
+}
+
+find_pack () {
+       for idx in $(ls $packdir/pack-*.idx)
+       do
+               git show-index <$idx >out &&
+               if grep -q "$1" out
+               then
+                       echo $idx
+               fi || return 1
+       done
+}
+
+test_expect_success 'cruft repack with --max-pack-size' '
        git init max-pack-size &&
        (
                cd max-pack-size &&
                test_commit base &&
+
                # two cruft objects which exceed the maximum pack size
-               test-tool genrandom foo 1048576 | git hash-object --stdin -w &&
-               test-tool genrandom bar 1048576 | git hash-object --stdin -w &&
+               foo=$(write_blob foo 1048576) &&
+               bar=$(write_blob bar 1048576) &&
+               test-tool chmtime --get -1000 \
+                       "$objdir/$(test_oid_to_path $foo)" >foo.mtime &&
+               test-tool chmtime --get -2000 \
+                       "$objdir/$(test_oid_to_path $bar)" >bar.mtime &&
                git repack --cruft --max-pack-size=1M &&
                find $packdir -name "*.mtimes" >cruft &&
-               test_line_count = 1 cruft &&
-               test-tool pack-mtimes "$(basename "$(cat cruft)")" >objects &&
-               test_line_count = 2 objects
+               test_line_count = 2 cruft &&
+
+               foo_mtimes="$(basename $(find_pack $foo) .idx).mtimes" &&
+               bar_mtimes="$(basename $(find_pack $bar) .idx).mtimes" &&
+               test-tool pack-mtimes $foo_mtimes >foo.actual &&
+               test-tool pack-mtimes $bar_mtimes >bar.actual &&
+
+               echo "$foo $(cat foo.mtime)" >foo.expect &&
+               echo "$bar $(cat bar.mtime)" >bar.expect &&
+
+               test_cmp foo.expect foo.actual &&
+               test_cmp bar.expect bar.actual &&
+               test "$foo_mtimes" != "$bar_mtimes"
        )
 '
 
-test_expect_success 'cruft repack ignores pack.packSizeLimit' '
+test_expect_success 'cruft repack with pack.packSizeLimit' '
        (
                cd max-pack-size &&
                # repack everything back together to remove the existing cruft
@@ -599,9 +630,12 @@ test_expect_success 'cruft repack ignores pack.packSizeLimit' '
                # ensure the same post condition is met when --max-pack-size
                # would otherwise be inferred from the configuration
                find $packdir -name "*.mtimes" >cruft &&
-               test_line_count = 1 cruft &&
-               test-tool pack-mtimes "$(basename "$(cat cruft)")" >objects &&
-               test_line_count = 2 objects
+               test_line_count = 2 cruft &&
+               for pack in $(cat cruft)
+               do
+                       test-tool pack-mtimes "$(basename $pack)" >objects &&
+                       test_line_count = 1 objects || return 1
+               done
        )
 '
 
index d18f2823d86e8b94c5331b1087f962469fc91f2c..bb15ac34f777641bacda13bf2b19874ca75b67e6 100755 (executable)
@@ -132,13 +132,18 @@ test_expect_success 'single branch object count' '
 '
 
 test_expect_success 'single given branch clone' '
-       git clone --single-branch --branch A "file://$(pwd)/." branch-a &&
-       test_must_fail git --git-dir=branch-a/.git rev-parse origin/B
+       GIT_TRACE2_EVENT="$(pwd)/branch-a/trace2_event" \
+               git clone --single-branch --branch A "file://$(pwd)/." branch-a &&
+       test_must_fail git --git-dir=branch-a/.git rev-parse origin/B &&
+       grep \"fetch-info\".*\"haves\":0 branch-a/trace2_event &&
+       grep \"fetch-info\".*\"wants\":1 branch-a/trace2_event
 '
 
 test_expect_success 'clone shallow depth 1' '
-       git clone --no-single-branch --depth 1 "file://$(pwd)/." shallow0 &&
-       test "$(git --git-dir=shallow0/.git rev-list --count HEAD)" = 1
+       GIT_TRACE2_EVENT="$(pwd)/shallow0/trace2_event" \
+               git clone --no-single-branch --depth 1 "file://$(pwd)/." shallow0 &&
+       test "$(git --git-dir=shallow0/.git rev-list --count HEAD)" = 1 &&
+       grep \"fetch-info\".*\"depth\":1 shallow0/trace2_event
 '
 
 test_expect_success 'clone shallow depth 1 with fsck' '
@@ -235,7 +240,10 @@ test_expect_success 'add two more (part 2)' '
 test_expect_success 'deepening pull in shallow repo' '
        (
                cd shallow &&
-               git pull --depth 4 .. B
+               GIT_TRACE2_EVENT="$(pwd)/trace2_event" \
+                       git pull --depth 4 .. B &&
+               grep \"fetch-info\".*\"depth\":4 trace2_event &&
+               grep \"fetch-info\".*\"shallows\":2 trace2_event
        )
 '
 
@@ -306,9 +314,12 @@ test_expect_success 'fetch --depth --no-shallow' '
 test_expect_success 'turn shallow to complete repository' '
        (
                cd shallow &&
-               git fetch --unshallow &&
+               GIT_TRACE2_EVENT="$(pwd)/trace2_event" \
+                       git fetch --unshallow &&
                ! test -f .git/shallow &&
-               git fsck --full
+               git fsck --full &&
+               grep \"fetch-info\".*\"shallows\":2 trace2_event &&
+               grep \"fetch-info\".*\"depth\":2147483647 trace2_event
        )
 '
 
@@ -826,13 +837,15 @@ test_expect_success 'clone shallow since ...' '
 '
 
 test_expect_success 'fetch shallow since ...' '
-       git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
+       GIT_TRACE2_EVENT=$(pwd)/shallow11/trace2_event \
+               git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
        git -C shallow11 log --pretty=tformat:%s origin/main >actual &&
        cat >expected <<-\EOF &&
        three
        two
        EOF
-       test_cmp expected actual
+       test_cmp expected actual &&
+       grep \"fetch-info\".*\"deepen-since\":true shallow11/trace2_event
 '
 
 test_expect_success 'clone shallow since selects no commits' '
@@ -987,13 +1000,16 @@ test_expect_success 'filtering by size' '
        test_config -C server uploadpack.allowfilter 1 &&
 
        test_create_repo client &&
-       git -C client fetch-pack --filter=blob:limit=0 ../server HEAD &&
+       GIT_TRACE2_EVENT=$(pwd)/client/trace2_event \
+               git -C client fetch-pack --filter=blob:limit=0 ../server HEAD &&
 
        # Ensure that object is not inadvertently fetched
        commit=$(git -C server rev-parse HEAD) &&
        blob=$(git hash-object server/one.t) &&
        git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
-       ! grep "$blob" oids
+       ! grep "$blob" oids &&
+
+       grep \"fetch-info\".*\"filter\":\"blob:limit\" client/trace2_event
 '
 
 test_expect_success 'filtering by size has no effect if support for it is not advertised' '
index 264de29c35c11cbe09d31d57629aabaae0423b35..079b2f2536e6974c90b152226d8ea2189016a6f6 100755 (executable)
@@ -5,6 +5,7 @@ test_description='pull options'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '
index 5a67bbc760fdc8c2b53dc7721a144e033bf8e934..ced40157ed68c077c17cb4758d1ebbc529e67d9c 100755 (executable)
@@ -5,6 +5,7 @@ test_description='ancestor culling and limiting by parent number'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 check_revlist () {
index a57f1ae2baa4a72e88183fcaa3b55802a80599ef..4821b90e7479ad8f4878ab4432ce0e9d2ce47de5 100755 (executable)
@@ -68,6 +68,7 @@ check --glob=refs/heads
 check --glob=refs/heads --
 check --glob=refs/heads -- file-1
 check --end-of-options -dashed-branch
+check --all --not refs/heads/main
 
 test_expect_success 'not only --stdin' '
        cat >expect <<-EOF &&
@@ -127,4 +128,24 @@ test_expect_success 'unknown option without --end-of-options' '
        test_cmp expect error
 '
 
+test_expect_success '--not on command line does not influence revisions read via --stdin' '
+       cat >input <<-EOF &&
+       refs/heads/main
+       EOF
+       git rev-list refs/heads/main >expect &&
+
+       git rev-list refs/heads/main --not --stdin <input >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '--not via stdin does not influence revisions from command line' '
+       cat >input <<-EOF &&
+       --not
+       EOF
+       git rev-list refs/heads/main >expect &&
+
+       git rev-list refs/heads/main --stdin refs/heads/main <input >actual &&
+       test_cmp expect actual
+'
+
 test_done
index 7b943fd34cdece8c4fca0b55e4fab8510ac4b7b1..00a060df0b5e81cc1c47758240a7c790384b758e 100755 (executable)
@@ -25,6 +25,13 @@ test_expect_success setup '
        disklen sha1:138
        disklen sha256:154
        EOF
+
+       # setup .mailmap
+       cat >.mailmap <<-EOF &&
+       A Thor <athor@example.com> A U Thor <author@example.com>
+       C Mitter <cmitter@example.com> C O Mitter <committer@example.com>
+       EOF
+
        setdate_and_increment &&
        echo "Using $datestamp" > one &&
        git add one &&
@@ -41,25 +48,29 @@ test_expect_success setup '
        git config push.default current
 '
 
-test_atom() {
+test_atom () {
        case "$1" in
                head) ref=refs/heads/main ;;
                 tag) ref=refs/tags/testtag ;;
                 sym) ref=refs/heads/sym ;;
                   *) ref=$1 ;;
        esac
+       format=$2
+       test_do=test_expect_${4:-success}
+
        printf '%s\n' "$3" >expected
-       test_expect_${4:-success} $PREREQ "basic atom: $1 $2" "
-               git for-each-ref --format='%($2)' $ref >actual &&
+       $test_do $PREREQ "basic atom: $ref $format" '
+               git for-each-ref --format="%($format)" "$ref" >actual &&
                sanitize_pgp <actual >actual.clean &&
                test_cmp expected actual.clean
-       "
+       '
+
        # Automatically test "contents:size" atom after testing "contents"
-       if test "$2" = "contents"
+       if test "$format" = "contents"
        then
                # for commit leg, $3 is changed there
                expect=$(printf '%s' "$3" | wc -c)
-               test_expect_${4:-success} $PREREQ "basic atom: $1 contents:size" '
+               $test_do $PREREQ "basic atom: $ref contents:size" '
                        type=$(git cat-file -t "$ref") &&
                        case $type in
                        tag)
@@ -141,15 +152,31 @@ test_atom head '*objectname' ''
 test_atom head '*objecttype' ''
 test_atom head author 'A U Thor <author@example.com> 1151968724 +0200'
 test_atom head authorname 'A U Thor'
+test_atom head authorname:mailmap 'A Thor'
 test_atom head authoremail '<author@example.com>'
 test_atom head authoremail:trim 'author@example.com'
 test_atom head authoremail:localpart 'author'
+test_atom head authoremail:trim,localpart 'author'
+test_atom head authoremail:mailmap '<athor@example.com>'
+test_atom head authoremail:mailmap,trim 'athor@example.com'
+test_atom head authoremail:trim,mailmap 'athor@example.com'
+test_atom head authoremail:mailmap,localpart 'athor'
+test_atom head authoremail:localpart,mailmap 'athor'
+test_atom head authoremail:mailmap,trim,localpart,mailmap,trim 'athor'
 test_atom head authordate 'Tue Jul 4 01:18:44 2006 +0200'
 test_atom head committer 'C O Mitter <committer@example.com> 1151968723 +0200'
 test_atom head committername 'C O Mitter'
+test_atom head committername:mailmap 'C Mitter'
 test_atom head committeremail '<committer@example.com>'
 test_atom head committeremail:trim 'committer@example.com'
 test_atom head committeremail:localpart 'committer'
+test_atom head committeremail:localpart,trim 'committer'
+test_atom head committeremail:mailmap '<cmitter@example.com>'
+test_atom head committeremail:mailmap,trim 'cmitter@example.com'
+test_atom head committeremail:trim,mailmap 'cmitter@example.com'
+test_atom head committeremail:mailmap,localpart 'cmitter'
+test_atom head committeremail:localpart,mailmap 'cmitter'
+test_atom head committeremail:trim,mailmap,trim,trim,localpart 'cmitter'
 test_atom head committerdate 'Tue Jul 4 01:18:43 2006 +0200'
 test_atom head tag ''
 test_atom head tagger ''
@@ -199,22 +226,46 @@ test_atom tag '*objectname' $(git rev-parse refs/tags/testtag^{})
 test_atom tag '*objecttype' 'commit'
 test_atom tag author ''
 test_atom tag authorname ''
+test_atom tag authorname:mailmap ''
 test_atom tag authoremail ''
 test_atom tag authoremail:trim ''
 test_atom tag authoremail:localpart ''
+test_atom tag authoremail:trim,localpart ''
+test_atom tag authoremail:mailmap ''
+test_atom tag authoremail:mailmap,trim ''
+test_atom tag authoremail:trim,mailmap ''
+test_atom tag authoremail:mailmap,localpart ''
+test_atom tag authoremail:localpart,mailmap ''
+test_atom tag authoremail:mailmap,trim,localpart,mailmap,trim ''
 test_atom tag authordate ''
 test_atom tag committer ''
 test_atom tag committername ''
+test_atom tag committername:mailmap ''
 test_atom tag committeremail ''
 test_atom tag committeremail:trim ''
 test_atom tag committeremail:localpart ''
+test_atom tag committeremail:localpart,trim ''
+test_atom tag committeremail:mailmap ''
+test_atom tag committeremail:mailmap,trim ''
+test_atom tag committeremail:trim,mailmap ''
+test_atom tag committeremail:mailmap,localpart ''
+test_atom tag committeremail:localpart,mailmap ''
+test_atom tag committeremail:trim,mailmap,trim,trim,localpart ''
 test_atom tag committerdate ''
 test_atom tag tag 'testtag'
 test_atom tag tagger 'C O Mitter <committer@example.com> 1151968725 +0200'
 test_atom tag taggername 'C O Mitter'
+test_atom tag taggername:mailmap 'C Mitter'
 test_atom tag taggeremail '<committer@example.com>'
 test_atom tag taggeremail:trim 'committer@example.com'
 test_atom tag taggeremail:localpart 'committer'
+test_atom tag taggeremail:trim,localpart 'committer'
+test_atom tag taggeremail:mailmap '<cmitter@example.com>'
+test_atom tag taggeremail:mailmap,trim 'cmitter@example.com'
+test_atom tag taggeremail:trim,mailmap 'cmitter@example.com'
+test_atom tag taggeremail:mailmap,localpart 'cmitter'
+test_atom tag taggeremail:localpart,mailmap 'cmitter'
+test_atom tag taggeremail:trim,mailmap,trim,localpart,localpart 'cmitter'
 test_atom tag taggerdate 'Tue Jul 4 01:18:45 2006 +0200'
 test_atom tag creator 'C O Mitter <committer@example.com> 1151968725 +0200'
 test_atom tag creatordate 'Tue Jul 4 01:18:45 2006 +0200'
@@ -267,6 +318,66 @@ test_expect_success 'arguments to %(objectname:short=) must be positive integers
        test_must_fail git for-each-ref --format="%(objectname:short=foo)"
 '
 
+test_bad_atom () {
+       case "$1" in
+       head) ref=refs/heads/main ;;
+        tag) ref=refs/tags/testtag ;;
+        sym) ref=refs/heads/sym ;;
+          *) ref=$1 ;;
+       esac
+       format=$2
+       test_do=test_expect_${4:-success}
+
+       printf '%s\n' "$3" >expect
+       $test_do $PREREQ "err basic atom: $ref $format" '
+               test_must_fail git for-each-ref \
+                       --format="%($format)" "$ref" 2>error &&
+               test_cmp expect error
+       '
+}
+
+test_bad_atom head 'authoremail:foo' \
+       'fatal: unrecognized %(authoremail) argument: foo'
+
+test_bad_atom head 'authoremail:mailmap,trim,bar' \
+       'fatal: unrecognized %(authoremail) argument: bar'
+
+test_bad_atom head 'authoremail:trim,' \
+       'fatal: unrecognized %(authoremail) argument: '
+
+test_bad_atom head 'authoremail:mailmaptrim' \
+       'fatal: unrecognized %(authoremail) argument: trim'
+
+test_bad_atom head 'committeremail: ' \
+       'fatal: unrecognized %(committeremail) argument:  '
+
+test_bad_atom head 'committeremail: trim,foo' \
+       'fatal: unrecognized %(committeremail) argument:  trim,foo'
+
+test_bad_atom head 'committeremail:mailmap,localpart ' \
+       'fatal: unrecognized %(committeremail) argument:  '
+
+test_bad_atom head 'committeremail:trim_localpart' \
+       'fatal: unrecognized %(committeremail) argument: _localpart'
+
+test_bad_atom head 'committeremail:localpart,,,trim' \
+       'fatal: unrecognized %(committeremail) argument: ,,trim'
+
+test_bad_atom tag 'taggeremail:mailmap,trim, foo ' \
+       'fatal: unrecognized %(taggeremail) argument:  foo '
+
+test_bad_atom tag 'taggeremail:trim,localpart,' \
+       'fatal: unrecognized %(taggeremail) argument: '
+
+test_bad_atom tag 'taggeremail:mailmap;localpart trim' \
+       'fatal: unrecognized %(taggeremail) argument: ;localpart trim'
+
+test_bad_atom tag 'taggeremail:localpart trim' \
+       'fatal: unrecognized %(taggeremail) argument:  trim'
+
+test_bad_atom tag 'taggeremail:mailmap,mailmap,trim,qux,localpart,trim' \
+       'fatal: unrecognized %(taggeremail) argument: qux,localpart,trim'
+
 test_date () {
        f=$1 &&
        committer_date=$2 &&
index 9677180a5b3392da63ab32f4462c5ec89a9958f3..72f8c1722ff76d332529450b4115d7afb39ed5ec 100755 (executable)
@@ -179,7 +179,8 @@ test_expect_success !WINDOWS 'custom merge driver that is killed with a signal'
 
        >./please-abort &&
        echo "* merge=custom" >.gitattributes &&
-       test_must_fail git merge main &&
+       test_must_fail git merge main 2>err &&
+       grep "^error: failed to execute internal merge" err &&
        git ls-files -u >output &&
        git diff --name-only HEAD >>output &&
        test_must_be_empty output
index 17b54d625d0e468047377c378faae25c50633c9b..5f414abc89267d3f3729366d67f8b7d6aec52c37 100755 (executable)
@@ -5,6 +5,7 @@ test_description='recursive merge corner cases involving criss-cross merges'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-merge.sh
 
index b16031465f34b20600cadd51c2f620ec64ae0e54..2b42f095dcba5b228a60cb6ce2ea5678e611c893 100755 (executable)
@@ -5,6 +5,7 @@ test_description='"git merge" top-level frontend'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 t3033_reset () {
index c9a86f2e947e4a2943438cc5adcaaeab39a465d9..daa507862c65ea73d39c555ed2c316503094be49 100755 (executable)
@@ -8,6 +8,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-merge.sh
 
index 69509d0c11db655a12fc6ed20215ed25976c46eb..04acf22d930421cf206556c54b1acf0a22b644d4 100755 (executable)
@@ -202,6 +202,30 @@ test_expect_success 'one of gc.reflogExpire{Unreachable,}=never does not skip "e
        grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out
 '
 
+test_expect_success 'gc.repackFilter launches repack with a filter' '
+       git clone --no-local --bare . bare.git &&
+
+       git -C bare.git -c gc.cruftPacks=false gc &&
+       test_stdout_line_count = 1 ls bare.git/objects/pack/*.pack &&
+
+       GIT_TRACE=$(pwd)/trace.out git -C bare.git -c gc.repackFilter=blob:none \
+               -c repack.writeBitmaps=false -c gc.cruftPacks=false gc &&
+       test_stdout_line_count = 2 ls bare.git/objects/pack/*.pack &&
+       grep -E "^trace: (built-in|exec|run_command): git repack .* --filter=blob:none ?.*" trace.out
+'
+
+test_expect_success 'gc.repackFilterTo store filtered out objects' '
+       test_when_finished "rm -rf bare.git filtered.git" &&
+
+       git init --bare filtered.git &&
+       git -C bare.git -c gc.repackFilter=blob:none \
+               -c gc.repackFilterTo=../filtered.git/objects/pack/pack \
+               -c repack.writeBitmaps=false -c gc.cruftPacks=false gc &&
+
+       test_stdout_line_count = 1 ls bare.git/objects/pack/*.pack &&
+       test_stdout_line_count = 1 ls filtered.git/objects/pack/*.pack
+'
+
 prepare_cruft_history () {
        test_commit base &&
 
@@ -303,6 +327,33 @@ test_expect_success 'gc.bigPackThreshold ignores cruft packs' '
        )
 '
 
+cruft_max_size_opts="git repack -d -l --cruft --cruft-expiration=2.weeks.ago"
+
+test_expect_success 'setup for --max-cruft-size tests' '
+       git init cruft--max-size &&
+       (
+               cd cruft--max-size &&
+               prepare_cruft_history
+       )
+'
+
+test_expect_success '--max-cruft-size sets appropriate repack options' '
+       GIT_TRACE2_EVENT=$(pwd)/trace2.txt git -C cruft--max-size \
+               gc --cruft --max-cruft-size=1M &&
+       test_subcommand $cruft_max_size_opts --max-cruft-size=1048576 <trace2.txt
+'
+
+test_expect_success 'gc.maxCruftSize sets appropriate repack options' '
+       GIT_TRACE2_EVENT=$(pwd)/trace2.txt \
+               git -C cruft--max-size -c gc.maxCruftSize=2M gc --cruft &&
+       test_subcommand $cruft_max_size_opts --max-cruft-size=2097152 <trace2.txt &&
+
+       GIT_TRACE2_EVENT=$(pwd)/trace2.txt \
+               git -C cruft--max-size -c gc.maxCruftSize=2M gc --cruft \
+               --max-cruft-size=3M &&
+       test_subcommand $cruft_max_size_opts --max-cruft-size=3145728 <trace2.txt
+'
+
 run_and_wait_for_auto_gc () {
        # We read stdout from gc for the side effect of waiting until the
        # background gc process exits, closing its fd 9.  Furthermore, the
diff --git a/t/t6700-tree-depth.sh b/t/t6700-tree-depth.sh
new file mode 100755 (executable)
index 0000000..9e70a7c
--- /dev/null
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='handling of deep trees in various commands'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+# We'll test against two depths here: a small one that will let us check the
+# behavior of the config setting easily, and a large one that should be
+# forbidden by default. Testing the default depth will let us know whether our
+# default is enough to prevent segfaults on systems that run the tests.
+small_depth=50
+big_depth=4100
+
+small_ok="-c core.maxtreedepth=$small_depth"
+small_no="-c core.maxtreedepth=$((small_depth-1))"
+
+# usage: mkdeep <name> <depth>
+#   Create a tag <name> containing a file whose path has depth <depth>.
+#
+# We'll use fast-import here for two reasons:
+#
+#   1. It's faster than creating $big_depth tree objects.
+#
+#   2. As we tighten tree limits, it's more likely to allow large sizes
+#      than trying to stuff a deep path into the index.
+mkdeep () {
+       {
+               echo "commit refs/tags/$1" &&
+               echo "committer foo <foo@example.com> 1234 -0000" &&
+               echo "data <<EOF" &&
+               echo "the commit message" &&
+               echo "EOF" &&
+
+               printf 'M 100644 inline ' &&
+               i=0 &&
+               while test $i -lt $2
+               do
+                       printf 'a/'
+                       i=$((i+1))
+               done &&
+               echo "file" &&
+
+               echo "data <<EOF" &&
+               echo "the file contents" &&
+               echo "EOF" &&
+               echo
+       } | git fast-import
+}
+
+test_expect_success 'create small tree' '
+       mkdeep small $small_depth
+'
+
+test_expect_success 'create big tree' '
+       mkdeep big $big_depth
+'
+
+test_expect_success 'limit recursion of git-archive' '
+       git $small_ok archive small >/dev/null &&
+       test_must_fail git $small_no archive small >/dev/null
+'
+
+test_expect_success 'default limit for git-archive fails gracefully' '
+       test_must_fail git archive big >/dev/null
+'
+
+test_expect_success 'limit recursion of ls-tree -r' '
+       git $small_ok ls-tree -r small &&
+       test_must_fail git $small_no ls-tree -r small
+'
+
+test_expect_success 'default limit for ls-tree fails gracefully' '
+       test_must_fail git ls-tree -r big >/dev/null
+'
+
+test_expect_success 'limit recursion of rev-list --objects' '
+       git $small_ok rev-list --objects small >/dev/null &&
+       test_must_fail git $small_no rev-list --objects small >/dev/null
+'
+
+test_expect_success 'default limit for rev-list fails gracefully' '
+       test_must_fail git rev-list --objects big >/dev/null
+'
+
+test_expect_success 'limit recursion of diff-tree -r' '
+       git $small_ok diff-tree -r $EMPTY_TREE small &&
+       test_must_fail git $small_no diff-tree -r $EMPTY_TREE small
+'
+
+test_expect_success 'default limit for diff-tree fails gracefully' '
+       test_must_fail git diff-tree -r $EMPTY_TREE big
+'
+
+test_done
index 35b9e6ed6b5ba337d9fb4603281500656313ed1d..ebf273e84380c4c97054d6f2c38319cf3de17453 100755 (executable)
@@ -497,6 +497,11 @@ test_expect_success 'checkout unmerged stage' '
        test ztheirside = "z$(cat file)"
 '
 
+test_expect_success 'checkout path with --merge from tree-ish is a no-no' '
+       setup_conflicting_index &&
+       test_must_fail git checkout -m HEAD -- file
+'
+
 test_expect_success 'checkout with --merge' '
        setup_conflicting_index &&
        echo "none of the above" >sample &&
@@ -517,6 +522,48 @@ test_expect_success 'checkout with --merge' '
        test_cmp merged file
 '
 
+test_expect_success 'checkout -m works after (mistaken) resolution' '
+       setup_conflicting_index &&
+       echo "none of the above" >sample &&
+       cat sample >fild &&
+       cat sample >file &&
+       cat sample >filf &&
+       # resolve to something
+       git add file &&
+       git checkout --merge -- fild file filf &&
+       {
+               echo "<<<<<<< ours" &&
+               echo ourside &&
+               echo "=======" &&
+               echo theirside &&
+               echo ">>>>>>> theirs"
+       } >merged &&
+       test_cmp expect fild &&
+       test_cmp expect filf &&
+       test_cmp merged file
+'
+
+test_expect_success 'checkout -m works after (mistaken) resolution to remove' '
+       setup_conflicting_index &&
+       echo "none of the above" >sample &&
+       cat sample >fild &&
+       cat sample >file &&
+       cat sample >filf &&
+       # resolve to remove
+       git rm file &&
+       git checkout --merge -- fild file filf &&
+       {
+               echo "<<<<<<< ours" &&
+               echo ourside &&
+               echo "=======" &&
+               echo theirside &&
+               echo ">>>>>>> theirs"
+       } >merged &&
+       test_cmp expect fild &&
+       test_cmp expect filf &&
+       test_cmp merged file
+'
+
 test_expect_success 'checkout with --merge, in diff3 -m style' '
        git config merge.conflictstyle diff3 &&
        setup_conflicting_index &&
index 232065504cbfdcba60d3f5f69ffb4536b5ae99e8..a5d1bc5c54ae095f79bf9b3ee420ba004bb18a88 100755 (executable)
@@ -11,6 +11,10 @@ as expected.
 
 TEST_PASSES_SANITIZE_LEAK=true
 TEST_NO_CREATE_REPO=1
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 . ./test-lib.sh
 
 test_expect_success 'setup' '
@@ -27,26 +31,28 @@ test_expect_success 'submodule config cache setup' '
                git checkout -b topic &&
                echo b >a &&
                git add . &&
-               git commit -mb
+               git commit -mb &&
+               git checkout main
        ) &&
        mkdir super &&
        (cd super &&
                git init &&
                git submodule add ../submodule &&
-               git commit -m "add submodule"
+               git submodule add --name thename ../submodule thepath &&
+               git commit -m "add submodules"
        )
 '
 
 test_expect_success 'ensure submodule branch is unset' '
        (cd super &&
-               ! grep branch .gitmodules
+               test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch
        )
 '
 
 test_expect_success 'test submodule set-branch --branch' '
        (cd super &&
                git submodule set-branch --branch topic submodule &&
-               grep "branch = topic" .gitmodules &&
+               test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
                git submodule update --remote &&
                cat <<-\EOF >expect &&
                b
@@ -57,13 +63,12 @@ test_expect_success 'test submodule set-branch --branch' '
 '
 
 test_expect_success 'test submodule set-branch --default' '
-       test_commit -C submodule c &&
        (cd super &&
                git submodule set-branch --default submodule &&
-               ! grep branch .gitmodules &&
+               test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
                git submodule update --remote &&
                cat <<-\EOF >expect &&
-               c
+               a
                EOF
                git -C submodule show -s --pretty=%s >actual &&
                test_cmp expect actual
@@ -71,10 +76,9 @@ test_expect_success 'test submodule set-branch --default' '
 '
 
 test_expect_success 'test submodule set-branch -b' '
-       test_commit -C submodule b &&
        (cd super &&
                git submodule set-branch -b topic submodule &&
-               grep "branch = topic" .gitmodules &&
+               test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
                git submodule update --remote &&
                cat <<-\EOF >expect &&
                b
@@ -85,17 +89,43 @@ test_expect_success 'test submodule set-branch -b' '
 '
 
 test_expect_success 'test submodule set-branch -d' '
-       test_commit -C submodule d &&
        (cd super &&
                git submodule set-branch -d submodule &&
-               ! grep branch .gitmodules &&
+               test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
                git submodule update --remote &&
                cat <<-\EOF >expect &&
-               d
+               a
                EOF
                git -C submodule show -s --pretty=%s >actual &&
                test_cmp expect actual
        )
 '
 
+test_expect_success 'test submodule set-branch --branch with named submodule' '
+       (cd super &&
+               git submodule set-branch --branch topic thepath &&
+               test_cmp_config topic -f .gitmodules submodule.thename.branch &&
+               test_cmp_config "" -f .gitmodules --default "" submodule.thepath.branch &&
+               git submodule update --remote &&
+               cat <<-\EOF >expect &&
+               b
+               EOF
+               git -C thepath show -s --pretty=%s >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'test submodule set-branch --default with named submodule' '
+       (cd super &&
+               git submodule set-branch --default thepath &&
+               test_cmp_config "" -f .gitmodules --default "" submodule.thename.branch &&
+               git submodule update --remote &&
+               cat <<-\EOF >expect &&
+               a
+               EOF
+               git -C thepath show -s --pretty=%s >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done
index d6bf62b3ac670fc0be8167150cdf79cbd9000a45..bf7f15ee7973958970dfe0d1b34cea9d25e635a9 100755 (executable)
@@ -25,17 +25,26 @@ test_expect_success 'submodule config cache setup' '
                git add file &&
                git commit -ma
        ) &&
+       mkdir namedsubmodule &&
+       (
+               cd namedsubmodule &&
+               git init &&
+               echo 1 >file &&
+               git add file &&
+               git commit -m1
+       ) &&
        mkdir super &&
        (
                cd super &&
                git init &&
                git submodule add ../submodule &&
-               git commit -m "add submodule"
+               git submodule add --name thename ../namedsubmodule thepath &&
+               git commit -m "add submodules"
        )
 '
 
 test_expect_success 'test submodule set-url' '
-       # add a commit and move the submodule (change the url)
+       # add commits and move the submodules (change the urls)
        (
                cd submodule &&
                echo b >>file &&
@@ -44,15 +53,28 @@ test_expect_success 'test submodule set-url' '
        ) &&
        mv submodule newsubmodule &&
 
+       (
+               cd namedsubmodule &&
+               echo 2 >>file &&
+               git add file &&
+               git commit -m2
+       ) &&
+       mv namedsubmodule newnamedsubmodule &&
+
        git -C newsubmodule show >expect &&
+       git -C newnamedsubmodule show >>expect &&
        (
                cd super &&
                test_must_fail git submodule update --remote &&
                git submodule set-url submodule ../newsubmodule &&
-               grep -F "url = ../newsubmodule" .gitmodules &&
+               test_cmp_config ../newsubmodule -f .gitmodules submodule.submodule.url &&
+               git submodule set-url thepath ../newnamedsubmodule &&
+               test_cmp_config ../newnamedsubmodule -f .gitmodules submodule.thename.url &&
+               test_cmp_config "" -f .gitmodules --default "" submodule.thepath.url &&
                git submodule update --remote
        ) &&
        git -C super/submodule show >actual &&
+       git -C super/thepath show >>actual &&
        test_cmp expect actual
 '
 
index 6928fd89f5d887b2f7a3feb9263b39d77affe9aa..6c46648e1128ccc7182c8618f89ac3d7c15b988c 100755 (executable)
@@ -1745,4 +1745,20 @@ test_expect_success 'slow status advice when core.untrackedCache true, and fsmon
        )
 '
 
+test_expect_success EXPENSIVE 'status does not re-read unchanged 4 or 8 GiB file' '
+       (
+               mkdir large-file &&
+               cd large-file &&
+               # Files are 2 GiB, 4 GiB, and 8 GiB sparse files.
+               test-tool truncate file-a 0x080000000 &&
+               test-tool truncate file-b 0x100000000 &&
+               test-tool truncate file-c 0x200000000 &&
+               # This will be slow.
+               git add file-a file-b file-c &&
+               git commit -m "add large files" &&
+               git diff-index HEAD file-a file-b file-c >actual &&
+               test_must_be_empty actual
+       )
+'
+
 test_done
index 97f10905d23fd3077aa9dd253fa079eb9c5be73d..832aff0616736025cb78d2b35e3823594b543b1d 100755 (executable)
@@ -489,7 +489,7 @@ test_expect_success 'multiline field treated as atomic for neighbor check' '
 '
 
 test_expect_success 'with config setup' '
-       git config trailer.ack.key "Acked-by: " &&
+       test_config trailer.ack.key "Acked-by: " &&
        cat >expected <<-\EOF &&
 
                Acked-by: Peff
@@ -503,8 +503,8 @@ test_expect_success 'with config setup' '
 '
 
 test_expect_success 'with config setup and ":=" as separators' '
-       git config trailer.separators ":=" &&
-       git config trailer.ack.key "Acked-by= " &&
+       test_config trailer.separators ":=" &&
+       test_config trailer.ack.key "Acked-by= " &&
        cat >expected <<-\EOF &&
 
                Acked-by= Peff
@@ -518,7 +518,7 @@ test_expect_success 'with config setup and ":=" as separators' '
 '
 
 test_expect_success 'with config setup and "%" as separators' '
-       git config trailer.separators "%" &&
+       test_config trailer.separators "%" &&
        cat >expected <<-\EOF &&
 
                bug% 42
@@ -532,6 +532,7 @@ test_expect_success 'with config setup and "%" as separators' '
 '
 
 test_expect_success 'with "%" as separators and a message with trailers' '
+       test_config trailer.separators "%" &&
        cat >special_message <<-\EOF &&
                Special Message
 
@@ -553,8 +554,8 @@ test_expect_success 'with "%" as separators and a message with trailers' '
 '
 
 test_expect_success 'with config setup and ":=#" as separators' '
-       git config trailer.separators ":=#" &&
-       git config trailer.bug.key "Bug #" &&
+       test_config trailer.separators ":=#" &&
+       test_config trailer.bug.key "Bug #" &&
        cat >expected <<-\EOF &&
 
                Bug #42
@@ -581,6 +582,8 @@ test_expect_success 'with basic patch' '
 '
 
 test_expect_success 'with commit complex message as argument' '
+       test_config trailer.separators ":=" &&
+       test_config trailer.ack.key "Acked-by= " &&
        cat complex_message_body complex_message_trailers >complex_message &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
@@ -594,6 +597,8 @@ test_expect_success 'with commit complex message as argument' '
 '
 
 test_expect_success 'with 2 files arguments' '
+       test_config trailer.separators ":=" &&
+       test_config trailer.ack.key "Acked-by= " &&
        cat basic_message >>expected &&
        echo >>expected &&
        cat basic_patch >>expected &&
@@ -677,6 +682,9 @@ test_expect_success 'with message that has an old style conflict block' '
 '
 
 test_expect_success 'with commit complex message and trailer args' '
+       test_config trailer.separators ":=#" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.bug.key "Bug #" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -692,6 +700,9 @@ test_expect_success 'with commit complex message and trailer args' '
 '
 
 test_expect_success 'with complex patch, args and --trim-empty' '
+       test_config trailer.separators ":=#" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.bug.key "Bug #" &&
        cat complex_message >complex_patch &&
        cat basic_patch >>complex_patch &&
        cat complex_message_body >expected &&
@@ -746,7 +757,10 @@ test_expect_success POSIXPERM,SANITY "in-place editing doesn't clobber original
 '
 
 test_expect_success 'using "where = before"' '
-       git config trailer.bug.where "before" &&
+       test_config trailer.separators ":=#" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -762,7 +776,9 @@ test_expect_success 'using "where = before"' '
 '
 
 test_expect_success 'overriding configuration with "--where after"' '
-       git config trailer.ack.where "before" &&
+       test_config trailer.separators ":=" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "before" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -776,7 +792,12 @@ test_expect_success 'overriding configuration with "--where after"' '
        test_cmp expected actual
 '
 
-test_expect_success 'using "where = before" with "--no-where"' '
+test_expect_success 'using "--where after" with "--no-where"' '
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "before" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -791,8 +812,59 @@ test_expect_success 'using "where = before" with "--no-where"' '
        test_cmp expected actual
 '
 
+# Check whether using "--no-where" clears out only the "--where after", such
+# that we still use the configuration in trailer.where (which is different from
+# the hardcoded default (in WHERE_END) assuming the absence of .gitconfig).
+# Here, the "start" setting of trailer.where is respected, so the new "Acked-by"
+# and "Bug" trailers are placed at the beginning, and not at the end which is
+# the harcoded default.
+test_expect_success 'using "--where after" with "--no-where" defaults to configuration' '
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.separators ":=#" &&
+       test_config trailer.where "start" &&
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+               Bug #42
+               Acked-by= Peff
+               Fixes: Z
+               Acked-by= Z
+               Reviewed-by: Z
+               Signed-off-by: Z
+       EOF
+       git interpret-trailers --where after --no-where --trailer "ack: Peff" \
+               --trailer "bug: 42" complex_message >actual &&
+       test_cmp expected actual
+'
+
+# The "--where after" will only get respected for the trailer that came
+# immediately after it. For the next trailer (Bug #42), we default to using the
+# hardcoded WHERE_END because we don't have any "trailer.where" or
+# "trailer.bug.where" configured.
+test_expect_success 'using "--no-where" defaults to harcoded default if nothing configured' '
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.separators ":=#" &&
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+               Fixes: Z
+               Acked-by= Z
+               Acked-by= Peff
+               Reviewed-by: Z
+               Signed-off-by: Z
+               Bug #42
+       EOF
+       git interpret-trailers --where after --trailer "ack: Peff" --no-where \
+               --trailer "bug: 42" complex_message >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'using "where = after"' '
-       git config trailer.ack.where "after" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -808,8 +880,11 @@ test_expect_success 'using "where = after"' '
 '
 
 test_expect_success 'using "where = end"' '
-       git config trailer.review.key "Reviewed-by" &&
-       git config trailer.review.where "end" &&
+       test_config trailer.review.key "Reviewed-by" &&
+       test_config trailer.review.where "end" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -827,8 +902,11 @@ test_expect_success 'using "where = end"' '
 '
 
 test_expect_success 'using "where = start"' '
-       git config trailer.review.key "Reviewed-by" &&
-       git config trailer.review.where "start" &&
+       test_config trailer.review.key "Reviewed-by" &&
+       test_config trailer.review.where "start" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Reviewed-by: Johannes
@@ -846,8 +924,13 @@ test_expect_success 'using "where = start"' '
 '
 
 test_expect_success 'using "where = before" for a token in the middle of the message' '
-       git config trailer.review.key "Reviewed-by:" &&
-       git config trailer.review.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.review.where "before" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -864,6 +947,12 @@ test_expect_success 'using "where = before" for a token in the middle of the mes
 '
 
 test_expect_success 'using "where = before" and --trim-empty' '
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        cat >>expected <<-\EOF &&
                Bug #46
@@ -878,6 +967,13 @@ test_expect_success 'using "where = before" and --trim-empty' '
 '
 
 test_expect_success 'the default is "ifExists = addIfDifferentNeighbor"' '
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.review.where "before" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -896,7 +992,13 @@ test_expect_success 'the default is "ifExists = addIfDifferentNeighbor"' '
 '
 
 test_expect_success 'default "ifExists" is now "addIfDifferent"' '
-       git config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -914,8 +1016,14 @@ test_expect_success 'default "ifExists" is now "addIfDifferent"' '
 '
 
 test_expect_success 'using "ifExists = addIfDifferent" with "where = end"' '
-       git config trailer.ack.ifExists "addIfDifferent" &&
-       git config trailer.ack.where "end" &&
+       test_config trailer.ack.ifExists "addIfDifferent" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "end" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -932,8 +1040,14 @@ test_expect_success 'using "ifExists = addIfDifferent" with "where = end"' '
 '
 
 test_expect_success 'using "ifExists = addIfDifferent" with "where = before"' '
-       git config trailer.ack.ifExists "addIfDifferent" &&
-       git config trailer.ack.where "before" &&
+       test_config trailer.ack.ifExists "addIfDifferent" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "before" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -950,8 +1064,14 @@ test_expect_success 'using "ifExists = addIfDifferent" with "where = before"' '
 '
 
 test_expect_success 'using "ifExists = addIfDifferentNeighbor" with "where = end"' '
-       git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
-       git config trailer.ack.where "end" &&
+       test_config trailer.ack.ifExists "addIfDifferentNeighbor" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "end" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -973,8 +1093,14 @@ test_expect_success 'using "ifExists = addIfDifferentNeighbor" with "where = end
 '
 
 test_expect_success 'using "ifExists = addIfDifferentNeighbor"  with "where = after"' '
-       git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
-       git config trailer.ack.where "after" &&
+       test_config trailer.ack.ifExists "addIfDifferentNeighbor" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -995,7 +1121,11 @@ test_expect_success 'using "ifExists = addIfDifferentNeighbor"  with "where = af
 '
 
 test_expect_success 'using "ifExists = addIfDifferentNeighbor" and --trim-empty' '
-       git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
+       test_config trailer.ack.ifExists "addIfDifferentNeighbor" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        cat >>expected <<-\EOF &&
                Bug #42
@@ -1011,8 +1141,14 @@ test_expect_success 'using "ifExists = addIfDifferentNeighbor" and --trim-empty'
 '
 
 test_expect_success 'using "ifExists = add" with "where = end"' '
-       git config trailer.ack.ifExists "add" &&
-       git config trailer.ack.where "end" &&
+       test_config trailer.ack.ifExists "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "end" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1036,8 +1172,14 @@ test_expect_success 'using "ifExists = add" with "where = end"' '
 '
 
 test_expect_success 'using "ifExists = add" with "where = after"' '
-       git config trailer.ack.ifExists "add" &&
-       git config trailer.ack.where "after" &&
+       test_config trailer.ack.ifExists "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1058,8 +1200,15 @@ test_expect_success 'using "ifExists = add" with "where = after"' '
 '
 
 test_expect_success 'overriding configuration with "--if-exists replace"' '
-       git config trailer.fix.key "Fixes: " &&
-       git config trailer.fix.ifExists "add" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.review.where "before" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1074,9 +1223,66 @@ test_expect_success 'overriding configuration with "--if-exists replace"' '
        test_cmp expected actual
 '
 
+# "trailer.ifexists" is set to "doNothing", so using "--no-if-exists" defaults
+# to this "doNothing" behavior. So the "Fixes: 53" trailer does not get added.
+test_expect_success 'using "--if-exists replace" with "--no-if-exists" defaults to configuration' '
+       test_config trailer.ifexists "doNothing" &&
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+               Fixes: Z
+               Acked-by: Z
+               Reviewed-by: Z
+               Signed-off-by: Z
+       EOF
+       git interpret-trailers --if-exists replace --no-if-exists --trailer "Fixes: 53" \
+               <complex_message >actual &&
+       test_cmp expected actual
+'
+
+# No "ifexists" configuration is set, so using "--no-if-exists" makes it default
+# to addIfDifferentNeighbor. Because we do have a different neighbor "Fixes: 53"
+# (because it got added by overriding with "--if-exists replace" earlier in the
+# arguments list), we add "Signed-off-by: addme".
+test_expect_success 'using "--no-if-exists" defaults to hardcoded default if nothing configured' '
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+               Acked-by: Z
+               Reviewed-by: Z
+               Signed-off-by: Z
+               Fixes: 53
+               Signed-off-by: addme
+       EOF
+       git interpret-trailers --if-exists replace --trailer "Fixes: 53" --no-if-exists \
+               --trailer "Signed-off-by: addme" <complex_message >actual &&
+       test_cmp expected actual
+'
+
+# The second "Fixes: 53" trailer is discarded, because the "--no-if-exists" here
+# makes us default to addIfDifferentNeighbor, and we already added the "Fixes:
+# 53" trailer earlier in the argument list.
+test_expect_success 'using "--no-if-exists" defaults to hardcoded default if nothing configured (no addition)' '
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+               Acked-by: Z
+               Reviewed-by: Z
+               Signed-off-by: Z
+               Fixes: 53
+       EOF
+       git interpret-trailers --if-exists replace --trailer "Fixes: 53" --no-if-exists \
+               --trailer "Fixes: 53" <complex_message >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'using "ifExists = replace"' '
-       git config trailer.fix.key "Fixes: " &&
-       git config trailer.fix.ifExists "replace" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "replace" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1095,7 +1301,16 @@ test_expect_success 'using "ifExists = replace"' '
 '
 
 test_expect_success 'using "ifExists = replace" with "where = after"' '
-       git config trailer.fix.where "after" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "replace" &&
+       test_config trailer.fix.where "after" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1114,7 +1329,15 @@ test_expect_success 'using "ifExists = replace" with "where = after"' '
 '
 
 test_expect_success 'using "ifExists = doNothing"' '
-       git config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1133,8 +1356,17 @@ test_expect_success 'using "ifExists = doNothing"' '
 '
 
 test_expect_success 'the default is "ifMissing = add"' '
-       git config trailer.cc.key "Cc: " &&
-       git config trailer.cc.where "before" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.cc.key "Cc: " &&
+       test_config trailer.cc.where "before" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1154,7 +1386,14 @@ test_expect_success 'the default is "ifMissing = add"' '
 '
 
 test_expect_success 'overriding configuration with "--if-missing doNothing"' '
-       git config trailer.ifmissing "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.ifmissing "add" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -1173,7 +1412,13 @@ test_expect_success 'overriding configuration with "--if-missing doNothing"' '
 '
 
 test_expect_success 'when default "ifMissing" is "doNothing"' '
-       git config trailer.ifmissing "doNothing" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.ifmissing "doNothing" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -1187,14 +1432,21 @@ test_expect_success 'when default "ifMissing" is "doNothing"' '
                --trailer "cc=Linus" --trailer "ack: Junio" \
                --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
                <complex_message >actual &&
-       test_cmp expected actual &&
-       git config trailer.ifmissing "add"
+       test_cmp expected actual
 '
 
 test_expect_success 'using "ifMissing = add" with "where = end"' '
-       git config trailer.cc.key "Cc: " &&
-       git config trailer.cc.where "end" &&
-       git config trailer.cc.ifMissing "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.cc.key "Cc: " &&
+       test_config trailer.cc.ifMissing "add" &&
+       test_config trailer.cc.where "end" &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1214,9 +1466,17 @@ test_expect_success 'using "ifMissing = add" with "where = end"' '
 '
 
 test_expect_success 'using "ifMissing = add" with "where = before"' '
-       git config trailer.cc.key "Cc: " &&
-       git config trailer.cc.where "before" &&
-       git config trailer.cc.ifMissing "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.cc.key "Cc: " &&
+       test_config trailer.cc.ifMissing "add" &&
+       test_config trailer.cc.where "before" &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Cc: Linus
@@ -1236,7 +1496,15 @@ test_expect_success 'using "ifMissing = add" with "where = before"' '
 '
 
 test_expect_success 'using "ifMissing = doNothing"' '
-       git config trailer.cc.ifMissing "doNothing" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.cc.ifMissing "doNothing" &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1254,9 +1522,50 @@ test_expect_success 'using "ifMissing = doNothing"' '
        test_cmp expected actual
 '
 
+# Ignore the "IgnoredTrailer" because of "--if-missing doNothing", but also
+# ignore the "StillIgnoredTrailer" because we set "trailer.ifMissing" to
+# "doNothing" in configuration.
+test_expect_success 'using "--no-if-missing" defaults to configuration' '
+       test_config trailer.ifMissing "doNothing" &&
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+                       Fixes: Z
+                       Acked-by: Z
+                       Reviewed-by: Z
+                       Signed-off-by: Z
+       EOF
+       git interpret-trailers --if-missing doNothing --trailer "IgnoredTrailer: ignoreme" --no-if-missing \
+                       --trailer "StillIgnoredTrailer: ignoreme" <complex_message >actual &&
+       test_cmp expected actual
+'
+
+# Add the "AddedTrailer" because the "--no-if-missing" clears the "--if-missing
+# doNothing" from earlier in the argument list.
+test_expect_success 'using "--no-if-missing" defaults to hardcoded default if nothing configured' '
+       cat complex_message_body >expected &&
+       sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+                       Fixes: Z
+                       Acked-by: Z
+                       Reviewed-by: Z
+                       Signed-off-by: Z
+                       AddedTrailer: addme
+       EOF
+       git interpret-trailers --if-missing doNothing --trailer "IgnoredTrailer: ignoreme" --no-if-missing \
+                       --trailer "AddedTrailer: addme" <complex_message >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'default "where" is now "after"' '
        git config trailer.where "after" &&
-       git config --unset trailer.ack.where &&
+       test_config trailer.ack.ifExists "add" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.ack.where "after" &&
+       test_config trailer.bug.key "Bug #" &&
+       test_config trailer.bug.where "before" &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=#" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Bug #42
@@ -1280,10 +1589,15 @@ test_expect_success 'default "where" is now "after"' '
 '
 
 test_expect_success 'with simple command' '
-       git config trailer.sign.key "Signed-off-by: " &&
-       git config trailer.sign.where "after" &&
-       git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
-       git config trailer.sign.command "echo \"A U Thor <author@example.com>\"" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.sign.command "echo \"A U Thor <author@example.com>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.sign.ifExists "addIfDifferentNeighbor" &&
+       test_config trailer.sign.where "after" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -1298,8 +1612,14 @@ test_expect_success 'with simple command' '
 '
 
 test_expect_success 'with command using committer information' '
-       git config trailer.sign.ifExists "addIfDifferent" &&
-       git config trailer.sign.command "echo \"\$GIT_COMMITTER_NAME <\$GIT_COMMITTER_EMAIL>\"" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.sign.command "echo \"\$GIT_COMMITTER_NAME <\$GIT_COMMITTER_EMAIL>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.sign.ifExists "addIfDifferent" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -1314,10 +1634,15 @@ test_expect_success 'with command using committer information' '
 '
 
 test_expect_success 'with command using author information' '
-       git config trailer.sign.key "Signed-off-by: " &&
-       git config trailer.sign.where "after" &&
-       git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
-       git config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.fix.ifExists "doNothing" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.sign.ifExists "addIfDifferentNeighbor" &&
+       test_config trailer.sign.where "after" &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
                Fixes: Z
@@ -1338,12 +1663,19 @@ test_expect_success 'setup a commit' '
 '
 
 test_expect_success 'cmd takes precedence over command' '
-       test_when_finished "git config --unset trailer.fix.cmd" &&
-       git config trailer.fix.ifExists "replace" &&
-       git config trailer.fix.cmd "test -n \"\$1\" && git log -1 --oneline --format=\"%h (%aN)\" \
-       --abbrev-commit --abbrev=14 \"\$1\" || true" &&
-       git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" \
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" \
                --abbrev-commit --abbrev=14 \$ARG" &&
+       test_config trailer.fix.cmd "test -n \"\$1\" && git log -1 --oneline --format=\"%h (%aN)\" \
+       --abbrev-commit --abbrev=14 \"\$1\" || true" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "replace" &&
+       test_config trailer.fix.where "after" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=" &&
        FIXED=$(git log -1 --oneline --format="%h (%aN)" --abbrev-commit --abbrev=14 HEAD) &&
        cat complex_message_body >expected2 &&
        sed -e "s/ Z\$/ /" >>expected2 <<-EOF &&
@@ -1359,8 +1691,16 @@ test_expect_success 'cmd takes precedence over command' '
 '
 
 test_expect_success 'with command using $ARG' '
-       git config trailer.fix.ifExists "replace" &&
-       git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "replace" &&
+       test_config trailer.fix.where "after" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=" &&
        FIXED=$(git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 HEAD) &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-EOF &&
@@ -1376,8 +1716,16 @@ test_expect_success 'with command using $ARG' '
 '
 
 test_expect_success 'with failing command using $ARG' '
-       git config trailer.fix.ifExists "replace" &&
-       git config trailer.fix.command "false \$ARG" &&
+       test_config trailer.ack.key "Acked-by= " &&
+       test_config trailer.fix.command "false \$ARG" &&
+       test_config trailer.fix.key "Fixes: " &&
+       test_config trailer.fix.ifExists "replace" &&
+       test_config trailer.fix.where "after" &&
+       test_config trailer.review.key "Reviewed-by:" &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.ifexists "addIfDifferent" &&
+       test_config trailer.separators ":=" &&
        cat complex_message_body >expected &&
        sed -e "s/ Z\$/ /" >>expected <<-EOF &&
                Fixes: Z
@@ -1392,7 +1740,9 @@ test_expect_success 'with failing command using $ARG' '
 '
 
 test_expect_success 'with empty tokens' '
-       git config --unset trailer.fix.command &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.sign.key "Signed-off-by: " &&
+       test_config trailer.ifexists "addIfDifferent" &&
        cat >expected <<-EOF &&
 
                Signed-off-by: A U Thor <author@example.com>
@@ -1403,7 +1753,8 @@ test_expect_success 'with empty tokens' '
 '
 
 test_expect_success 'with command but no key' '
-       git config --unset trailer.sign.key &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.ifexists "addIfDifferent" &&
        cat >expected <<-EOF &&
 
                sign: A U Thor <author@example.com>
@@ -1414,7 +1765,9 @@ test_expect_success 'with command but no key' '
 '
 
 test_expect_success 'with no command and no key' '
-       git config --unset trailer.review.key &&
+       test_config trailer.review.where "before" &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
+       test_config trailer.ifexists "addIfDifferent" &&
        cat >expected <<-EOF &&
 
                review: Junio
@@ -1426,6 +1779,8 @@ test_expect_success 'with no command and no key' '
 '
 
 test_expect_success 'with cut line' '
+       test_config trailer.review.where "before" &&
+       test_config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
        cat >expected <<-\EOF &&
                my subject
 
@@ -1443,7 +1798,8 @@ test_expect_success 'with cut line' '
 '
 
 test_expect_success 'only trailers' '
-       git config trailer.sign.command "echo config-value" &&
+       test_config trailer.sign.command "echo config-value" &&
+       test_config trailer.ifexists "addIfDifferent" &&
        cat >expected <<-\EOF &&
                existing: existing-value
                sign: config-value
@@ -1462,7 +1818,7 @@ test_expect_success 'only trailers' '
 '
 
 test_expect_success 'only-trailers omits non-trailer in middle of block' '
-       git config trailer.sign.command "echo config-value" &&
+       test_config trailer.sign.command "echo config-value" &&
        cat >expected <<-\EOF &&
                Signed-off-by: nobody <nobody@nowhere>
                Signed-off-by: somebody <somebody@somewhere>
@@ -1482,7 +1838,7 @@ test_expect_success 'only-trailers omits non-trailer in middle of block' '
 '
 
 test_expect_success 'only input' '
-       git config trailer.sign.command "echo config-value" &&
+       test_config trailer.sign.command "echo config-value" &&
        cat >expected <<-\EOF &&
                existing: existing-value
        EOF
index bd238d89b0cb07ed6a92707dcfd80ac277b75524..e08767df66e452e9cbbd0e6ccc1f35ce56ff1f98 100755 (executable)
@@ -349,13 +349,13 @@ test_expect_success 'Cannot rebase with multiple heads' '
 
 test_expect_success 'merge c1 with c2' '
        git reset --hard c1 &&
-       test -f c0.c &&
-       test -f c1.c &&
-       test ! -f c2.c &&
-       test ! -f c3.c &&
+       test_path_is_file c0.c &&
+       test_path_is_file c1.c &&
+       test_path_is_missing c2.c &&
+       test_path_is_missing c3.c &&
        git merge c2 &&
-       test -f c1.c &&
-       test -f c2.c
+       test_path_is_file c1.c &&
+       test_path_is_file c2.c
 '
 
 test_expect_success 'fast-forward pull succeeds with "true" in pull.ff' '
@@ -411,8 +411,8 @@ test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
        git reset --hard c1 &&
        git config pull.twohead ours &&
        git merge c2 &&
-       test -f c1.c &&
-       ! test -f c2.c
+       test_path_is_file c1.c &&
+       test_path_is_missing c2.c
 '
 
 test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '
@@ -431,10 +431,10 @@ test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octo
        test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
        test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
        git diff --exit-code &&
-       test -f c0.c &&
-       test -f c1.c &&
-       test -f c2.c &&
-       test -f c3.c
+       test_path_is_file c0.c &&
+       test_path_is_file c1.c &&
+       test_path_is_file c2.c &&
+       test_path_is_file c3.c
 '
 
 conflict_count()
index ff085b086cc38f36a180e22ab02bbea12a29cc0c..3669d33bd5a15fc19fbfd2cbea14507c8e273642 100755 (executable)
@@ -4,6 +4,7 @@ test_description='git merge
 
 Testing octopus merge with more than 25 refs.'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '
index 4887ca705b330e8cbf6f25595cbcadfdfd67f9f2..0e85b21ec82cc64e7d1e519c269a9bdcb189e01b 100755 (executable)
@@ -4,6 +4,7 @@ test_description='git merge
 
 Testing octopus merge when reducing parents to independent branches.'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # 0 - 1
index 89a62ac53b3d6012d13b3b1ce0dfa97d494060f2..9001674f2ea2201836613e4909d9442062f609f4 100755 (executable)
@@ -4,6 +4,7 @@ test_description="Test that merge state is as expected after failed merge"
 
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'Ensure we restore original state if no merge strategy handles it' '
index 0b908ab2e7128052a0513e740b54ba308b9feadc..2179938c437e47552eccb7af85fa3e4669ccc1bf 100755 (executable)
@@ -4,6 +4,7 @@ test_description='test auto-generated merge messages'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 check_oneline() {
index 27b66807cd82cbb93c4985905a8de7945cc17cbc..d2975e6c93a07480e8da4e89bb1bd48faf397cba 100755 (executable)
@@ -327,6 +327,203 @@ test_expect_success 'auto-bitmaps do not complain if unavailable' '
        test_must_be_empty actual
 '
 
+test_expect_success 'repacking with a filter works' '
+       git -C bare.git repack -a -d &&
+       test_stdout_line_count = 1 ls bare.git/objects/pack/*.pack &&
+       git -C bare.git -c repack.writebitmaps=false repack -a -d --filter=blob:none &&
+       test_stdout_line_count = 2 ls bare.git/objects/pack/*.pack &&
+       commit_pack=$(test-tool -C bare.git find-pack -c 1 HEAD) &&
+       blob_pack=$(test-tool -C bare.git find-pack -c 1 HEAD:file1) &&
+       test "$commit_pack" != "$blob_pack" &&
+       tree_pack=$(test-tool -C bare.git find-pack -c 1 HEAD^{tree}) &&
+       test "$tree_pack" = "$commit_pack" &&
+       blob_pack2=$(test-tool -C bare.git find-pack -c 1 HEAD:file2) &&
+       test "$blob_pack2" = "$blob_pack"
+'
+
+test_expect_success '--filter fails with --write-bitmap-index' '
+       test_must_fail \
+               env GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \
+               git -C bare.git repack -a -d --write-bitmap-index --filter=blob:none
+'
+
+test_expect_success 'repacking with two filters works' '
+       git init two-filters &&
+       (
+               cd two-filters &&
+               mkdir subdir &&
+               test_commit foo &&
+               test_commit subdir_bar subdir/bar &&
+               test_commit subdir_baz subdir/baz
+       ) &&
+       git clone --no-local --bare two-filters two-filters.git &&
+       (
+               cd two-filters.git &&
+               test_stdout_line_count = 1 ls objects/pack/*.pack &&
+               git -c repack.writebitmaps=false repack -a -d \
+                       --filter=blob:none --filter=tree:1 &&
+               test_stdout_line_count = 2 ls objects/pack/*.pack &&
+               commit_pack=$(test-tool find-pack -c 1 HEAD) &&
+               blob_pack=$(test-tool find-pack -c 1 HEAD:foo.t) &&
+               root_tree_pack=$(test-tool find-pack -c 1 HEAD^{tree}) &&
+               subdir_tree_hash=$(git ls-tree --object-only HEAD -- subdir) &&
+               subdir_tree_pack=$(test-tool find-pack -c 1 "$subdir_tree_hash") &&
+
+               # Root tree and subdir tree are not in the same packfiles
+               test "$commit_pack" != "$blob_pack" &&
+               test "$commit_pack" = "$root_tree_pack" &&
+               test "$blob_pack" = "$subdir_tree_pack"
+       )
+'
+
+prepare_for_keep_packs () {
+       git init keep-packs &&
+       (
+               cd keep-packs &&
+               test_commit foo &&
+               test_commit bar
+       ) &&
+       git clone --no-local --bare keep-packs keep-packs.git &&
+       (
+               cd keep-packs.git &&
+
+               # Create two packs
+               # The first pack will contain all of the objects except one blob
+               git rev-list --objects --all >objs &&
+               grep -v "bar.t" objs | git pack-objects pack &&
+               # The second pack will contain the excluded object and be kept
+               packid=$(grep "bar.t" objs | git pack-objects pack) &&
+               >pack-$packid.keep &&
+
+               # Replace the existing pack with the 2 new ones
+               rm -f objects/pack/pack* &&
+               mv pack-* objects/pack/
+       )
+}
+
+test_expect_success '--filter works with .keep packs' '
+       prepare_for_keep_packs &&
+       (
+               cd keep-packs.git &&
+
+               foo_pack=$(test-tool find-pack -c 1 HEAD:foo.t) &&
+               bar_pack=$(test-tool find-pack -c 1 HEAD:bar.t) &&
+               head_pack=$(test-tool find-pack -c 1 HEAD) &&
+
+               test "$foo_pack" != "$bar_pack" &&
+               test "$foo_pack" = "$head_pack" &&
+
+               git -c repack.writebitmaps=false repack -a -d --filter=blob:none &&
+
+               foo_pack_1=$(test-tool find-pack -c 1 HEAD:foo.t) &&
+               bar_pack_1=$(test-tool find-pack -c 1 HEAD:bar.t) &&
+               head_pack_1=$(test-tool find-pack -c 1 HEAD) &&
+
+               # Object bar is still only in the old .keep pack
+               test "$foo_pack_1" != "$foo_pack" &&
+               test "$bar_pack_1" = "$bar_pack" &&
+               test "$head_pack_1" != "$head_pack" &&
+
+               test "$foo_pack_1" != "$bar_pack_1" &&
+               test "$foo_pack_1" != "$head_pack_1" &&
+               test "$bar_pack_1" != "$head_pack_1"
+       )
+'
+
+test_expect_success '--filter works with --pack-kept-objects and .keep packs' '
+       rm -rf keep-packs keep-packs.git &&
+       prepare_for_keep_packs &&
+       (
+               cd keep-packs.git &&
+
+               foo_pack=$(test-tool find-pack -c 1 HEAD:foo.t) &&
+               bar_pack=$(test-tool find-pack -c 1 HEAD:bar.t) &&
+               head_pack=$(test-tool find-pack -c 1 HEAD) &&
+
+               test "$foo_pack" != "$bar_pack" &&
+               test "$foo_pack" = "$head_pack" &&
+
+               git -c repack.writebitmaps=false repack -a -d --filter=blob:none \
+                       --pack-kept-objects &&
+
+               foo_pack_1=$(test-tool find-pack -c 1 HEAD:foo.t) &&
+               test-tool find-pack -c 2 HEAD:bar.t >bar_pack_1 &&
+               head_pack_1=$(test-tool find-pack -c 1 HEAD) &&
+
+               test "$foo_pack_1" != "$foo_pack" &&
+               test "$foo_pack_1" != "$bar_pack" &&
+               test "$head_pack_1" != "$head_pack" &&
+
+               # Object bar is in both the old .keep pack and the new
+               # pack that contained the filtered out objects
+               grep "$bar_pack" bar_pack_1 &&
+               grep "$foo_pack_1" bar_pack_1 &&
+               test "$foo_pack_1" != "$head_pack_1"
+       )
+'
+
+test_expect_success '--filter-to stores filtered out objects' '
+       git -C bare.git repack -a -d &&
+       test_stdout_line_count = 1 ls bare.git/objects/pack/*.pack &&
+
+       git init --bare filtered.git &&
+       git -C bare.git -c repack.writebitmaps=false repack -a -d \
+               --filter=blob:none \
+               --filter-to=../filtered.git/objects/pack/pack &&
+       test_stdout_line_count = 1 ls bare.git/objects/pack/pack-*.pack &&
+       test_stdout_line_count = 1 ls filtered.git/objects/pack/pack-*.pack &&
+
+       commit_pack=$(test-tool -C bare.git find-pack -c 1 HEAD) &&
+       blob_pack=$(test-tool -C bare.git find-pack -c 0 HEAD:file1) &&
+       blob_hash=$(git -C bare.git rev-parse HEAD:file1) &&
+       test -n "$blob_hash" &&
+       blob_pack=$(test-tool -C filtered.git find-pack -c 1 $blob_hash) &&
+
+       echo $(pwd)/filtered.git/objects >bare.git/objects/info/alternates &&
+       blob_pack=$(test-tool -C bare.git find-pack -c 1 HEAD:file1) &&
+       blob_content=$(git -C bare.git show $blob_hash) &&
+       test "$blob_content" = "content1"
+'
+
+test_expect_success '--filter works with --max-pack-size' '
+       rm -rf filtered.git &&
+       git init --bare filtered.git &&
+       git init max-pack-size &&
+       (
+               cd max-pack-size &&
+               test_commit base &&
+               # two blobs which exceed the maximum pack size
+               test-tool genrandom foo 1048576 >foo &&
+               git hash-object -w foo &&
+               test-tool genrandom bar 1048576 >bar &&
+               git hash-object -w bar &&
+               git add foo bar &&
+               git commit -m "adding foo and bar"
+       ) &&
+       git clone --no-local --bare max-pack-size max-pack-size.git &&
+       (
+               cd max-pack-size.git &&
+               git -c repack.writebitmaps=false repack -a -d --filter=blob:none \
+                       --max-pack-size=1M \
+                       --filter-to=../filtered.git/objects/pack/pack &&
+               echo $(cd .. && pwd)/filtered.git/objects >objects/info/alternates &&
+
+               # Check that the 3 blobs are in different packfiles in filtered.git
+               test_stdout_line_count = 3 ls ../filtered.git/objects/pack/pack-*.pack &&
+               test_stdout_line_count = 1 ls objects/pack/pack-*.pack &&
+               foo_pack=$(test-tool find-pack -c 1 HEAD:foo) &&
+               bar_pack=$(test-tool find-pack -c 1 HEAD:bar) &&
+               base_pack=$(test-tool find-pack -c 1 HEAD:base.t) &&
+               test "$foo_pack" != "$bar_pack" &&
+               test "$foo_pack" != "$base_pack" &&
+               test "$bar_pack" != "$base_pack" &&
+               for pack in "$foo_pack" "$bar_pack" "$base_pack"
+               do
+                       case "$foo_pack" in */filtered.git/objects/pack/*) true ;; *) return 1 ;; esac
+               done
+       )
+'
+
 objdir=.git/objects
 midx=$objdir/pack/multi-pack-index
 
@@ -633,125 +830,4 @@ test_expect_success '-n overrides repack.updateServerInfo=true' '
        test_server_info_missing
 '
 
-test_expect_success '--expire-to stores pruned objects (now)' '
-       git init expire-to-now &&
-       (
-               cd expire-to-now &&
-
-               git branch -M main &&
-
-               test_commit base &&
-
-               git checkout -b cruft &&
-               test_commit --no-tag cruft &&
-
-               git rev-list --objects --no-object-names main..cruft >moved.raw &&
-               sort moved.raw >moved.want &&
-
-               git rev-list --all --objects --no-object-names >expect.raw &&
-               sort expect.raw >expect &&
-
-               git checkout main &&
-               git branch -D cruft &&
-               git reflog expire --all --expire=all &&
-
-               git init --bare expired.git &&
-               git repack -d \
-                       --cruft --cruft-expiration="now" \
-                       --expire-to="expired.git/objects/pack/pack" &&
-
-               expired="$(ls expired.git/objects/pack/pack-*.idx)" &&
-               test_path_is_file "${expired%.idx}.mtimes" &&
-
-               # Since the `--cruft-expiration` is "now", the effective
-               # behavior is to move _all_ unreachable objects out to
-               # the location in `--expire-to`.
-               git show-index <$expired >expired.raw &&
-               cut -d" " -f2 expired.raw | sort >expired.objects &&
-               git rev-list --all --objects --no-object-names \
-                       >remaining.objects &&
-
-               # ...in other words, the combined contents of this
-               # repository and expired.git should be the same as the
-               # set of objects we started with.
-               cat expired.objects remaining.objects | sort >actual &&
-               test_cmp expect actual &&
-
-               # The "moved" objects (i.e., those in expired.git)
-               # should be the same as the cruft objects which were
-               # expired in the previous step.
-               test_cmp moved.want expired.objects
-       )
-'
-
-test_expect_success '--expire-to stores pruned objects (5.minutes.ago)' '
-       git init expire-to-5.minutes.ago &&
-       (
-               cd expire-to-5.minutes.ago &&
-
-               git branch -M main &&
-
-               test_commit base &&
-
-               # Create two classes of unreachable objects, one which
-               # is older than 5 minutes (stale), and another which is
-               # newer (recent).
-               for kind in stale recent
-               do
-                       git checkout -b $kind main &&
-                       test_commit --no-tag $kind || return 1
-               done &&
-
-               git rev-list --objects --no-object-names main..stale >in &&
-               stale="$(git pack-objects $objdir/pack/pack <in)" &&
-               mtime="$(test-tool chmtime --get =-600 $objdir/pack/pack-$stale.pack)" &&
-
-               # expect holds the set of objects we expect to find in
-               # this repository after repacking
-               git rev-list --objects --no-object-names recent >expect.raw &&
-               sort expect.raw >expect &&
-
-               # moved.want holds the set of objects we expect to find
-               # in expired.git
-               git rev-list --objects --no-object-names main..stale >out &&
-               sort out >moved.want &&
-
-               git checkout main &&
-               git branch -D stale recent &&
-               git reflog expire --all --expire=all &&
-               git prune-packed &&
-
-               git init --bare expired.git &&
-               git repack -d \
-                       --cruft --cruft-expiration=5.minutes.ago \
-                       --expire-to="expired.git/objects/pack/pack" &&
-
-               # Some of the remaining objects in this repository are
-               # unreachable, so use `cat-file --batch-all-objects`
-               # instead of `rev-list` to get their names
-               git cat-file --batch-all-objects --batch-check="%(objectname)" \
-                       >remaining.objects &&
-               sort remaining.objects >actual &&
-               test_cmp expect actual &&
-
-               (
-                       cd expired.git &&
-
-                       expired="$(ls objects/pack/pack-*.mtimes)" &&
-                       test-tool pack-mtimes $(basename $expired) >out &&
-                       cut -d" " -f1 out | sort >../moved.got &&
-
-                       # Ensure that there are as many objects with the
-                       # expected mtime as were moved to expired.git.
-                       #
-                       # In other words, ensure that the recorded
-                       # mtimes of any moved objects was written
-                       # correctly.
-                       grep " $mtime$" out >matching &&
-                       test_line_count = $(wc -l <../moved.want) matching
-               ) &&
-               test_cmp moved.want moved.got
-       )
-'
-
 test_done
diff --git a/t/t7704-repack-cruft.sh b/t/t7704-repack-cruft.sh
new file mode 100755 (executable)
index 0000000..be3735d
--- /dev/null
@@ -0,0 +1,414 @@
+#!/bin/sh
+
+test_description='git repack works correctly'
+
+. ./test-lib.sh
+
+objdir=.git/objects
+packdir=$objdir/pack
+
+test_expect_success '--expire-to stores pruned objects (now)' '
+       git init expire-to-now &&
+       (
+               cd expire-to-now &&
+
+               git branch -M main &&
+
+               test_commit base &&
+
+               git checkout -b cruft &&
+               test_commit --no-tag cruft &&
+
+               git rev-list --objects --no-object-names main..cruft >moved.raw &&
+               sort moved.raw >moved.want &&
+
+               git rev-list --all --objects --no-object-names >expect.raw &&
+               sort expect.raw >expect &&
+
+               git checkout main &&
+               git branch -D cruft &&
+               git reflog expire --all --expire=all &&
+
+               git init --bare expired.git &&
+               git repack -d \
+                       --cruft --cruft-expiration="now" \
+                       --expire-to="expired.git/objects/pack/pack" &&
+
+               expired="$(ls expired.git/objects/pack/pack-*.idx)" &&
+               test_path_is_file "${expired%.idx}.mtimes" &&
+
+               # Since the `--cruft-expiration` is "now", the effective
+               # behavior is to move _all_ unreachable objects out to
+               # the location in `--expire-to`.
+               git show-index <$expired >expired.raw &&
+               cut -d" " -f2 expired.raw | sort >expired.objects &&
+               git rev-list --all --objects --no-object-names \
+                       >remaining.objects &&
+
+               # ...in other words, the combined contents of this
+               # repository and expired.git should be the same as the
+               # set of objects we started with.
+               cat expired.objects remaining.objects | sort >actual &&
+               test_cmp expect actual &&
+
+               # The "moved" objects (i.e., those in expired.git)
+               # should be the same as the cruft objects which were
+               # expired in the previous step.
+               test_cmp moved.want expired.objects
+       )
+'
+
+test_expect_success '--expire-to stores pruned objects (5.minutes.ago)' '
+       git init expire-to-5.minutes.ago &&
+       (
+               cd expire-to-5.minutes.ago &&
+
+               git branch -M main &&
+
+               test_commit base &&
+
+               # Create two classes of unreachable objects, one which
+               # is older than 5 minutes (stale), and another which is
+               # newer (recent).
+               for kind in stale recent
+               do
+                       git checkout -b $kind main &&
+                       test_commit --no-tag $kind || return 1
+               done &&
+
+               git rev-list --objects --no-object-names main..stale >in &&
+               stale="$(git pack-objects $objdir/pack/pack <in)" &&
+               mtime="$(test-tool chmtime --get =-600 $objdir/pack/pack-$stale.pack)" &&
+
+               # expect holds the set of objects we expect to find in
+               # this repository after repacking
+               git rev-list --objects --no-object-names recent >expect.raw &&
+               sort expect.raw >expect &&
+
+               # moved.want holds the set of objects we expect to find
+               # in expired.git
+               git rev-list --objects --no-object-names main..stale >out &&
+               sort out >moved.want &&
+
+               git checkout main &&
+               git branch -D stale recent &&
+               git reflog expire --all --expire=all &&
+               git prune-packed &&
+
+               git init --bare expired.git &&
+               git repack -d \
+                       --cruft --cruft-expiration=5.minutes.ago \
+                       --expire-to="expired.git/objects/pack/pack" &&
+
+               # Some of the remaining objects in this repository are
+               # unreachable, so use `cat-file --batch-all-objects`
+               # instead of `rev-list` to get their names
+               git cat-file --batch-all-objects --batch-check="%(objectname)" \
+                       >remaining.objects &&
+               sort remaining.objects >actual &&
+               test_cmp expect actual &&
+
+               (
+                       cd expired.git &&
+
+                       expired="$(ls objects/pack/pack-*.mtimes)" &&
+                       test-tool pack-mtimes $(basename $expired) >out &&
+                       cut -d" " -f1 out | sort >../moved.got &&
+
+                       # Ensure that there are as many objects with the
+                       # expected mtime as were moved to expired.git.
+                       #
+                       # In other words, ensure that the recorded
+                       # mtimes of any moved objects was written
+                       # correctly.
+                       grep " $mtime$" out >matching &&
+                       test_line_count = $(wc -l <../moved.want) matching
+               ) &&
+               test_cmp moved.want moved.got
+       )
+'
+
+generate_random_blob() {
+       test-tool genrandom "$@" >blob &&
+       git hash-object -w -t blob blob &&
+       rm blob
+}
+
+pack_random_blob () {
+       generate_random_blob "$@" &&
+       git repack -d -q >/dev/null
+}
+
+generate_cruft_pack () {
+       pack_random_blob "$@" >/dev/null &&
+
+       ls $packdir/pack-*.pack | xargs -n 1 basename >in &&
+       pack="$(git pack-objects --cruft $packdir/pack <in)" &&
+       git prune-packed &&
+
+       echo "$packdir/pack-$pack.mtimes"
+}
+
+test_expect_success '--max-cruft-size creates new packs when above threshold' '
+       git init max-cruft-size-large &&
+       (
+               cd max-cruft-size-large &&
+               test_commit base &&
+
+               foo="$(pack_random_blob foo $((1*1024*1024)))" &&
+               git repack --cruft -d &&
+               cruft_foo="$(ls $packdir/pack-*.mtimes)" &&
+
+               bar="$(pack_random_blob bar $((1*1024*1024)))" &&
+               git repack --cruft -d --max-cruft-size=1M &&
+               cruft_bar="$(ls $packdir/pack-*.mtimes | grep -v $cruft_foo)" &&
+
+               test-tool pack-mtimes $(basename "$cruft_foo") >foo.objects &&
+               test-tool pack-mtimes $(basename "$cruft_bar") >bar.objects &&
+
+               grep "^$foo" foo.objects &&
+               test_line_count = 1 foo.objects &&
+               grep "^$bar" bar.objects &&
+               test_line_count = 1 bar.objects
+       )
+'
+
+test_expect_success '--max-cruft-size combines existing packs when below threshold' '
+       git init max-cruft-size-small &&
+       (
+               cd max-cruft-size-small &&
+               test_commit base &&
+
+               foo="$(pack_random_blob foo $((1*1024*1024)))" &&
+               git repack --cruft -d &&
+
+               bar="$(pack_random_blob bar $((1*1024*1024)))" &&
+               git repack --cruft -d --max-cruft-size=10M &&
+
+               cruft=$(ls $packdir/pack-*.mtimes) &&
+               test-tool pack-mtimes $(basename "$cruft") >cruft.objects &&
+
+               grep "^$foo" cruft.objects &&
+               grep "^$bar" cruft.objects &&
+               test_line_count = 2 cruft.objects
+       )
+'
+
+test_expect_success '--max-cruft-size combines smaller packs first' '
+       git init max-cruft-size-consume-small &&
+       (
+               cd max-cruft-size-consume-small &&
+
+               test_commit base &&
+               git repack -ad &&
+
+               cruft_foo="$(generate_cruft_pack foo 524288)" &&    # 0.5 MiB
+               cruft_bar="$(generate_cruft_pack bar 524288)" &&    # 0.5 MiB
+               cruft_baz="$(generate_cruft_pack baz 1048576)" &&   # 1.0 MiB
+               cruft_quux="$(generate_cruft_pack quux 1572864)" && # 1.5 MiB
+
+               test-tool pack-mtimes "$(basename $cruft_foo)" >expect.raw &&
+               test-tool pack-mtimes "$(basename $cruft_bar)" >>expect.raw &&
+               sort expect.raw >expect.objects &&
+
+               # repacking with `--max-cruft-size=2M` should combine
+               # both 0.5 MiB packs together, instead of, say, one of
+               # the 0.5 MiB packs with the 1.0 MiB pack
+               ls $packdir/pack-*.mtimes | sort >cruft.before &&
+               git repack -d --cruft --max-cruft-size=2M &&
+               ls $packdir/pack-*.mtimes | sort >cruft.after &&
+
+               comm -13 cruft.before cruft.after >cruft.new &&
+               comm -23 cruft.before cruft.after >cruft.removed &&
+
+               test_line_count = 1 cruft.new &&
+               test_line_count = 2 cruft.removed &&
+
+               # the two smaller packs should be rolled up first
+               printf "%s\n" $cruft_foo $cruft_bar | sort >expect.removed &&
+               test_cmp expect.removed cruft.removed &&
+
+               # ...and contain the set of objects rolled up
+               test-tool pack-mtimes "$(basename $(cat cruft.new))" >actual.raw &&
+               sort actual.raw >actual.objects &&
+
+               test_cmp expect.objects actual.objects
+       )
+'
+
+test_expect_success 'setup --max-cruft-size with freshened objects' '
+       git init max-cruft-size-freshen &&
+       (
+               cd max-cruft-size-freshen &&
+
+               test_commit base &&
+               git repack -ad &&
+
+               foo="$(generate_random_blob foo 64)" &&
+               test-tool chmtime --get -10000 \
+                       "$objdir/$(test_oid_to_path "$foo")" >foo.mtime &&
+
+               git repack --cruft -d &&
+
+               cruft="$(ls $packdir/pack-*.mtimes)" &&
+               test-tool pack-mtimes "$(basename $cruft)" >actual &&
+               echo "$foo $(cat foo.mtime)" >expect &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success '--max-cruft-size with freshened objects (loose)' '
+       (
+               cd max-cruft-size-freshen &&
+
+               # regenerate the object, setting its mtime to be more recent
+               foo="$(generate_random_blob foo 64)" &&
+               test-tool chmtime --get -100 \
+                       "$objdir/$(test_oid_to_path "$foo")" >foo.mtime &&
+
+               git repack --cruft -d &&
+
+               cruft="$(ls $packdir/pack-*.mtimes)" &&
+               test-tool pack-mtimes "$(basename $cruft)" >actual &&
+               echo "$foo $(cat foo.mtime)" >expect &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success '--max-cruft-size with freshened objects (packed)' '
+       (
+               cd max-cruft-size-freshen &&
+
+               # regenerate the object and store it in a packfile,
+               # setting its mtime to be more recent
+               #
+               # store it alongside another cruft object so that we
+               # do not create an identical copy of the existing
+               # cruft pack (which contains $foo).
+               foo="$(generate_random_blob foo 64)" &&
+               bar="$(generate_random_blob bar 64)" &&
+               foo_pack="$(printf "%s\n" $foo $bar | git pack-objects $packdir/pack)" &&
+               git prune-packed &&
+
+               test-tool chmtime --get -10 \
+                       "$packdir/pack-$foo_pack.pack" >foo.mtime &&
+
+               git repack --cruft -d &&
+
+               cruft="$(ls $packdir/pack-*.mtimes)" &&
+               test-tool pack-mtimes "$(basename $cruft)" >actual &&
+               echo "$foo $(cat foo.mtime)" >expect.raw &&
+               echo "$bar $(cat foo.mtime)" >>expect.raw &&
+               sort expect.raw >expect &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success '--max-cruft-size with pruning' '
+       git init max-cruft-size-prune &&
+       (
+               cd max-cruft-size-prune &&
+
+               test_commit base &&
+               foo="$(generate_random_blob foo $((1024*1024)))" &&
+               bar="$(generate_random_blob bar $((1024*1024)))" &&
+               baz="$(generate_random_blob baz $((1024*1024)))" &&
+
+               test-tool chmtime -10000 "$objdir/$(test_oid_to_path "$foo")" &&
+
+               git repack -d --cruft --max-cruft-size=1M &&
+
+               # backdate the mtimes of all cruft packs to validate
+               # that they were rewritten as a result of pruning
+               ls $packdir/pack-*.mtimes | sort >cruft.before &&
+               for cruft in $(cat cruft.before)
+               do
+                       mtime="$(test-tool chmtime --get -10000 "$cruft")" &&
+                       echo $cruft $mtime >>mtimes || return 1
+               done &&
+
+               # repack (and prune) with a --max-cruft-size to ensure
+               # that we appropriately split the resulting set of packs
+               git repack -d --cruft --max-cruft-size=1M \
+                       --cruft-expiration=10.seconds.ago &&
+               ls $packdir/pack-*.mtimes | sort >cruft.after &&
+
+               for cruft in $(cat cruft.after)
+               do
+                       old_mtime="$(grep $cruft mtimes | cut -d" " -f2)" &&
+                       new_mtime="$(test-tool chmtime --get $cruft)" &&
+                       test $old_mtime -lt $new_mtime || return 1
+               done &&
+
+               test_line_count = 3 cruft.before &&
+               test_line_count = 2 cruft.after &&
+               test_must_fail git cat-file -e $foo &&
+               git cat-file -e $bar &&
+               git cat-file -e $baz
+       )
+'
+
+test_expect_success '--max-cruft-size ignores non-local packs' '
+       repo="max-cruft-size-non-local" &&
+       git init $repo &&
+       (
+               cd $repo &&
+               test_commit base &&
+               generate_random_blob foo 64 &&
+               git repack --cruft -d
+       ) &&
+
+       git clone --reference=$repo $repo $repo-alt &&
+       (
+               cd $repo-alt &&
+
+               test_commit other &&
+               generate_random_blob bar 64 &&
+
+               # ensure that we do not attempt to pick up packs from
+               # the non-alternated repository, which would result in a
+               # crash
+               git repack --cruft --max-cruft-size=1M -d
+       )
+'
+
+test_expect_success 'reachable packs are preferred over cruft ones' '
+       repo="cruft-preferred-packs" &&
+       git init "$repo" &&
+       (
+               cd "$repo" &&
+
+               # This test needs to exercise careful control over when a MIDX
+               # is and is not written. Unset the corresponding TEST variable
+               # accordingly.
+               sane_unset GIT_TEST_MULTI_PACK_INDEX &&
+
+               test_commit base &&
+               test_commit --no-tag cruft &&
+
+               non_cruft="$(echo base | git pack-objects --revs $packdir/pack)" &&
+               # Write a cruft pack which both (a) sorts ahead of the non-cruft
+               # pack in lexical order, and (b) has an older mtime to appease
+               # the MIDX preferred pack selection routine.
+               cruft="$(echo pack-$non_cruft.pack | git pack-objects --cruft $packdir/pack-A)" &&
+               test-tool chmtime -1000 $packdir/pack-A-$cruft.pack &&
+
+               test_commit other &&
+               git repack -d &&
+
+               git repack --geometric 2 -d --write-midx --write-bitmap-index &&
+
+               # After repacking, there are two packs left: one reachable one
+               # (which is the result of combining both of the existing two
+               # non-cruft packs), and one cruft pack.
+               find .git/objects/pack -type f -name "*.pack" >packs &&
+               test_line_count = 2 packs &&
+
+               # Make sure that the pack we just wrote is marked as preferred,
+               # not the cruft one.
+               pack="$(test-tool read-midx --preferred-pack $objdir)" &&
+               test_path_is_missing "$packdir/$(basename "$pack" ".idx").mtimes"
+       )
+'
+
+test_done
index 39d6d713ecbe05e9638f8f6ee3f79ff49628b2cf..1caaf12430929a2c01e09dad4270947e480ec614 100755 (executable)
@@ -808,6 +808,19 @@ test_expect_success 'grep -f, ignore empty lines, read patterns from stdin' '
        test_cmp expected actual
 '
 
+test_expect_success 'grep -f, use cwd relative file' '
+       test_when_finished "git rm -f sub/dir/file" &&
+       mkdir -p sub/dir &&
+       echo hit >sub/dir/file &&
+       git add sub/dir/file &&
+       echo hit >sub/dir/pattern &&
+       echo miss >pattern &&
+       (
+               cd sub/dir && git grep -f pattern file
+       ) &&
+       git -C sub/dir grep -f pattern file
+'
+
 cat >expected <<EOF
 y:y yy
 --
@@ -1234,6 +1247,33 @@ test_expect_success 'outside of git repository with fallbackToNoIndex' '
        )
 '
 
+test_expect_success 'no repository with path outside $cwd' '
+       test_when_finished rm -fr non &&
+       rm -fr non &&
+       mkdir -p non/git/sub non/tig &&
+       (
+               GIT_CEILING_DIRECTORIES="$(pwd)/non" &&
+               export GIT_CEILING_DIRECTORIES &&
+               cd non/git &&
+               test_expect_code 128 git grep --no-index search .. 2>error &&
+               grep "is outside the directory tree" error
+       ) &&
+       (
+               GIT_CEILING_DIRECTORIES="$(pwd)/non" &&
+               export GIT_CEILING_DIRECTORIES &&
+               cd non/git &&
+               test_expect_code 128 git grep --no-index search ../tig 2>error &&
+               grep "is outside the directory tree" error
+       ) &&
+       (
+               GIT_CEILING_DIRECTORIES="$(pwd)/non" &&
+               export GIT_CEILING_DIRECTORIES &&
+               cd non/git &&
+               test_expect_code 128 git grep --no-index search ../non 2>error &&
+               grep "no such path in the working tree" error
+       )
+'
+
 test_expect_success 'inside git repository but with --no-index' '
        rm -fr is &&
        mkdir -p is/git/sub &&
index 487e326b3fac126fb611e50851465d7d8b963888..e56f5980dc488ef969dad56560003916daf84829 100755 (executable)
@@ -744,7 +744,15 @@ test_expect_success 'start and stop Linux/systemd maintenance' '
        # start registers the repo
        git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
 
-       test_systemd_analyze_verify "systemd/user/git-maintenance@.service" &&
+       for schedule in hourly daily weekly
+       do
+               test_path_is_file "systemd/user/git-maintenance@$schedule.timer" || return 1
+       done &&
+       test_path_is_file "systemd/user/git-maintenance@.service" &&
+
+       test_systemd_analyze_verify "systemd/user/git-maintenance@hourly.service" &&
+       test_systemd_analyze_verify "systemd/user/git-maintenance@daily.service" &&
+       test_systemd_analyze_verify "systemd/user/git-maintenance@weekly.service" &&
 
        printf -- "--user enable --now git-maintenance@%s.timer\n" hourly daily weekly >expect &&
        test_cmp expect args &&
@@ -755,7 +763,10 @@ test_expect_success 'start and stop Linux/systemd maintenance' '
        # stop does not unregister the repo
        git config --get --global --fixed-value maintenance.repo "$(pwd)" &&
 
-       test_path_is_missing "systemd/user/git-maintenance@.timer" &&
+       for schedule in hourly daily weekly
+       do
+               test_path_is_missing "systemd/user/git-maintenance@$schedule.timer" || return 1
+       done &&
        test_path_is_missing "systemd/user/git-maintenance@.service" &&
 
        printf -- "--user disable --now git-maintenance@%s.timer\n" hourly daily weekly >expect &&
@@ -838,4 +849,17 @@ test_expect_success 'register and unregister bare repo' '
        )
 '
 
+test_expect_success 'failed schedule prevents config change' '
+       git init --bare failcase &&
+
+       for scheduler in crontab launchctl schtasks systemctl
+       do
+               GIT_TEST_MAINT_SCHEDULER="$scheduler:false" &&
+               export GIT_TEST_MAINT_SCHEDULER &&
+               test_must_fail \
+                       git -C failcase maintenance start &&
+               test_must_fail git -C failcase config maintenance.auto || return 1
+       done
+'
+
 test_done
index 263db3ad17ff2591029267d5272cc16850b6c72c..dc7785eadb9814894183171d1452f35d2cf2250f 100755 (executable)
@@ -633,6 +633,25 @@ test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
        test_cmp expect actual
 '
 
+test_expect_success $PREREQ "--validate hook supports multiple addresses in arguments" '
+       hooks_path="$(pwd)/my-hooks" &&
+       test_config core.hooksPath "$hooks_path" &&
+       test_when_finished "rm my-hooks.ran" &&
+       test_must_fail git send-email \
+               --from="Example <nobody@example.com>" \
+               --to=nobody@example.com,abc@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               --validate \
+               longline.patch 2>actual &&
+       test_path_is_file my-hooks.ran &&
+       cat >expect <<-EOF &&
+       fatal: longline.patch: rejected by sendemail-validate hook
+       fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1
+       warning: no patches were sent
+       EOF
+       test_cmp expect actual
+'
+
 test_expect_success $PREREQ "--validate hook supports header argument" '
        write_script my-hooks/sendemail-validate <<-\EOF &&
        if test "$#" -ge 2
@@ -2505,4 +2524,45 @@ test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '
                HEAD^
 '
 
+test_expect_success $PREREQ '--compose handles lowercase headers' '
+       write_script fake-editor <<-\EOF &&
+       sed "s/^From:.*/from: edited-from@example.com/i" "$1" >"$1.tmp" &&
+       mv "$1.tmp" "$1"
+       EOF
+       clean_fake_sendmail &&
+       git send-email \
+               --compose \
+               --from="Example <from@example.com>" \
+               --to=nobody@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               HEAD^ &&
+       grep "From: edited-from@example.com" msgtxt1
+'
+
+test_expect_success $PREREQ '--compose handles to headers' '
+       write_script fake-editor <<-\EOF &&
+       sed "s/^To: .*/&, edited-to@example.com/" <"$1" >"$1.tmp" &&
+       echo this is the body >>"$1.tmp" &&
+       mv "$1.tmp" "$1"
+       EOF
+       clean_fake_sendmail &&
+       GIT_SEND_EMAIL_NOTTY=1 \
+       git send-email \
+               --compose \
+               --from="Example <from@example.com>" \
+               --to=nobody@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               HEAD^ &&
+       # Check both that the cover letter used our modified "to" line,
+       # but also that it was picked up for the patch.
+       q_to_tab >expect <<-\EOF &&
+       To: nobody@example.com,
+       Qedited-to@example.com
+       EOF
+       grep -A1 "^To:" msgtxt1 >msgtxt1.to &&
+       test_cmp expect msgtxt1.to &&
+       grep -A1 "^To:" msgtxt2 >msgtxt2.to &&
+       test_cmp expect msgtxt2.to
+'
+
 test_done
index 47e20fb8b149de244a9336e509b0852b87281000..a7c3b4eb63abfe251dcb9edc4b14b136dcfc91c6 100755 (executable)
@@ -2464,6 +2464,24 @@ test_expect_success 'completion used <cmd> completion for alias: !f() { : git <c
        EOF
 '
 
+test_expect_success 'completion used <cmd> completion for alias: !f() { : <cmd> ; ... }' '
+       test_config alias.co "!f() { : checkout ; if ... } f" &&
+       test_completion "git co m" <<-\EOF
+       main Z
+       mybranch Z
+       mytag Z
+       EOF
+'
+
+test_expect_success 'completion used <cmd> completion for alias: !f() { : <cmd>; ... }' '
+       test_config alias.co "!f() { : checkout; if ... } f" &&
+       test_completion "git co m" <<-\EOF
+       main Z
+       mybranch Z
+       mytag Z
+       EOF
+'
+
 test_expect_success 'completion without explicit _git_xxx function' '
        test_completion "git version --" <<-\EOF
        --build-options Z
index f26ec95ab4d867a278e1aacbf337d6eef986355f..d3ecac27728efe8c06dd78f6e394d789d4c1bc7e 100644 (file)
@@ -58,7 +58,8 @@ static struct tr2_sysenv_entry tr2_sysenv_settings[] = {
 /* clang-format on */
 
 static int tr2_sysenv_cb(const char *key, const char *value,
-                        const struct config_context *ctx UNUSED, void *d)
+                        const struct config_context *ctx UNUSED,
+                        void *d UNUSED)
 {
        int k;
 
index 53091781eca5dc788e1f9048b0679aae41e6b11a..59910a1a4f7c0f280fb6839873429d9cc877d3cf 100644 (file)
@@ -335,7 +335,7 @@ static void fn_alias_fl(const char *file, int line, const char *alias,
 }
 
 static void fn_child_start_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute,
+                             uint64_t us_elapsed_absolute UNUSED,
                              const struct child_process *cmd)
 {
        const char *event_name = "child_start";
@@ -367,7 +367,8 @@ static void fn_child_start_fl(const char *file, int line,
 }
 
 static void fn_child_exit_fl(const char *file, int line,
-                            uint64_t us_elapsed_absolute, int cid, int pid,
+                            uint64_t us_elapsed_absolute UNUSED,
+                            int cid, int pid,
                             int code, uint64_t us_elapsed_child)
 {
        const char *event_name = "child_exit";
@@ -388,7 +389,8 @@ static void fn_child_exit_fl(const char *file, int line,
 }
 
 static void fn_child_ready_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute, int cid, int pid,
+                             uint64_t us_elapsed_absolute UNUSED,
+                             int cid, int pid,
                              const char *ready, uint64_t us_elapsed_child)
 {
        const char *event_name = "child_ready";
@@ -409,7 +411,7 @@ static void fn_child_ready_fl(const char *file, int line,
 }
 
 static void fn_thread_start_fl(const char *file, int line,
-                              uint64_t us_elapsed_absolute)
+                              uint64_t us_elapsed_absolute UNUSED)
 {
        const char *event_name = "thread_start";
        struct json_writer jw = JSON_WRITER_INIT;
@@ -423,7 +425,7 @@ static void fn_thread_start_fl(const char *file, int line,
 }
 
 static void fn_thread_exit_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute,
+                             uint64_t us_elapsed_absolute UNUSED,
                              uint64_t us_elapsed_thread)
 {
        const char *event_name = "thread_exit";
@@ -439,7 +441,8 @@ static void fn_thread_exit_fl(const char *file, int line,
        jw_release(&jw);
 }
 
-static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
+static void fn_exec_fl(const char *file, int line,
+                      uint64_t us_elapsed_absolute UNUSED,
                       int exec_id, const char *exe, const char **argv)
 {
        const char *event_name = "exec";
@@ -460,8 +463,8 @@ static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
 }
 
 static void fn_exec_result_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute, int exec_id,
-                             int code)
+                             uint64_t us_elapsed_absolute UNUSED,
+                             int exec_id, int code)
 {
        const char *event_name = "exec_result";
        struct json_writer jw = JSON_WRITER_INIT;
@@ -511,7 +514,7 @@ static void fn_repo_fl(const char *file, int line,
 }
 
 static void fn_region_enter_printf_va_fl(const char *file, int line,
-                                        uint64_t us_elapsed_absolute,
+                                        uint64_t us_elapsed_absolute UNUSED,
                                         const char *category,
                                         const char *label,
                                         const struct repository *repo,
@@ -538,7 +541,7 @@ static void fn_region_enter_printf_va_fl(const char *file, int line,
 }
 
 static void fn_region_leave_printf_va_fl(
-       const char *file, int line, uint64_t us_elapsed_absolute,
+       const char *file, int line, uint64_t us_elapsed_absolute UNUSED,
        uint64_t us_elapsed_region, const char *category, const char *label,
        const struct repository *repo, const char *fmt, va_list ap)
 {
index d25ea131643c0b228280b438d2a38ffcd95f9a0d..38d5ebddf65f8061e9d9dbdf18f35c274bc6a31c 100644 (file)
@@ -86,7 +86,7 @@ static void fn_version_fl(const char *file, int line)
 }
 
 static void fn_start_fl(const char *file, int line,
-                       uint64_t us_elapsed_absolute, const char **argv)
+                       uint64_t us_elapsed_absolute UNUSED, const char **argv)
 {
        struct strbuf buf_payload = STRBUF_INIT;
 
@@ -215,7 +215,7 @@ static void fn_alias_fl(const char *file, int line, const char *alias,
 }
 
 static void fn_child_start_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute,
+                             uint64_t us_elapsed_absolute UNUSED,
                              const struct child_process *cmd)
 {
        struct strbuf buf_payload = STRBUF_INIT;
@@ -243,7 +243,8 @@ static void fn_child_start_fl(const char *file, int line,
 }
 
 static void fn_child_exit_fl(const char *file, int line,
-                            uint64_t us_elapsed_absolute, int cid, int pid,
+                            uint64_t us_elapsed_absolute UNUSED,
+                            int cid, int pid,
                             int code, uint64_t us_elapsed_child)
 {
        struct strbuf buf_payload = STRBUF_INIT;
@@ -256,7 +257,8 @@ static void fn_child_exit_fl(const char *file, int line,
 }
 
 static void fn_child_ready_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute, int cid, int pid,
+                             uint64_t us_elapsed_absolute UNUSED,
+                             int cid, int pid,
                              const char *ready, uint64_t us_elapsed_child)
 {
        struct strbuf buf_payload = STRBUF_INIT;
@@ -268,7 +270,8 @@ static void fn_child_ready_fl(const char *file, int line,
        strbuf_release(&buf_payload);
 }
 
-static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
+static void fn_exec_fl(const char *file, int line,
+                      uint64_t us_elapsed_absolute UNUSED,
                       int exec_id, const char *exe, const char **argv)
 {
        struct strbuf buf_payload = STRBUF_INIT;
@@ -284,8 +287,8 @@ static void fn_exec_fl(const char *file, int line, uint64_t us_elapsed_absolute,
 }
 
 static void fn_exec_result_fl(const char *file, int line,
-                             uint64_t us_elapsed_absolute, int exec_id,
-                             int code)
+                             uint64_t us_elapsed_absolute UNUSED,
+                             int exec_id, int code)
 {
        struct strbuf buf_payload = STRBUF_INIT;
 
@@ -321,7 +324,8 @@ static void fn_repo_fl(const char *file, int line,
 }
 
 static void fn_printf_va_fl(const char *file, int line,
-                           uint64_t us_elapsed_absolute, const char *fmt,
+                           uint64_t us_elapsed_absolute UNUSED,
+                           const char *fmt,
                            va_list ap)
 {
        struct strbuf buf_payload = STRBUF_INIT;
index f408f9b058dbbc33b1360cf36e1e023b7bba1a54..b6de5d9cb2dab2c07c26775e62e5bfc40241c9fc 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -711,30 +711,35 @@ static void add_arg_item(struct list_head *arg_head, char *tok, char *val,
        list_add_tail(&new_item->list, arg_head);
 }
 
-static void process_command_line_args(struct list_head *arg_head,
-                                     struct list_head *new_trailer_head)
+static void parse_trailers_from_config(struct list_head *config_head)
 {
        struct arg_item *item;
-       struct strbuf tok = STRBUF_INIT;
-       struct strbuf val = STRBUF_INIT;
-       const struct conf_info *conf;
        struct list_head *pos;
 
-       /*
-        * In command-line arguments, '=' is accepted (in addition to the
-        * separators that are defined).
-        */
-       char *cl_separators = xstrfmt("=%s", separators);
-
        /* Add an arg item for each configured trailer with a command */
        list_for_each(pos, &conf_head) {
                item = list_entry(pos, struct arg_item, list);
                if (item->conf.command)
-                       add_arg_item(arg_head,
+                       add_arg_item(config_head,
                                     xstrdup(token_from_item(item, NULL)),
                                     xstrdup(""),
                                     &item->conf, NULL);
        }
+}
+
+static void parse_trailers_from_command_line_args(struct list_head *arg_head,
+                                                 struct list_head *new_trailer_head)
+{
+       struct strbuf tok = STRBUF_INIT;
+       struct strbuf val = STRBUF_INIT;
+       const struct conf_info *conf;
+       struct list_head *pos;
+
+       /*
+        * In command-line arguments, '=' is accepted (in addition to the
+        * separators that are defined).
+        */
+       char *cl_separators = xstrfmt("=%s", separators);
 
        /* Add an arg item for each trailer on the command line */
        list_for_each(pos, new_trailer_head) {
@@ -961,28 +966,24 @@ static void unfold_value(struct strbuf *val)
        strbuf_release(&out);
 }
 
-static size_t process_input_file(FILE *outfile,
-                                const char *str,
-                                struct list_head *head,
-                                const struct process_trailer_options *opts)
+/*
+ * Parse trailers in "str", populating the trailer info and "head"
+ * linked list structure.
+ */
+static void parse_trailers(struct trailer_info *info,
+                            const char *str,
+                            struct list_head *head,
+                            const struct process_trailer_options *opts)
 {
-       struct trailer_info info;
        struct strbuf tok = STRBUF_INIT;
        struct strbuf val = STRBUF_INIT;
        size_t i;
 
-       trailer_info_get(&info, str, opts);
-
-       /* Print lines before the trailers as is */
-       if (!opts->only_trailers)
-               fwrite(str, 1, info.trailer_start - str, outfile);
+       trailer_info_get(info, str, opts);
 
-       if (!opts->only_trailers && !info.blank_line_before_trailer)
-               fprintf(outfile, "\n");
-
-       for (i = 0; i < info.trailer_nr; i++) {
+       for (i = 0; i < info->trailer_nr; i++) {
                int separator_pos;
-               char *trailer = info.trailers[i];
+               char *trailer = info->trailers[i];
                if (trailer[0] == comment_line_char)
                        continue;
                separator_pos = find_separator(trailer, separators);
@@ -1002,10 +1003,6 @@ static size_t process_input_file(FILE *outfile,
                                         strbuf_detach(&val, NULL));
                }
        }
-
-       trailer_info_release(&info);
-
-       return info.trailer_end - str;
 }
 
 static void free_all(struct list_head *head)
@@ -1054,6 +1051,7 @@ void process_trailers(const char *file,
 {
        LIST_HEAD(head);
        struct strbuf sb = STRBUF_INIT;
+       struct trailer_info info;
        size_t trailer_end;
        FILE *outfile = stdout;
 
@@ -1064,18 +1062,30 @@ void process_trailers(const char *file,
        if (opts->in_place)
                outfile = create_in_place_tempfile(file);
 
+       parse_trailers(&info, sb.buf, &head, opts);
+       trailer_end = info.trailer_end - sb.buf;
+
        /* Print the lines before the trailers */
-       trailer_end = process_input_file(outfile, sb.buf, &head, opts);
+       if (!opts->only_trailers)
+               fwrite(sb.buf, 1, info.trailer_start - sb.buf, outfile);
+
+       if (!opts->only_trailers && !info.blank_line_before_trailer)
+               fprintf(outfile, "\n");
+
 
        if (!opts->only_input) {
+               LIST_HEAD(config_head);
                LIST_HEAD(arg_head);
-               process_command_line_args(&arg_head, new_trailer_head);
+               parse_trailers_from_config(&config_head);
+               parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
+               list_splice(&config_head, &arg_head);
                process_trailers_lists(&head, &arg_head);
        }
 
        print_all(outfile, &head, opts);
 
        free_all(&head);
+       trailer_info_release(&info);
 
        /* Print the lines after the trailers as is */
        if (!opts->only_trailers)
@@ -1220,14 +1230,14 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
        strbuf_init(&iter->key, 0);
        strbuf_init(&iter->val, 0);
        opts.no_divider = 1;
-       trailer_info_get(&iter->info, msg, &opts);
-       iter->cur = 0;
+       trailer_info_get(&iter->internal.info, msg, &opts);
+       iter->internal.cur = 0;
 }
 
 int trailer_iterator_advance(struct trailer_iterator *iter)
 {
-       while (iter->cur < iter->info.trailer_nr) {
-               char *trailer = iter->info.trailers[iter->cur++];
+       while (iter->internal.cur < iter->internal.info.trailer_nr) {
+               char *trailer = iter->internal.info.trailers[iter->internal.cur++];
                int separator_pos = find_separator(trailer, separators);
 
                if (separator_pos < 1)
@@ -1245,7 +1255,7 @@ int trailer_iterator_advance(struct trailer_iterator *iter)
 
 void trailer_iterator_release(struct trailer_iterator *iter)
 {
-       trailer_info_release(&iter->info);
+       trailer_info_release(&iter->internal.info);
        strbuf_release(&iter->val);
        strbuf_release(&iter->key);
 }
index 795d2fccfd9579500b798ac667feef2ee549f4b4..ab2cd017567b3f782fa9b342ad03e7e93bc17a37 100644 (file)
--- a/trailer.h
+++ b/trailer.h
@@ -119,8 +119,10 @@ struct trailer_iterator {
        struct strbuf val;
 
        /* private */
-       struct trailer_info info;
-       size_t cur;
+       struct {
+               struct trailer_info info;
+               size_t cur;
+       } internal;
 };
 
 /*
index 8fc159b86ec02ac54d6c8886351b6c3c0ba058b9..46107772d178f9b3706f288e6055a34a040db00c 100644 (file)
@@ -7,6 +7,7 @@
 #include "hash.h"
 #include "tree.h"
 #include "tree-walk.h"
+#include "environment.h"
 
 /*
  * Some mode bits are also used internally for computations.
@@ -45,7 +46,8 @@
 static struct combine_diff_path *ll_diff_tree_paths(
        struct combine_diff_path *p, const struct object_id *oid,
        const struct object_id **parents_oid, int nparent,
-       struct strbuf *base, struct diff_options *opt);
+       struct strbuf *base, struct diff_options *opt,
+       int depth);
 static void ll_diff_tree_oid(const struct object_id *old_oid,
                             const struct object_id *new_oid,
                             struct strbuf *base, struct diff_options *opt);
@@ -196,7 +198,7 @@ static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
 static struct combine_diff_path *emit_path(struct combine_diff_path *p,
        struct strbuf *base, struct diff_options *opt, int nparent,
        struct tree_desc *t, struct tree_desc *tp,
-       int imin)
+       int imin, int depth)
 {
        unsigned short mode;
        const char *path;
@@ -302,7 +304,8 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
 
                strbuf_add(base, path, pathlen);
                strbuf_addch(base, '/');
-               p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt);
+               p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt,
+                                      depth + 1);
                FAST_ARRAY_FREE(parents_oid, nparent);
        }
 
@@ -423,12 +426,16 @@ static inline void update_tp_entries(struct tree_desc *tp, int nparent)
 static struct combine_diff_path *ll_diff_tree_paths(
        struct combine_diff_path *p, const struct object_id *oid,
        const struct object_id **parents_oid, int nparent,
-       struct strbuf *base, struct diff_options *opt)
+       struct strbuf *base, struct diff_options *opt,
+       int depth)
 {
        struct tree_desc t, *tp;
        void *ttree, **tptree;
        int i;
 
+       if (depth > max_allowed_tree_depth)
+               die("exceeded maximum allowed tree depth");
+
        FAST_ARRAY_ALLOC(tp, nparent);
        FAST_ARRAY_ALLOC(tptree, nparent);
 
@@ -522,7 +529,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
 
                        /* D += {δ(t,pi) if pi=p[imin];  "+a" if pi > p[imin]} */
                        p = emit_path(p, base, opt, nparent,
-                                       &t, tp, imin);
+                                       &t, tp, imin, depth);
 
                skip_emit_t_tp:
                        /* t↓,  ∀ pi=p[imin]  pi↓ */
@@ -534,7 +541,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
                else if (cmp < 0) {
                        /* D += "+t" */
                        p = emit_path(p, base, opt, nparent,
-                                       &t, /*tp=*/NULL, -1);
+                                       &t, /*tp=*/NULL, -1, depth);
 
                        /* t↓ */
                        update_tree_entry(&t);
@@ -550,7 +557,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
                        }
 
                        p = emit_path(p, base, opt, nparent,
-                                       /*t=*/NULL, tp, imin);
+                                       /*t=*/NULL, tp, imin, depth);
 
                skip_emit_tp:
                        /* ∀ pi=p[imin]  pi↓ */
@@ -572,7 +579,7 @@ struct combine_diff_path *diff_tree_paths(
        const struct object_id **parents_oid, int nparent,
        struct strbuf *base, struct diff_options *opt)
 {
-       p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt);
+       p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt, 0);
 
        /*
         * free pre-allocated last element, if any
index 29ead71be1731c9e6bd94cf348551d5b4fae78e2..b517792ba23a2104f5f8207519e64cbc5d2daaa4 100644 (file)
@@ -9,6 +9,7 @@
 #include "tree.h"
 #include "pathspec.h"
 #include "json-writer.h"
+#include "environment.h"
 
 static const char *get_mode(const char *str, unsigned int *modep)
 {
@@ -441,22 +442,25 @@ int traverse_trees(struct index_state *istate,
                   int n, struct tree_desc *t,
                   struct traverse_info *info)
 {
-       int error = 0;
-       struct name_entry entry[MAX_TRAVERSE_TREES];
+       int ret = 0;
+       struct name_entry *entry;
        int i;
-       struct tree_desc_x tx[ARRAY_SIZE(entry)];
+       struct tree_desc_x *tx;
        struct strbuf base = STRBUF_INIT;
        int interesting = 1;
        char *traverse_path;
 
+       if (traverse_trees_cur_depth > max_allowed_tree_depth)
+               return error("exceeded maximum allowed tree depth");
+
        traverse_trees_count++;
        traverse_trees_cur_depth++;
 
        if (traverse_trees_cur_depth > traverse_trees_max_depth)
                traverse_trees_max_depth = traverse_trees_cur_depth;
 
-       if (n >= ARRAY_SIZE(entry))
-               BUG("traverse_trees() called with too many trees (%d)", n);
+       ALLOC_ARRAY(entry, n);
+       ALLOC_ARRAY(tx, n);
 
        for (i = 0; i < n; i++) {
                tx[i].d = t[i];
@@ -539,7 +543,7 @@ int traverse_trees(struct index_state *istate,
                if (interesting) {
                        trees_used = info->fn(n, mask, dirmask, entry, info);
                        if (trees_used < 0) {
-                               error = trees_used;
+                               ret = trees_used;
                                if (!info->show_all_errors)
                                        break;
                        }
@@ -551,12 +555,14 @@ int traverse_trees(struct index_state *istate,
        }
        for (i = 0; i < n; i++)
                free_extended_entry(tx + i);
+       free(tx);
+       free(entry);
        free(traverse_path);
        info->traverse_path = NULL;
        strbuf_release(&base);
 
        traverse_trees_cur_depth--;
-       return error;
+       return ret;
 }
 
 struct dir_state {
index 74cdceb3fed258eb7216ebec1fe8a86aef0fa264..a6bfa3da3a826bf5c218132b93582e53ace876be 100644 (file)
@@ -6,8 +6,6 @@
 struct index_state;
 struct repository;
 
-#define MAX_TRAVERSE_TREES 8
-
 /**
  * The tree walking API is used to traverse and inspect trees.
  */
diff --git a/tree.c b/tree.c
index c745462f968ed11db2cca234c304dedb5b5c23ae..990f9c9854e6a1a957ed01f74b20e694af07f278 100644 (file)
--- a/tree.c
+++ b/tree.c
 #include "alloc.h"
 #include "tree-walk.h"
 #include "repository.h"
+#include "environment.h"
 
 const char *tree_type = "tree";
 
 int read_tree_at(struct repository *r,
                 struct tree *tree, struct strbuf *base,
+                int depth,
                 const struct pathspec *pathspec,
                 read_tree_fn_t fn, void *context)
 {
@@ -24,6 +26,9 @@ int read_tree_at(struct repository *r,
        int len, oldlen = base->len;
        enum interesting retval = entry_not_interesting;
 
+       if (depth > max_allowed_tree_depth)
+               return error("exceeded maximum allowed tree depth");
+
        if (parse_tree(tree))
                return -1;
 
@@ -74,7 +79,7 @@ int read_tree_at(struct repository *r,
                strbuf_add(base, entry.path, len);
                strbuf_addch(base, '/');
                retval = read_tree_at(r, lookup_tree(r, &oid),
-                                     base, pathspec,
+                                     base, depth + 1, pathspec,
                                      fn, context);
                strbuf_setlen(base, oldlen);
                if (retval)
@@ -89,7 +94,7 @@ int read_tree(struct repository *r,
              read_tree_fn_t fn, void *context)
 {
        struct strbuf sb = STRBUF_INIT;
-       int ret = read_tree_at(r, tree, &sb, pathspec, fn, context);
+       int ret = read_tree_at(r, tree, &sb, 0, pathspec, fn, context);
        strbuf_release(&sb);
        return ret;
 }
diff --git a/tree.h b/tree.h
index 1b5ecbda6b335b4962ee2150534dfd8c0a73964c..cc6ddf51b3273c2dbeb798b2cb945de29dd28a36 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -44,6 +44,7 @@ typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const c
 
 int read_tree_at(struct repository *r,
                 struct tree *tree, struct strbuf *base,
+                int depth,
                 const struct pathspec *pathspec,
                 read_tree_fn_t fn, void *context);
 
index e15fb0455bbd9d6b5fa113ec9bb5cea4f6b6d375..be5bf8c4f2ff28827507a70846907aeca731d530 100644 (file)
@@ -396,14 +396,13 @@ static const struct interval double_width[] = {
 { 0x2E80, 0x2E99 },
 { 0x2E9B, 0x2EF3 },
 { 0x2F00, 0x2FD5 },
-{ 0x2FF0, 0x2FFB },
-{ 0x3000, 0x303E },
+{ 0x2FF0, 0x303E },
 { 0x3041, 0x3096 },
 { 0x3099, 0x30FF },
 { 0x3105, 0x312F },
 { 0x3131, 0x318E },
 { 0x3190, 0x31E3 },
-{ 0x31F0, 0x321E },
+{ 0x31EF, 0x321E },
 { 0x3220, 0x3247 },
 { 0x3250, 0x4DBF },
 { 0x4E00, 0xA48C },
index 87517364dc0190acb499ca6d2972e69e1a9fe74e..c2b20b80d5a448b7b5c76d2de4ac9358fa596b69 100644 (file)
@@ -2,7 +2,7 @@
 #include "advice.h"
 #include "strvec.h"
 #include "repository.h"
-#include "config.h"
+#include "parse.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
@@ -864,8 +864,8 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
        struct unpack_trees_options *o = info->data;
        int i, ret, bottom;
        int nr_buf = 0;
-       struct tree_desc t[MAX_UNPACK_TREES];
-       void *buf[MAX_UNPACK_TREES];
+       struct tree_desc *t;
+       void **buf;
        struct traverse_info newinfo;
        struct name_entry *p;
        int nr_entries;
@@ -902,6 +902,9 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
        newinfo.pathlen = st_add3(newinfo.pathlen, tree_entry_len(p), 1);
        newinfo.df_conflicts |= df_conflicts;
 
+       ALLOC_ARRAY(t, n);
+       ALLOC_ARRAY(buf, n);
+
        /*
         * Fetch the tree from the ODB for each peer directory in the
         * n commits.
@@ -937,6 +940,8 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
 
        for (i = 0; i < nr_buf; i++)
                free(buf[i]);
+       free(buf);
+       free(t);
 
        return ret;
 }
index 9b827c307f6d565fe6becf25839f45f81340b8ce..5867e26e17777483f3fc5df0084deb7a4dd135da 100644 (file)
@@ -7,7 +7,7 @@
 #include "string-list.h"
 #include "tree-walk.h"
 
-#define MAX_UNPACK_TREES MAX_TRAVERSE_TREES
+#define MAX_UNPACK_TREES 8
 
 struct cache_entry;
 struct unpack_trees_options;
index 83f3d2651ab3feee758178f86394627ffe4f76b0..ea234ab6a4522489c7a70a3cfa6d6449c46013c5 100644 (file)
@@ -33,6 +33,7 @@
 #include "commit-reach.h"
 #include "shallow.h"
 #include "write-or-die.h"
+#include "json-writer.h"
 
 /* Remember to update object flag allocation in object.h */
 #define THEY_HAVE      (1u << 11)
@@ -1552,6 +1553,30 @@ static int parse_have(const char *line, struct oid_array *haves)
        return 0;
 }
 
+static void trace2_fetch_info(struct upload_pack_data *data)
+{
+       struct json_writer jw = JSON_WRITER_INIT;
+
+       jw_object_begin(&jw, 0);
+       jw_object_intmax(&jw, "haves", data->haves.nr);
+       jw_object_intmax(&jw, "wants", data->want_obj.nr);
+       jw_object_intmax(&jw, "want-refs", data->wanted_refs.nr);
+       jw_object_intmax(&jw, "depth", data->depth);
+       jw_object_intmax(&jw, "shallows", data->shallows.nr);
+       jw_object_bool(&jw, "deepen-since", data->deepen_since);
+       jw_object_intmax(&jw, "deepen-not", data->deepen_not.nr);
+       jw_object_bool(&jw, "deepen-relative", data->deepen_relative);
+       if (data->filter_options.choice)
+               jw_object_string(&jw, "filter", list_object_filter_config_name(data->filter_options.choice));
+       else
+               jw_object_null(&jw, "filter");
+       jw_end(&jw);
+
+       trace2_data_json("upload-pack", the_repository, "fetch-info", &jw);
+
+       jw_release(&jw);
+}
+
 static void process_args(struct packet_reader *request,
                         struct upload_pack_data *data)
 {
@@ -1640,6 +1665,9 @@ static void process_args(struct packet_reader *request,
 
        if (request->status != PACKET_READ_FLUSH)
                die(_("expected flush after fetch arguments"));
+
+       if (trace2_is_enabled())
+               trace2_fetch_info(data);
 }
 
 static int process_haves(struct upload_pack_data *data, struct oid_array *common)
diff --git a/url.c b/url.c
index 2e1a9f6feec96b055a9415748eb721937461c07f..282b12495ae7d4af9db51a76017af6065b924d3a 100644 (file)
--- a/url.c
+++ b/url.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "hex.h"
+#include "hex-ll.h"
 #include "strbuf.h"
 #include "url.h"
 
index 1c45f23adf2c2fe770c147e9bbf0d5a557fcf688..1d0254abacbc3f393062351bc55ccd9bef32051a 100644 (file)
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "hex.h"
+#include "hex-ll.h"
 #include "strbuf.h"
 #include "urlmatch.h"
 
index b8cf29e6a1587f5cbb2440a83ef5349fe49d0f48..a56a6c2a3d136d31019520fdae68fc46c428194d 100644 (file)
@@ -581,8 +581,10 @@ static void repair_gitfile(struct worktree *wt,
        strbuf_release(&dotgit);
 }
 
-static void repair_noop(int iserr, const char *path, const char *msg,
-                       void *cb_data)
+static void repair_noop(int iserr UNUSED,
+                       const char *path UNUSED,
+                       const char *msg UNUSED,
+                       void *cb_data UNUSED)
 {
        /* nothing */
 }
index 5160c9e28de87af79e561db5917d021ad9a3a562..7da15a56da614ce82ca1d6a5c6e2277b444f1063 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -3,9 +3,8 @@
  */
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "parse.h"
 #include "gettext.h"
-#include "object.h"
 #include "repository.h"
 #include "strbuf.h"
 #include "trace2.h"
@@ -632,11 +631,6 @@ int rmdir_or_warn(const char *file)
        return warn_if_unremovable("rmdir", file, rmdir(file));
 }
 
-int remove_or_warn(unsigned int mode, const char *file)
-{
-       return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
-}
-
 static int access_error_is_ok(int err, unsigned flag)
 {
        return (is_missing_file_error(err) ||
@@ -819,3 +813,13 @@ int csprng_bytes(void *buf, size_t len)
        return 0;
 #endif
 }
+
+uint32_t git_rand(void)
+{
+       uint32_t result;
+
+       if (csprng_bytes(&result, sizeof(result)) < 0)
+               die(_("unable to get random bytes"));
+
+       return result;
+}
index 79a9c1b5077b4df0bef51538b778abba220740e6..1b2b047ea069272052b13371c31ca06924231cc9 100644 (file)
--- a/wrapper.h
+++ b/wrapper.h
@@ -106,11 +106,6 @@ int unlink_or_msg(const char *file, struct strbuf *err);
  * not exist.
  */
 int rmdir_or_warn(const char *path);
-/*
- * Calls the correct function out of {unlink,rmdir}_or_warn based on
- * the supplied file mode.
- */
-int remove_or_warn(unsigned int mode, const char *path);
 
 /*
  * Call access(2), but warn for any error except "missing file"
@@ -139,4 +134,10 @@ void sleep_millisec(int millisec);
  */
 int csprng_bytes(void *buf, size_t len);
 
+/*
+ * Returns a random uint32_t, uniformly distributed across all possible
+ * values.
+ */
+uint32_t git_rand(void);
+
 #endif /* WRAPPER_H */
index d8355c0c3e36830f8b9dbd9af696ed3917860c9e..42a2dc73cd3f18638445780e7fa9aa9b67ba871c 100644 (file)
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "parse.h"
 #include "run-command.h"
 #include "write-or-die.h"
 
index d03dfab9e47d128b15295e499c8113346a593cf7..9f45bf69490e6fa4939948aadb63e7201d0e868e 100644 (file)
@@ -739,7 +739,7 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
                        ps.max_depth = -1;
 
                        strbuf_add(&base, ce->name, ce->ce_namelen);
-                       read_tree_at(istate->repo, tree, &base, &ps,
+                       read_tree_at(istate->repo, tree, &base, 0, &ps,
                                     add_file_to_list, s);
                        continue;
                }