aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--.travis.yml2
-rw-r--r--Documentation/CodingGuidelines14
-rw-r--r--Documentation/Makefile1
-rw-r--r--Documentation/RelNotes/2.10.0.txt229
-rw-r--r--Documentation/RelNotes/2.9.1.txt117
-rw-r--r--Documentation/RelNotes/2.9.2.txt13
-rw-r--r--Documentation/config.txt195
-rw-r--r--Documentation/date-formats.txt2
-rw-r--r--Documentation/diff-config.txt4
-rw-r--r--Documentation/diff-format.txt8
-rw-r--r--Documentation/diff-generate-patch.txt8
-rw-r--r--Documentation/fetch-options.txt8
-rw-r--r--Documentation/git-am.txt7
-rw-r--r--Documentation/git-bisect-lk2009.txt2
-rw-r--r--Documentation/git-bisect.txt4
-rw-r--r--Documentation/git-branch.txt6
-rw-r--r--Documentation/git-cat-file.txt12
-rw-r--r--Documentation/git-checkout.txt4
-rw-r--r--Documentation/git-cherry-pick.txt2
-rw-r--r--Documentation/git-clean.txt2
-rw-r--r--Documentation/git-clone.txt5
-rw-r--r--Documentation/git-commit-tree.txt2
-rw-r--r--Documentation/git-commit.txt10
-rw-r--r--Documentation/git-config.txt30
-rw-r--r--Documentation/git-credential-store.txt2
-rw-r--r--Documentation/git-cvsimport.txt12
-rw-r--r--Documentation/git-cvsserver.txt12
-rw-r--r--Documentation/git-daemon.txt10
-rw-r--r--Documentation/git-describe.txt2
-rw-r--r--Documentation/git-diff-index.txt4
-rw-r--r--Documentation/git-diff-tree.txt20
-rw-r--r--Documentation/git-difftool.txt2
-rw-r--r--Documentation/git-fast-import.txt4
-rw-r--r--Documentation/git-fetch-pack.txt4
-rw-r--r--Documentation/git-filter-branch.txt8
-rw-r--r--Documentation/git-for-each-ref.txt2
-rw-r--r--Documentation/git-format-patch.txt6
-rw-r--r--Documentation/git-fsck.txt2
-rw-r--r--Documentation/git-gc.txt16
-rw-r--r--Documentation/git-grep.txt12
-rw-r--r--Documentation/git-gui.txt2
-rw-r--r--Documentation/git-help.txt32
-rw-r--r--Documentation/git-http-backend.txt8
-rw-r--r--Documentation/git-http-push.txt4
-rw-r--r--Documentation/git-init.txt2
-rw-r--r--Documentation/git-instaweb.txt4
-rw-r--r--Documentation/git-interpret-trailers.txt2
-rw-r--r--Documentation/git-log.txt8
-rw-r--r--Documentation/git-ls-files.txt2
-rw-r--r--Documentation/git-ls-tree.txt8
-rw-r--r--Documentation/git-mailsplit.txt7
-rw-r--r--Documentation/git-mktree.txt2
-rw-r--r--Documentation/git-mv.txt4
-rw-r--r--Documentation/git-notes.txt22
-rw-r--r--Documentation/git-p4.txt26
-rw-r--r--Documentation/git-push.txt8
-rw-r--r--Documentation/git-quiltimport.txt4
-rw-r--r--Documentation/git-rebase.txt10
-rw-r--r--Documentation/git-remote.txt10
-rw-r--r--Documentation/git-repack.txt17
-rw-r--r--Documentation/git-replace.txt2
-rw-r--r--Documentation/git-revert.txt4
-rw-r--r--Documentation/git-send-email.txt80
-rw-r--r--Documentation/git-send-pack.txt10
-rw-r--r--Documentation/git-sh-setup.txt2
-rw-r--r--Documentation/git-shell.txt4
-rw-r--r--Documentation/git-show-branch.txt2
-rw-r--r--Documentation/git-show-ref.txt6
-rw-r--r--Documentation/git-svn.txt42
-rw-r--r--Documentation/git-tag.txt6
-rw-r--r--Documentation/git-update-index.txt14
-rw-r--r--Documentation/git-verify-commit.txt2
-rw-r--r--Documentation/git-web--browse.txt8
-rw-r--r--Documentation/git-worktree.txt10
-rw-r--r--Documentation/git.txt150
-rw-r--r--Documentation/gitcore-tutorial.txt2
-rw-r--r--Documentation/gitdiffcore.txt4
-rw-r--r--Documentation/gitignore.txt2
-rw-r--r--Documentation/gitk.txt2
-rw-r--r--Documentation/gitmodules.txt2
-rw-r--r--Documentation/gitremote-helpers.txt16
-rw-r--r--Documentation/gitweb.conf.txt2
-rw-r--r--Documentation/gitweb.txt4
-rw-r--r--Documentation/howto/new-command.txt2
-rw-r--r--Documentation/merge-config.txt2
-rw-r--r--Documentation/pretty-options.txt4
-rw-r--r--Documentation/rev-list-options.txt2
-rw-r--r--Documentation/revisions.txt26
-rw-r--r--Documentation/technical/signature-format.txt186
-rw-r--r--Makefile5
-rw-r--r--advice.c23
-rw-r--r--archive-tar.c62
-rw-r--r--bisect.c57
-rw-r--r--builtin/add.c33
-rw-r--r--builtin/am.c14
-rw-r--r--builtin/apply.c1438
-rw-r--r--builtin/blame.c27
-rw-r--r--builtin/branch.c6
-rw-r--r--builtin/checkout.c8
-rw-r--r--builtin/clone.c9
-rw-r--r--builtin/commit.c19
-rw-r--r--builtin/fetch.c6
-rw-r--r--builtin/gc.c2
-rw-r--r--builtin/grep.c4
-rw-r--r--builtin/init-db.c17
-rw-r--r--builtin/interpret-trailers.c2
-rw-r--r--builtin/log.c14
-rw-r--r--builtin/mailsplit.c18
-rw-r--r--builtin/merge.c12
-rw-r--r--builtin/notes.c24
-rw-r--r--builtin/pack-objects.c31
-rw-r--r--builtin/pull.c2
-rw-r--r--builtin/receive-pack.c15
-rw-r--r--builtin/remote.c21
-rw-r--r--builtin/repack.c12
-rw-r--r--builtin/reset.c2
-rw-r--r--builtin/shortlog.c6
-rw-r--r--builtin/submodule--helper.c66
-rw-r--r--builtin/worktree.c10
-rw-r--r--cache.h23
-rw-r--r--color.c35
-rw-r--r--color.h20
-rw-r--r--commit.c9
-rw-r--r--commit.h8
-rw-r--r--compat/mingw.c6
-rw-r--r--compat/mingw.h4
-rw-r--r--compat/regex/regcomp.c2
-rw-r--r--compat/regex/regex.c1
-rw-r--r--compat/winansi.c2
-rw-r--r--config.c136
-rw-r--r--connect.c15
-rw-r--r--contrib/completion/git-completion.bash121
-rw-r--r--contrib/completion/git-prompt.sh6
-rw-r--r--contrib/credential/gnome-keyring/Makefile5
-rw-r--r--date.c2
-rwxr-xr-xgit-add--interactive.perl4
-rwxr-xr-xgit-bisect.sh8
-rw-r--r--git-compat-util.h17
-rwxr-xr-xgit-merge-octopus.sh23
-rwxr-xr-xgit-p4.py2
-rw-r--r--git-rebase--am.sh4
-rw-r--r--git-rebase--interactive.sh295
-rw-r--r--git-rebase--merge.sh4
-rwxr-xr-xgit-rebase.sh5
-rwxr-xr-xgit-send-email.perl40
-rw-r--r--git-sh-i18n.sh18
-rw-r--r--git-sh-setup.sh69
-rwxr-xr-xgit-stash.sh1
-rwxr-xr-xgit-submodule.sh25
-rwxr-xr-xgit-svn.perl5
-rw-r--r--gpg-interface.c93
-rw-r--r--graph.c7
-rw-r--r--graph.h5
-rw-r--r--help.c6
-rw-r--r--http.c124
-rw-r--r--http.h2
-rw-r--r--imap-send.c1
-rw-r--r--line-log.c3
-rw-r--r--log-tree.c6
-rw-r--r--notes.c2
-rw-r--r--parse-options-cb.c2
-rw-r--r--perl/Git/SVN.pm33
-rw-r--r--po/is.po46
-rw-r--r--pretty.c58
-rw-r--r--read-cache.c11
-rw-r--r--reflog-walk.c6
-rw-r--r--refs.h2
-rw-r--r--revision.c2
-rw-r--r--run-command.c152
-rw-r--r--run-command.h31
-rw-r--r--send-pack.c33
-rw-r--r--sequencer.c32
-rw-r--r--setup.c16
-rw-r--r--sideband.c136
-rw-r--r--sideband.h2
-rw-r--r--strbuf.h2
-rw-r--r--submodule.c2
-rw-r--r--t/helper/test-config.c36
-rw-r--r--t/helper/test-date.c34
-rw-r--r--t/helper/test-parse-options.c2
-rw-r--r--t/lib-httpd.sh1
-rw-r--r--t/lib-rebase.sh1
-rw-r--r--t/perf/README12
-rwxr-xr-xt/perf/p4211-line-log.sh6
-rw-r--r--t/perf/perf-lib.sh11
-rwxr-xr-xt/t0006-date.sh52
-rwxr-xr-xt/t0008-ignores.sh4
-rwxr-xr-xt/t1011-read-tree-sparse-checkout.sh4
-rwxr-xr-xt/t1300-repo-config.sh8
-rwxr-xr-xt/t1307-config-blob.sh5
-rwxr-xr-xt/t1308-config-set.sh39
-rwxr-xr-xt/t1400-update-ref.sh2
-rwxr-xr-xt/t1401-symbolic-ref.sh2
-rwxr-xr-xt/t1410-reflog.sh22
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh2
-rwxr-xr-xt/t2010-checkout-ambiguous.sh2
-rwxr-xr-xt/t2018-checkout-branch.sh2
-rwxr-xr-xt/t2300-cd-to-toplevel.sh10
-rwxr-xr-xt/t3200-branch.sh6
-rwxr-xr-xt/t3201-branch-contains.sh2
-rwxr-xr-xt/t3310-notes-merge-manual-resolve.sh8
-rwxr-xr-xt/t3320-notes-merge-worktrees.sh4
-rwxr-xr-xt/t3400-rebase.sh4
-rwxr-xr-xt/t3404-rebase-interactive.sh20
-rwxr-xr-xt/t3420-rebase-autostash.sh31
-rwxr-xr-xt/t3427-rebase-subtree.sh119
-rwxr-xr-xt/t3700-add.sh30
-rwxr-xr-xt/t4014-format-patch.sh41
-rwxr-xr-xt/t4026-color.sh9
-rwxr-xr-xt/t4150-am.sh20
-rwxr-xr-xt/t4153-am-resume-override-opts.sh2
-rwxr-xr-xt/t4202-log.sh32
-rwxr-xr-xt/t4205-log-pretty-formats.sh57
-rwxr-xr-xt/t4208-log-magic-pathspec.sh4
-rwxr-xr-xt/t5000-tar-tree.sh74
-rw-r--r--t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902abin0 -> 2048 bytes
-rw-r--r--t/t5000/huge-and-future.tarbin0 -> 2048 bytes
-rwxr-xr-xt/t5100-mailinfo.sh31
-rw-r--r--t/t5100/0001mboxrd4
-rw-r--r--t/t5100/0002mboxrd5
-rw-r--r--t/t5100/sample.mboxrd19
-rwxr-xr-xt/t5505-remote.sh2
-rwxr-xr-xt/t5510-fetch.sh2
-rwxr-xr-xt/t5520-pull.sh2
-rwxr-xr-xt/t5523-push-upstream.sh12
-rwxr-xr-xt/t5536-fetch-conflicts.sh4
-rwxr-xr-xt/t5541-http-push-smart.sh12
-rwxr-xr-xt/t5544-pack-objects-hook.sh62
-rwxr-xr-xt/t5614-clone-submodules.sh67
-rwxr-xr-xt/t6030-bisect-porcelain.sh26
-rwxr-xr-xt/t6301-for-each-ref-errors.sh10
-rwxr-xr-xt/t7004-tag.sh9
-rwxr-xr-xt/t7063-status-untracked-cache.sh2
-rwxr-xr-xt/t7102-reset.sh4
-rwxr-xr-xt/t7201-co.sh2
-rwxr-xr-xt/t7400-submodule-basic.sh2
-rwxr-xr-xt/t7403-submodule-sync.sh4
-rwxr-xr-xt/t7406-submodule-update.sh10
-rwxr-xr-xt/t7508-status.sh4
-rwxr-xr-xt/t7510-signed-commit.sh7
-rwxr-xr-xt/t7607-merge-overwrite.sh4
-rwxr-xr-xt/t7609-merge-co-error-msgs.sh10
-rwxr-xr-xt/t7701-repack-unpack-unreachable.sh28
-rwxr-xr-xt/t7800-difftool.sh2
-rwxr-xr-xt/t7810-grep.sh62
-rwxr-xr-xt/t8008-blame-formats.sh17
-rwxr-xr-xt/t9003-help-autocorrect.sh4
-rwxr-xr-xt/t9300-fast-import.sh23
-rw-r--r--t/test-lib-functions.sh14
-rw-r--r--t/test-lib.sh9
-rw-r--r--transport-helper.c2
-rw-r--r--transport.c20
-rw-r--r--tree-diff.c22
-rw-r--r--unpack-trees.c18
-rw-r--r--upload-pack.c32
-rw-r--r--worktree.c18
-rw-r--r--wrapper.c43
-rw-r--r--write_or_die.c11
-rw-r--r--wt-status.c6
260 files changed, 4615 insertions, 2033 deletions
diff --git a/.mailmap b/.mailmap
index a9162c009..a714e69a1 100644
--- a/.mailmap
+++ b/.mailmap
@@ -46,6 +46,7 @@ David D. Kilzer <ddkilzer@kilzer.net>
David KÃ¥gedal <davidk@lysator.liu.se>
David Reiss <dreiss@facebook.com> <dreiss@dreiss-vmware.(none)>
David S. Miller <davem@davemloft.net>
+David Turner <novalis@novalis.org> <dturner@twopensource.com>
Deskin Miller <deskinm@umich.edu>
Dirk Süsserott <newsletter@dirk.my1.cc>
Eric Blake <eblake@redhat.com> <ebb9@byu.net>
diff --git a/.travis.yml b/.travis.yml
index c20ec540c..c2b76f9b7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -82,6 +82,8 @@ before_install:
brew tap homebrew/binary --quiet
brew_force_set_latest_binary_hash perforce
brew_force_set_latest_binary_hash perforce-server
+ # Uncomment this if you want to run perf tests:
+ # brew install gnu-time
brew install git-lfs perforce-server perforce gettext
brew link --force gettext
;;
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 0ddd36879..4cd95da6b 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -526,12 +526,20 @@ Writing Documentation:
modifying paragraphs or option/command explanations that contain options
or commands:
- Literal examples (e.g. use of command-line options, command names, and
- configuration variables) are typeset in monospace, and if you can use
- `backticks around word phrases`, do so.
+ Literal examples (e.g. use of command-line options, command names,
+ branch names, configuration and environment variables) must be
+ typeset in monospace (i.e. wrapped with backticks):
`--pretty=oneline`
`git rev-list`
`remote.pushDefault`
+ `GIT_DIR`
+ `HEAD`
+
+ An environment variable must be prefixed with "$" only when referring to its
+ value and not when referring to the variable itself, in this case there is
+ nothing to add except the backticks:
+ `GIT_DIR` is specified
+ `$GIT_DIR/hooks/pre-receive`
Word phrases enclosed in `backtick characters` are rendered literally
and will not be further expanded. The use of `backticks` to achieve the
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 35c1385ef..b43d66eae 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -76,6 +76,7 @@ TECH_DOCS += technical/protocol-common
TECH_DOCS += technical/racy-git
TECH_DOCS += technical/send-pack-pipeline
TECH_DOCS += technical/shallow
+TECH_DOCS += technical/signature-format
TECH_DOCS += technical/trivial-merge
SP_ARTICLES += $(TECH_DOCS)
SP_ARTICLES += technical/api-index
diff --git a/Documentation/RelNotes/2.10.0.txt b/Documentation/RelNotes/2.10.0.txt
index eac12490a..4252eb734 100644
--- a/Documentation/RelNotes/2.10.0.txt
+++ b/Documentation/RelNotes/2.10.0.txt
@@ -20,6 +20,67 @@ UI, Workflows & Features
* Update the funcname definition to support css files.
+ * The completion script (in contrib/) learned to complete "git
+ status" options.
+
+ * Messages that are generated by auto gc during "git push" on the
+ receiving end are now passed back to the sending end in such a way
+ that they are shown with "remote: " prefix to avoid confusing the
+ users.
+
+ * "git add -i/-p" learned to honor diff.compactionHeuristic
+ experimental knob, so that the user can work on the same hunk split
+ as "git diff" output.
+
+ * "upload-pack" allows a custom "git pack-objects" replacement when
+ responding to "fetch/clone" via the uploadpack.packObjectsHook.
+ (merge 20b20a2 jk/upload-pack-hook later to maint).
+
+ * Teach format-patch and mailsplit (hence "am") how a line that
+ happens to begin with "From " in the e-mail message is quoted with
+ ">", so that these lines can be restored to their original shape.
+ (merge d9925d1 ew/mboxrd-format-am later to maint).
+
+ * "git repack" learned the "--keep-unreachable" option, which sends
+ loose unreachable objects to a pack instead of leaving them loose.
+ This helps heuristics based on the number of loose objects
+ (e.g. "gc --auto").
+ (merge e26a8c4 jk/repack-keep-unreachable later to maint).
+
+ * "log --graph --format=" learned that "%>|(N)" specifies the width
+ relative to the terminal's left edge, not relative to the area to
+ draw text that is to the right of the ancestry-graph section. It
+ also now accepts negative N that means the column limit is relative
+ to the right border.
+
+ * A careless invocation of "git send-email directory/" after editing
+ 0001-change.patch with an editor often ends up sending both
+ 0001-change.patch and its backup file, 0001-change.patch~, causing
+ embarrassment and a minor confusion. Detect such an input and
+ offer to skip the backup files when sending the patches out.
+ (merge 531220b jc/send-email-skip-backup later to maint).
+
+ * "git submodule update" that drives many "git clone" could
+ eventually hit flaky servers/network conditions on one of the
+ submodules; the command learned to retry the attempt.
+
+ * The output coloring scheme learned two new attributes, italic and
+ strike, in addition to existing bold, reverse, etc.
+
+ * "git log" learns log.showSignature configuration variable, and a
+ command line option "--no-show-signature" to countermand it.
+ (merge fce04c3 mj/log-show-signature-conf later to maint).
+
+ * A couple of "git svn" updates.
+
+ * More markings of messages for i18n, with updates to various tests
+ to pass GETTEXT_POISON tests.
+
+ * "git archive" learned to handle files that are larger than 8GB and
+ commits far in the future than expressible by the traditional US-TAR
+ format.
+ (merge 5caeeb8 jk/big-and-future-archive-tar later to maint).
+
Performance, Internal Implementation, Development Support etc.
@@ -31,11 +92,55 @@ Performance, Internal Implementation, Development Support etc.
connection from a client that silently goes offline can hang around
for a long time, wasting resources. The socket-level KEEPALIVE has
been enabled to allow the OS to notice such failed connections.
- (merge a43b68a ew/daemon-socket-keepalive later to maint).
* "git upload-pack" command has been updated to use the parse-options
API.
+ * The "git apply" standalone program is being libified; this is the
+ first step to move many state variables into a structure that can
+ be explicitly (re)initialized to make the machinery callable more
+ than once.
+
+ * HTTP transport gained an option to produce more detailed debugging
+ trace.
+ (merge 73e57aa ep/http-curl-trace later to maint).
+
+ * Instead of taking advantage of a struct string_list that is
+ allocated with all NULs happens to be STRING_LIST_INIT_NODUP kind,
+ initialize them explicitly as such, to document their behaviour
+ better.
+ (merge 2721ce2 jk/string-list-static-init later to maint).
+
+ * HTTPd tests learned to show the server error log to help diagnosing
+ a failing tests.
+ (merge 44f243d nd/test-lib-httpd-show-error-log-in-verbose later to maint).
+
+ * The ownership rule for the piece of memory that hold references to
+ be fetched in "git fetch" was screwy, which has been cleaned up.
+
+ * "git bisect" makes an internal call to "git diff-tree" when
+ bisection finds the culprit, but this call did not initialize the
+ data structure to pass to the diff-tree API correctly.
+
+ * Further preparatory clean-up for "worktree" feature continues.
+ (merge 0409e0b nd/worktree-cleanup-post-head-protection later to maint).
+
+ * Formats of the various data (and how to validate them) where we use
+ GPG signature have been documented.
+
+ * A new run-command API function pipe_command() is introduced to
+ sanely feed data to the standard input while capturing data from
+ the standard output and the standard error of an external process,
+ which is cumbersome to hand-roll correctly without deadlocking.
+
+ The codepath to sign data in a prepared buffer with GPG has been
+ updated to use this API to read from the status-fd to check for
+ errors (instead of relying on GPG's exit status).
+ (merge efee955 jk/gpg-interface-cleanup later to maint).
+
+ * Allow t/perf framework to use the features from the most recent
+ version of Git even when testing an older installed version.
+
Also contains various documentation updates and code clean-ups.
@@ -52,17 +157,133 @@ notes for details).
--no-color or with --color=auto when the output is not connected to
a tty; this was corrected to make the format truly behave as
"auto".
- (merge b15a3e0 et/pretty-format-c-auto later to maint).
* "git rev-list --count" whose walk-length is limited with "-n"
option did not work well with the counting optimized to look at the
bitmap index.
- (merge fb85db8 jk/rev-list-count-with-bitmap later to maint).
* "git show -W" (extend hunks to cover the entire function, delimited
by lines that match the "funcname" pattern) used to show the entire
file when a change added an entire function at the end of the file,
which has been fixed.
- (merge 6f8d9bc rs/xdiff-hunk-with-func-line later to maint).
+
+ * The documentation set has been updated so that literal commands,
+ configuration variables and environment variables are consistently
+ typeset in fixed-width font and bold in manpages.
+
+ * "git svn propset" subcommand that was added in 2.3 days is
+ documented now.
+
+ * The documentation tries to consistently spell "GPG"; when
+ referring to the specific program name, "gpg" is used.
+
+ * "git reflog" stopped upon seeing an entry that denotes a branch
+ creation event (aka "unborn"), which made it appear as if the
+ reflog was truncated.
+
+ * The git-prompt scriptlet (in contrib/) was not friendly with those
+ who uses "set -u", which has been fixed.
+
+ * compat/regex code did not cleanly compile.
+
+ * A codepath that used alloca(3) to place an unbounded amount of data
+ on the stack has been updated to avoid doing so.
+
+ * "git update-index --add --chmod=+x file" may be usable as an escape
+ hatch, but not a friendly thing to force for people who do need to
+ use it regularly. "git add --chmod=+x file" can be used instead.
+
+ * Build improvements for gnome-keyring (in contrib/)
+
+ * "git status" used to say "working directory" when it meant "working
+ tree".
+
+ * Comments about misbehaving FreeBSD shells have been clarified with
+ the version number (9.x and before are broken, newer ones are OK).
+
+ * "git cherry-pick A" worked on an unborn branch, but "git
+ cherry-pick A..B" didn't.
+
+ * Fix an unintended regression in v2.9 that breaks "clone --depth"
+ that recurses down to submodules by forcing the submodules to also
+ be cloned shallowly, which many server instances that host upstream
+ of the submodules are not prepared for.
+
+ * Fix unnecessarily waste in the idiomatic use of ': ${VAR=default}'
+ to set the default value, without enclosing it in double quotes.
+
+ * Some platform-specific code had non-ANSI strict declarations of C
+ functions that do not take any parameters, which has been
+ corrected.
+
+ * The internal code used to show local timezone offset is not
+ prepared to handle timestamps beyond year 2100, and gave a
+ bogus offset value to the caller. Use a more benign looking
+ +0000 instead and let "git log" going in such a case, instead
+ of aborting.
+ (merge bab7483 jk/tzoffset-fix later to maint).
+
+ * One among four invocations of readlink(1) in our test suite has
+ been rewritten so that the test can run on systems without the
+ command (others are in valgrind test framework and t9802).
+
+ * t/perf needs /usr/bin/time with GNU extension; the invocation of it
+ is updated to "gtime" on Darwin.
+
+ * A bug, which caused "git p4" while running under verbose mode to
+ report paths that are omitted due to branch prefix incorrectly, has
+ been fixed; the command said "Ignoring file outside of prefix" for
+ paths that are _inside_.
+
+ * The top level documentation "git help git" still pointed at the
+ documentation set hosted at now-defunct google-code repository.
+ Update it to point to https://git.github.io/htmldocs/git.html
+ instead.
+
+ * A helper function that takes the contents of a commit object and
+ finds its subject line did not ignore leading blank lines, as is
+ commonly done by other codepaths. Make it ignore leading blank
+ lines to match.
+ (merge 054a5ae js/find-commit-subject-ignore-leading-blanks later to maint).
+
+ * For a long time, we carried an in-code comment that said our
+ colored output would work only when we use fprintf/fputs on
+ Windows, which no longer is the case for the past few years.
+ (merge 3d0a833 js/color-on-windows-comment later to maint).
+
+ * "gc.autoPackLimit" when set to 1 should not trigger a repacking
+ when there is only one pack, but the code counted poorly and did
+ so.
+ (merge 5f4e3bf ew/gc-auto-pack-limit-fix later to maint).
+
+ * Add a test to specify the desired behaviour that currently is not
+ available in "git rebase -Xsubtree=...".
+ (merge 5f35900 dg/subtree-rebase-test later to maint).
+
+ * More mark-up updates to typeset strings that are expected to
+ literally typed by the end user in fixed-width font.
+ (merge 661c3e9 mm/doc-tt later to maint).
+
+ * "git commit --amend --allow-empty-message -S" for a commit without
+ any message body could have misidentified where the header of the
+ commit object ends.
+ (merge 3324dd8 js/sign-empty-commit-fix later to maint).
+
+ * "git rebase -i --autostash" did not restore the auto-stashed change
+ when the operation was aborted.
+ (merge 33ba9c6 ps/rebase-i-auto-unstash-upon-abort later to maint).
+
+ * Git does not know what the contents in the index should be for a
+ path added with "git add -N" yet, so "git grep --cached" should not
+ show hits (or show lack of hits, with -L) in such a path, but that
+ logic does not apply to "git grep", i.e. searching in the working
+ tree files. But we did so by mistake, which has been corrected.
+ (merge b8e47d1 nd/ita-cleanup later to maint).
* Other minor clean-ups and documentation updates
+ (merge e51b0df pb/commit-editmsg-path later to maint).
+ (merge b333d0d jk/send-pack-stdio later to maint).
+ (merge fcf0fe9 lf/sideband-returns-void later to maint).
+ (merge c2691e2 ah/unpack-trees-advice-messages later to maint).
+ (merge 82f6178 nd/doc-new-command later to maint).
+ (merge fa90ab4 js/t3404-grammo-fix later to maint).
diff --git a/Documentation/RelNotes/2.9.1.txt b/Documentation/RelNotes/2.9.1.txt
new file mode 100644
index 000000000..338394097
--- /dev/null
+++ b/Documentation/RelNotes/2.9.1.txt
@@ -0,0 +1,117 @@
+Git v2.9.1 Release Notes
+========================
+
+Fixes since v2.9
+----------------
+
+ * When "git daemon" is run without --[init-]timeout specified, a
+ connection from a client that silently goes offline can hang around
+ for a long time, wasting resources. The socket-level KEEPALIVE has
+ been enabled to allow the OS to notice such failed connections.
+
+ * The commands in `git log` family take %C(auto) in a custom format
+ string. This unconditionally turned the color on, ignoring
+ --no-color or with --color=auto when the output is not connected to
+ a tty; this was corrected to make the format truly behave as
+ "auto".
+
+ * "git rev-list --count" whose walk-length is limited with "-n"
+ option did not work well with the counting optimized to look at the
+ bitmap index.
+
+ * "git show -W" (extend hunks to cover the entire function, delimited
+ by lines that match the "funcname" pattern) used to show the entire
+ file when a change added an entire function at the end of the file,
+ which has been fixed.
+
+ * The documentation set has been updated so that literal commands,
+ configuration variables and environment variables are consistently
+ typeset in fixed-width font and bold in manpages.
+
+ * "git svn propset" subcommand that was added in 2.3 days is
+ documented now.
+
+ * The documentation tries to consistently spell "GPG"; when
+ referring to the specific program name, "gpg" is used.
+
+ * "git reflog" stopped upon seeing an entry that denotes a branch
+ creation event (aka "unborn"), which made it appear as if the
+ reflog was truncated.
+
+ * The git-prompt scriptlet (in contrib/) was not friendly with those
+ who uses "set -u", which has been fixed.
+
+ * A codepath that used alloca(3) to place an unbounded amount of data
+ on the stack has been updated to avoid doing so.
+
+ * "git update-index --add --chmod=+x file" may be usable as an escape
+ hatch, but not a friendly thing to force for people who do need to
+ use it regularly. "git add --chmod=+x file" can be used instead.
+
+ * Build improvements for gnome-keyring (in contrib/)
+
+ * "git status" used to say "working directory" when it meant "working
+ tree".
+
+ * Comments about misbehaving FreeBSD shells have been clarified with
+ the version number (9.x and before are broken, newer ones are OK).
+
+ * "git cherry-pick A" worked on an unborn branch, but "git
+ cherry-pick A..B" didn't.
+
+ * "git add -i/-p" learned to honor diff.compactionHeuristic
+ experimental knob, so that the user can work on the same hunk split
+ as "git diff" output.
+
+ * "log --graph --format=" learned that "%>|(N)" specifies the width
+ relative to the terminal's left edge, not relative to the area to
+ draw text that is to the right of the ancestry-graph section. It
+ also now accepts negative N that means the column limit is relative
+ to the right border.
+
+ * The ownership rule for the piece of memory that hold references to
+ be fetched in "git fetch" was screwy, which has been cleaned up.
+
+ * "git bisect" makes an internal call to "git diff-tree" when
+ bisection finds the culprit, but this call did not initialize the
+ data structure to pass to the diff-tree API correctly.
+
+ * Formats of the various data (and how to validate them) where we use
+ GPG signature have been documented.
+
+ * Fix an unintended regression in v2.9 that breaks "clone --depth"
+ that recurses down to submodules by forcing the submodules to also
+ be cloned shallowly, which many server instances that host upstream
+ of the submodules are not prepared for.
+
+ * Fix unnecessarily waste in the idiomatic use of ': ${VAR=default}'
+ to set the default value, without enclosing it in double quotes.
+
+ * Some platform-specific code had non-ANSI strict declarations of C
+ functions that do not take any parameters, which has been
+ corrected.
+
+ * The internal code used to show local timezone offset is not
+ prepared to handle timestamps beyond year 2100, and gave a
+ bogus offset value to the caller. Use a more benign looking
+ +0000 instead and let "git log" going in such a case, instead
+ of aborting.
+
+ * One among four invocations of readlink(1) in our test suite has
+ been rewritten so that the test can run on systems without the
+ command (others are in valgrind test framework and t9802).
+
+ * t/perf needs /usr/bin/time with GNU extension; the invocation of it
+ is updated to "gtime" on Darwin.
+
+ * A bug, which caused "git p4" while running under verbose mode to
+ report paths that are omitted due to branch prefix incorrectly, has
+ been fixed; the command said "Ignoring file outside of prefix" for
+ paths that are _inside_.
+
+ * The top level documentation "git help git" still pointed at the
+ documentation set hosted at now-defunct google-code repository.
+ Update it to point to https://git.github.io/htmldocs/git.html
+ instead.
+
+Also contains minor documentation updates and code clean-ups.
diff --git a/Documentation/RelNotes/2.9.2.txt b/Documentation/RelNotes/2.9.2.txt
new file mode 100644
index 000000000..2620003dc
--- /dev/null
+++ b/Documentation/RelNotes/2.9.2.txt
@@ -0,0 +1,13 @@
+Git v2.9.2 Release Notes
+========================
+
+Fixes since v2.9.1
+------------------
+
+ * A fix merged to v2.9.1 had a few tests that are not meant to be
+ run on platforms without 64-bit long, which caused unnecessary
+ test failures on them because we didn't detect the platform and
+ skip them. These tests are now skipped on platforms that they
+ are not applicable to.
+
+No other change is included in this update.
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 58673cf21..226c12a15 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -140,7 +140,7 @@ boolean::
false;; Boolean false can be spelled as `no`, `off`,
`false`, or `0`.
+
-When converting value to the canonical form using '--bool' type
+When converting value to the canonical form using `--bool` type
specifier; 'git config' will ensure that the output is "true" or
"false" (spelled in lowercase).
@@ -150,27 +150,34 @@ integer::
1024", "by 1024x1024", etc.
color::
- The value for a variables that takes a color is a list of
- colors (at most two) and attributes (at most one), separated
- by spaces. The colors accepted are `normal`, `black`,
- `red`, `green`, `yellow`, `blue`, `magenta`, `cyan` and
- `white`; the attributes are `bold`, `dim`, `ul`, `blink` and
- `reverse`. The first color given is the foreground; the
- second is the background. The position of the attribute, if
- any, doesn't matter. Attributes may be turned off specifically
- by prefixing them with `no` (e.g., `noreverse`, `noul`, etc).
-+
-Colors (foreground and background) may also be given as numbers between
-0 and 255; these use ANSI 256-color mode (but note that not all
-terminals may support this). If your terminal supports it, you may also
-specify 24-bit RGB values as hex, like `#ff0ab3`.
-+
-The attributes are meant to be reset at the beginning of each item
-in the colored output, so setting color.decorate.branch to `black`
-will paint that branch name in a plain `black`, even if the previous
-thing on the same output line (e.g. opening parenthesis before the
-list of branch names in `log --decorate` output) is set to be
-painted with `bold` or some other attribute.
+ The value for a variable that takes a color is a list of
+ colors (at most two, one for foreground and one for background)
+ and attributes (as many as you want), separated by spaces.
++
+The basic colors accepted are `normal`, `black`, `red`, `green`, `yellow`,
+`blue`, `magenta`, `cyan` and `white`. The first color given is the
+foreground; the second is the background.
++
+Colors may also be given as numbers between 0 and 255; these use ANSI
+256-color mode (but note that not all terminals may support this). If
+your terminal supports it, you may also specify 24-bit RGB values as
+hex, like `#ff0ab3`.
++
+The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`,
+`italic`, and `strike` (for crossed-out or "strikethrough" letters).
+The position of any attributes with respect to the colors
+(before, after, or in between), doesn't matter. Specific attributes may
+be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
+`no-ul`, etc).
++
+For git's pre-defined color slots, the attributes are meant to be reset
+at the beginning of each item in the colored output. So setting
+`color.decorate.branch` to `black` will paint that branch name in a
+plain `black`, even if the previous thing on the same output line (e.g.
+opening parenthesis before the list of branch names in `log --decorate`
+output) is set to be painted with `bold` or some other attribute.
+However, custom log formats may do more complicated and layered
+coloring, and the negated forms may be useful there.
pathname::
A variable that takes a pathname value can be given a
@@ -434,7 +441,7 @@ core.gitProxy::
may be set multiple times and is matched in the given order;
the first match wins.
+
-Can be overridden by the 'GIT_PROXY_COMMAND' environment variable
+Can be overridden by the `GIT_PROXY_COMMAND` environment variable
(which always applies universally, without the special "for"
handling).
+
@@ -443,6 +450,13 @@ specify that no proxy be used for a given domain pattern.
This is useful for excluding servers inside a firewall from
proxy use, while defaulting to a common proxy for external domains.
+core.sshCommand::
+ If this variable is set, `git fetch` and `git push` will
+ use the specified command instead of `ssh` when they need to
+ connect to a remote system. The command is in the same form as
+ the `GIT_SSH_COMMAND` environment variable and is overridden
+ when the environment variable is set.
+
core.ignoreStat::
If true, Git will avoid using lstat() calls to detect if files have
changed by setting the "assume-unchanged" bit for those tracked files
@@ -478,10 +492,10 @@ false), while all other repositories are assumed to be bare (bare
core.worktree::
Set the path to the root of the working tree.
- If GIT_COMMON_DIR environment variable is set, core.worktree
+ If `GIT_COMMON_DIR` environment variable is set, core.worktree
is ignored and not used for determining the root of working tree.
- This can be overridden by the GIT_WORK_TREE environment
- variable and the '--work-tree' command-line option.
+ This can be overridden by the `GIT_WORK_TREE` environment
+ variable and the `--work-tree` command-line option.
The value can be an absolute path or relative to the path to
the .git directory, which is either specified by --git-dir
or GIT_DIR, or automatically discovered.
@@ -545,7 +559,7 @@ core.compression::
-1 is the zlib default. 0 means no compression,
and 1..9 are various speed/size tradeoffs, 9 being slowest.
If set, this provides a default to other compression variables,
- such as 'core.looseCompression' and 'pack.compression'.
+ such as `core.looseCompression` and `pack.compression`.
core.looseCompression::
An integer -1..9, indicating the compression level for objects that
@@ -619,9 +633,9 @@ core.excludesFile::
core.askPass::
Some commands (e.g. svn and http interfaces) that interactively
ask for a password can be told to use an external program given
- via the value of this variable. Can be overridden by the 'GIT_ASKPASS'
+ via the value of this variable. Can be overridden by the `GIT_ASKPASS`
environment variable. If not set, fall back to the value of the
- 'SSH_ASKPASS' environment variable or, failing that, a simple password
+ `SSH_ASKPASS` environment variable or, failing that, a simple password
prompt. The external program shall be given a suitable prompt as
command-line argument and write the password on its STDOUT.
@@ -764,7 +778,7 @@ core.notesRef::
notes should be printed.
+
This setting defaults to "refs/notes/commits", and it can be overridden by
-the 'GIT_NOTES_REF' environment variable. See linkgit:git-notes[1].
+the `GIT_NOTES_REF` environment variable. See linkgit:git-notes[1].
core.sparseCheckout::
Enable "sparse checkout" feature. See section "Sparse checkout" in
@@ -779,7 +793,7 @@ core.abbrev::
add.ignoreErrors::
add.ignore-errors (deprecated)::
Tells 'git add' to continue adding files when some files cannot be
- added due to indexing errors. Equivalent to the '--ignore-errors'
+ added due to indexing errors. Equivalent to the `--ignore-errors`
option of linkgit:git-add[1]. `add.ignore-errors` is deprecated,
as it does not follow the usual naming convention for configuration
variables.
@@ -800,14 +814,14 @@ it will be treated as a shell command. For example, defining
"gitk --all --not ORIG_HEAD". Note that shell commands will be
executed from the top-level directory of a repository, which may
not necessarily be the current directory.
-'GIT_PREFIX' is set as returned by running 'git rev-parse --show-prefix'
+`GIT_PREFIX` is set as returned by running 'git rev-parse --show-prefix'
from the original current directory. See linkgit:git-rev-parse[1].
am.keepcr::
If true, git-am will call git-mailsplit for patches in mbox format
- with parameter '--keep-cr'. In this case git-mailsplit will
+ with parameter `--keep-cr`. In this case git-mailsplit will
not remove `\r` from lines ending with `\r\n`. Can be overridden
- by giving '--no-keep-cr' from the command line.
+ by giving `--no-keep-cr` from the command line.
See linkgit:git-am[1], linkgit:git-mailsplit[1].
am.threeWay::
@@ -820,7 +834,7 @@ am.threeWay::
apply.ignoreWhitespace::
When set to 'change', tells 'git apply' to ignore changes in
- whitespace, in the same way as the '--ignore-space-change'
+ whitespace, in the same way as the `--ignore-space-change`
option.
When set to one of: no, none, never, false tells 'git apply' to
respect all whitespace differences.
@@ -828,7 +842,7 @@ apply.ignoreWhitespace::
apply.whitespace::
Tells 'git apply' how to handle whitespaces, in the same way
- as the '--whitespace' option. See linkgit:git-apply[1].
+ as the `--whitespace` option. See linkgit:git-apply[1].
branch.autoSetupMerge::
Tells 'git branch' and 'git checkout' to set up new branches
@@ -930,7 +944,7 @@ browser.<tool>.cmd::
browser.<tool>.path::
Override the path for the given tool that may be used to
- browse HTML help (see '-w' option in linkgit:git-help[1]) or a
+ browse HTML help (see `-w` option in linkgit:git-help[1]) or a
working repository in gitweb (see linkgit:git-instaweb[1]).
clean.requireForce::
@@ -1429,24 +1443,24 @@ gitcvs.logFile::
gitcvs.usecrlfattr::
If true, the server will look up the end-of-line conversion
- attributes for files to determine the '-k' modes to use. If
+ attributes for files to determine the `-k` modes to use. If
the attributes force Git to treat a file as text,
- the '-k' mode will be left blank so CVS clients will
+ the `-k` mode will be left blank so CVS clients will
treat it as text. If they suppress text conversion, the file
will be set with '-kb' mode, which suppresses any newline munging
the client might otherwise do. If the attributes do not allow
- the file type to be determined, then 'gitcvs.allBinary' is
+ the file type to be determined, then `gitcvs.allBinary` is
used. See linkgit:gitattributes[5].
gitcvs.allBinary::
- This is used if 'gitcvs.usecrlfattr' does not resolve
+ This is used if `gitcvs.usecrlfattr` does not resolve
the correct '-kb' mode to use. If true, all
unresolved files are sent to the client in
mode '-kb'. This causes the client to treat them
as binary files, which suppresses any newline munging it
otherwise might do. Alternatively, if it is set to "guess",
then the contents of the file are examined to decide if
- it is binary, similar to 'core.autocrlf'.
+ it is binary, similar to `core.autocrlf`.
gitcvs.dbName::
Database used by git-cvsserver to cache revision information
@@ -1465,7 +1479,7 @@ gitcvs.dbDriver::
See linkgit:git-cvsserver[1].
gitcvs.dbUser, gitcvs.dbPass::
- Database user and password. Only useful if setting 'gitcvs.dbDriver',
+ Database user and password. Only useful if setting `gitcvs.dbDriver`,
since SQLite has no concept of database users and/or passwords.
'gitcvs.dbUser' supports variable substitution (see
linkgit:git-cvsserver[1] for details).
@@ -1477,8 +1491,8 @@ gitcvs.dbTableNamePrefix::
linkgit:git-cvsserver[1] for details). Any non-alphabetic
characters will be replaced with underscores.
-All gitcvs variables except for 'gitcvs.usecrlfattr' and
-'gitcvs.allBinary' can also be specified as
+All gitcvs variables except for `gitcvs.usecrlfattr` and
+`gitcvs.allBinary` can also be specified as
'gitcvs.<access_method>.<varname>' (where 'access_method'
is one of "ext" and "pserver") to make them apply only for the given
access method.
@@ -1501,17 +1515,17 @@ gitweb.snapshot::
See linkgit:gitweb.conf[5] for description.
grep.lineNumber::
- If set to true, enable '-n' option by default.
+ If set to true, enable `-n` option by default.
grep.patternType::
Set the default matching behavior. Using a value of 'basic', 'extended',
- 'fixed', or 'perl' will enable the '--basic-regexp', '--extended-regexp',
- '--fixed-strings', or '--perl-regexp' option accordingly, while the
+ 'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,
+ `--fixed-strings`, or `--perl-regexp` option accordingly, while the
value 'default' will return to the default matching behavior.
grep.extendedRegexp::
- If set to true, enable '--extended-regexp' option by default. This
- option is ignored when the 'grep.patternType' option is set to a value
+ If set to true, enable `--extended-regexp` option by default. This
+ option is ignored when the `grep.patternType` option is set to a value
other than 'default'.
grep.threads::
@@ -1596,7 +1610,7 @@ guitool.<name>.cmd::
of the linkgit:git-gui[1] `Tools` menu is invoked. This option is
mandatory for every tool. The command is executed from the root of
the working directory, and in the environment it receives the name of
- the tool as 'GIT_GUITOOL', the name of the currently selected file as
+ the tool as `GIT_GUITOOL`, the name of the currently selected file as
'FILENAME', and the name of the current branch as 'CUR_BRANCH' (if
the head is detached, 'CUR_BRANCH' is empty).
@@ -1617,7 +1631,7 @@ guitool.<name>.confirm::
guitool.<name>.argPrompt::
Request a string argument from the user, and pass it to the tool
- through the 'ARGS' environment variable. Since requesting an
+ through the `ARGS` environment variable. Since requesting an
argument implies confirmation, the 'confirm' option has no effect
if this is enabled. If the option is set to 'true', 'yes', or '1',
the dialog uses a built-in generic prompt; otherwise the exact
@@ -1625,7 +1639,7 @@ guitool.<name>.argPrompt::
guitool.<name>.revPrompt::
Request a single valid revision from the user, and set the
- 'REVISION' environment variable. In other aspects this option
+ `REVISION` environment variable. In other aspects this option
is similar to 'argPrompt', and can be used together with it.
guitool.<name>.revUnmerged::
@@ -1681,7 +1695,7 @@ http.proxyAuthMethod::
only takes effect if the configured proxy string contains a user name part
(i.e. is of the form 'user@host' or 'user@host:port'). This can be
overridden on a per-remote basis; see `remote.<name>.proxyAuthMethod`.
- Both can be overridden by the 'GIT_HTTP_PROXY_AUTHMETHOD' environment
+ Both can be overridden by the `GIT_HTTP_PROXY_AUTHMETHOD` environment
variable. Possible values are:
+
--
@@ -1740,9 +1754,9 @@ http.sslVersion::
- tlsv1.2
+
-Can be overridden by the 'GIT_SSL_VERSION' environment variable.
+Can be overridden by the `GIT_SSL_VERSION` environment variable.
To force git to use libcurl's default ssl version and ignore any
-explicit http.sslversion option, set 'GIT_SSL_VERSION' to the
+explicit http.sslversion option, set `GIT_SSL_VERSION` to the
empty string.
http.sslCipherList::
@@ -1753,41 +1767,41 @@ http.sslCipherList::
option; see the libcurl documentation for more details on the format
of this list.
+
-Can be overridden by the 'GIT_SSL_CIPHER_LIST' environment variable.
+Can be overridden by the `GIT_SSL_CIPHER_LIST` environment variable.
To force git to use libcurl's default cipher list and ignore any
-explicit http.sslCipherList option, set 'GIT_SSL_CIPHER_LIST' to the
+explicit http.sslCipherList option, set `GIT_SSL_CIPHER_LIST` to the
empty string.
http.sslVerify::
Whether to verify the SSL certificate when fetching or pushing
- over HTTPS. Can be overridden by the 'GIT_SSL_NO_VERIFY' environment
+ over HTTPS. Can be overridden by the `GIT_SSL_NO_VERIFY` environment
variable.
http.sslCert::
File containing the SSL certificate when fetching or pushing
- over HTTPS. Can be overridden by the 'GIT_SSL_CERT' environment
+ over HTTPS. Can be overridden by the `GIT_SSL_CERT` environment
variable.
http.sslKey::
File containing the SSL private key when fetching or pushing
- over HTTPS. Can be overridden by the 'GIT_SSL_KEY' environment
+ over HTTPS. Can be overridden by the `GIT_SSL_KEY` environment
variable.
http.sslCertPasswordProtected::
Enable Git's password prompt for the SSL certificate. Otherwise
OpenSSL will prompt the user, possibly many times, if the
certificate or private key is encrypted. Can be overridden by the
- 'GIT_SSL_CERT_PASSWORD_PROTECTED' environment variable.
+ `GIT_SSL_CERT_PASSWORD_PROTECTED` environment variable.
http.sslCAInfo::
File containing the certificates to verify the peer with when
fetching or pushing over HTTPS. Can be overridden by the
- 'GIT_SSL_CAINFO' environment variable.
+ `GIT_SSL_CAINFO` environment variable.
http.sslCAPath::
Path containing files with the CA certificates to verify the peer
with when fetching or pushing over HTTPS. Can be overridden
- by the 'GIT_SSL_CAPATH' environment variable.
+ by the `GIT_SSL_CAPATH` environment variable.
http.pinnedpubkey::
Public key of the https service. It may either be the filename of
@@ -1807,7 +1821,7 @@ http.sslTry::
http.maxRequests::
How many HTTP requests to launch in parallel. Can be overridden
- by the 'GIT_HTTP_MAX_REQUESTS' environment variable. Default is 5.
+ by the `GIT_HTTP_MAX_REQUESTS` environment variable. Default is 5.
http.minSessions::
The number of curl sessions (counted across slots) to be kept across
@@ -1826,13 +1840,13 @@ http.postBuffer::
http.lowSpeedLimit, http.lowSpeedTime::
If the HTTP transfer speed is less than 'http.lowSpeedLimit'
for longer than 'http.lowSpeedTime' seconds, the transfer is aborted.
- Can be overridden by the 'GIT_HTTP_LOW_SPEED_LIMIT' and
- 'GIT_HTTP_LOW_SPEED_TIME' environment variables.
+ Can be overridden by the `GIT_HTTP_LOW_SPEED_LIMIT` and
+ `GIT_HTTP_LOW_SPEED_TIME` environment variables.
http.noEPSV::
A boolean which disables using of EPSV ftp command by curl.
This can helpful with some "poor" ftp servers which don't
- support EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'
+ support EPSV mode. Can be overridden by the `GIT_CURL_FTP_NO_EPSV`
environment variable. Default is false (curl will use EPSV).
http.userAgent::
@@ -1842,7 +1856,7 @@ http.userAgent::
such as Mozilla/4.0. This may be necessary, for instance, if
connecting through a firewall that restricts HTTP connections to a set
of common USER_AGENT strings (but not including those like git/1.7.1).
- Can be overridden by the 'GIT_HTTP_USER_AGENT' environment variable.
+ Can be overridden by the `GIT_HTTP_USER_AGENT` environment variable.
http.<url>.*::
Any of the http.* options above can be applied selectively to some URLs.
@@ -1967,7 +1981,7 @@ log.decorate::
specified, the full ref name (including prefix) will be printed.
If 'auto' is specified, then if the output is going to a terminal,
the ref names are shown as if 'short' were given, otherwise no ref
- names are shown. This is the same as the '--decorate' option
+ names are shown. This is the same as the `--decorate` option
of the `git log`.
log.follow::
@@ -2350,16 +2364,16 @@ 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'.
+ `--no-follow-tags`.
push.gpgSign::
May be set to a boolean value, or the string 'if-asked'. A true
- value causes all pushes to be GPG signed, as if '--signed' is
+ value causes all pushes to be GPG signed, as if `--signed` is
passed to linkgit:git-push[1]. The string 'if-asked' causes
pushes to be signed if the server supports it, as if
- '--signed=if-asked' is passed to 'git push'. A false value may
+ `--signed=if-asked` is passed to 'git push'. A false value may
override a value from a lower-priority config file. An explicit
command-line flag always overrides this config option.
@@ -2382,7 +2396,7 @@ rebase.stat::
rebase. False by default.
rebase.autoSquash::
- If set to true enable '--autosquash' option by default.
+ If set to true enable `--autosquash` option by default.
rebase.autoStash::
When set to true, automatically create a temporary stash
@@ -2639,7 +2653,7 @@ sendemail.identity::
A configuration identity. When given, causes values in the
'sendemail.<identity>' subsection to take precedence over
values in the 'sendemail' section. The default identity is
- the value of 'sendemail.identity'.
+ the value of `sendemail.identity`.
sendemail.smtpEncryption::
See linkgit:git-send-email[1] for description. Note that this
@@ -2656,7 +2670,7 @@ sendemail.<identity>.*::
Identity-specific versions of the 'sendemail.*' parameters
found below, taking precedence over those when the this
identity is selected, through command-line or
- 'sendemail.identity'.
+ `sendemail.identity`.
sendemail.aliasesFile::
sendemail.aliasFileType::
@@ -2686,7 +2700,7 @@ sendemail.xmailer::
See linkgit:git-send-email[1] for description.
sendemail.signedoffcc (deprecated)::
- Deprecated alias for 'sendemail.signedoffbycc'.
+ Deprecated alias for `sendemail.signedoffbycc`.
showbranch.default::
The default set of branches for linkgit:git-show-branch[1].
@@ -2892,6 +2906,21 @@ uploadpack.keepAlive::
`uploadpack.keepAlive` seconds. Setting this option to 0
disables keepalive packets entirely. The default is 5 seconds.
+uploadpack.packObjectsHook::
+ If this option is set, when `upload-pack` would run
+ `git pack-objects` to create a packfile for a client, it will
+ run this shell command instead. The `pack-objects` command and
+ arguments it _would_ have run (including the `git pack-objects`
+ at the beginning) are appended to the shell command. The stdin
+ and stdout of the hook are treated as if `pack-objects` itself
+ was run. I.e., `upload-pack` will feed input intended for
+ `pack-objects` to the hook, and expects a completed packfile on
+ stdout.
++
+Note that this configuration variable is ignored if it is seen in the
+repository-level config (this is a safety measure against fetching from
+untrusted repositories).
+
url.<base>.insteadOf::
Any URL that starts with this value will be rewritten to
start, instead, with <base>. In cases where some site serves a
@@ -2918,17 +2947,17 @@ url.<base>.pushInsteadOf::
user.email::
Your email address to be recorded in any newly created commits.
- Can be overridden by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and
- 'EMAIL' environment variables. See linkgit:git-commit-tree[1].
+ Can be overridden by the `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_EMAIL`, and
+ `EMAIL` environment variables. See linkgit:git-commit-tree[1].
user.name::
Your full name to be recorded in any newly created commits.
- Can be overridden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME'
+ Can be overridden by the `GIT_AUTHOR_NAME` and `GIT_COMMITTER_NAME`
environment variables. See linkgit:git-commit-tree[1].
user.useConfigOnly::
- Instruct Git to avoid trying to guess defaults for 'user.email'
- and 'user.name', and instead retrieve the values only from the
+ Instruct Git to avoid trying to guess defaults for `user.email`
+ and `user.name`, and instead retrieve the values only from the
configuration. For example, if you have multiple email addresses
and would like to use a different one for each repository, then
with this configuration option set to `true` in the global config
diff --git a/Documentation/date-formats.txt b/Documentation/date-formats.txt
index ccd1fc812..35e8da201 100644
--- a/Documentation/date-formats.txt
+++ b/Documentation/date-formats.txt
@@ -1,7 +1,7 @@
DATE FORMATS
------------
-The GIT_AUTHOR_DATE, GIT_COMMITTER_DATE environment variables
+The `GIT_AUTHOR_DATE`, `GIT_COMMITTER_DATE` environment variables
ifdef::git-commit[]
and the `--date` option
endif::git-commit[]
diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index d78cfc5a3..d5a5b17d5 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
@@ -75,7 +75,7 @@ diff.ignoreSubmodules::
commands such as 'git diff-files'. 'git checkout' also honors
this setting when reporting uncommitted changes. Setting it to
'all' disables the submodule summary normally shown by 'git commit'
- and 'git status' when 'status.submoduleSummary' is set unless it is
+ and 'git status' when `status.submoduleSummary` is set unless it is
overridden by using the --ignore-submodules command-line option.
The 'git submodule' commands are not affected by this setting.
@@ -105,7 +105,7 @@ diff.orderFile::
diff.renameLimit::
The number of files to consider when performing the copy/rename
- detection; equivalent to the 'git diff' option '-l'.
+ detection; equivalent to the 'git diff' option `-l`.
diff.renames::
Whether and how Git detects renames. If set to "false",
diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
index 85b08909c..cf5262622 100644
--- a/Documentation/diff-format.txt
+++ b/Documentation/diff-format.txt
@@ -46,11 +46,11 @@ That is, from the left to the right:
. sha1 for "dst"; 0\{40\} if creation, unmerged or "look at work tree".
. a space.
. status, followed by optional "score" number.
-. a tab or a NUL when '-z' option is used.
+. a tab or a NUL when `-z` option is used.
. path for "src"
-. a tab or a NUL when '-z' option is used; only exists for C or R.
+. a tab or a NUL when `-z` option is used; only exists for C or R.
. path for "dst"; only exists for C or R.
-. an LF or a NUL when '-z' option is used, to terminate the record.
+. an LF or a NUL when `-z` option is used, to terminate the record.
Possible status letters are:
@@ -86,7 +86,7 @@ diff format for merges
----------------------
"git-diff-tree", "git-diff-files" and "git-diff --raw"
-can take '-c' or '--cc' option
+can take `-c` or `--cc` option
to generate diff output also for merge commits. The output differs
from the format described above in the following way:
diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt
index bcf54da82..d2a7ff56e 100644
--- a/Documentation/diff-generate-patch.txt
+++ b/Documentation/diff-generate-patch.txt
@@ -2,11 +2,11 @@ Generating patches with -p
--------------------------
When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
-with a '-p' option, "git diff" without the '--raw' option, or
+with a `-p` option, "git diff" without the `--raw` option, or
"git log" with the "-p" option, they
do not produce the output described above; instead they produce a
patch file. You can customize the creation of such patches via the
-GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.
+`GIT_EXTERNAL_DIFF` and the `GIT_DIFF_OPTS` environment variables.
What the -p option produces is slightly different from the traditional
diff format:
@@ -114,11 +114,11 @@ index fabadb8,cc95eb0..4866510
------------
1. It is preceded with a "git diff" header, that looks like
- this (when '-c' option is used):
+ this (when `-c` option is used):
diff --combined file
+
-or like this (when '--cc' option is used):
+or like this (when `--cc` option is used):
diff --cc file
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index 036edfb09..9eab1f5fa 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -52,7 +52,7 @@ ifndef::git-pull[]
-p::
--prune::
- After fetching, remove any remote-tracking references that no
+ Before fetching, remove any remote-tracking references that no
longer exist on the remote. Tags are not subject to pruning
if they are fetched only because of the default tag
auto-following or due to a --tags option. However, if tags
@@ -88,7 +88,7 @@ ifndef::git-pull[]
to whatever else would otherwise be fetched. Using this
option alone does not subject tags to pruning, even if --prune
is used (though tags may be pruned anyway if they are also the
- destination of an explicit refspec; see '--prune').
+ destination of an explicit refspec; see `--prune`).
--recurse-submodules[=yes|on-demand|no]::
This option controls if and under what conditions new commits of
@@ -110,7 +110,7 @@ ifndef::git-pull[]
--no-recurse-submodules::
Disable recursive fetching of submodules (this has the same effect as
- using the '--recurse-submodules=no' option).
+ using the `--recurse-submodules=no` option).
--submodule-prefix=<path>::
Prepend <path> to paths printed in informative messages
@@ -137,7 +137,7 @@ endif::git-pull[]
--upload-pack <upload-pack>::
When given, and the repository to fetch from is handled
- by 'git fetch-pack', '--exec=<upload-pack>' is passed to
+ by 'git fetch-pack', `--exec=<upload-pack>` is passed to
the command to specify non-default path for the command
run on the other end.
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 13cdd7f3b..12879e402 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -116,7 +116,8 @@ default. You can use `--no-utf8` to override this.
By default the command will try to detect the patch format
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, stgit, stgit-series and hg.
+ interpreted as. Valid formats are mbox, mboxrd,
+ stgit, stgit-series and hg.
-i::
--interactive::
@@ -198,12 +199,12 @@ When initially invoking `git am`, you give it the names of the mailboxes
to process. Upon seeing the first patch that does not apply, it
aborts in the middle. You can recover from this in one of two ways:
-. skip the current patch by re-running the command with the '--skip'
+. skip the current patch by re-running the command with the `--skip`
option.
. hand resolve the conflict in the working directory, and update
the index file to bring it into a state that the patch should
- have produced. Then run the command with the '--continue' option.
+ have produced. Then run the command with the `--continue` option.
The command refuses to process new mailboxes until the current
operation is finished, so if you decide to start over from scratch,
diff --git a/Documentation/git-bisect-lk2009.txt b/Documentation/git-bisect-lk2009.txt
index c06efbd42..e015f5b3c 100644
--- a/Documentation/git-bisect-lk2009.txt
+++ b/Documentation/git-bisect-lk2009.txt
@@ -366,7 +366,7 @@ skip" to do the same thing. (In fact the special exit code 125 makes
Or if you want more control, you can inspect the current state using
for example "git bisect visualize". It will launch gitk (or "git log"
-if the DISPLAY environment variable is not set) to help you find a
+if the `DISPLAY` environment variable is not set) to help you find a
better bisection point.
Either way, if you have a string of untestable commits, it might
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 7e79aaede..2bb9a577a 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -205,7 +205,7 @@ $ git bisect visualize
`view` may also be used as a synonym for `visualize`.
-If the 'DISPLAY' environment variable is not set, 'git log' is used
+If the `DISPLAY` environment variable is not set, 'git log' is used
instead. You can also give command-line options such as `-p` and
`--stat`.
@@ -358,7 +358,7 @@ OPTIONS
--no-checkout::
+
Do not checkout the new working tree at each iteration of the bisection
-process. Instead just update a special reference named 'BISECT_HEAD' to make
+process. Instead just update a special reference named `BISECT_HEAD` to make
it point to the commit that should be tested.
+
This option may be useful when the test you would perform in each step
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 4a7037f1c..1fe73448f 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -39,10 +39,10 @@ named commit). With `--merged`, only branches merged into the named
commit (i.e. the branches whose tip commits are reachable from the named
commit) will be listed. With `--no-merged` only branches not merged into
the named commit will be listed. If the <commit> argument is missing it
-defaults to 'HEAD' (i.e. the tip of the current branch).
+defaults to `HEAD` (i.e. the tip of the current branch).
The command's second form creates a new branch head named <branchname>
-which points to the current 'HEAD', or <start-point> if given.
+which points to the current `HEAD`, or <start-point> if given.
Note that this will create the new branch, but it will not switch the
working tree to it; use "git checkout <newbranch>" to switch to the
@@ -172,7 +172,7 @@ This option is only applicable in non-verbose mode.
+
This behavior is the default when the start point is a remote-tracking branch.
Set the branch.autoSetupMerge configuration variable to `false` if you
-want `git checkout` and `git branch` to always behave as if '--no-track'
+want `git checkout` and `git branch` to always behave as if `--no-track`
were given. Set it to `always` if you want this behavior when the
start-point is either a local or remote-tracking branch.
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index eb3d6945a..18d03d8e8 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -15,8 +15,8 @@ SYNOPSIS
DESCRIPTION
-----------
In its first form, the command provides the content or the type of an object in
-the repository. The type is required unless '-t' or '-p' is used to find the
-object type, or '-s' is used to find the object size, or '--textconv' is used
+the repository. The type is required unless `-t` or `-p` is used to find the
+object type, or `-s` is used to find the object size, or `--textconv` is used
(which implies type "blob").
In the second form, a list of objects (separated by linefeeds) is provided on
@@ -144,13 +144,13 @@ respectively print:
OUTPUT
------
-If '-t' is specified, one of the <type>.
+If `-t` is specified, one of the <type>.
-If '-s' is specified, the size of the <object> in bytes.
+If `-s` is specified, the size of the <object> in bytes.
-If '-e' is specified, no output.
+If `-e` is specified, no output.
-If '-p' is specified, the contents of <object> are pretty-printed.
+If `-p` is specified, the contents of <object> are pretty-printed.
If <type> is specified, the raw (though uncompressed) contents of the <object>
will be returned.
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 5e5273e07..7a2201b05 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -157,7 +157,7 @@ of it").
When creating a new branch, set up "upstream" configuration. See
"--track" in linkgit:git-branch[1] for details.
+
-If no '-b' option is given, the name of the new branch will be
+If no `-b` option is given, the name of the new branch will be
derived from the remote-tracking branch, by looking at the local part of
the refspec configured for the corresponding remote, and then stripping
the initial part up to the "*".
@@ -165,7 +165,7 @@ This would tell us to use "hack" as the local branch when branching
off of "origin/hack" (or "remotes/origin/hack", or even
"refs/remotes/origin/hack"). If the given name has no slash, or the above
guessing results in an empty name, the guessing is aborted. You can
-explicitly give a name with '-b' in such a case.
+explicitly give a name with `-b` in such a case.
--no-track::
Do not set up "upstream" configuration, even if the
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index c104a594a..d35d771fc 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -47,7 +47,7 @@ OPTIONS
For a more complete list of ways to spell commits, see
linkgit:gitrevisions[7].
Sets of commits can be passed but no traversal is done by
- default, as if the '--no-walk' option was specified, see
+ default, as if the `--no-walk` option was specified, see
linkgit:git-rev-list[1]. Note that specifying a range will
feed all <commit>... arguments to a single revision walk
(see a later example that uses 'maint master..next').
diff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt
index 51a7e26a8..03056dad0 100644
--- a/Documentation/git-clean.txt
+++ b/Documentation/git-clean.txt
@@ -16,7 +16,7 @@ DESCRIPTION
Cleans the working tree by recursively removing files that are not
under version control, starting from the current directory.
-Normally, only files unknown to Git are removed, but if the '-x'
+Normally, only files unknown to Git are removed, but if the `-x`
option is specified, ignored files are also removed. This can, for
example, be useful to remove all build products.
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 1b15cd7b1..ec41d3d69 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -191,9 +191,8 @@ objects from the source repository into a pack in the cloned repository.
Create a 'shallow' clone with a history truncated to the
specified number of commits. Implies `--single-branch` unless
`--no-single-branch` is given to fetch the histories near the
- tips of all branches. This implies `--shallow-submodules`. If
- you want to have a shallow superproject clone, but full submodules,
- also pass `--no-shallow-submodules`.
+ tips of all branches. If you want to clone submodules shallowly,
+ also pass `--shallow-submodules`.
--[no-]single-branch::
Clone only the history leading to the tip of a single branch,
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index cb69faab6..002dae625 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -44,7 +44,7 @@ OPTIONS
An existing tree object
-p <parent>::
- Each '-p' indicates the id of a parent commit object.
+ Each `-p` indicates the id of a parent commit object.
-m <message>::
A paragraph in the commit log message. This can be given more than
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index d474226eb..b0a294d3b 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -75,7 +75,7 @@ OPTIONS
-c <commit>::
--reedit-message=<commit>::
- Like '-C', but with '-c' the editor is invoked, so that
+ Like '-C', but with `-c` the editor is invoked, so that
the user can further edit the commit message.
--fixup=<commit>::
@@ -201,7 +201,7 @@ default::
Otherwise `whitespace`.
--
+
-The default can be changed by the 'commit.cleanup' configuration
+The default can be changed by the `commit.cleanup` configuration
variable (see linkgit:git-config[1]).
-e::
@@ -260,7 +260,7 @@ FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
staged for other paths. This is the default mode of operation of
'git commit' if any paths are given on the command line,
in which case this option can be omitted.
- If this option is specified together with '--amend', then
+ If this option is specified together with `--amend`, then
no paths need to be specified, which can be used to amend
the last commit without committing changes that have
already been staged.
@@ -450,8 +450,8 @@ include::i18n.txt[]
ENVIRONMENT AND CONFIGURATION VARIABLES
---------------------------------------
The editor used to edit the commit log message will be chosen from the
-GIT_EDITOR environment variable, the core.editor configuration variable, the
-VISUAL environment variable, or the EDITOR environment variable (in that
+`GIT_EDITOR` environment variable, the core.editor configuration variable, the
+`VISUAL` environment variable, or the `EDITOR` environment variable (in that
order). See linkgit:git-var[1] for details.
HOOKS
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 6843114fc..f163113a6 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -31,29 +31,29 @@ You can query/set/replace/unset options with this command. The name is
actually the section and the key separated by a dot, and the value will be
escaped.
-Multiple lines can be added to an option by using the '--add' option.
+Multiple lines can be added to an option by using the `--add` option.
If you want to update or unset an option which can occur on multiple
lines, a POSIX regexp `value_regex` needs to be given. Only the
existing values that match the regexp are updated or unset. If
you want to handle the lines that do *not* match the regex, just
prepend a single exclamation mark in front (see also <<EXAMPLES>>).
-The type specifier can be either '--int' or '--bool', to make
+The type specifier can be either `--int` or `--bool`, to make
'git config' ensure that the variable(s) are of the given type and
convert the value to the canonical form (simple decimal number for int,
-a "true" or "false" string for bool), or '--path', which does some
-path expansion (see '--path' below). If no type specifier is passed, no
+a "true" or "false" string for bool), or `--path`, which does some
+path expansion (see `--path` below). If no type specifier is passed, no
checks or transformations are performed on the value.
When reading, the values are read from the system, global and
repository local configuration files by default, and options
-'--system', '--global', '--local' and '--file <filename>' can be
+`--system`, `--global`, `--local` and `--file <filename>` can be
used to tell the command to read from only that location (see <<FILES>>).
When writing, the new value is written to the repository local
-configuration file by default, and options '--system', '--global',
-'--file <filename>' can be used to tell the command to write to
-that location (you can say '--local' but that is the default).
+configuration file by default, and options `--system`, `--global`,
+`--file <filename>` can be used to tell the command to write to
+that location (you can say `--local` but that is the default).
This command will fail with non-zero status upon error. Some exit
codes are:
@@ -138,7 +138,7 @@ See also <<FILES>>.
Use the given config file instead of the one specified by GIT_CONFIG.
--blob blob::
- Similar to '--file' but use the given blob instead of a file. E.g.
+ Similar to `--file` but use the given blob instead of a file. E.g.
you can use 'master:.gitmodules' to read values from the file
'.gitmodules' in the master branch. See "SPECIFYING REVISIONS"
section in linkgit:gitrevisions[7] for a more complete list of
@@ -220,7 +220,7 @@ See also <<FILES>>.
-e::
--edit::
Opens an editor to modify the specified config file; either
- '--system', '--global', or repository (default).
+ `--system`, `--global`, or repository (default).
--[no-]includes::
Respect `include.*` directives in config files when looking up
@@ -232,7 +232,7 @@ See also <<FILES>>.
FILES
-----
-If not set explicitly with '--file', there are four files where
+If not set explicitly with `--file`, there are four files where
'git config' will search for configuration options:
$(prefix)/etc/gitconfig::
@@ -264,12 +264,12 @@ precedence over values read earlier. When multiple values are taken then all
values of a key from all files will be used.
All writing options will per default write to the repository specific
-configuration file. Note that this also affects options like '--replace-all'
-and '--unset'. *'git config' will only ever change one file at a time*.
+configuration file. Note that this also affects options like `--replace-all`
+and `--unset`. *'git config' will only ever change one file at a time*.
You can override these rules either by command-line options or by environment
-variables. The '--global' and the '--system' options will limit the file used
-to the global or system-wide file respectively. The GIT_CONFIG environment
+variables. The `--global` and the `--system` options will limit the file used
+to the global or system-wide file respectively. The `GIT_CONFIG` environment
variable has a similar effect, but you can specify any filename you want.
diff --git a/Documentation/git-credential-store.txt b/Documentation/git-credential-store.txt
index e3c8f276b..25fb963f4 100644
--- a/Documentation/git-credential-store.txt
+++ b/Documentation/git-credential-store.txt
@@ -44,7 +44,7 @@ OPTIONS
FILES
-----
-If not set explicitly with '--file', there are two files where
+If not set explicitly with `--file`, there are two files where
git-credential-store will search for credentials in order of precedence:
~/.git-credentials::
diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt
index 00a0679a2..41207a24b 100644
--- a/Documentation/git-cvsimport.txt
+++ b/Documentation/git-cvsimport.txt
@@ -74,10 +74,10 @@ OPTIONS
akin to the way 'git clone' uses 'origin' by default.
-o <branch-for-HEAD>::
- When no remote is specified (via -r) the 'HEAD' branch
+ When no remote is specified (via -r) the `HEAD` branch
from CVS is imported to the 'origin' branch within the Git
- repository, as 'HEAD' already has a special meaning for Git.
- When a remote is specified the 'HEAD' branch is named
+ repository, as `HEAD` already has a special meaning for Git.
+ When a remote is specified the `HEAD` branch is named
remotes/<remote>/master mirroring 'git clone' behaviour.
Use this option if you want to import into a different
branch.
@@ -103,7 +103,7 @@ the old cvs2git tool.
-p <options-for-cvsps>::
Additional options for cvsps.
- The options '-u' and '-A' are implicit and should not be used here.
+ The options `-u` and '-A' are implicit and should not be used here.
+
If you need to pass multiple options, separate them with a comma.
@@ -122,7 +122,7 @@ If you need to pass multiple options, separate them with a comma.
-M <regex>::
Attempt to detect merges based on the commit message with a custom
- regex. It can be used with '-m' to enable the default regexes
+ regex. It can be used with `-m` to enable the default regexes
as well. You must escape forward slashes.
+
The regex must capture the source branch name in $1.
@@ -186,7 +186,7 @@ messages, bug-tracking systems, email archives, and the like.
OUTPUT
------
-If '-v' is specified, the script reports what it is doing.
+If `-v` is specified, the script reports what it is doing.
Otherwise, success is indicated the Unix way, i.e. by simply exiting with
a zero exit status.
diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index db4d7a917..a336ae5f6 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -54,7 +54,7 @@ Print usage information and exit
You can specify a list of allowed directories. If no directories
are given, all are allowed. This is an additional restriction, gitcvs
access still needs to be enabled by the `gitcvs.enabled` config option
-unless '--export-all' was given, too.
+unless `--export-all` was given, too.
DESCRIPTION
@@ -332,7 +332,7 @@ To get a checkout with the Eclipse CVS client:
3. Browse the 'modules' available. It will give you a list of the heads in
the repository. You will not be able to browse the tree from there. Only
the heads.
-4. Pick 'HEAD' when it asks what branch/tag to check out. Untick the
+4. Pick `HEAD` when it asks what branch/tag to check out. Untick the
"launch commit wizard" to avoid committing the .project file.
Protocol notes: If you are using anonymous access via pserver, just select that.
@@ -402,12 +402,12 @@ Exports and tagging (tags and branches) are not supported at this stage.
CRLF Line Ending Conversions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-By default the server leaves the '-k' mode blank for all files,
+By default the server leaves the `-k` mode blank for all files,
which causes the CVS client to treat them as a text files, subject
to end-of-line conversion on some platforms.
You can make the server use the end-of-line conversion attributes to
-set the '-k' modes for files by setting the `gitcvs.usecrlfattr`
+set the `-k` modes for files by setting the `gitcvs.usecrlfattr`
config variable. See linkgit:gitattributes[5] for more information
about end-of-line conversion.
@@ -415,9 +415,9 @@ Alternatively, if `gitcvs.usecrlfattr` config is not enabled
or the attributes do not allow automatic detection for a filename, then
the server uses the `gitcvs.allBinary` config for the default setting.
If `gitcvs.allBinary` is set, then file not otherwise
-specified will default to '-kb' mode. Otherwise the '-k' mode
+specified will default to '-kb' mode. Otherwise the `-k` mode
is left blank. But if `gitcvs.allBinary` is set to "guess", then
-the correct '-k' mode will be guessed based on the contents of
+the correct `-k` mode will be guessed based on the contents of
the file.
For best consistency with 'cvs', it is probably best to override the
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
index a69b3616e..3c91db7be 100644
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -30,7 +30,7 @@ that service if it is enabled.
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 '--export-all' parameter is specified). If you
+for export this way (unless the `--export-all` parameter is specified). If you
pass some directory paths as 'git daemon' arguments, you can further restrict
the offers to a whitelist comprising of those.
@@ -90,10 +90,10 @@ OPTIONS
is not supported, then --listen=hostname is also not supported and
--listen must be given an IPv4 address.
Can be given more than once.
- Incompatible with '--inetd' option.
+ Incompatible with `--inetd` option.
--port=<n>::
- Listen on an alternative port. Incompatible with '--inetd' option.
+ Listen on an alternative port. Incompatible with `--inetd` option.
--init-timeout=<n>::
Timeout (in seconds) between the moment the connection is established
@@ -188,7 +188,7 @@ Git configuration files in that directory are readable by `<user>`.
arguments. The external command can decide to decline the
service by exiting with a non-zero status (or to allow it by
exiting with a zero status). It can also look at the $REMOTE_ADDR
- and $REMOTE_PORT environment variables to learn about the
+ and `$REMOTE_PORT` environment variables to learn about the
requestor when making this decision.
+
The external command can optionally write a single line to its
@@ -296,7 +296,7 @@ they correspond to these IP addresses.
selectively enable/disable services per repository::
To enable 'git archive --remote' and disable 'git fetch' against
a repository, have the following in the configuration file in the
- repository (that is the file 'config' next to 'HEAD', 'refs' and
+ repository (that is the file 'config' next to `HEAD`, 'refs' and
'objects').
+
----------------------------------------------------------------
diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index c8f28c8c8..e4ac448ff 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -154,7 +154,7 @@ is found, its name will be output and searching will stop.
If an exact match was not found, 'git describe' will walk back
through the commit history to locate an ancestor commit which
has been tagged. The ancestor's tag will be output along with an
-abbreviation of the input commit-ish's SHA-1. If '--first-parent' was
+abbreviation of the input commit-ish's SHA-1. If `--first-parent` was
specified then the walk will only consider the first parent of each
commit.
diff --git a/Documentation/git-diff-index.txt b/Documentation/git-diff-index.txt
index a86cf62e6..a17150695 100644
--- a/Documentation/git-diff-index.txt
+++ b/Documentation/git-diff-index.txt
@@ -40,13 +40,13 @@ include::diff-format.txt[]
Operating Modes
---------------
You can choose whether you want to trust the index file entirely
-(using the '--cached' flag) or ask the diff logic to show any files
+(using the `--cached` flag) or ask the diff logic to show any files
that don't match the stat state as being "tentatively changed". Both
of these operations are very useful indeed.
Cached Mode
-----------
-If '--cached' is specified, it allows you to ask:
+If `--cached` is specified, it allows you to ask:
show me the differences between HEAD and the current index
contents (the ones I'd write using 'git write-tree')
diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
index 1439486e4..7870e175b 100644
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -43,11 +43,11 @@ include::diff-options.txt[]
show tree entry itself as well as subtrees. Implies -r.
--root::
- When '--root' is specified the initial commit will be shown as a big
+ When `--root` is specified the initial commit will be shown as a big
creation event. This is equivalent to a diff against the NULL tree.
--stdin::
- When '--stdin' is specified, the command does not take
+ When `--stdin` is specified, the command does not take
<tree-ish> arguments from the command line. Instead, it
reads lines containing either two <tree>, one <commit>, or a
list of <commit> from its standard input. (Use a single space
@@ -70,13 +70,13 @@ commits (but not trees).
By default, 'git diff-tree --stdin' does not show
differences for merge commits. With this flag, it shows
differences to that commit from all of its parents. See
- also '-c'.
+ also `-c`.
-s::
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.
+ 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.
-v::
This flag causes 'git diff-tree --stdin' to also show
@@ -91,17 +91,17 @@ include::pretty-options.txt[]
-c::
This flag changes the way a merge commit is displayed
(which means it is useful only when the command is given
- one <tree-ish>, or '--stdin'). It shows the differences
+ one <tree-ish>, or `--stdin`). It 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 (which is what the '-m' option does).
+ result one at a time (which is what the `-m` option does).
Furthermore, it lists only files which were modified
from all parents.
--cc::
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
+ 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
have only two variants and the merge result picks one of them
without modification. When all hunks are uninteresting, the commit
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 333cf6ff9..224fb3090 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -98,7 +98,7 @@ instead. `--no-symlinks` is the default on Windows.
invoked diff tool returns a non-zero exit code.
+
'git-difftool' will forward the exit code of the invoked tool when
-'--trust-exit-code' is used.
+`--trust-exit-code` is used.
See linkgit:git-diff[1] for the full list of supported options.
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 644df993f..2b762654b 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -1056,7 +1056,7 @@ relative-marks::
no-relative-marks::
force::
Act as though the corresponding command-line option with
- a leading '--' was passed on the command line
+ a leading `--` was passed on the command line
(see OPTIONS, above).
import-marks::
@@ -1107,7 +1107,7 @@ options the user may specify to git fast-import itself.
The `<option>` part of the command may contain any of the options
listed in the OPTIONS section that do not change import semantics,
-without the leading '--' and is treated in the same way.
+without the leading `--` and is treated in the same way.
Option commands must be the first commands on the input (not counting
feature commands), to give an option command after any non-option
diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt
index 239623cc2..24417ee3a 100644
--- a/Documentation/git-fetch-pack.txt
+++ b/Documentation/git-fetch-pack.txt
@@ -41,13 +41,13 @@ OPTIONS
option, then the refs from stdin are processed after those
on the command line.
+
-If '--stateless-rpc' is specified together with this option then
+If `--stateless-rpc` is specified together with this option then
the list of refs must be in packet format (pkt-line). Each ref must
be in a separate packet, and the list must end with a flush packet.
-q::
--quiet::
- Pass '-q' flag to 'git unpack-objects'; this makes the
+ Pass `-q` flag to 'git unpack-objects'; this makes the
cloning process less verbose.
-k::
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 003731f6a..0a09698c0 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -52,7 +52,7 @@ if different from the rewritten ones, will be stored in the namespace
Note that since this operation is very I/O expensive, it might
be a good idea to redirect the temporary directory off-disk with the
-'-d' option, e.g. on tmpfs. Reportedly the speedup is very noticeable.
+`-d` option, e.g. on tmpfs. Reportedly the speedup is very noticeable.
Filters
@@ -61,7 +61,7 @@ Filters
The filters are applied in the order as listed below. The <command>
argument is always evaluated in the shell context using the 'eval' command
(with the notable exception of the commit filter, for technical reasons).
-Prior to that, the $GIT_COMMIT environment variable will be set to contain
+Prior to that, the `$GIT_COMMIT` environment variable will be set to contain
the id of the commit being rewritten. Also, GIT_AUTHOR_NAME,
GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
and GIT_COMMITTER_DATE are taken from the current commit and exported to
@@ -171,7 +171,7 @@ to other tags will be rewritten to point to the underlying commit.
untouched. This switch allow git-filter-branch to ignore such
commits. Though, this switch only applies for commits that have one
and only one parent, it will hence keep merges points. Also, this
- option is not compatible with the use of '--commit-filter'. Though you
+ option is not compatible with the use of `--commit-filter`. Though you
just need to use the function 'git_commit_non_empty_tree "$@"' instead
of the `git commit-tree "$@"` idiom in your commit filter to make that
happen.
@@ -197,7 +197,7 @@ to other tags will be rewritten to point to the underlying commit.
<rev-list options>...::
Arguments for 'git rev-list'. All positive refs included by
these options are rewritten. You may also specify options
- such as '--all', but you must use '--' to separate them from
+ such as `--all`, but you must use `--` to separate them from
the 'git filter-branch' options. Implies <<Remap_to_ancestor>>.
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
index d9d406dcf..f57e69bc8 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -142,7 +142,7 @@ align::
<width> and <position> used instead. For instance,
`%(align:<width>,<position>)`. If the contents length is more
than the width then no alignment is performed. If used with
- '--quote' everything in between %(align:...) and %(end) is
+ `--quote` everything in between %(align:...) and %(end) is
quoted, but if nested then only the topmost level performs
quoting.
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index bdeecd59e..9624c84a6 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -58,7 +58,7 @@ output, unless the `--stdout` option is specified.
If `-o` is specified, output files are created in <dir>. Otherwise
they are created in the current working directory. The default path
-can be set with the 'format.outputDirectory' configuration option.
+can be set with the `format.outputDirectory` configuration option.
The `-o` option takes precedence over `format.outputDirectory`.
To store patches in the current working directory even when
`format.outputDirectory` points elsewhere, use `-o .`.
@@ -146,9 +146,9 @@ series, where the head is chosen from the cover letter, the
`--in-reply-to`, and the first patch mail, in this order. 'deep'
threading makes every mail a reply to the previous one.
+
-The default is `--no-thread`, unless the 'format.thread' configuration
+The default is `--no-thread`, unless the `format.thread` configuration
is set. If `--thread` is specified without a style, it defaults to the
-style specified by 'format.thread' if any, or else `shallow`.
+style specified by `format.thread` if any, or else `shallow`.
+
Beware that the default for 'git send-email' is to thread emails
itself. If you want `git format-patch` to take care of threading, you
diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt
index 84ee92e15..7fc68eb31 100644
--- a/Documentation/git-fsck.txt
+++ b/Documentation/git-fsck.txt
@@ -95,7 +95,7 @@ DISCUSSION
git-fsck tests SHA-1 and general object sanity, and it does full tracking
of the resulting reachability and everything else. It prints out any
corruption it finds (missing or bad objects), and if you use the
-'--unreachable' flag it will also print out objects that exist but that
+`--unreachable` flag it will also print out objects that exist but that
aren't reachable from any of the specified head nodes (or the default
set, as mentioned above).
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index fa1510480..bed60f471 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -82,13 +82,13 @@ automatic consolidation of packs.
Configuration
-------------
-The optional configuration variable 'gc.reflogExpire' can be
+The optional configuration variable `gc.reflogExpire` can be
set to indicate how long historical entries within each branch's
reflog should remain available in this repository. The setting is
expressed as a length of time, for example '90 days' or '3 months'.
It defaults to '90 days'.
-The optional configuration variable 'gc.reflogExpireUnreachable'
+The optional configuration variable `gc.reflogExpireUnreachable`
can be set to indicate how long historical reflog entries which
are not part of the current branch should remain available in
this repository. These types of entries are generally created as
@@ -107,30 +107,30 @@ branches:
reflogExpireUnreachable = 3 days
------------
-The optional configuration variable 'gc.rerereResolved' indicates
+The optional configuration variable `gc.rerereResolved` indicates
how long records of conflicted merge you resolved earlier are
kept. This defaults to 60 days.
-The optional configuration variable 'gc.rerereUnresolved' indicates
+The optional configuration variable `gc.rerereUnresolved` indicates
how long records of conflicted merge you have not resolved are
kept. This defaults to 15 days.
-The optional configuration variable 'gc.packRefs' determines if
+The optional configuration variable `gc.packRefs` determines if
'git gc' runs 'git pack-refs'. This can be set to "notbare" to enable
it within all non-bare repos or it can be set to a boolean value.
This defaults to true.
-The optional configuration variable 'gc.aggressiveWindow' controls how
+The optional configuration variable `gc.aggressiveWindow` controls how
much time is spent optimizing the delta compression of the objects in
the repository when the --aggressive option is specified. The larger
the value, the more time is spent optimizing the delta compression. See
the documentation for the --window' option in linkgit:git-repack[1] for
more details. This defaults to 250.
-Similarly, the optional configuration variable 'gc.aggressiveDepth'
+Similarly, the optional configuration variable `gc.aggressiveDepth`
controls --depth option in linkgit:git-repack[1]. This defaults to 250.
-The optional configuration variable 'gc.pruneExpire' controls how old
+The optional configuration variable `gc.pruneExpire` controls how old
the unreferenced loose objects have to be before they are pruned. The
default is "2 weeks ago".
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index cb0f6cf67..0ecea6e49 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -41,17 +41,17 @@ CONFIGURATION
-------------
grep.lineNumber::
- If set to true, enable '-n' option by default.
+ If set to true, enable `-n` option by default.
grep.patternType::
Set the default matching behavior. Using a value of 'basic', 'extended',
- 'fixed', or 'perl' will enable the '--basic-regexp', '--extended-regexp',
- '--fixed-strings', or '--perl-regexp' option accordingly, while the
+ 'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,
+ `--fixed-strings`, or `--perl-regexp` option accordingly, while the
value 'default' will return to the default matching behavior.
grep.extendedRegexp::
- If set to true, enable '--extended-regexp' option by default. This
- option is ignored when the 'grep.patternType' option is set to a value
+ If set to true, enable `--extended-regexp` option by default. This
+ option is ignored when the `grep.patternType` option is set to a value
other than 'default'.
grep.threads::
@@ -59,7 +59,7 @@ grep.threads::
8 threads are used by default (for now).
grep.fullName::
- If set to true, enable '--full-name' option by default.
+ If set to true, enable `--full-name` option by default.
grep.fallbackToNoIndex::
If set to true, fall back to git grep --no-index if git grep
diff --git a/Documentation/git-gui.txt b/Documentation/git-gui.txt
index 8144527ae..c1a3e8bf0 100644
--- a/Documentation/git-gui.txt
+++ b/Documentation/git-gui.txt
@@ -35,7 +35,7 @@ blame::
browser::
Start a tree browser showing all files in the specified
- commit (or 'HEAD' by default). Files selected through the
+ commit (or `HEAD` by default). Files selected through the
browser are opened in the blame viewer.
citool::
diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index 395652521..40d328a4b 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -18,10 +18,10 @@ With no options and no COMMAND or GUIDE given, the synopsis of the 'git'
command and a list of the most commonly used Git commands are printed
on the standard output.
-If the option '--all' or '-a' is given, all available commands are
+If the option `--all` or `-a` is given, all available commands are
printed on the standard output.
-If the option '--guide' or '-g' is given, a list of the useful
+If the option `--guide` or `-g` is given, a list of the useful
Git guides is also printed on the standard output.
If a command, or a guide, is given, a manual page for that command or
@@ -57,10 +57,10 @@ OPTIONS
--man::
Display manual page for the command in the 'man' format. This
option may be used to override a value set in the
- 'help.format' configuration variable.
+ `help.format` configuration variable.
+
By default the 'man' program will be used to display the manual page,
-but the 'man.viewer' configuration variable may be used to choose
+but the `man.viewer` configuration variable may be used to choose
other display programs (see below).
-w::
@@ -69,7 +69,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 none 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.
@@ -80,7 +80,7 @@ CONFIGURATION VARIABLES
help.format
~~~~~~~~~~~
-If no command-line option is passed, the 'help.format' configuration
+If no command-line option is passed, the `help.format` configuration
variable will be checked. The following values are supported for this
variable; they make 'git help' behave as their corresponding command-
line option:
@@ -92,7 +92,7 @@ line option:
help.browser, web.browser and browser.<tool>.path
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The 'help.browser', 'web.browser' and 'browser.<tool>.path' will also
+The `help.browser`, `web.browser` and `browser.<tool>.path` will also
be checked if the 'web' format is chosen (either by command-line
option or configuration variable). See '-w|--web' in the OPTIONS
section above and linkgit:git-web{litdd}browse[1].
@@ -100,7 +100,7 @@ section above and linkgit:git-web{litdd}browse[1].
man.viewer
~~~~~~~~~~
-The 'man.viewer' configuration variable will be checked if the 'man'
+The `man.viewer` configuration variable will be checked if the 'man'
format is chosen. The following values are currently supported:
* "man": use the 'man' program as usual,
@@ -110,9 +110,9 @@ format is chosen. The following values are currently supported:
tab (see 'Note about konqueror' below).
Values for other tools can be used if there is a corresponding
-'man.<tool>.cmd' configuration entry (see below).
+`man.<tool>.cmd` configuration entry (see below).
-Multiple values may be given to the 'man.viewer' configuration
+Multiple values may be given to the `man.viewer` configuration
variable. Their corresponding programs will be tried in the order
listed in the configuration file.
@@ -128,14 +128,14 @@ will try to use konqueror first. But this may fail (for example, if
DISPLAY is not set) and in that case emacs' woman mode will be tried.
If everything fails, or if no viewer is configured, the viewer specified
-in the GIT_MAN_VIEWER environment variable will be tried. If that
+in the `GIT_MAN_VIEWER` environment variable will be tried. If that
fails too, the 'man' program will be tried anyway.
man.<tool>.path
~~~~~~~~~~~~~~~
You can explicitly provide a full path to your preferred man viewer by
-setting the configuration variable 'man.<tool>.path'. For example, you
+setting the configuration variable `man.<tool>.path`. For example, you
can configure the absolute path to konqueror by setting
'man.konqueror.path'. Otherwise, 'git help' assumes the tool is
available in PATH.
@@ -143,9 +143,9 @@ available in PATH.
man.<tool>.cmd
~~~~~~~~~~~~~~
-When the man viewer, specified by the 'man.viewer' configuration
+When the man viewer, specified by the `man.viewer` configuration
variables, is not among the supported ones, then the corresponding
-'man.<tool>.cmd' configuration variable will be looked up. If this
+`man.<tool>.cmd` configuration variable will be looked up. If this
variable exists then the specified tool will be treated as a custom
command and a shell eval will be used to run the command with the man
page passed as arguments.
@@ -153,7 +153,7 @@ page passed as arguments.
Note about konqueror
~~~~~~~~~~~~~~~~~~~~
-When 'konqueror' is specified in the 'man.viewer' configuration
+When 'konqueror' is specified in the `man.viewer` configuration
variable, we launch 'kfmclient' to try to open the man page on an
already opened konqueror in a new tab if possible.
@@ -176,7 +176,7 @@ Note about git config --global
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that all these configuration variables should probably be set
-using the '--global' flag, for example like this:
+using the `--global` flag, for example like this:
------------------------------------------------
$ git config --global help.format web
diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt
index 9268fb6b1..bb0db195c 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -21,7 +21,7 @@ pushing using the smart HTTP protocol.
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` environmental 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
@@ -241,7 +241,7 @@ $HTTP["url"] =~ "^/git/private" {
ENVIRONMENT
-----------
-'git http-backend' relies upon the CGI environment variables set
+'git http-backend' relies upon the `CGI` environment variables set
by the invoking web server, including:
* PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
@@ -251,7 +251,7 @@ 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` environmental 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.
@@ -269,7 +269,7 @@ GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
ensuring that any reflogs created by 'git-receive-pack' contain some
identifying information of the remote user who performed the push.
-All CGI environment variables are available to each of the hooks
+All `CGI` environment variables are available to each of the hooks
invoked by the 'git-receive-pack'.
GIT
diff --git a/Documentation/git-http-push.txt b/Documentation/git-http-push.txt
index 2e67362bd..2aceb6f26 100644
--- a/Documentation/git-http-push.txt
+++ b/Documentation/git-http-push.txt
@@ -81,13 +81,13 @@ destination side.
exist in the set of remote refs; the ref matched <src>
locally is used as the name of the destination.
-Without '--force', the <src> ref is stored at the remote only if
+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.
-With '--force', the fast-forward check is disabled for all refs.
+With `--force`, the fast-forward check is disabled for all refs.
Optionally, a <ref> parameter can be prefixed with a plus '+' sign
to disable the fast-forward check only on that ref.
diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt
index 6364e5dc4..9d27197de 100644
--- a/Documentation/git-init.txt
+++ b/Documentation/git-init.txt
@@ -47,7 +47,7 @@ Only print error and warning messages; all other output will be suppressed.
--bare::
-Create a bare repository. If GIT_DIR environment is not set, it is set to the
+Create a bare repository. If `GIT_DIR` environment is not set, it is set to the
current working directory.
--template=<template_directory>::
diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt
index cc75b2502..e8ecdbf92 100644
--- a/Documentation/git-instaweb.txt
+++ b/Documentation/git-instaweb.txt
@@ -80,8 +80,8 @@ You may specify configuration in your .git/config
-----------------------------------------------------------------------
-If the configuration variable 'instaweb.browser' is not set,
-'web.browser' will be used instead if it is defined. See
+If the configuration variable `instaweb.browser` is not set,
+`web.browser` will be used instead if it is defined. See
linkgit:git-web{litdd}browse[1] for more information about this.
SEE ALSO
diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt
index a77b901f1..93d1db652 100644
--- a/Documentation/git-interpret-trailers.txt
+++ b/Documentation/git-interpret-trailers.txt
@@ -219,7 +219,7 @@ Signed-off-by: Alice <alice@example.com>
Signed-off-by: Bob <bob@example.com>
------------
-* Use the '--in-place' option to edit a message file in place:
+* Use the `--in-place` option to edit a message file in place:
+
------------
$ cat msg.txt
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index dec379b3e..32246fdb0 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -198,12 +198,16 @@ log.showRoot::
`git log -p` output would be shown without a diff attached.
The default is `true`.
+log.showSignature::
+ If `true`, `git log` and related commands will act as if the
+ `--show-signature` option was passed to them.
+
mailmap.*::
See linkgit:git-shortlog[1].
notes.displayRef::
Which refs, in addition to the default set by `core.notesRef`
- or 'GIT_NOTES_REF', to read notes from when showing commit
+ or `GIT_NOTES_REF`, to read notes from when showing commit
messages with the `log` family of commands. See
linkgit:git-notes[1].
+
@@ -212,7 +216,7 @@ multiple times. A warning will be issued for refs that do not exist,
but a glob that does not match any refs is silently ignored.
+
This setting can be disabled by the `--no-notes` option,
-overridden by the 'GIT_NOTES_DISPLAY_REF' environment variable,
+overridden by the `GIT_NOTES_DISPLAY_REF` environment variable,
and overridden by the `--notes=<ref>` option.
GIT
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 75c3f4157..078b55666 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -175,7 +175,7 @@ followed by the ("attr/<eolattr>").
Output
------
-'git ls-files' just outputs the filenames unless '--stage' is specified in
+'git ls-files' just outputs the filenames unless `--stage` is specified in
which case it outputs:
[<tag> ]<mode> <object> <stage> <file>
diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index 16e87fd6d..dbc91f98f 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -20,16 +20,16 @@ in the current working directory. Note that:
- the behaviour is slightly different from that of "/bin/ls" in that the
'<path>' denotes just a list of patterns to match, e.g. so specifying
- directory name (without '-r') will behave differently, and order of the
+ directory name (without `-r`) will behave differently, and order of the
arguments does not matter.
- the behaviour is similar to that of "/bin/ls" in that the '<path>' is
taken as relative to the current working directory. E.g. when you are
in a directory 'sub' that has a directory 'dir', you can run 'git
ls-tree -r HEAD dir' to list the contents of the tree (that is
- 'sub/dir' in 'HEAD'). You don't want to give a tree that is not at the
+ 'sub/dir' in `HEAD`). You don't want to give a tree that is not at the
root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that
- would result in asking for 'sub/sub/dir' in the 'HEAD' commit.
+ would result in asking for 'sub/sub/dir' in the `HEAD` commit.
However, the current working directory can be ignored by passing
--full-tree option.
@@ -46,7 +46,7 @@ OPTIONS
-t::
Show tree entries even when going to recurse them. Has no effect
- if '-r' was not passed. '-d' implies '-t'.
+ if `-r` was not passed. `-d` implies `-t`.
-l::
--long::
diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt
index 4d1b871d9..e3b2a88c4 100644
--- a/Documentation/git-mailsplit.txt
+++ b/Documentation/git-mailsplit.txt
@@ -8,7 +8,8 @@ git-mailsplit - Simple UNIX mbox splitter program
SYNOPSIS
--------
[verse]
-'git mailsplit' [-b] [-f<nn>] [-d<prec>] [--keep-cr] -o<directory> [--] [(<mbox>|<Maildir>)...]
+'git mailsplit' [-b] [-f<nn>] [-d<prec>] [--keep-cr] [--mboxrd]
+ -o<directory> [--] [(<mbox>|<Maildir>)...]
DESCRIPTION
-----------
@@ -47,6 +48,10 @@ OPTIONS
--keep-cr::
Do not remove `\r` from lines ending with `\r\n`.
+--mboxrd::
+ Input is of the "mboxrd" format and "^>+From " line escaping is
+ reversed.
+
GIT
---
Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mktree.txt b/Documentation/git-mktree.txt
index 5c6ebdfad..c3616e771 100644
--- a/Documentation/git-mktree.txt
+++ b/Documentation/git-mktree.txt
@@ -32,7 +32,7 @@ OPTIONS
--batch::
Allow building of more than one tree object before exiting. Each
tree is separated by as single blank line. The final new-line is
- optional. Note - if the '-z' option is used, lines are terminated
+ optional. Note - if the `-z` option is used, lines are terminated
with NUL.
GIT
diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt
index e4531325c..79449bf98 100644
--- a/Documentation/git-mv.txt
+++ b/Documentation/git-mv.txt
@@ -32,10 +32,10 @@ OPTIONS
--force::
Force renaming or moving of a file even if the target exists
-k::
- Skip move or rename actions which would lead to an error
+ Skip move or rename actions which would lead to an error
condition. An error happens when a source is neither existing nor
controlled by Git, or when it would overwrite an existing
- file unless '-f' is given.
+ file unless `-f` is given.
-n::
--dry-run::
Do nothing; only show what would happen
diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt
index 9c4fd6812..be7db3048 100644
--- a/Documentation/git-notes.txt
+++ b/Documentation/git-notes.txt
@@ -152,7 +152,7 @@ OPTIONS
-c <object>::
--reedit-message=<object>::
- Like '-C', but with '-c' the editor is invoked, so that
+ Like '-C', but with `-c` the editor is invoked, so that
the user can further edit the note message.
--allow-empty::
@@ -161,7 +161,7 @@ OPTIONS
--ref <ref>::
Manipulate the notes tree in <ref>. This overrides
- 'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref
+ `GIT_NOTES_REF` and the "core.notesRef" configuration. The ref
specifies 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.
@@ -333,10 +333,10 @@ notes.<name>.mergeStrategy::
notes.displayRef::
Which ref (or refs, if a glob or specified more than once), in
addition to the default set by `core.notesRef` or
- 'GIT_NOTES_REF', to read notes from when showing commit
+ `GIT_NOTES_REF`, to read notes from when showing commit
messages with the 'git log' family of commands.
This setting can be overridden on the command line or by the
- 'GIT_NOTES_DISPLAY_REF' environment variable.
+ `GIT_NOTES_DISPLAY_REF` environment variable.
See linkgit:git-log[1].
notes.rewrite.<command>::
@@ -345,7 +345,7 @@ notes.rewrite.<command>::
notes from the original to the rewritten commit. Defaults to
`true`. See also "`notes.rewriteRef`" below.
+
-This setting can be overridden by the 'GIT_NOTES_REWRITE_REF'
+This setting can be overridden by the `GIT_NOTES_REWRITE_REF`
environment variable.
notes.rewriteMode::
@@ -366,33 +366,33 @@ notes.rewriteRef::
Does not have a default value; you must configure this variable to
enable note rewriting.
+
-Can be overridden with the 'GIT_NOTES_REWRITE_REF' environment variable.
+Can be overridden with the `GIT_NOTES_REWRITE_REF` environment variable.
ENVIRONMENT
-----------
-'GIT_NOTES_REF'::
+`GIT_NOTES_REF`::
Which ref to manipulate notes from, instead of `refs/notes/commits`.
This overrides the `core.notesRef` setting.
-'GIT_NOTES_DISPLAY_REF'::
+`GIT_NOTES_DISPLAY_REF`::
Colon-delimited list of refs or globs indicating which refs,
in addition to the default from `core.notesRef` or
- 'GIT_NOTES_REF', to read notes from when showing commit
+ `GIT_NOTES_REF`, to read notes from when showing commit
messages.
This overrides the `notes.displayRef` setting.
+
A warning will be issued for refs that do not exist, but a glob that
does not match any refs is silently ignored.
-'GIT_NOTES_REWRITE_MODE'::
+`GIT_NOTES_REWRITE_MODE`::
When copying notes during a rewrite, what to do if the target
commit already has a note.
Must be one of `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
This overrides the `core.rewriteMode` setting.
-'GIT_NOTES_REWRITE_REF'::
+`GIT_NOTES_REWRITE_REF`::
When rewriting commits, which notes to copy from the original
to the rewritten commit. Must be a colon-delimited list of
refs or globs.
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 88ba42b45..c83aaf39c 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -104,7 +104,7 @@ $ git p4 sync //path/in/your/perforce/depot
------------
This imports the specified depot into
'refs/remotes/p4/master' in an existing Git repository. The
-'--branch' option can be used to specify a different branch to
+`--branch` option can be used to specify a different branch to
be used for the p4 content.
If a Git repository includes branches 'refs/remotes/origin/p4', these
@@ -114,7 +114,7 @@ from a Git remote, this can be useful in a multi-developer environment.
If there are multiple branches, doing 'git p4 sync' will automatically
use the "BRANCH DETECTION" algorithm to try to partition new changes
-into the right branch. This can be overridden with the '--branch'
+into the right branch. This can be overridden with the `--branch`
option to specify just a single branch to update.
@@ -134,7 +134,7 @@ Submit
~~~~~~
Submitting changes from a Git repository back to the p4 repository
requires a separate p4 client workspace. This should be specified
-using the 'P4CLIENT' environment variable or the Git configuration
+using the `P4CLIENT` environment variable or the Git configuration
variable 'git-p4.client'. The p4 client must exist, but the client root
will be created and populated if it does not already exist.
@@ -150,10 +150,10 @@ $ git p4 submit topicbranch
------------
The upstream reference is generally 'refs/remotes/p4/master', but can
-be overridden using the '--origin=' command-line option.
+be overridden using the `--origin=` command-line option.
The p4 changes will be created as the user invoking 'git p4 submit'. The
-'--preserve-user' option will cause ownership to be modified
+`--preserve-user` option will cause ownership to be modified
according to the author of the Git commit. This option requires admin
privileges in p4, which can be granted using 'p4 protect'.
@@ -166,7 +166,7 @@ General options
All commands except clone accept these options.
--git-dir <dir>::
- Set the 'GIT_DIR' environment variable. See linkgit:git[1].
+ Set the `GIT_DIR` environment variable. See linkgit:git[1].
-v::
--verbose::
@@ -221,7 +221,7 @@ Git repository:
where they will be treated as remote-tracking branches by
linkgit:git-branch[1] and other commands. This option instead
puts p4 branches in 'refs/heads/p4/'. Note that future
- sync operations must specify '--import-local' as well so that
+ sync operations must specify `--import-local` as well so that
they can find the p4 branches in refs/heads.
--max-changes <n>::
@@ -245,7 +245,7 @@ Git repository:
default, involves removing the entire depot path. With this
option, the full p4 depot path is retained in Git. For example,
path '//depot/main/foo/bar.c', when imported from
- '//depot/main/', becomes 'foo/bar.c'. With '--keep-path', the
+ '//depot/main/', becomes 'foo/bar.c'. With `--keep-path`, the
Git path is instead 'depot/main/foo/bar.c'.
--use-client-spec::
@@ -275,7 +275,7 @@ These options can be used to modify 'git p4 submit' behavior.
--origin <commit>::
Upstream location from which commits are identified to submit to
p4. By default, this is the most recent p4 commit reachable
- from 'HEAD'.
+ from `HEAD`.
-M::
Detect renames. See linkgit:git-diff[1]. Renames will be
@@ -341,7 +341,7 @@ p4 revision specifier on the end:
Import all changes from both named depot paths into a single
repository. Only files below these directories are included.
There is not a subdirectory in Git for each "proj1" and "proj2".
- You must use the '--destination' option when specifying more
+ You must use the `--destination` option when specifying more
than one depot path. The revision specifier must be specified
identically on each depot path. If there are files in the
depot paths with the same name, the path with the most recently
@@ -355,7 +355,7 @@ CLIENT SPEC
The p4 client specification is maintained with the 'p4 client' command
and contains among other fields, a View that specifies how the depot
is mapped into the client repository. The 'clone' and 'sync' commands
-can consult the client spec when given the '--use-client-spec' option or
+can consult the client spec when given the `--use-client-spec` option or
when the useClientSpec variable is true. After 'git p4 clone', the
useClientSpec variable is automatically set in the repository
configuration file. This allows future 'git p4 submit' commands to
@@ -390,7 +390,7 @@ different areas in the tree, and indicate related content. 'git p4'
can use these mappings to determine branch relationships.
If you have a repository where all the branches of interest exist as
-subdirectories of a single depot path, you can use '--detect-branches'
+subdirectories of a single depot path, you can use `--detect-branches`
when cloning or syncing to have 'git p4' automatically find
subdirectories in p4, and to generate these as branches in Git.
@@ -507,7 +507,7 @@ git-p4.labelImportRegexp::
git-p4.useClientSpec::
Specify that the p4 client spec should be used to identify p4
depot paths of interest. This is equivalent to specifying the
- option '--use-client-spec'. See the "CLIENT SPEC" section above.
+ option `--use-client-spec`. See the "CLIENT SPEC" section above.
This variable is a boolean, not the name of a p4 client.
git-p4.pathEncoding::
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index cf6ee4a4d..93c3527f0 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -137,8 +137,8 @@ already exists on the remote side.
and also push annotated tags in `refs/tags` that are missing
from the remote but are pointing at commit-ish that are
reachable from the refs being pushed. This can also be specified
- with configuration variable 'push.followTags'. For more
- information, see 'push.followTags' in linkgit:git-config[1].
+ with configuration variable `push.followTags`. For more
+ information, see `push.followTags` in linkgit:git-config[1].
--[no-]signed::
--sign=(true|false|if-asked)::
@@ -240,7 +240,7 @@ origin +master` to force a push to the `master` branch). See the
For every branch that is up to date or successfully pushed, add
upstream (tracking) reference, used by argument-less
linkgit:git-pull[1] and other commands. For more information,
- see 'branch.<name>.merge' in linkgit:git-config[1].
+ see `branch.<name>.merge` in linkgit:git-config[1].
--[no-]thin::
These options are passed to linkgit:git-send-pack[1]. A thin transfer
@@ -275,7 +275,7 @@ origin +master` to force a push to the `master` branch). See the
all submodules that changed in the revisions to be pushed will be
pushed. If on-demand was not able to push all necessary revisions
it will also be aborted and exit with non-zero status. A value of
- 'no' or using '--no-recurse-submodules' can be used to override the
+ 'no' or using `--no-recurse-submodules` can be used to override the
push.recurseSubmodules configuration variable when no submodule
recursion is required.
diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt
index ff633b0db..8cf952b4d 100644
--- a/Documentation/git-quiltimport.txt
+++ b/Documentation/git-quiltimport.txt
@@ -46,14 +46,14 @@ OPTIONS
The directory to find the quilt patches.
+
The default for the patch directory is patches
-or the value of the $QUILT_PATCHES environment
+or the value of the `$QUILT_PATCHES` environment
variable.
--series <file>::
The quilt series file.
+
The default for the series file is <patches>/series
-or the value of the $QUILT_SERIES environment
+or the value of the `$QUILT_SERIES` environment
variable.
GIT
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 0387b40e0..de222c81a 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -208,10 +208,10 @@ rebase.stat::
rebase. False by default.
rebase.autoSquash::
- If set to true enable '--autosquash' option by default.
+ If set to true enable `--autosquash` option by default.
rebase.autoStash::
- If set to true enable '--autostash' option by default.
+ If set to true enable `--autostash` option by default.
rebase.missingCommitsCheck::
If set to "warn", print warnings about removed commits in
@@ -220,7 +220,7 @@ rebase.missingCommitsCheck::
done. "ignore" by default.
rebase.instructionFormat::
- Custom commit list format to use during an '--interactive' rebase.
+ Custom commit list format to use during an `--interactive` rebase.
OPTIONS
-------
@@ -428,9 +428,9 @@ without an explicit `--interactive`.
"fixup! " or "squash! " after the first, in case you referred to an
earlier fixup/squash with `git commit --fixup/--squash`.
+
-This option is only valid when the '--interactive' option is used.
+This option is only valid when the `--interactive` option is used.
+
-If the '--autosquash' option is enabled by default using the
+If the `--autosquash` option is enabled by default using the
configuration variable `rebase.autoSquash`, this option can be
used to override and disable this setting.
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 1d7eceaa9..577b969c1 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -137,9 +137,9 @@ branches, adds to that list.
Retrieves the URLs for a remote. Configurations for `insteadOf` and
`pushInsteadOf` are expanded here. By default, only the first URL is listed.
+
-With '--push', push URLs are queried rather than fetch URLs.
+With `--push`, push URLs are queried rather than fetch URLs.
+
-With '--all', all URLs for the remote will be listed.
+With `--all`, all URLs for the remote will be listed.
'set-url'::
@@ -147,11 +147,11 @@ Changes URLs for the remote. Sets first URL for remote <name> that matches
regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If
<oldurl> doesn't match any URL, an error occurs and nothing is changed.
+
-With '--push', push URLs are manipulated instead of fetch URLs.
+With `--push`, push URLs are manipulated instead of fetch URLs.
+
-With '--add', instead of changing existing URLs, new URL is added.
+With `--add`, instead of changing existing URLs, new URL is added.
+
-With '--delete', instead of changing existing URLs, all URLs matching
+With `--delete`, instead of changing existing URLs, all URLs matching
regex <url> are deleted for remote <name>. Trying to delete all
non-push URLs is an error.
+
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index b9c02ce48..c5975234f 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -33,7 +33,7 @@ OPTIONS
pack everything referenced into a single pack.
Especially useful when packing a repository that is used
for private development. Use
- with '-d'. This will clean up the objects that `git prune`
+ with `-d`. This will clean up the objects that `git prune`
leaves behind, but `git fsck --full --dangling` shows as
dangling.
+
@@ -42,7 +42,7 @@ whole new pack in order to get any contained object, no matter how many
other objects in that pack they already have locally.
-A::
- Same as `-a`, unless '-d' is used. Then any unreachable
+ Same as `-a`, unless `-d` is used. Then any unreachable
objects in a previous pack become loose, unpacked objects,
instead of being left in the old pack. Unreachable objects
are never intentionally added to a pack, even when repacking.
@@ -128,6 +128,19 @@ other objects in that pack they already have locally.
with `-b` or `repack.writeBitmaps`, as it ensures that the
bitmapped packfile has the necessary objects.
+--unpack-unreachable=<when>::
+ When loosening unreachable objects, do not bother loosening any
+ objects older than `<when>`. This can be used to optimize out
+ the write of any objects that would be immediately pruned by
+ a follow-up `git prune`.
+
+-k::
+--keep-unreachable::
+ When used with `-ad`, any unreachable objects from existing
+ packs will be appended to the end of the packfile instead of
+ being removed. In addition, any unreachable loose objects will
+ be packed (and their loose counterparts removed).
+
Configuration
-------------
diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt
index 8fff598fd..e5c57ae6e 100644
--- a/Documentation/git-replace.txt
+++ b/Documentation/git-replace.txt
@@ -51,7 +51,7 @@ $ git cat-file commit foo
shows information about commit 'bar'.
-The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
+The `GIT_NO_REPLACE_OBJECTS` environment variable can be set to
achieve the same effect as the `--no-replace-objects` option.
OPTIONS
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 573616a04..837707a8f 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -24,7 +24,7 @@ from the HEAD commit).
Note: 'git revert' is used to record some new commits to reverse the
effect of some earlier commits (often only a faulty one). If you want to
throw away all uncommitted changes in your working directory, you
-should see linkgit:git-reset[1], particularly the '--hard' option. If
+should see linkgit:git-reset[1], particularly the `--hard` option. If
you want to extract specific files as they were in another commit, you
should see linkgit:git-checkout[1], specifically the `git checkout
<commit> -- <filename>` syntax. Take care with these alternatives as
@@ -37,7 +37,7 @@ OPTIONS
For a more complete list of ways to spell commit names, see
linkgit:gitrevisions[7].
Sets of commits can also be given but no traversal is done by
- default, see linkgit:git-rev-list[1] and its '--no-walk'
+ default, see linkgit:git-rev-list[1] and its `--no-walk`
option.
-e::
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index a88d18604..642d0ef19 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -47,18 +47,18 @@ Composing
--annotate::
Review and edit each patch you're about to send. Default is the value
- of 'sendemail.annotate'. See the CONFIGURATION section for
- 'sendemail.multiEdit'.
+ of `sendemail.annotate`. See the CONFIGURATION section for
+ `sendemail.multiEdit`.
--bcc=<address>,...::
Specify a "Bcc:" value for each email. Default is the value of
- 'sendemail.bcc'.
+ `sendemail.bcc`.
+
This option may be specified multiple times.
--cc=<address>,...::
Specify a starting "Cc:" value for each email.
- Default is the value of 'sendemail.cc'.
+ Default is the value of `sendemail.cc`.
+
This option may be specified multiple times.
@@ -66,7 +66,7 @@ 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
+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,
@@ -74,12 +74,12 @@ and In-Reply-To headers will be used unless they are removed.
+
Missing From or In-Reply-To headers will be prompted for.
+
-See the CONFIGURATION section for 'sendemail.multiEdit'.
+See the CONFIGURATION section for `sendemail.multiEdit`.
--from=<address>::
Specify the sender of the emails. If not specified on the command line,
- the value of the 'sendemail.from' configuration option is used. If
- neither the command-line option nor 'sendemail.from' are set, then the
+ the value of the `sendemail.from` configuration option is used. If
+ neither the command-line option nor `sendemail.from` are set, then the
user will be prompted for the value. The default for the prompt will be
the value of GIT_AUTHOR_IDENT, or GIT_COMMITTER_IDENT if that is not
set, as returned by "git var -l".
@@ -114,7 +114,7 @@ is not set, this will be prompted for.
--to=<address>,...::
Specify the primary recipient of the emails generated. Generally, this
will be the upstream maintainer of the project involved. Default is the
- value of the 'sendemail.to' configuration value; if that is unspecified,
+ value of the `sendemail.to` configuration value; if that is unspecified,
and --to-cmd is not specified, this will be prompted for.
+
This option may be specified multiple times.
@@ -138,7 +138,7 @@ Note that no attempts whatsoever are made to validate the encoding.
can be useful when the repository contains files that contain carriage
returns, but makes the raw patch email file (as saved from a MUA) much
harder to inspect manually. base64 is even more fool proof, but also
- even more opaque. Default is the value of the 'sendemail.transferEncoding'
+ even more opaque. Default is the value of the `sendemail.transferEncoding`
configuration value; if that is unspecified, git will use 8bit and not
add a Content-Transfer-Encoding header.
@@ -157,20 +157,20 @@ Sending
subscribed to a list. In order to use the 'From' address, set the
value to "auto". If you use the sendmail binary, you must have
suitable privileges for the -f parameter. Default is the value of the
- 'sendemail.envelopeSender' configuration variable; if that is
+ `sendemail.envelopeSender` configuration variable; if that is
unspecified, choosing the envelope sender is left to your MTA.
--smtp-encryption=<encryption>::
Specify the encryption to use, either 'ssl' or 'tls'. Any other
value reverts to plain SMTP. Default is the value of
- 'sendemail.smtpEncryption'.
+ `sendemail.smtpEncryption`.
--smtp-domain=<FQDN>::
Specifies the Fully Qualified Domain Name (FQDN) used in the
HELO/EHLO command to the SMTP server. Some servers require the
FQDN to match your IP address. If not set, git send-email attempts
to determine your FQDN automatically. Default is the value of
- 'sendemail.smtpDomain'.
+ `sendemail.smtpDomain`.
--smtp-auth=<mechanisms>::
Whitespace-separated list of allowed SMTP-AUTH mechanisms. This setting
@@ -182,19 +182,19 @@ $ git send-email --smtp-auth="PLAIN LOGIN GSSAPI" ...
+
If at least one of the specified mechanisms matches the ones advertised by the
SMTP server and if it is supported by the utilized SASL library, the mechanism
-is used for authentication. If neither 'sendemail.smtpAuth' nor '--smtp-auth'
+is used for authentication. If neither 'sendemail.smtpAuth' nor `--smtp-auth`
is specified, all mechanisms supported by the SASL library can be used.
--smtp-pass[=<password>]::
Password for SMTP-AUTH. The argument is optional: If no
argument is specified, then the empty string is used as
- the password. Default is the value of 'sendemail.smtpPass',
- however '--smtp-pass' always overrides this value.
+ the password. Default is the value of `sendemail.smtpPass`,
+ however `--smtp-pass` always overrides this value.
+
Furthermore, passwords need not be specified in configuration files
or on the command line. If a username has been specified (with
-'--smtp-user' or a 'sendemail.smtpUser'), but no password has been
-specified (with '--smtp-pass' or 'sendemail.smtpPass'), then
+`--smtp-user` or a `sendemail.smtpUser`), but no password has been
+specified (with `--smtp-pass` or `sendemail.smtpPass`), then
a password is obtained using 'git-credential'.
--smtp-server=<host>::
@@ -202,7 +202,7 @@ a password is obtained using 'git-credential'.
`smtp.example.com` or a raw IP address). Alternatively it can
specify a full pathname of a sendmail-like program instead;
the program must support the `-i` option. Default value can
- be specified by the 'sendemail.smtpServer' configuration
+ be specified by the `sendemail.smtpServer` configuration
option; the built-in default is `/usr/sbin/sendmail` or
`/usr/lib/sendmail` if such program is available, or
`localhost` otherwise.
@@ -213,11 +213,11 @@ a password is obtained using 'git-credential'.
submission port 587, or the common SSL smtp port 465);
symbolic port names (e.g. "submission" instead of 587)
are also accepted. The port can also be set with the
- 'sendemail.smtpServerPort' configuration variable.
+ `sendemail.smtpServerPort` configuration variable.
--smtp-server-option=<option>::
If set, specifies the outgoing SMTP server option to use.
- Default value can be specified by the 'sendemail.smtpServerOption'
+ Default value can be specified by the `sendemail.smtpServerOption`
configuration option.
+
The --smtp-server-option option must be repeated for each option you want
@@ -234,13 +234,13 @@ must be used for each option.
certificates concatenated together: see verify(1) -CAfile and
-CApath for more information on these). Set it to an empty string
to disable certificate verification. Defaults to the value of the
- 'sendemail.smtpsslcertpath' configuration variable, if set, or the
+ `sendemail.smtpsslcertpath` configuration variable, if set, or the
backing SSL library's compiled-in default otherwise (which should
be the best choice on most platforms).
--smtp-user=<user>::
- Username for SMTP-AUTH. Default is the value of 'sendemail.smtpUser';
- if a username is not specified (with '--smtp-user' or 'sendemail.smtpUser'),
+ Username for SMTP-AUTH. Default is the value of `sendemail.smtpUser`;
+ if a username is not specified (with `--smtp-user` or `sendemail.smtpUser`),
then authentication is not attempted.
--smtp-debug=0|1::
@@ -261,25 +261,25 @@ Automating
Specify a command to execute once per patch file which
should generate patch file specific "Cc:" entries.
Output of this command must be single email address per line.
- Default is the value of 'sendemail.ccCmd' configuration value.
+ Default is the value of `sendemail.ccCmd` configuration value.
--[no-]chain-reply-to::
If this is set, each email will be sent as a reply to the previous
email sent. If disabled with "--no-chain-reply-to", all emails after
the first will be sent as replies to the first email sent. When using
this, it is recommended that the first file given be an overview of the
- entire patch series. Disabled by default, but the 'sendemail.chainReplyTo'
+ entire patch series. Disabled by default, but the `sendemail.chainReplyTo`
configuration variable can be used to enable it.
--identity=<identity>::
A configuration identity. When given, causes values in the
'sendemail.<identity>' subsection to take precedence over
values in the 'sendemail' section. The default identity is
- the value of 'sendemail.identity'.
+ the value of `sendemail.identity`.
--[no-]signed-off-by-cc::
If this is set, add emails found in Signed-off-by: or Cc: lines to the
- cc list. Default is the value of 'sendemail.signedoffbycc' configuration
+ cc list. Default is the value of `sendemail.signedoffbycc` configuration
value; if that is unspecified, default to --signed-off-by-cc.
--[no-]cc-cover::
@@ -312,13 +312,13 @@ Automating
- 'all' will suppress all auto cc values.
--
+
-Default is the value of 'sendemail.suppresscc' configuration value; if
+Default is the value of `sendemail.suppresscc` configuration value; if
that is unspecified, default to 'self' if --suppress-from is
specified, as well as 'body' if --no-signed-off-cc is specified.
--[no-]suppress-from::
If this is set, do not add the From: address to the cc: list.
- Default is the value of 'sendemail.suppressFrom' configuration
+ Default is the value of `sendemail.suppressFrom` configuration
value; if that is unspecified, default to --no-suppress-from.
--[no-]thread::
@@ -330,7 +330,7 @@ specified, as well as 'body' if --no-signed-off-cc is specified.
+
If disabled with "--no-thread", those headers will not be added
(unless specified with --in-reply-to). Default is the value of the
-'sendemail.thread' configuration value; if that is unspecified,
+`sendemail.thread` configuration value; if that is unspecified,
default to --thread.
+
It is up to the user to ensure that no In-Reply-To header already
@@ -355,7 +355,7 @@ Administering
- 'auto' is equivalent to 'cc' + 'compose'
--
+
-Default is the value of 'sendemail.confirm' configuration value; if that
+Default is the value of `sendemail.confirm` configuration value; if that
is unspecified, default to 'auto' unless any of the suppress options
have been specified, in which case default to 'compose'.
@@ -364,8 +364,8 @@ have been specified, in which case default to 'compose'.
--[no-]format-patch::
When an argument may be understood either as a reference or as a file name,
- choose to understand it as a format-patch argument ('--format-patch')
- or as a file name ('--no-format-patch'). By default, when such a conflict
+ choose to understand it as a format-patch argument (`--format-patch`)
+ or as a file name (`--no-format-patch`). By default, when such a conflict
occurs, git send-email will fail.
--quiet::
@@ -381,8 +381,8 @@ have been specified, in which case default to 'compose'.
is due to SMTP limits as described by http://www.ietf.org/rfc/rfc2821.txt.
--
+
-Default is the value of 'sendemail.validate'; if this is not set,
-default to '--validate'.
+Default is the value of `sendemail.validate`; if this is not set,
+default to `--validate`.
--force::
Send emails even if safety checks would prevent it.
@@ -403,7 +403,7 @@ CONFIGURATION
sendemail.aliasesFile::
To avoid typing long email addresses, point this to one or more
- email aliases files. You must also supply 'sendemail.aliasFileType'.
+ email aliases files. You must also supply `sendemail.aliasFileType`.
sendemail.aliasFileType::
Format of the file(s) specified in sendemail.aliasesFile. Must be
@@ -428,13 +428,13 @@ sendmail;;
sendemail.multiEdit::
If true (default), a single editor instance will be spawned to edit
- files you have to edit (patches when '--annotate' is used, and the
- summary when '--compose' is used). If false, files will be edited one
+ files you have to edit (patches when `--annotate` is used, and the
+ summary when `--compose` is used). If false, files will be edited one
after the other, spawning a new editor each time.
sendemail.confirm::
Sets the default for whether to confirm before sending. Must be
- one of 'always', 'never', 'cc', 'compose', or 'auto'. See '--confirm'
+ one of 'always', 'never', 'cc', 'compose', or 'auto'. See `--confirm`
in the previous section for the meaning of these values.
EXAMPLE
diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt
index 6aa91e830..a831dd028 100644
--- a/Documentation/git-send-pack.txt
+++ b/Documentation/git-send-pack.txt
@@ -44,7 +44,7 @@ OPTIONS
option, then the refs from stdin are processed after those
on the command line.
+
-If '--stateless-rpc' is specified together with this option then
+If `--stateless-rpc` is specified together with this option then
the list of refs must be in packet format (pkt-line). Each ref must
be in a separate packet, and the list must end with a flush packet.
@@ -99,11 +99,11 @@ 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 `--all` flag, all refs that exist locally are transferred to
the remote side. You cannot specify any '<ref>' if you use
this flag.
-Without '--all' and without any '<ref>', the heads that exist
+Without `--all` and without any '<ref>', the heads that exist
both on the local side and on the remote side are updated.
When one or more '<ref>' are specified explicitly (whether on the
@@ -134,13 +134,13 @@ name. See linkgit:git-rev-parse[1].
exist in the set of remote refs; the ref matched <src>
locally is used as the name of the destination.
-Without '--force', the <src> ref is stored at the remote only if
+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.
-With '--force', the fast-forward check is disabled for all refs.
+With `--force`, the fast-forward check is disabled for all refs.
Optionally, a <ref> parameter can be prefixed with a plus '+' sign
to disable the fast-forward check only on that ref.
diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index 4f67c4cde..8632612c3 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -41,7 +41,7 @@ usage::
die with the usage message.
set_reflog_action::
- Set GIT_REFLOG_ACTION environment to a given string (typically
+ Set `GIT_REFLOG_ACTION` environment to a given string (typically
the name of the program) unless it is already set. Whenever
the script runs a `git` command that updates refs, a reflog
entry is created using the value of this string to leave the
diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt
index e4bdd2235..2e30a3e42 100644
--- a/Documentation/git-shell.txt
+++ b/Documentation/git-shell.txt
@@ -24,7 +24,7 @@ named `git-shell-commands` in the user's home directory.
COMMANDS
--------
-'git shell' accepts the following commands after the '-c' option:
+'git shell' accepts the following commands after the `-c` option:
'git receive-pack <argument>'::
'git upload-pack <argument>'::
@@ -43,7 +43,7 @@ directory.
INTERACTIVE USE
---------------
-By default, the commands above can be executed only with the '-c'
+By default, the commands above can be executed only with the `-c`
option; the shell is not interactive.
If a `~/git-shell-commands` directory is present, 'git shell'
diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt
index b91d4e545..7818e0f09 100644
--- a/Documentation/git-show-branch.txt
+++ b/Documentation/git-show-branch.txt
@@ -60,7 +60,7 @@ OPTIONS
are shown before their parents).
--date-order::
- This option is similar to '--topo-order' in the sense that no
+ This option is similar to `--topo-order` in the sense that no
parent comes before all of its children, but otherwise commits
are ordered according to their commit date.
diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index 3a3245198..c0aa871c9 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -60,7 +60,7 @@ OPTIONS
Enable stricter reference checking by requiring an exact ref path.
Aside from returning an error code of 1, it will also print an error
- message if '--quiet' was not specified.
+ message if `--quiet` was not specified.
--abbrev[=<n>]::
@@ -70,7 +70,7 @@ OPTIONS
-q::
--quiet::
- Do not print any results to stdout. When combined with '--verify' this
+ Do not print any results to stdout. When combined with `--verify` this
can be used to silently check if a reference exists.
--exclude-existing[=<pattern>]::
@@ -134,7 +134,7 @@ use:
This will show "refs/heads/master" but also "refs/remote/other-repo/master",
if such references exists.
-When using the '--verify' flag, the command requires an exact path:
+When using the `--verify` flag, the command requires an exact path:
-----------------------------------------------------------------------------
git show-ref --verify refs/heads/master
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index fb23a98a1..7e17cade7 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -98,11 +98,11 @@ your Perl's Getopt::Long is < v2.37).
--ignore-paths=<regex>;;
When passed to 'init' or 'clone' this regular expression will
be preserved as a config key. See 'fetch' for a description
- of '--ignore-paths'.
+ of `--ignore-paths`.
--include-paths=<regex>;;
When passed to 'init' or 'clone' this regular expression will
be preserved as a config key. See 'fetch' for a description
- of '--include-paths'.
+ of `--include-paths`.
--no-minimize-url;;
When tracking multiple directories (using --stdlayout,
--branches, or --tags options), git svn will attempt to connect
@@ -110,7 +110,7 @@ your Perl's Getopt::Long is < v2.37).
repository. This default allows better tracking of history if
entire projects are moved within a repository, but may cause
issues on repositories where read access restrictions are in
- place. Passing '--no-minimize-url' will allow git svn to
+ place. Passing `--no-minimize-url` will allow git svn to
accept URLs as-is without attempting to connect to a higher
level directory. This option is off by default when only
one URL/branch is tracked (it would do little good).
@@ -141,7 +141,7 @@ the same local time zone.
--ignore-paths=<regex>;;
This allows one to specify a Perl regular expression that will
cause skipping of all matching paths from checkout from SVN.
- The '--ignore-paths' option should match for every 'fetch'
+ The `--ignore-paths` option should match for every 'fetch'
(including automatic fetches due to 'clone', 'dcommit',
'rebase', etc) on a given repository.
+
@@ -170,10 +170,10 @@ Skip "branches" and "tags" of first level directories;;
--include-paths=<regex>;;
This allows one to specify a Perl regular expression that will
cause the inclusion of only matching paths from checkout from SVN.
- The '--include-paths' option should match for every 'fetch'
+ The `--include-paths` option should match for every 'fetch'
(including automatic fetches due to 'clone', 'dcommit',
- 'rebase', etc) on a given repository. '--ignore-paths' takes
- precedence over '--include-paths'.
+ 'rebase', etc) on a given repository. `--ignore-paths` takes
+ precedence over `--include-paths`.
+
[verse]
config key: svn-remote.<name>.include-paths
@@ -191,7 +191,7 @@ config key: svn-remote.<name>.include-paths
or if a second argument is passed; it will create a directory
and work within that. It accepts all arguments that the
'init' and 'fetch' commands accept; with the exception of
- '--fetch-all' and '--parent'. After a repository is cloned,
+ `--fetch-all` and `--parent`. After a repository is cloned,
the 'fetch' command will be able to update revisions without
affecting the working tree; and the 'rebase' command will be
able to update the working tree with the latest changes.
@@ -216,7 +216,7 @@ it preserves linear history with 'git rebase' instead of
'git merge' for ease of dcommitting with 'git svn'.
+
This accepts all options that 'git svn fetch' and 'git rebase'
-accept. However, '--fetch-all' only fetches from the current
+accept. However, `--fetch-all` only fetches from the current
[svn-remote], and not all [svn-remote] definitions.
+
Like 'git rebase'; this requires that the working tree be clean
@@ -459,6 +459,20 @@ Any other arguments are passed directly to 'git log'
Gets the Subversion property given as the first argument, for a
file. A specific revision can be specified with -r/--revision.
+'propset'::
+ Sets the Subversion property given as the first argument, to the
+ value given as the second argument for the file given as the
+ third argument.
++
+Example:
++
+------------------------------------------------------------------------
+git svn propset svn:keywords "FreeBSD=%H" devel/py-tipper/Makefile
+------------------------------------------------------------------------
++
+This will set the property 'svn:keywords' to 'FreeBSD=%H' for the file
+'devel/py-tipper/Makefile'.
+
'show-externals'::
Shows the Subversion externals. Use -r/--revision to specify a
specific revision.
@@ -748,7 +762,7 @@ svn-remote.<name>.rewriteUUID::
svn-remote.<name>.pushurl::
- Similar to Git's 'remote.<name>.pushurl', this key is designed
+ Similar to Git's `remote.<name>.pushurl`, this key is designed
to be used in cases where 'url' points to an SVN repository
via a read-only transport, to provide an alternate read/write
transport. It is assumed that both keys point to the same
@@ -905,7 +919,7 @@ parent of the branch. However, it is possible that there is no suitable
Git commit to serve as parent. This will happen, among other reasons,
if the SVN branch is a copy of a revision that was not fetched by 'git
svn' (e.g. because it is an old revision that was skipped with
-'--revision'), or if in SVN a directory was copied that is not tracked
+`--revision`), or if in SVN a directory was copied that is not tracked
by 'git svn' (such as a branch that is not tracked at all, or a
subdirectory of a tracked branch). In these cases, 'git svn' will still
create a Git branch, but instead of using an existing Git commit as the
@@ -982,12 +996,12 @@ directories in the working copy. While this is the easiest way to get a
copy of a complete repository, for projects with many branches it will
lead to a working copy many times larger than just the trunk. Thus for
projects using the standard directory structure (trunk/branches/tags),
-it is recommended to clone with option '--stdlayout'. If the project
+it is recommended to clone with option `--stdlayout`. If the project
uses a non-standard structure, and/or if branches and tags are not
required, it is easiest to only clone one directory (typically trunk),
without giving any repository layout options. If the full history with
-branches and tags is required, the options '--trunk' / '--branches' /
-'--tags' must be used.
+branches and tags is required, the options `--trunk` / `--branches` /
+`--tags` must be used.
When using multiple --branches or --tags, 'git svn' does not automatically
handle name collisions (for example, if two branches from different paths have
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index abab4814e..7ecca8e24 100644
--- a/Documentation/git-tag.txt
+++ b/Documentation/git-tag.txt
@@ -78,7 +78,7 @@ OPTIONS
-v::
--verify::
- Verify the gpg signature of the given tag names.
+ Verify the GPG signature of the given tag names.
-n<num>::
<num> specifies how many lines from the annotation, if any,
@@ -104,7 +104,7 @@ OPTIONS
order can also be affected by the
"versionsort.prereleaseSuffix" configuration variable.
The keys supported are the same as those in `git for-each-ref`.
- Sort order defaults to the value configured for the 'tag.sort'
+ Sort order defaults to the value configured for the `tag.sort`
variable if it exists, or lexicographic order otherwise. See
linkgit:git-config[1].
@@ -167,7 +167,7 @@ This option is only applicable when listing tags without annotation lines.
--[no-]merged [<commit>]::
Only list tags whose tips are reachable, or not reachable
- if '--no-merged' is used, from the specified commit ('HEAD'
+ if `--no-merged` is used, from the specified commit (`HEAD`
if not specified).
CONFIGURATION
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index c6cbed189..7386c9316 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -102,7 +102,7 @@ thus, in case the assumed-untracked file is changed upstream,
you will need to handle the situation manually.
--really-refresh::
- Like '--refresh', but checks stat information unconditionally,
+ Like `--refresh`, but checks stat information unconditionally,
without regard to the "assume unchanged" setting.
--[no-]skip-worktree::
@@ -211,7 +211,7 @@ will remove the intended effect of the option.
Using --refresh
---------------
-'--refresh' does not calculate a new sha1 file or bring the index
+`--refresh` does not calculate a new sha1 file or bring the index
up-to-date for mode/content changes. But what it *does* do is to
"re-match" the stat information of a file with the index, so that you
can refresh the index for a file that hasn't been changed but where
@@ -222,7 +222,7 @@ up the stat index details with the proper files.
Using --cacheinfo or --info-only
--------------------------------
-'--cacheinfo' is used to register a file that is not in the
+`--cacheinfo` is used to register a file that is not in the
current working directory. This is useful for minimum-checkout
merging.
@@ -232,12 +232,12 @@ To pretend you have a file with mode and sha1 at path, say:
$ git update-index --cacheinfo <mode>,<sha1>,<path>
----------------
-'--info-only' is used to register files without placing them in the object
+`--info-only` is used to register files without placing them in the object
database. This is useful for status-only repositories.
-Both '--cacheinfo' and '--info-only' behave similarly: the index is updated
-but the object database isn't. '--cacheinfo' is useful when the object is
-in the database but the file isn't available locally. '--info-only' is
+Both `--cacheinfo` and `--info-only` behave similarly: the index is updated
+but the object database isn't. `--cacheinfo` is useful when the object is
+in the database but the file isn't available locally. `--info-only` is
useful when the file is available, but you do not wish to update the
object database.
diff --git a/Documentation/git-verify-commit.txt b/Documentation/git-verify-commit.txt
index ecf4da16c..92097f667 100644
--- a/Documentation/git-verify-commit.txt
+++ b/Documentation/git-verify-commit.txt
@@ -12,7 +12,7 @@ SYNOPSIS
DESCRIPTION
-----------
-Validates the gpg signature created by 'git commit -S'.
+Validates the GPG signature created by 'git commit -S'.
OPTIONS
-------
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 16ede5b4c..2d6b09a43 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -62,14 +62,14 @@ CONF.VAR (from -c option) and web.browser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The web browser can be specified using a configuration variable passed
-with the -c (or --config) command-line option, or the 'web.browser'
+with the -c (or --config) command-line option, or the `web.browser`
configuration variable if the former is not used.
browser.<tool>.path
~~~~~~~~~~~~~~~~~~~
You can explicitly provide a full path to your preferred browser by
-setting the configuration variable 'browser.<tool>.path'. For example,
+setting the configuration variable `browser.<tool>.path`. For example,
you can configure the absolute path to firefox by setting
'browser.firefox.path'. Otherwise, 'git web{litdd}browse' assumes the tool
is available in PATH.
@@ -79,7 +79,7 @@ browser.<tool>.cmd
When the browser, specified by options or configuration variables, is
not among the supported ones, then the corresponding
-'browser.<tool>.cmd' configuration variable will be looked up. If this
+`browser.<tool>.cmd` configuration variable will be looked up. If this
variable exists then 'git web{litdd}browse' will treat the specified tool
as a custom command and will use a shell eval to run the command with
the URLs passed as arguments.
@@ -110,7 +110,7 @@ Note about git-config --global
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that these configuration variables should probably be set using
-the '--global' flag, for example like this:
+the `--global` flag, for example like this:
------------------------------------------------
$ git config --global web.browser firefox
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 23d8d2ace..7c4cfb088 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -10,8 +10,8 @@ SYNOPSIS
--------
[verse]
'git worktree add' [-f] [--detach] [--checkout] [-b <new-branch>] <path> [<branch>]
-'git worktree prune' [-n] [-v] [--expire <expire>]
'git worktree list' [--porcelain]
+'git worktree prune' [-n] [-v] [--expire <expire>]
DESCRIPTION
-----------
@@ -55,10 +55,6 @@ If `<branch>` is omitted and neither `-b` nor `-B` nor `--detached` used,
then, as a convenience, a new branch based at HEAD is created automatically,
as if `-b $(basename <path>)` was specified.
-prune::
-
-Prune working tree information in $GIT_DIR/worktrees.
-
list::
List details of each worktree. The main worktree is listed first, followed by
@@ -66,6 +62,10 @@ each of the linked worktrees. The output details include if the worktree is
bare, the revision currently checked out, and the branch currently checked out
(or 'detached HEAD' if none).
+prune::
+
+Prune working tree information in $GIT_DIR/worktrees.
+
OPTIONS
-------
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 5490d3c60..f4dfc9d42 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -31,8 +31,8 @@ page to learn what commands Git offers. You can learn more about
individual Git commands with "git help command". linkgit:gitcli[7]
manual page gives you an overview of the command-line command syntax.
-Formatted and hyperlinked version of the latest Git documentation
-can be viewed at `http://git-htmldocs.googlecode.com/git/git.html`.
+A formatted and hyperlinked copy of the latest Git documentation
+can be viewed at `https://git.github.io/htmldocs/git.html`.
ifdef::stalenotes[]
[NOTE]
@@ -43,9 +43,11 @@ unreleased) version of Git, that is available from the 'master'
branch of the `git.git` repository.
Documentation for older releases are available here:
-* link:v2.9.0/git.html[documentation for release 2.9]
+* link:v2.9.2/git.html[documentation for release 2.9.2]
* release notes for
+ link:RelNotes/2.9.2.txt[2.9.2],
+ link:RelNotes/2.9.1.txt[2.9.1],
link:RelNotes/2.9.0.txt[2.9].
* link:v2.8.4/git.html[documentation for release 2.8.4]
@@ -513,7 +515,7 @@ OPTIONS
--help::
Prints the synopsis and a list of the most commonly used
- commands. If the option '--all' or '-a' is given then all
+ commands. If the option `--all` or `-a` is given then all
available commands are printed. If a Git command is named this
option will bring up the manual page for that command.
+
@@ -577,7 +579,7 @@ foo.bar= ...`) sets `foo.bar` to the empty string.
--git-dir=<path>::
Set the path to the repository. This can also be controlled by
- setting the GIT_DIR environment variable. It can be an absolute
+ setting the `GIT_DIR` environment variable. It can be an absolute
path or relative path to current working directory.
--work-tree=<path>::
@@ -827,46 +829,46 @@ These environment variables apply to 'all' core Git commands. Nb: it
is worth noting that they may be used/overridden by SCMS sitting above
Git so take care if using a foreign front-end.
-'GIT_INDEX_FILE'::
+`GIT_INDEX_FILE`::
This environment allows the specification of an alternate
index file. If not specified, the default of `$GIT_DIR/index`
is used.
-'GIT_INDEX_VERSION'::
+`GIT_INDEX_VERSION`::
This environment variable allows the specification of an index
version for new repositories. It won't affect existing index
files. By default index file version 2 or 3 is used. See
linkgit:git-update-index[1] for more information.
-'GIT_OBJECT_DIRECTORY'::
+`GIT_OBJECT_DIRECTORY`::
If the object storage directory is specified via this
environment variable then the sha1 directories are created
underneath - otherwise the default `$GIT_DIR/objects`
directory is used.
-'GIT_ALTERNATE_OBJECT_DIRECTORIES'::
+`GIT_ALTERNATE_OBJECT_DIRECTORIES`::
Due to the immutable nature of Git objects, old objects can be
archived into shared, read-only directories. This variable
specifies a ":" separated (on Windows ";" separated) list
of Git object directories which can be used to search for Git
objects. New objects will not be written to these directories.
-'GIT_DIR'::
- If the 'GIT_DIR' environment variable is set then it
+`GIT_DIR`::
+ If the `GIT_DIR` environment variable is set then it
specifies a path to use instead of the default `.git`
for the base of the repository.
- The '--git-dir' command-line option also sets this value.
+ The `--git-dir` command-line option also sets this value.
-'GIT_WORK_TREE'::
+`GIT_WORK_TREE`::
Set the path to the root of the working tree.
- This can also be controlled by the '--work-tree' command-line
+ This can also be controlled by the `--work-tree` command-line
option and the core.worktree configuration variable.
-'GIT_NAMESPACE'::
+`GIT_NAMESPACE`::
Set the Git namespace; see linkgit:gitnamespaces[7] for details.
- The '--namespace' command-line option also sets this value.
+ The `--namespace` command-line option also sets this value.
-'GIT_CEILING_DIRECTORIES'::
+`GIT_CEILING_DIRECTORIES`::
This should be a colon-separated list of absolute paths. If
set, it is a list of directories that Git should not chdir up
into while looking for a repository directory (useful for
@@ -879,19 +881,19 @@ Git so take care if using a foreign front-end.
can add an empty entry to the list to tell Git that the
subsequent entries are not symlinks and needn't be resolved;
e.g.,
- 'GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink'.
+ `GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink`.
-'GIT_DISCOVERY_ACROSS_FILESYSTEM'::
+`GIT_DISCOVERY_ACROSS_FILESYSTEM`::
When run in a directory that does not have ".git" repository
directory, Git tries to find such a directory in the parent
directories to find the top of the working tree, but by default it
does not cross filesystem boundaries. This environment variable
can be set to true to tell Git not to stop at filesystem
- boundaries. Like 'GIT_CEILING_DIRECTORIES', this will not affect
- an explicit repository directory set via 'GIT_DIR' or on the
+ boundaries. Like `GIT_CEILING_DIRECTORIES`, this will not affect
+ an explicit repository directory set via `GIT_DIR` or on the
command line.
-'GIT_COMMON_DIR'::
+`GIT_COMMON_DIR`::
If this variable is set to a path, non-worktree files that are
normally in $GIT_DIR will be taken from this path
instead. Worktree-specific files such as HEAD or index are
@@ -902,28 +904,28 @@ Git so take care if using a foreign front-end.
Git Commits
~~~~~~~~~~~
-'GIT_AUTHOR_NAME'::
-'GIT_AUTHOR_EMAIL'::
-'GIT_AUTHOR_DATE'::
-'GIT_COMMITTER_NAME'::
-'GIT_COMMITTER_EMAIL'::
-'GIT_COMMITTER_DATE'::
+`GIT_AUTHOR_NAME`::
+`GIT_AUTHOR_EMAIL`::
+`GIT_AUTHOR_DATE`::
+`GIT_COMMITTER_NAME`::
+`GIT_COMMITTER_EMAIL`::
+`GIT_COMMITTER_DATE`::
'EMAIL'::
see linkgit:git-commit-tree[1]
Git Diffs
~~~~~~~~~
-'GIT_DIFF_OPTS'::
+`GIT_DIFF_OPTS`::
Only valid setting is "--unified=??" or "-u??" to set the
number of context lines shown when a unified diff is created.
This takes precedence over any "-U" or "--unified" option
value passed on the Git diff command line.
-'GIT_EXTERNAL_DIFF'::
- When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
+`GIT_EXTERNAL_DIFF`::
+ When the environment variable `GIT_EXTERNAL_DIFF` is set, the
program named by it is called, instead of the diff invocation
described above. For a path that is added, removed, or modified,
- 'GIT_EXTERNAL_DIFF' is called with 7 parameters:
+ `GIT_EXTERNAL_DIFF` is called with 7 parameters:
path old-file old-hex old-mode new-file new-hex new-mode
+
@@ -937,49 +939,49 @@ where:
The file parameters can point at the user's working file
(e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file`
when a new file is added), or a temporary file (e.g. `old-file` in the
-index). 'GIT_EXTERNAL_DIFF' should not worry about unlinking the
-temporary file --- it is removed when 'GIT_EXTERNAL_DIFF' exits.
+index). `GIT_EXTERNAL_DIFF` should not worry about unlinking the
+temporary file --- it is removed when `GIT_EXTERNAL_DIFF` exits.
+
-For a path that is unmerged, 'GIT_EXTERNAL_DIFF' is called with 1
+For a path that is unmerged, `GIT_EXTERNAL_DIFF` is called with 1
parameter, <path>.
+
-For each path 'GIT_EXTERNAL_DIFF' is called, two environment variables,
-'GIT_DIFF_PATH_COUNTER' and 'GIT_DIFF_PATH_TOTAL' are set.
+For each path `GIT_EXTERNAL_DIFF` is called, two environment variables,
+`GIT_DIFF_PATH_COUNTER` and `GIT_DIFF_PATH_TOTAL` are set.
-'GIT_DIFF_PATH_COUNTER'::
+`GIT_DIFF_PATH_COUNTER`::
A 1-based counter incremented by one for every path.
-'GIT_DIFF_PATH_TOTAL'::
+`GIT_DIFF_PATH_TOTAL`::
The total number of paths.
other
~~~~~
-'GIT_MERGE_VERBOSITY'::
+`GIT_MERGE_VERBOSITY`::
A number controlling the amount of output shown by
the recursive merge strategy. Overrides merge.verbosity.
See linkgit:git-merge[1]
-'GIT_PAGER'::
+`GIT_PAGER`::
This environment variable overrides `$PAGER`. If it is set
to an empty string or to the value "cat", Git will not launch
a pager. See also the `core.pager` option in
linkgit:git-config[1].
-'GIT_EDITOR'::
+`GIT_EDITOR`::
This environment variable overrides `$EDITOR` and `$VISUAL`.
It is used by several Git commands when, on interactive mode,
an editor is to be launched. See also linkgit:git-var[1]
and the `core.editor` option in linkgit:git-config[1].
-'GIT_SSH'::
-'GIT_SSH_COMMAND'::
+`GIT_SSH`::
+`GIT_SSH_COMMAND`::
If either of these environment variables is set then 'git fetch'
and 'git push' will use the specified command instead of 'ssh'
when they need to connect to a remote system.
The command will be given exactly two or four arguments: the
'username@host' (or just 'host') from the URL and the shell
command to execute on that remote system, optionally preceded by
- '-p' (literally) and the 'port' from the URL when it specifies
+ `-p` (literally) and the 'port' from the URL when it specifies
something other than the default SSH port.
+
`$GIT_SSH_COMMAND` takes precedence over `$GIT_SSH`, and is interpreted
@@ -992,18 +994,18 @@ Usually it is easier to configure any desired options through your
personal `.ssh/config` file. Please consult your ssh documentation
for further details.
-'GIT_ASKPASS'::
+`GIT_ASKPASS`::
If this environment variable is set, then Git commands which need to
acquire passwords or passphrases (e.g. for HTTP or IMAP authentication)
will call this program with a suitable prompt as command-line argument
- and read the password from its STDOUT. See also the 'core.askPass'
+ and read the password from its STDOUT. See also the `core.askPass`
option in linkgit:git-config[1].
-'GIT_TERMINAL_PROMPT'::
+`GIT_TERMINAL_PROMPT`::
If this environment variable is set to `0`, git will not prompt
on the terminal (e.g., when asking for HTTP authentication).
-'GIT_CONFIG_NOSYSTEM'::
+`GIT_CONFIG_NOSYSTEM`::
Whether to skip reading settings from the system-wide
`$(prefix)/etc/gitconfig` file. This environment variable can
be used along with `$HOME` and `$XDG_CONFIG_HOME` to create a
@@ -1011,7 +1013,7 @@ for further details.
temporarily to avoid using a buggy `/etc/gitconfig` file while
waiting for someone with sufficient permissions to fix it.
-'GIT_FLUSH'::
+`GIT_FLUSH`::
If this environment variable is set to "1", then commands such
as 'git blame' (in incremental mode), 'git rev-list', 'git log',
'git check-attr' and 'git check-ignore' will
@@ -1022,7 +1024,7 @@ for further details.
not set, Git will choose buffered or record-oriented flushing
based on whether stdout appears to be redirected to a file or not.
-'GIT_TRACE'::
+`GIT_TRACE`::
Enables general trace messages, e.g. alias expansion, built-in
command execution and external command execution.
+
@@ -1043,21 +1045,21 @@ into it.
Unsetting the variable, or setting it to empty, "0" or
"false" (case insensitive) disables trace messages.
-'GIT_TRACE_PACK_ACCESS'::
+`GIT_TRACE_PACK_ACCESS`::
Enables trace messages for all accesses to any packs. For each
access, the pack file name and an offset in the pack is
recorded. This may be helpful for troubleshooting some
pack-related performance problems.
- See 'GIT_TRACE' for available trace output options.
+ See `GIT_TRACE` for available trace output options.
-'GIT_TRACE_PACKET'::
+`GIT_TRACE_PACKET`::
Enables trace messages for all packets coming in or out of a
given program. This can help with debugging object negotiation
or other protocol issues. Tracing is turned off at a packet
- starting with "PACK" (but see 'GIT_TRACE_PACKFILE' below).
- See 'GIT_TRACE' for available trace output options.
+ starting with "PACK" (but see `GIT_TRACE_PACKFILE` below).
+ See `GIT_TRACE` for available trace output options.
-'GIT_TRACE_PACKFILE'::
+`GIT_TRACE_PACKFILE`::
Enables tracing of packfiles sent or received by a
given program. Unlike other trace output, this trace is
verbatim: no headers, and no quoting of binary data. You almost
@@ -1068,22 +1070,30 @@ Unsetting the variable, or setting it to empty, "0" or
Note that this is currently only implemented for the client side
of clones and fetches.
-'GIT_TRACE_PERFORMANCE'::
+`GIT_TRACE_PERFORMANCE`::
Enables performance related trace messages, e.g. total execution
time of each Git command.
- See 'GIT_TRACE' for available trace output options.
+ See `GIT_TRACE` for available trace output options.
-'GIT_TRACE_SETUP'::
+`GIT_TRACE_SETUP`::
Enables trace messages printing the .git, working tree and current
working directory after Git has completed its setup phase.
- See 'GIT_TRACE' for available trace output options.
+ See `GIT_TRACE` for available trace output options.
-'GIT_TRACE_SHALLOW'::
+`GIT_TRACE_SHALLOW`::
Enables trace messages that can help debugging fetching /
cloning of shallow repositories.
- See 'GIT_TRACE' for available trace output options.
+ See `GIT_TRACE` for available trace output options.
-'GIT_LITERAL_PATHSPECS'::
+`GIT_TRACE_CURL`::
+ Enables a curl full trace dump of all incoming and outgoing data,
+ including descriptive information, of the git transport protocol.
+ This is similar to doing curl `--trace-ascii` on the command line.
+ This option overrides setting the `GIT_CURL_VERBOSE` environment
+ variable.
+ See `GIT_TRACE` for available trace output options.
+
+`GIT_LITERAL_PATHSPECS`::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search
@@ -1092,19 +1102,19 @@ of clones and fetches.
literal paths to Git (e.g., paths previously given to you by
`git ls-tree`, `--raw` diff output, etc).
-'GIT_GLOB_PATHSPECS'::
+`GIT_GLOB_PATHSPECS`::
Setting this variable to `1` will cause Git to treat all
pathspecs as glob patterns (aka "glob" magic).
-'GIT_NOGLOB_PATHSPECS'::
+`GIT_NOGLOB_PATHSPECS`::
Setting this variable to `1` will cause Git to treat all
pathspecs as literal (aka "literal" magic).
-'GIT_ICASE_PATHSPECS'::
+`GIT_ICASE_PATHSPECS`::
Setting this variable to `1` will cause Git to treat all
pathspecs as case-insensitive.
-'GIT_REFLOG_ACTION'::
+`GIT_REFLOG_ACTION`::
When a ref is updated, reflog entries are created to keep
track of the reason why the ref was updated (which is
typically the name of the high-level command that updated
@@ -1114,7 +1124,7 @@ of clones and fetches.
variable when it is invoked as the top level command by the
end user, to be recorded in the body of the reflog.
-'GIT_REF_PARANOIA'::
+`GIT_REF_PARANOIA`::
If set to `1`, include broken or badly named refs when iterating
over lists of refs. In a normal, non-corrupted repository, this
does nothing. However, enabling it may help git to detect and
@@ -1125,7 +1135,7 @@ of clones and fetches.
an operation has touched every ref (e.g., because you are
cloning a repository to make a backup).
-'GIT_ALLOW_PROTOCOL'::
+`GIT_ALLOW_PROTOCOL`::
If set, provide a colon-separated list of protocols which are
allowed to be used with fetch/push/clone. This is useful to
restrict recursive submodule initialization from an untrusted
diff --git a/Documentation/gitcore-tutorial.txt b/Documentation/gitcore-tutorial.txt
index 15b3bfa8d..4546fa0d7 100644
--- a/Documentation/gitcore-tutorial.txt
+++ b/Documentation/gitcore-tutorial.txt
@@ -949,7 +949,7 @@ for details.
[NOTE]
If there were more commits on the 'master' branch after the merge, the
merge commit itself would not be shown by 'git show-branch' by
-default. You would need to provide '--sparse' option to make the
+default. You would need to provide `--sparse` option to make the
merge commit visible in this case.
Now, let's pretend you are the one who did all the work in
diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt
index c579593e5..08cf62278 100644
--- a/Documentation/gitdiffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -28,8 +28,8 @@ The 'git diff-{asterisk}' family works by first comparing two sets of
files:
- 'git diff-index' compares contents of a "tree" object and the
- working directory (when '--cached' flag is not used) or a
- "tree" object and the index file (when '--cached' flag is
+ working directory (when `--cached` flag is not used) or a
+ "tree" object and the index file (when `--cached` flag is
used);
- 'git diff-files' compares contents of the index file and the
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 473623d63..63260f005 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -38,7 +38,7 @@ precedence, the last matching pattern decides the outcome):
* Patterns read from `$GIT_DIR/info/exclude`.
* Patterns read from the file specified by the configuration
- variable 'core.excludesFile'.
+ variable `core.excludesFile`.
Which file to place a pattern in depends on how the pattern is meant to
be used.
diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 6ade00217..a68d860fa 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -82,7 +82,7 @@ linkgit:git-rev-list[1] for a complete list.
--simplify-merges::
- Additional option to '--full-history' to remove some needless
+ Additional option to `--full-history` to remove some needless
merges from the resulting history, as there are no selected
commits contributing to this merge. (See "History
simplification" in linkgit:git-log[1] for a more detailed
diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt
index ac70eca32..07cdd73ab 100644
--- a/Documentation/gitmodules.txt
+++ b/Documentation/gitmodules.txt
@@ -19,7 +19,7 @@ of linkgit:git-config[1].
The file contains one subsection per submodule, and the subsection value
is the name of the submodule. The name is set to the path where the
-submodule has been added unless it was customized with the '--name'
+submodule has been added unless it was customized with the `--name`
option of 'git submodule add'. Each submodule section also contains the
following required keys:
diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index 78e0b27c1..a4de50ad2 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -43,7 +43,7 @@ arguments. The first argument specifies a remote repository as in Git;
it is either the name of a configured remote or a URL. The second
argument specifies a URL; it is usually of the form
'<transport>://<address>', but any arbitrary string is possible.
-The 'GIT_DIR' environment variable is set up for the remote helper
+The `GIT_DIR` environment variable is set up for the remote helper
and can be used to determine where to store additional data or from
which directory to invoke auxiliary Git commands.
@@ -61,10 +61,10 @@ argument. If such a URL is encountered directly on the command line,
the first argument is '<address>', and if it is encountered in a
configured remote, the first argument is the name of that remote.
-Additionally, when a configured remote has 'remote.<name>.vcs' set to
+Additionally, when a configured remote has `remote.<name>.vcs` set to
'<transport>', Git explicitly invokes 'git remote-<transport>' with
'<name>' as the first argument. If set, the second argument is
-'remote.<name>.url'; otherwise, the second argument is omitted.
+`remote.<name>.url`; otherwise, the second argument is omitted.
INPUT FORMAT
------------
@@ -210,17 +210,17 @@ the remote repository.
'export-marks' <file>::
This modifies the 'export' capability, instructing Git to dump the
internal marks table to <file> when complete. For details,
- read up on '--export-marks=<file>' in linkgit:git-fast-export[1].
+ read up on `--export-marks=<file>` in linkgit:git-fast-export[1].
'import-marks' <file>::
This modifies the 'export' capability, instructing Git to load the
marks specified in <file> before processing any input. For details,
- read up on '--import-marks=<file>' in linkgit:git-fast-export[1].
+ read up on `--import-marks=<file>` in linkgit:git-fast-export[1].
'signed-tags'::
This modifies the 'export' capability, instructing Git to pass
- '--signed-tags=verbatim' to linkgit:git-fast-export[1]. In the
- absence of this capability, Git will use '--signed-tags=warn-strip'.
+ `--signed-tags=verbatim` to linkgit:git-fast-export[1]. In the
+ absence of this capability, Git will use `--signed-tags=warn-strip`.
@@ -298,7 +298,7 @@ Supported if the helper has the "fetch" capability.
is followed by a blank line). For example, the following would
be two batches of 'push', the first asking the remote-helper
to push the local ref 'master' to the remote ref 'master' and
- the local 'HEAD' to the remote 'branch', and the second
+ the local `HEAD` to the remote 'branch', and the second
asking to push ref 'foo' to ref 'bar' (forced update requested
by the '+').
+
diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt
index 8a4227007..a79e35024 100644
--- a/Documentation/gitweb.conf.txt
+++ b/Documentation/gitweb.conf.txt
@@ -376,7 +376,7 @@ $site_name::
Name of your site or organization, to appear in page titles. Set it
to something descriptive for clearer bookmarks etc. If this variable
is not set or is, then gitweb uses the value of the `SERVER_NAME`
- CGI environment variable, setting site name to "$SERVER_NAME Git",
+ `CGI` environment variable, setting site name to "$SERVER_NAME Git",
or "Untitled Git" if this variable is not set (e.g. if running gitweb
as standalone script).
+
diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt
index cd9c8951b..96156e5e1 100644
--- a/Documentation/gitweb.txt
+++ b/Documentation/gitweb.txt
@@ -206,8 +206,8 @@ $export_auth_hook = sub {
Per-repository gitweb configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can configure individual repositories shown in gitweb by creating file
-in the 'GIT_DIR' of Git repository, or by setting some repo configuration
-variable (in 'GIT_DIR/config', see linkgit:git-config[1]).
+in the `GIT_DIR` of Git repository, or by setting some repo configuration
+variable (in `GIT_DIR/config`, see linkgit:git-config[1]).
You can use the following files in repository:
diff --git a/Documentation/howto/new-command.txt b/Documentation/howto/new-command.txt
index 6d772bd92..15a4c8031 100644
--- a/Documentation/howto/new-command.txt
+++ b/Documentation/howto/new-command.txt
@@ -94,7 +94,7 @@ your language, document it in the INSTALL file.
6. There is a file command-list.txt in the distribution main directory
that categorizes commands by type, so they can be listed in appropriate
subsections in the documentation's summary command list. Add an entry
-for yours. To understand the categories, look at git-commands.txt
+for yours. To understand the categories, look at command-list.txt
in the main directory. If the new command is part of the typical Git
workflow and you believe it common enough to be mentioned in 'git help',
map this command to a common group in the column [common].
diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
index 002ca58c2..df3ea3779 100644
--- a/Documentation/merge-config.txt
+++ b/Documentation/merge-config.txt
@@ -61,7 +61,7 @@ merge.verbosity::
message if conflicts were detected. Level 1 outputs only
conflicts, 2 outputs conflicts and file changes. Level 5 and
above outputs debugging information. The default is level 2.
- Can be overridden by the 'GIT_MERGE_VERBOSITY' environment variable.
+ Can be overridden by the `GIT_MERGE_VERBOSITY` environment variable.
merge.<driver>.name::
Defines a human-readable name for a custom low-level
diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt
index 6c6718272..e44fc8f73 100644
--- a/Documentation/pretty-options.txt
+++ b/Documentation/pretty-options.txt
@@ -26,7 +26,7 @@ people using 80-column terminals.
--no-abbrev-commit::
Show the full 40-byte hexadecimal commit object name. This negates
`--abbrev-commit` and those options which imply it such as
- "--oneline". It also overrides the 'log.abbrevCommit' variable.
+ "--oneline". It also overrides the `log.abbrevCommit` variable.
--oneline::
This is a shorthand for "--pretty=oneline --abbrev-commit"
@@ -65,7 +65,7 @@ ifndef::git-rev-list[]
on the command line.
+
By default, the notes shown are from the notes refs listed in the
-'core.notesRef' and 'notes.displayRef' variables (or corresponding
+`core.notesRef` and `notes.displayRef` variables (or corresponding
environment overrides). See linkgit:git-config[1] for more details.
+
With an optional '<treeish>' argument, use the treeish to find the notes
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 4f009d442..c5bd21812 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -193,7 +193,7 @@ endif::git-rev-list[]
--stdin::
In addition to the '<commit>' listed on the command
- line, read them from the standard input. If a '--' separator is
+ line, read them from the standard input. If a `--` separator is
seen, stop reading commits and start reading paths to limit the
result.
diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index 19314e3b7..abae36398 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -28,8 +28,8 @@ blobs contained in a commit.
first match in the following rules:
. If '$GIT_DIR/<refname>' exists, that is what you mean (this is usually
- useful only for 'HEAD', 'FETCH_HEAD', 'ORIG_HEAD', 'MERGE_HEAD'
- and 'CHERRY_PICK_HEAD');
+ useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD`, `MERGE_HEAD`
+ and `CHERRY_PICK_HEAD`);
. otherwise, 'refs/<refname>' if it exists;
@@ -41,16 +41,16 @@ blobs contained in a commit.
. otherwise, 'refs/remotes/<refname>/HEAD' if it exists.
+
-'HEAD' names the commit on which you based the changes in the working tree.
-'FETCH_HEAD' records the branch which you fetched from a remote repository
+`HEAD` names the commit on which you based the changes in the working tree.
+`FETCH_HEAD` records the branch which you fetched from a remote repository
with your last `git fetch` invocation.
-'ORIG_HEAD' is created by commands that move your 'HEAD' in a drastic
-way, to record the position of the 'HEAD' before their operation, so that
+`ORIG_HEAD` is created by commands that move your `HEAD` in a drastic
+way, to record the position of the `HEAD` before their operation, so that
you can easily change the tip of the branch back to the state before you ran
them.
-'MERGE_HEAD' records the commit(s) which you are merging into your branch
+`MERGE_HEAD` records the commit(s) which you are merging into your branch
when you run `git merge`.
-'CHERRY_PICK_HEAD' records the commit which you are cherry-picking
+`CHERRY_PICK_HEAD` records the commit which you are cherry-picking
when you run `git cherry-pick`.
+
Note that any of the 'refs/*' cases above may come either from
@@ -59,7 +59,7 @@ While the ref name encoding is unspecified, UTF-8 is preferred as
some output processing may assume ref names in UTF-8.
'@'::
- '@' alone is a shortcut for 'HEAD'.
+ '@' alone is a shortcut for `HEAD`.
'<refname>@{<date>}', e.g. 'master@\{yesterday\}', 'HEAD@{5 minutes ago}'::
A ref followed by the suffix '@' with a date specification
@@ -71,7 +71,7 @@ some output processing may assume ref names in UTF-8.
existing log ('$GIT_DIR/logs/<ref>'). Note that this looks up the state
of your *local* ref at a given time; e.g., what was in your local
'master' branch last week. If you want to look at commits made during
- certain times, see '--since' and '--until'.
+ certain times, see `--since` and `--until`.
'<refname>@{<n>}', e.g. 'master@\{1\}'::
A ref followed by the suffix '@' with an ordinal specification
@@ -101,7 +101,7 @@ some output processing may assume ref names in UTF-8.
'<branchname>@\{push\}', e.g. 'master@\{push\}', '@\{push\}'::
The suffix '@\{push}' reports the branch "where we would push to" if
`git push` were run while `branchname` was checked out (or the current
- 'HEAD' if no branchname is specified). Since our push destination is
+ `HEAD` if no branchname is specified). Since our push destination is
in a remote repository, of course, we report the local tracking branch
that corresponds to that branch (i.e., something in 'refs/remotes/').
+
@@ -283,12 +283,12 @@ To summarize:
'<rev1>..<rev2>'::
Include commits that are reachable from <rev2> but exclude
those that are reachable from <rev1>. When either <rev1> or
- <rev2> is omitted, it defaults to 'HEAD'.
+ <rev2> is omitted, it defaults to `HEAD`.
'<rev1>\...<rev2>'::
Include commits that are reachable from either <rev1> or
<rev2> but exclude those that are reachable from both. When
- either <rev1> or <rev2> is omitted, it defaults to 'HEAD'.
+ either <rev1> or <rev2> is omitted, it defaults to `HEAD`.
'<rev>{caret}@', e.g. 'HEAD{caret}@'::
A suffix '{caret}' followed by an at sign is the same as listing
diff --git a/Documentation/technical/signature-format.txt b/Documentation/technical/signature-format.txt
new file mode 100644
index 000000000..2c9406a56
--- /dev/null
+++ b/Documentation/technical/signature-format.txt
@@ -0,0 +1,186 @@
+Git signature format
+====================
+
+== Overview
+
+Git uses cryptographic signatures in various places, currently objects (tags,
+commits, mergetags) and transactions (pushes). In every case, the command which
+is about to create an object or transaction determines a payload from that,
+calls gpg to obtain a detached signature for the payload (`gpg -bsa`) and
+embeds the signature into the object or transaction.
+
+Signatures always begin with `-----BEGIN PGP SIGNATURE-----`
+and end with `-----END PGP SIGNATURE-----`, unless gpg is told to
+produce RFC1991 signatures which use `MESSAGE` instead of `SIGNATURE`.
+
+The signed payload and the way the signature is embedded depends
+on the type of the object resp. transaction.
+
+== Tag signatures
+
+- created by: `git tag -s`
+- payload: annotated tag object
+- embedding: append the signature to the unsigned tag object
+- example: tag `signedtag` with subject `signed tag`
+
+----
+object 04b871796dc0420f8e7561a895b52484b701d51a
+type commit
+tag signedtag
+tagger C O Mitter <committer@example.com> 1465981006 +0000
+
+signed tag
+
+signed tag message body
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1
+
+iQEcBAABAgAGBQJXYRhOAAoJEGEJLoW3InGJklkIAIcnhL7RwEb/+QeX9enkXhxn
+rxfdqrvWd1K80sl2TOt8Bg/NYwrUBw/RWJ+sg/hhHp4WtvE1HDGHlkEz3y11Lkuh
+8tSxS3qKTxXUGozyPGuE90sJfExhZlW4knIQ1wt/yWqM+33E9pN4hzPqLwyrdods
+q8FWEqPPUbSJXoMbRPw04S5jrLtZSsUWbRYjmJCHzlhSfFWW4eFd37uquIaLUBS0
+rkC3Jrx7420jkIpgFcTI2s60uhSQLzgcCwdA2ukSYIRnjg/zDkj8+3h/GaROJ72x
+lZyI6HWixKJkWw8lE9aAOD9TmTW9sFJwcVAzmAuFX2kUreDUKMZduGcoRYGpD7E=
+=jpXa
+-----END PGP SIGNATURE-----
+----
+
+- verify with: `git verify-tag [-v]` or `git tag -v`
+
+----
+gpg: Signature made Wed Jun 15 10:56:46 2016 CEST using RSA key ID B7227189
+gpg: Good signature from "Eris Discordia <discord@example.net>"
+gpg: WARNING: This key is not certified with a trusted signature!
+gpg: There is no indication that the signature belongs to the owner.
+Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
+object 04b871796dc0420f8e7561a895b52484b701d51a
+type commit
+tag signedtag
+tagger C O Mitter <committer@example.com> 1465981006 +0000
+
+signed tag
+
+signed tag message body
+----
+
+== Commit signatures
+
+- created by: `git commit -S`
+- payload: commit object
+- embedding: header entry `gpgsig`
+ (content is preceded by a space)
+- example: commit with subject `signed commit`
+
+----
+tree eebfed94e75e7760540d1485c740902590a00332
+parent 04b871796dc0420f8e7561a895b52484b701d51a
+author A U Thor <author@example.com> 1465981137 +0000
+committer C O Mitter <committer@example.com> 1465981137 +0000
+gpgsig -----BEGIN PGP SIGNATURE-----
+ Version: GnuPG v1
+
+ iQEcBAABAgAGBQJXYRjRAAoJEGEJLoW3InGJ3IwIAIY4SA6GxY3BjL60YyvsJPh/
+ HRCJwH+w7wt3Yc/9/bW2F+gF72kdHOOs2jfv+OZhq0q4OAN6fvVSczISY/82LpS7
+ DVdMQj2/YcHDT4xrDNBnXnviDO9G7am/9OE77kEbXrp7QPxvhjkicHNwy2rEflAA
+ zn075rtEERDHr8nRYiDh8eVrefSO7D+bdQ7gv+7GsYMsd2auJWi1dHOSfTr9HIF4
+ HJhWXT9d2f8W+diRYXGh4X0wYiGg6na/soXc+vdtDYBzIxanRqjg8jCAeo1eOTk1
+ EdTwhcTZlI0x5pvJ3H0+4hA2jtldVtmPM4OTB0cTrEWBad7XV6YgiyuII73Ve3I=
+ =jKHM
+ -----END PGP SIGNATURE-----
+
+signed commit
+
+signed commit message body
+----
+
+- verify with: `git verify-commit [-v]` (or `git show --show-signature`)
+
+----
+gpg: Signature made Wed Jun 15 10:58:57 2016 CEST using RSA key ID B7227189
+gpg: Good signature from "Eris Discordia <discord@example.net>"
+gpg: WARNING: This key is not certified with a trusted signature!
+gpg: There is no indication that the signature belongs to the owner.
+Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
+tree eebfed94e75e7760540d1485c740902590a00332
+parent 04b871796dc0420f8e7561a895b52484b701d51a
+author A U Thor <author@example.com> 1465981137 +0000
+committer C O Mitter <committer@example.com> 1465981137 +0000
+
+signed commit
+
+signed commit message body
+----
+
+== Mergetag signatures
+
+- created by: `git merge` on signed tag
+- payload/embedding: the whole signed tag object is embedded into
+ the (merge) commit object as header entry `mergetag`
+- example: merge of the signed tag `signedtag` as above
+
+----
+tree c7b1cff039a93f3600a1d18b82d26688668c7dea
+parent c33429be94b5f2d3ee9b0adad223f877f174b05d
+parent 04b871796dc0420f8e7561a895b52484b701d51a
+author A U Thor <author@example.com> 1465982009 +0000
+committer C O Mitter <committer@example.com> 1465982009 +0000
+mergetag object 04b871796dc0420f8e7561a895b52484b701d51a
+ type commit
+ tag signedtag
+ tagger C O Mitter <committer@example.com> 1465981006 +0000
+
+ signed tag
+
+ signed tag message body
+ -----BEGIN PGP SIGNATURE-----
+ Version: GnuPG v1
+
+ iQEcBAABAgAGBQJXYRhOAAoJEGEJLoW3InGJklkIAIcnhL7RwEb/+QeX9enkXhxn
+ rxfdqrvWd1K80sl2TOt8Bg/NYwrUBw/RWJ+sg/hhHp4WtvE1HDGHlkEz3y11Lkuh
+ 8tSxS3qKTxXUGozyPGuE90sJfExhZlW4knIQ1wt/yWqM+33E9pN4hzPqLwyrdods
+ q8FWEqPPUbSJXoMbRPw04S5jrLtZSsUWbRYjmJCHzlhSfFWW4eFd37uquIaLUBS0
+ rkC3Jrx7420jkIpgFcTI2s60uhSQLzgcCwdA2ukSYIRnjg/zDkj8+3h/GaROJ72x
+ lZyI6HWixKJkWw8lE9aAOD9TmTW9sFJwcVAzmAuFX2kUreDUKMZduGcoRYGpD7E=
+ =jpXa
+ -----END PGP SIGNATURE-----
+
+Merge tag 'signedtag' into downstream
+
+signed tag
+
+signed tag message body
+
+# gpg: Signature made Wed Jun 15 08:56:46 2016 UTC using RSA key ID B7227189
+# gpg: Good signature from "Eris Discordia <discord@example.net>"
+# gpg: WARNING: This key is not certified with a trusted signature!
+# gpg: There is no indication that the signature belongs to the owner.
+# Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
+----
+
+- verify with: verification is embedded in merge commit message by default,
+ alternatively with `git show --show-signature`:
+
+----
+commit 9863f0c76ff78712b6800e199a46aa56afbcbd49
+merged tag 'signedtag'
+gpg: Signature made Wed Jun 15 10:56:46 2016 CEST using RSA key ID B7227189
+gpg: Good signature from "Eris Discordia <discord@example.net>"
+gpg: WARNING: This key is not certified with a trusted signature!
+gpg: There is no indication that the signature belongs to the owner.
+Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
+Merge: c33429b 04b8717
+Author: A U Thor <author@example.com>
+Date: Wed Jun 15 09:13:29 2016 +0000
+
+ Merge tag 'signedtag' into downstream
+
+ signed tag
+
+ signed tag message body
+
+ # gpg: Signature made Wed Jun 15 08:56:46 2016 UTC using RSA key ID B7227189
+ # gpg: Good signature from "Eris Discordia <discord@example.net>"
+ # gpg: WARNING: This key is not certified with a trusted signature!
+ # gpg: There is no indication that the signature belongs to the owner.
+ # Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189
+----
diff --git a/Makefile b/Makefile
index de5a03025..3cb1d601a 100644
--- a/Makefile
+++ b/Makefile
@@ -2063,7 +2063,10 @@ XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
--keyword=gettextln --keyword=eval_gettextln
XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
-LOCALIZED_SH = $(SCRIPT_SH) git-parse-remote.sh
+LOCALIZED_SH = $(SCRIPT_SH)
+LOCALIZED_SH += git-parse-remote.sh
+LOCALIZED_SH += git-rebase--interactive.sh
+LOCALIZED_SH += git-sh-setup.sh
LOCALIZED_PERL = $(SCRIPT_PERL)
ifdef XGETTEXT_INCLUDE_TESTS
diff --git a/advice.c b/advice.c
index 4dc5cf10a..b84ae4960 100644
--- a/advice.c
+++ b/advice.c
@@ -79,7 +79,20 @@ int git_default_advice_config(const char *var, const char *value)
int error_resolve_conflict(const char *me)
{
- error("%s is not possible because you have unmerged files.", me);
+ if (!strcmp(me, "cherry-pick"))
+ error(_("Cherry-picking is not possible because you have unmerged files."));
+ else if (!strcmp(me, "commit"))
+ error(_("Committing is not possible because you have unmerged files."));
+ else if (!strcmp(me, "merge"))
+ error(_("Merging is not possible because you have unmerged files."));
+ else if (!strcmp(me, "pull"))
+ error(_("Pulling is not possible because you have unmerged files."));
+ else if (!strcmp(me, "revert"))
+ error(_("Reverting is not possible because you have unmerged files."));
+ else
+ error(_("It is not possible to %s because you have unmerged files."),
+ me);
+
if (advice_resolve_conflict)
/*
* Message used both when 'git commit' fails and when
@@ -93,7 +106,7 @@ int error_resolve_conflict(const char *me)
void NORETURN die_resolve_conflict(const char *me)
{
error_resolve_conflict(me);
- die("Exiting because of an unresolved conflict.");
+ die(_("Exiting because of an unresolved conflict."));
}
void NORETURN die_conclude_merge(void)
@@ -106,14 +119,14 @@ void NORETURN die_conclude_merge(void)
void detach_advice(const char *new_name)
{
- const char fmt[] =
- "Note: checking out '%s'.\n\n"
+ const char *fmt =
+ _("Note: checking out '%s'.\n\n"
"You are in 'detached HEAD' state. You can look around, make experimental\n"
"changes and commit them, and you can discard any commits you make in this\n"
"state without impacting any branches by performing another checkout.\n\n"
"If you want to create a new branch to retain commits you create, you may\n"
"do so (now or later) by using -b with the checkout command again. Example:\n\n"
- " git checkout -b <new-branch-name>\n\n";
+ " git checkout -b <new-branch-name>\n\n");
fprintf(stderr, fmt, new_name);
}
diff --git a/archive-tar.c b/archive-tar.c
index cb99df281..55682404d 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -18,6 +18,21 @@ static int tar_umask = 002;
static int write_tar_filter_archive(const struct archiver *ar,
struct archiver_args *args);
+/*
+ * This is the max value that a ustar size header can specify, as it is fixed
+ * at 11 octal digits. POSIX specifies that we switch to extended headers at
+ * this size.
+ *
+ * Likewise for the mtime (which happens to use a buffer of the same size).
+ */
+#if ULONG_MAX == 0xFFFFFFFF
+#define USTAR_MAX_SIZE ULONG_MAX
+#define USTAR_MAX_MTIME ULONG_MAX
+#else
+#define USTAR_MAX_SIZE 077777777777UL
+#define USTAR_MAX_MTIME 077777777777UL
+#endif
+
/* writes out the whole block, but only if it is full */
static void write_if_needed(void)
{
@@ -137,6 +152,20 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword,
strbuf_addch(sb, '\n');
}
+/*
+ * Like strbuf_append_ext_header, but for numeric values.
+ */
+static void strbuf_append_ext_header_uint(struct strbuf *sb,
+ const char *keyword,
+ uintmax_t value)
+{
+ char buf[40]; /* big enough for 2^128 in decimal, plus NUL */
+ int len;
+
+ len = xsnprintf(buf, sizeof(buf), "%"PRIuMAX, value);
+ strbuf_append_ext_header(sb, keyword, buf, len);
+}
+
static unsigned int ustar_header_chksum(const struct ustar_header *header)
{
const unsigned char *p = (const unsigned char *)header;
@@ -208,7 +237,7 @@ static int write_tar_entry(struct archiver_args *args,
struct ustar_header header;
struct strbuf ext_header = STRBUF_INIT;
unsigned int old_mode = mode;
- unsigned long size;
+ unsigned long size, size_in_header;
void *buffer;
int err = 0;
@@ -267,7 +296,13 @@ static int write_tar_entry(struct archiver_args *args,
memcpy(header.linkname, buffer, size);
}
- prepare_header(args, &header, mode, size);
+ size_in_header = size;
+ if (S_ISREG(mode) && size > USTAR_MAX_SIZE) {
+ size_in_header = 0;
+ strbuf_append_ext_header_uint(&ext_header, "size", size);
+ }
+
+ prepare_header(args, &header, mode, size_in_header);
if (ext_header.len > 0) {
err = write_extended_header(args, sha1, ext_header.buf,
@@ -289,15 +324,25 @@ static int write_tar_entry(struct archiver_args *args,
return err;
}
-static int write_global_extended_header(struct archiver_args *args)
+static void write_global_extended_header(struct archiver_args *args)
{
const unsigned char *sha1 = args->commit_sha1;
struct strbuf ext_header = STRBUF_INIT;
struct ustar_header header;
unsigned int mode;
- int err = 0;
- strbuf_append_ext_header(&ext_header, "comment", sha1_to_hex(sha1), 40);
+ if (sha1)
+ strbuf_append_ext_header(&ext_header, "comment",
+ sha1_to_hex(sha1), 40);
+ if (args->time > USTAR_MAX_MTIME) {
+ strbuf_append_ext_header_uint(&ext_header, "mtime",
+ args->time);
+ args->time = USTAR_MAX_MTIME;
+ }
+
+ if (!ext_header.len)
+ return;
+
memset(&header, 0, sizeof(header));
*header.typeflag = TYPEFLAG_GLOBAL_HEADER;
mode = 0100666;
@@ -306,7 +351,6 @@ static int write_global_extended_header(struct archiver_args *args)
write_blocked(&header, sizeof(header));
write_blocked(ext_header.buf, ext_header.len);
strbuf_release(&ext_header);
- return err;
}
static struct archiver **tar_filters;
@@ -382,10 +426,8 @@ static int write_tar_archive(const struct archiver *ar,
{
int err = 0;
- if (args->commit_sha1)
- err = write_global_extended_header(args);
- if (!err)
- err = write_archive_entries(args, write_tar_entry);
+ write_global_extended_header(args);
+ err = write_archive_entries(args, write_tar_entry);
if (!err)
write_trailer();
return err;
diff --git a/bisect.c b/bisect.c
index 6d93edbcb..b2a75c60c 100644
--- a/bisect.c
+++ b/bisect.c
@@ -438,12 +438,12 @@ static void read_bisect_paths(struct argv_array *array)
FILE *fp = fopen(filename, "r");
if (!fp)
- die_errno("Could not open file '%s'", filename);
+ die_errno(_("Could not open file '%s'"), filename);
while (strbuf_getline_lf(&str, fp) != EOF) {
strbuf_trim(&str);
if (sq_dequote_to_argv_array(str.buf, array))
- die("Badly quoted content in file '%s': %s",
+ die(_("Badly quoted content in file '%s': %s"),
filename, str.buf);
}
@@ -649,7 +649,7 @@ static void exit_if_skipped_commits(struct commit_list *tried,
print_commit_list(tried, "%s\n", "%s\n");
if (bad)
printf("%s\n", oid_to_hex(bad));
- printf("We cannot bisect more!\n");
+ printf(_("We cannot bisect more!\n"));
exit(2);
}
@@ -702,7 +702,7 @@ static struct commit *get_commit_reference(const unsigned char *sha1)
{
struct commit *r = lookup_commit_reference(sha1);
if (!r)
- die("Not a valid commit name %s", sha1_to_hex(sha1));
+ die(_("Not a valid commit name %s"), sha1_to_hex(sha1));
return r;
}
@@ -726,27 +726,27 @@ static void handle_bad_merge_base(void)
char *bad_hex = oid_to_hex(current_bad_oid);
char *good_hex = join_sha1_array_hex(&good_revs, ' ');
if (!strcmp(term_bad, "bad") && !strcmp(term_good, "good")) {
- fprintf(stderr, "The merge base %s is bad.\n"
+ fprintf(stderr, _("The merge base %s is bad.\n"
"This means the bug has been fixed "
- "between %s and [%s].\n",
+ "between %s and [%s].\n"),
bad_hex, bad_hex, good_hex);
} else if (!strcmp(term_bad, "new") && !strcmp(term_good, "old")) {
- fprintf(stderr, "The merge base %s is new.\n"
+ fprintf(stderr, _("The merge base %s is new.\n"
"The property has changed "
- "between %s and [%s].\n",
+ "between %s and [%s].\n"),
bad_hex, bad_hex, good_hex);
} else {
- fprintf(stderr, "The merge base %s is %s.\n"
+ fprintf(stderr, _("The merge base %s is %s.\n"
"This means the first '%s' commit is "
- "between %s and [%s].\n",
+ "between %s and [%s].\n"),
bad_hex, term_bad, term_good, bad_hex, good_hex);
}
exit(3);
}
- fprintf(stderr, "Some %s revs are not ancestor of the %s rev.\n"
+ fprintf(stderr, _("Some %s revs are not ancestor of the %s rev.\n"
"git bisect cannot work properly in this case.\n"
- "Maybe you mistook %s and %s revs?\n",
+ "Maybe you mistook %s and %s revs?\n"),
term_good, term_bad, term_good, term_bad);
exit(1);
}
@@ -757,11 +757,11 @@ static void handle_skipped_merge_base(const unsigned char *mb)
char *bad_hex = sha1_to_hex(current_bad_oid->hash);
char *good_hex = join_sha1_array_hex(&good_revs, ' ');
- warning("the merge base between %s and [%s] "
+ warning(_("the merge base between %s and [%s] "
"must be skipped.\n"
"So we cannot be sure the first %s commit is "
"between %s and %s.\n"
- "We continue anyway.",
+ "We continue anyway."),
bad_hex, good_hex, term_bad, mb_hex, bad_hex);
free(good_hex);
}
@@ -792,7 +792,7 @@ static void check_merge_bases(int no_checkout)
} else if (0 <= sha1_array_lookup(&skipped_revs, mb)) {
handle_skipped_merge_base(mb);
} else {
- printf("Bisecting: a merge base must be tested\n");
+ printf(_("Bisecting: a merge base must be tested\n"));
exit(bisect_checkout(mb, no_checkout));
}
}
@@ -843,7 +843,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
int fd;
if (!current_bad_oid)
- die("a %s revision is needed", term_bad);
+ die(_("a %s revision is needed"), term_bad);
/* Check if file BISECT_ANCESTORS_OK exists. */
if (!stat(filename, &st) && S_ISREG(st.st_mode))
@@ -860,7 +860,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
/* Create file BISECT_ANCESTORS_OK. */
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (fd < 0)
- warning_errno("could not create file '%s'",
+ warning_errno(_("could not create file '%s'"),
filename);
else
close(fd);
@@ -890,6 +890,7 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
if (!opt.diffopt.output_format)
opt.diffopt.output_format = DIFF_FORMAT_RAW;
+ setup_revisions(0, NULL, &opt, NULL);
log_tree_commit(&opt, commit);
}
@@ -910,7 +911,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
*read_good = "good";
return;
} else {
- die_errno("could not read file '%s'", filename);
+ die_errno(_("could not read file '%s'"), filename);
}
} else {
strbuf_getline_lf(&str, fp);
@@ -936,10 +937,11 @@ int bisect_next_all(const char *prefix, int no_checkout)
struct commit_list *tried;
int reaches = 0, all = 0, nr, steps;
const unsigned char *bisect_rev;
+ char steps_msg[32];
read_bisect_terms(&term_bad, &term_good);
if (read_bisect_refs())
- die("reading bisect refs failed");
+ die(_("reading bisect refs failed"));
check_good_are_ancestors_of_bad(prefix, no_checkout);
@@ -959,7 +961,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
*/
exit_if_skipped_commits(tried, NULL);
- printf("%s was both %s and %s\n",
+ printf(_("%s was both %s and %s\n"),
oid_to_hex(current_bad_oid),
term_good,
term_bad);
@@ -967,8 +969,8 @@ int bisect_next_all(const char *prefix, int no_checkout)
}
if (!all) {
- fprintf(stderr, "No testable commit found.\n"
- "Maybe you started with bad path parameters?\n");
+ fprintf(stderr, _("No testable commit found.\n"
+ "Maybe you started with bad path parameters?\n"));
exit(4);
}
@@ -985,9 +987,14 @@ int bisect_next_all(const char *prefix, int no_checkout)
nr = all - reaches - 1;
steps = estimate_bisect_steps(all);
- printf("Bisecting: %d revision%s left to test after this "
- "(roughly %d step%s)\n", nr, (nr == 1 ? "" : "s"),
- steps, (steps == 1 ? "" : "s"));
+ xsnprintf(steps_msg, sizeof(steps_msg),
+ Q_("(roughly %d step)", "(roughly %d steps)", steps),
+ steps);
+ /* TRANSLATORS: the last %s will be replaced with
+ "(roughly %d steps)" translation */
+ printf(Q_("Bisecting: %d revision left to test after this %s\n",
+ "Bisecting: %d revisions left to test after this %s\n",
+ nr), nr, steps_msg);
return bisect_checkout(bisect_rev, no_checkout);
}
diff --git a/builtin/add.c b/builtin/add.c
index 145f06ef9..b1dddb4ac 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -26,7 +26,7 @@ static int patch_interactive, add_interactive, edit_interactive;
static int take_worktree_changes;
struct update_callback_data {
- int flags;
+ int flags, force_mode;
int add_errors;
};
@@ -65,7 +65,8 @@ static void update_callback(struct diff_queue_struct *q,
die(_("unexpected diff status %c"), p->status);
case DIFF_STATUS_MODIFIED:
case DIFF_STATUS_TYPE_CHANGED:
- if (add_file_to_index(&the_index, path, data->flags)) {
+ if (add_file_to_index(&the_index, path,
+ data->flags, data->force_mode)) {
if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
die(_("updating files failed"));
data->add_errors++;
@@ -83,14 +84,15 @@ static void update_callback(struct diff_queue_struct *q,
}
}
-int add_files_to_cache(const char *prefix,
- const struct pathspec *pathspec, int flags)
+int add_files_to_cache(const char *prefix, const struct pathspec *pathspec,
+ int flags, int force_mode)
{
struct update_callback_data data;
struct rev_info rev;
memset(&data, 0, sizeof(data));
data.flags = flags;
+ data.force_mode = force_mode;
init_revisions(&rev, prefix);
setup_revisions(0, NULL, &rev, NULL);
@@ -238,6 +240,8 @@ static int ignore_add_errors, intent_to_add, ignore_missing;
static int addremove = ADDREMOVE_DEFAULT;
static int addremove_explicit = -1; /* unspecified */
+static char *chmod_arg;
+
static int ignore_removal_cb(const struct option *opt, const char *arg, int unset)
{
/* if we are told to ignore, we are not adding removals */
@@ -263,6 +267,7 @@ static struct option builtin_add_options[] = {
OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
+ OPT_STRING( 0 , "chmod", &chmod_arg, N_("(+/-)x"), N_("override the executable bit of the listed files")),
OPT_END(),
};
@@ -276,7 +281,7 @@ static int add_config(const char *var, const char *value, void *cb)
return git_default_config(var, value, cb);
}
-static int add_files(struct dir_struct *dir, int flags)
+static int add_files(struct dir_struct *dir, int flags, int force_mode)
{
int i, exit_status = 0;
@@ -289,7 +294,8 @@ static int add_files(struct dir_struct *dir, int flags)
}
for (i = 0; i < dir->nr; i++)
- if (add_file_to_cache(dir->entries[i]->name, flags)) {
+ if (add_file_to_index(&the_index, dir->entries[i]->name,
+ flags, force_mode)) {
if (!ignore_add_errors)
die(_("adding files failed"));
exit_status = 1;
@@ -302,7 +308,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int exit_status = 0;
struct pathspec pathspec;
struct dir_struct dir;
- int flags;
+ int flags, force_mode;
int add_new_files;
int require_pathspec;
char *seen = NULL;
@@ -336,6 +342,15 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (!show_only && ignore_missing)
die(_("Option --ignore-missing can only be used together with --dry-run"));
+ if (!chmod_arg)
+ force_mode = 0;
+ else if (!strcmp(chmod_arg, "-x"))
+ force_mode = 0666;
+ else if (!strcmp(chmod_arg, "+x"))
+ force_mode = 0777;
+ else
+ die(_("--chmod param '%s' must be either -x or +x"), chmod_arg);
+
add_new_files = !take_worktree_changes && !refresh_only;
require_pathspec = !(take_worktree_changes || (0 < addremove_explicit));
@@ -426,10 +441,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
plug_bulk_checkin();
- exit_status |= add_files_to_cache(prefix, &pathspec, flags);
+ exit_status |= add_files_to_cache(prefix, &pathspec, flags, force_mode);
if (add_new_files)
- exit_status |= add_files(&dir, flags);
+ exit_status |= add_files(&dir, flags, force_mode);
unplug_bulk_checkin();
diff --git a/builtin/am.c b/builtin/am.c
index 3dfe70b7a..d5da5fe09 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -70,7 +70,8 @@ enum patch_format {
PATCH_FORMAT_MBOX,
PATCH_FORMAT_STGIT,
PATCH_FORMAT_STGIT_SERIES,
- PATCH_FORMAT_HG
+ PATCH_FORMAT_HG,
+ PATCH_FORMAT_MBOXRD
};
enum keep_type {
@@ -712,7 +713,8 @@ done:
* Splits out individual email patches from `paths`, where each path is either
* a mbox file or a Maildir. Returns 0 on success, -1 on failure.
*/
-static int split_mail_mbox(struct am_state *state, const char **paths, int keep_cr)
+static int split_mail_mbox(struct am_state *state, const char **paths,
+ int keep_cr, int mboxrd)
{
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf last = STRBUF_INIT;
@@ -724,6 +726,8 @@ static int split_mail_mbox(struct am_state *state, const char **paths, int keep_
argv_array_push(&cp.args, "-b");
if (keep_cr)
argv_array_push(&cp.args, "--keep-cr");
+ if (mboxrd)
+ argv_array_push(&cp.args, "--mboxrd");
argv_array_push(&cp.args, "--");
argv_array_pushv(&cp.args, paths);
@@ -965,13 +969,15 @@ static int split_mail(struct am_state *state, enum patch_format patch_format,
switch (patch_format) {
case PATCH_FORMAT_MBOX:
- return split_mail_mbox(state, paths, keep_cr);
+ return split_mail_mbox(state, paths, keep_cr, 0);
case PATCH_FORMAT_STGIT:
return split_mail_conv(stgit_patch_to_mail, state, paths, keep_cr);
case PATCH_FORMAT_STGIT_SERIES:
return split_mail_stgit_series(state, paths, keep_cr);
case PATCH_FORMAT_HG:
return split_mail_conv(hg_patch_to_mail, state, paths, keep_cr);
+ case PATCH_FORMAT_MBOXRD:
+ return split_mail_mbox(state, paths, keep_cr, 1);
default:
die("BUG: invalid patch_format");
}
@@ -2201,6 +2207,8 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
*opt_value = PATCH_FORMAT_STGIT_SERIES;
else if (!strcmp(arg, "hg"))
*opt_value = PATCH_FORMAT_HG;
+ else if (!strcmp(arg, "mboxrd"))
+ *opt_value = PATCH_FORMAT_MBOXRD;
else
return error(_("Invalid value for --patch-format: %s"), arg);
return 0;
diff --git a/builtin/apply.c b/builtin/apply.c
index c770d7d3d..1a488f9e8 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -21,132 +21,161 @@
#include "ll-merge.h"
#include "rerere.h"
-/*
- * --check turns on checking that the working tree matches the
- * files that are being modified, but doesn't apply the patch
- * --stat does just a diffstat, and doesn't actually apply
- * --numstat does numeric diffstat, and doesn't actually apply
- * --index-info shows the old and new index info for paths if available.
- * --index updates the cache as well.
- * --cached updates only the cache without ever touching the working tree.
- */
-static const char *prefix;
-static int prefix_length = -1;
-static int newfd = -1;
-
-static int unidiff_zero;
-static int p_value = 1;
-static int p_value_known;
-static int check_index;
-static int update_index;
-static int cached;
-static int diffstat;
-static int numstat;
-static int summary;
-static int check;
-static int apply = 1;
-static int apply_in_reverse;
-static int apply_with_reject;
-static int apply_verbosely;
-static int allow_overlap;
-static int no_add;
-static int threeway;
-static int unsafe_paths;
-static const char *fake_ancestor;
-static int line_termination = '\n';
-static unsigned int p_context = UINT_MAX;
-static const char * const apply_usage[] = {
- N_("git apply [<options>] [<patch>...]"),
- NULL
-};
-
-static enum ws_error_action {
+enum ws_error_action {
nowarn_ws_error,
warn_on_ws_error,
die_on_ws_error,
correct_ws_error
-} ws_error_action = warn_on_ws_error;
-static int whitespace_error;
-static int squelch_whitespace_errors = 5;
-static int applied_after_fixing_ws;
+};
+
-static enum ws_ignore {
+enum ws_ignore {
ignore_ws_none,
ignore_ws_change
-} ws_ignore_action = ignore_ws_none;
+};
+
+/*
+ * We need to keep track of how symlinks in the preimage are
+ * manipulated by the patches. A patch to add a/b/c where a/b
+ * is a symlink should not be allowed to affect the directory
+ * the symlink points at, but if the same patch removes a/b,
+ * it is perfectly fine, as the patch removes a/b to make room
+ * to create a directory a/b so that a/b/c can be created.
+ *
+ * See also "struct string_list symlink_changes" in "struct
+ * apply_state".
+ */
+#define SYMLINK_GOES_AWAY 01
+#define SYMLINK_IN_RESULT 02
+struct apply_state {
+ const char *prefix;
+ int prefix_length;
+
+ /* These are lock_file related */
+ struct lock_file *lock_file;
+ int newfd;
+
+ /* These control what gets looked at and modified */
+ int apply; /* this is not a dry-run */
+ int cached; /* apply to the index only */
+ int check; /* preimage must match working tree, don't actually apply */
+ int check_index; /* preimage must match the indexed version */
+ int update_index; /* check_index && apply */
+
+ /* These control cosmetic aspect of the output */
+ int diffstat; /* just show a diffstat, and don't actually apply */
+ int numstat; /* just show a numeric diffstat, and don't actually apply */
+ int summary; /* just report creation, deletion, etc, and don't actually apply */
+
+ /* These boolean parameters control how the apply is done */
+ int allow_overlap;
+ int apply_in_reverse;
+ int apply_with_reject;
+ int apply_verbosely;
+ int no_add;
+ int threeway;
+ int unidiff_zero;
+ int unsafe_paths;
+
+ /* Other non boolean parameters */
+ const char *fake_ancestor;
+ const char *patch_input_file;
+ int line_termination;
+ struct strbuf root;
+ int p_value;
+ int p_value_known;
+ unsigned int p_context;
+
+ /* Exclude and include path parameters */
+ struct string_list limit_by_name;
+ int has_include;
+
+ /* Various "current state" */
+ int linenr; /* current line number */
+ struct string_list symlink_changes; /* we have to track symlinks */
-static const char *patch_input_file;
-static struct strbuf root = STRBUF_INIT;
-static int read_stdin = 1;
-static int options;
+ /*
+ * For "diff-stat" like behaviour, we keep track of the biggest change
+ * we've seen, and the longest filename. That allows us to do simple
+ * scaling.
+ */
+ int max_change;
+ int max_len;
-static void parse_whitespace_option(const char *option)
+ /*
+ * Records filenames that have been touched, in order to handle
+ * the case where more than one patches touch the same file.
+ */
+ struct string_list fn_table;
+
+ /* These control whitespace errors */
+ enum ws_error_action ws_error_action;
+ enum ws_ignore ws_ignore_action;
+ const char *whitespace_option;
+ int whitespace_error;
+ int squelch_whitespace_errors;
+ int applied_after_fixing_ws;
+};
+
+static const char * const apply_usage[] = {
+ N_("git apply [<options>] [<patch>...]"),
+ NULL
+};
+
+static void parse_whitespace_option(struct apply_state *state, const char *option)
{
if (!option) {
- ws_error_action = warn_on_ws_error;
+ state->ws_error_action = warn_on_ws_error;
return;
}
if (!strcmp(option, "warn")) {
- ws_error_action = warn_on_ws_error;
+ state->ws_error_action = warn_on_ws_error;
return;
}
if (!strcmp(option, "nowarn")) {
- ws_error_action = nowarn_ws_error;
+ state->ws_error_action = nowarn_ws_error;
return;
}
if (!strcmp(option, "error")) {
- ws_error_action = die_on_ws_error;
+ state->ws_error_action = die_on_ws_error;
return;
}
if (!strcmp(option, "error-all")) {
- ws_error_action = die_on_ws_error;
- squelch_whitespace_errors = 0;
+ state->ws_error_action = die_on_ws_error;
+ state->squelch_whitespace_errors = 0;
return;
}
if (!strcmp(option, "strip") || !strcmp(option, "fix")) {
- ws_error_action = correct_ws_error;
+ state->ws_error_action = correct_ws_error;
return;
}
die(_("unrecognized whitespace option '%s'"), option);
}
-static void parse_ignorewhitespace_option(const char *option)
+static void parse_ignorewhitespace_option(struct apply_state *state,
+ const char *option)
{
if (!option || !strcmp(option, "no") ||
!strcmp(option, "false") || !strcmp(option, "never") ||
!strcmp(option, "none")) {
- ws_ignore_action = ignore_ws_none;
+ state->ws_ignore_action = ignore_ws_none;
return;
}
if (!strcmp(option, "change")) {
- ws_ignore_action = ignore_ws_change;
+ state->ws_ignore_action = ignore_ws_change;
return;
}
die(_("unrecognized whitespace ignore option '%s'"), option);
}
-static void set_default_whitespace_mode(const char *whitespace_option)
+static void set_default_whitespace_mode(struct apply_state *state)
{
- if (!whitespace_option && !apply_default_whitespace)
- ws_error_action = (apply ? warn_on_ws_error : nowarn_ws_error);
+ if (!state->whitespace_option && !apply_default_whitespace)
+ state->ws_error_action = (state->apply ? warn_on_ws_error : nowarn_ws_error);
}
/*
- * For "diff-stat" like behaviour, we keep track of the biggest change
- * we've seen, and the longest filename. That allows us to do simple
- * scaling.
- */
-static int max_change, max_len;
-
-/*
- * Various "current state", notably line numbers and what
- * file (and how) we're patching right now.. The "is_xxxx"
- * things are flags, where -1 means "don't know yet".
- */
-static int linenr = 1;
-
-/*
* This represents one "hunk" from a patch, starting with
* "@@ -oldpos,oldlines +newpos,newlines @@" marker. The
* patch text is pointed at by patch, and its byte length
@@ -265,13 +294,6 @@ struct image {
struct line *line;
};
-/*
- * Records filenames that have been touched, in order to handle
- * the case where more than one patches touch the same file.
- */
-
-static struct string_list fn_table;
-
static uint32_t hash_line(const char *cp, size_t len)
{
size_t i;
@@ -469,7 +491,10 @@ static char *squash_slash(char *name)
return name;
}
-static char *find_name_gnu(const char *line, const char *def, int p_value)
+static char *find_name_gnu(struct apply_state *state,
+ const char *line,
+ const char *def,
+ int p_value)
{
struct strbuf name = STRBUF_INIT;
char *cp;
@@ -493,8 +518,8 @@ static char *find_name_gnu(const char *line, const char *def, int p_value)
}
strbuf_remove(&name, 0, cp - name.buf);
- if (root.len)
- strbuf_insert(&name, 0, root.buf, root.len);
+ if (state->root.len)
+ strbuf_insert(&name, 0, state->root.buf, state->root.len);
return squash_slash(strbuf_detach(&name, NULL));
}
@@ -657,8 +682,12 @@ static size_t diff_timestamp_len(const char *line, size_t len)
return line + len - end;
}
-static char *find_name_common(const char *line, const char *def,
- int p_value, const char *end, int terminate)
+static char *find_name_common(struct apply_state *state,
+ const char *line,
+ const char *def,
+ int p_value,
+ const char *end,
+ int terminate)
{
int len;
const char *start = NULL;
@@ -696,32 +725,39 @@ static char *find_name_common(const char *line, const char *def,
return squash_slash(xstrdup(def));
}
- if (root.len) {
- char *ret = xstrfmt("%s%.*s", root.buf, len, start);
+ if (state->root.len) {
+ char *ret = xstrfmt("%s%.*s", state->root.buf, len, start);
return squash_slash(ret);
}
return squash_slash(xmemdupz(start, len));
}
-static char *find_name(const char *line, char *def, int p_value, int terminate)
+static char *find_name(struct apply_state *state,
+ const char *line,
+ char *def,
+ int p_value,
+ int terminate)
{
if (*line == '"') {
- char *name = find_name_gnu(line, def, p_value);
+ char *name = find_name_gnu(state, line, def, p_value);
if (name)
return name;
}
- return find_name_common(line, def, p_value, NULL, terminate);
+ return find_name_common(state, line, def, p_value, NULL, terminate);
}
-static char *find_name_traditional(const char *line, char *def, int p_value)
+static char *find_name_traditional(struct apply_state *state,
+ const char *line,
+ char *def,
+ int p_value)
{
size_t len;
size_t date_len;
if (*line == '"') {
- char *name = find_name_gnu(line, def, p_value);
+ char *name = find_name_gnu(state, line, def, p_value);
if (name)
return name;
}
@@ -729,10 +765,10 @@ static char *find_name_traditional(const char *line, char *def, int p_value)
len = strchrnul(line, '\n') - line;
date_len = diff_timestamp_len(line, len);
if (!date_len)
- return find_name_common(line, def, p_value, NULL, TERM_TAB);
+ return find_name_common(state, line, def, p_value, NULL, TERM_TAB);
len -= date_len;
- return find_name_common(line, def, p_value, line + len, 0);
+ return find_name_common(state, line, def, p_value, line + len, 0);
}
static int count_slashes(const char *cp)
@@ -750,30 +786,30 @@ static int count_slashes(const char *cp)
* Given the string after "--- " or "+++ ", guess the appropriate
* p_value for the given patch.
*/
-static int guess_p_value(const char *nameline)
+static int guess_p_value(struct apply_state *state, const char *nameline)
{
char *name, *cp;
int val = -1;
if (is_dev_null(nameline))
return -1;
- name = find_name_traditional(nameline, NULL, 0);
+ name = find_name_traditional(state, nameline, NULL, 0);
if (!name)
return -1;
cp = strchr(name, '/');
if (!cp)
val = 0;
- else if (prefix) {
+ else if (state->prefix) {
/*
* Does it begin with "a/$our-prefix" and such? Then this is
* very likely to apply to our directory.
*/
- if (!strncmp(name, prefix, prefix_length))
- val = count_slashes(prefix);
+ if (!strncmp(name, state->prefix, state->prefix_length))
+ val = count_slashes(state->prefix);
else {
cp++;
- if (!strncmp(cp, prefix, prefix_length))
- val = count_slashes(prefix) + 1;
+ if (!strncmp(cp, state->prefix, state->prefix_length))
+ val = count_slashes(state->prefix) + 1;
}
}
free(name);
@@ -860,36 +896,39 @@ static int has_epoch_timestamp(const char *nameline)
* files, we can happily check the index for a match, but for creating a
* new file we should try to match whatever "patch" does. I have no idea.
*/
-static void parse_traditional_patch(const char *first, const char *second, struct patch *patch)
+static void parse_traditional_patch(struct apply_state *state,
+ const char *first,
+ const char *second,
+ struct patch *patch)
{
char *name;
first += 4; /* skip "--- " */
second += 4; /* skip "+++ " */
- if (!p_value_known) {
+ if (!state->p_value_known) {
int p, q;
- p = guess_p_value(first);
- q = guess_p_value(second);
+ p = guess_p_value(state, first);
+ q = guess_p_value(state, second);
if (p < 0) p = q;
if (0 <= p && p == q) {
- p_value = p;
- p_value_known = 1;
+ state->p_value = p;
+ state->p_value_known = 1;
}
}
if (is_dev_null(first)) {
patch->is_new = 1;
patch->is_delete = 0;
- name = find_name_traditional(second, NULL, p_value);
+ name = find_name_traditional(state, second, NULL, state->p_value);
patch->new_name = name;
} else if (is_dev_null(second)) {
patch->is_new = 0;
patch->is_delete = 1;
- name = find_name_traditional(first, NULL, p_value);
+ name = find_name_traditional(state, first, NULL, state->p_value);
patch->old_name = name;
} else {
char *first_name;
- first_name = find_name_traditional(first, NULL, p_value);
- name = find_name_traditional(second, first_name, p_value);
+ first_name = find_name_traditional(state, first, NULL, state->p_value);
+ name = find_name_traditional(state, second, first_name, state->p_value);
free(first_name);
if (has_epoch_timestamp(first)) {
patch->is_new = 1;
@@ -905,10 +944,12 @@ static void parse_traditional_patch(const char *first, const char *second, struc
}
}
if (!name)
- die(_("unable to find filename in patch at line %d"), linenr);
+ die(_("unable to find filename in patch at line %d"), state->linenr);
}
-static int gitdiff_hdrend(const char *line, struct patch *patch)
+static int gitdiff_hdrend(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
return -1;
}
@@ -925,107 +966,135 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
#define DIFF_OLD_NAME 0
#define DIFF_NEW_NAME 1
-static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, int side)
+static void gitdiff_verify_name(struct apply_state *state,
+ const char *line,
+ int isnull,
+ char **name,
+ int side)
{
- if (!orig_name && !isnull)
- return find_name(line, NULL, p_value, TERM_TAB);
+ if (!*name && !isnull) {
+ *name = find_name(state, line, NULL, state->p_value, TERM_TAB);
+ return;
+ }
- if (orig_name) {
- int len = strlen(orig_name);
+ if (*name) {
+ int len = strlen(*name);
char *another;
if (isnull)
die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"),
- orig_name, linenr);
- another = find_name(line, NULL, p_value, TERM_TAB);
- if (!another || memcmp(another, orig_name, len + 1))
+ *name, state->linenr);
+ another = find_name(state, line, NULL, state->p_value, TERM_TAB);
+ if (!another || memcmp(another, *name, len + 1))
die((side == DIFF_NEW_NAME) ?
_("git apply: bad git-diff - inconsistent new filename on line %d") :
- _("git apply: bad git-diff - inconsistent old filename on line %d"), linenr);
+ _("git apply: bad git-diff - inconsistent old filename on line %d"), state->linenr);
free(another);
- return orig_name;
} else {
/* expect "/dev/null" */
if (memcmp("/dev/null", line, 9) || line[9] != '\n')
- die(_("git apply: bad git-diff - expected /dev/null on line %d"), linenr);
- return NULL;
+ die(_("git apply: bad git-diff - expected /dev/null on line %d"), state->linenr);
}
}
-static int gitdiff_oldname(const char *line, struct patch *patch)
+static int gitdiff_oldname(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
- patch->old_name = gitdiff_verify_name(line, patch->is_new, patch->old_name,
- DIFF_OLD_NAME);
+ gitdiff_verify_name(state, line,
+ patch->is_new, &patch->old_name,
+ DIFF_OLD_NAME);
return 0;
}
-static int gitdiff_newname(const char *line, struct patch *patch)
+static int gitdiff_newname(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
- patch->new_name = gitdiff_verify_name(line, patch->is_delete, patch->new_name,
- DIFF_NEW_NAME);
+ gitdiff_verify_name(state, line,
+ patch->is_delete, &patch->new_name,
+ DIFF_NEW_NAME);
return 0;
}
-static int gitdiff_oldmode(const char *line, struct patch *patch)
+static int gitdiff_oldmode(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->old_mode = strtoul(line, NULL, 8);
return 0;
}
-static int gitdiff_newmode(const char *line, struct patch *patch)
+static int gitdiff_newmode(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->new_mode = strtoul(line, NULL, 8);
return 0;
}
-static int gitdiff_delete(const char *line, struct patch *patch)
+static int gitdiff_delete(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->is_delete = 1;
free(patch->old_name);
patch->old_name = xstrdup_or_null(patch->def_name);
- return gitdiff_oldmode(line, patch);
+ return gitdiff_oldmode(state, line, patch);
}
-static int gitdiff_newfile(const char *line, struct patch *patch)
+static int gitdiff_newfile(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->is_new = 1;
free(patch->new_name);
patch->new_name = xstrdup_or_null(patch->def_name);
- return gitdiff_newmode(line, patch);
+ return gitdiff_newmode(state, line, patch);
}
-static int gitdiff_copysrc(const char *line, struct patch *patch)
+static int gitdiff_copysrc(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->is_copy = 1;
free(patch->old_name);
- patch->old_name = find_name(line, NULL, p_value ? p_value - 1 : 0, 0);
+ patch->old_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0);
return 0;
}
-static int gitdiff_copydst(const char *line, struct patch *patch)
+static int gitdiff_copydst(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->is_copy = 1;
free(patch->new_name);
- patch->new_name = find_name(line, NULL, p_value ? p_value - 1 : 0, 0);
+ patch->new_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0);
return 0;
}
-static int gitdiff_renamesrc(const char *line, struct patch *patch)
+static int gitdiff_renamesrc(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->is_rename = 1;
free(patch->old_name);
- patch->old_name = find_name(line, NULL, p_value ? p_value - 1 : 0, 0);
+ patch->old_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0);
return 0;
}
-static int gitdiff_renamedst(const char *line, struct patch *patch)
+static int gitdiff_renamedst(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
patch->is_rename = 1;
free(patch->new_name);
- patch->new_name = find_name(line, NULL, p_value ? p_value - 1 : 0, 0);
+ patch->new_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0);
return 0;
}
-static int gitdiff_similarity(const char *line, struct patch *patch)
+static int gitdiff_similarity(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
unsigned long val = strtoul(line, NULL, 10);
if (val <= 100)
@@ -1033,7 +1102,9 @@ static int gitdiff_similarity(const char *line, struct patch *patch)
return 0;
}
-static int gitdiff_dissimilarity(const char *line, struct patch *patch)
+static int gitdiff_dissimilarity(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
unsigned long val = strtoul(line, NULL, 10);
if (val <= 100)
@@ -1041,7 +1112,9 @@ static int gitdiff_dissimilarity(const char *line, struct patch *patch)
return 0;
}
-static int gitdiff_index(const char *line, struct patch *patch)
+static int gitdiff_index(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
/*
* index line is N hexadecimal, "..", N hexadecimal,
@@ -1078,7 +1151,9 @@ static int gitdiff_index(const char *line, struct patch *patch)
* This is normal for a diff that doesn't change anything: we'll fall through
* into the next diff. Tell the parser to break out.
*/
-static int gitdiff_unrecognized(const char *line, struct patch *patch)
+static int gitdiff_unrecognized(struct apply_state *state,
+ const char *line,
+ struct patch *patch)
{
return -1;
}
@@ -1087,15 +1162,17 @@ static int gitdiff_unrecognized(const char *line, struct patch *patch)
* Skip p_value leading components from "line"; as we do not accept
* absolute paths, return NULL in that case.
*/
-static const char *skip_tree_prefix(const char *line, int llen)
+static const char *skip_tree_prefix(struct apply_state *state,
+ const char *line,
+ int llen)
{
int nslash;
int i;
- if (!p_value)
+ if (!state->p_value)
return (llen && line[0] == '/') ? NULL : line;
- nslash = p_value;
+ nslash = state->p_value;
for (i = 0; i < llen; i++) {
int ch = line[i];
if (ch == '/' && --nslash <= 0)
@@ -1112,7 +1189,9 @@ static const char *skip_tree_prefix(const char *line, int llen)
* creation or deletion of an empty file. In any of these cases,
* both sides are the same name under a/ and b/ respectively.
*/
-static char *git_header_name(const char *line, int llen)
+static char *git_header_name(struct apply_state *state,
+ const char *line,
+ int llen)
{
const char *name;
const char *second = NULL;
@@ -1130,7 +1209,7 @@ static char *git_header_name(const char *line, int llen)
goto free_and_fail1;
/* strip the a/b prefix including trailing slash */
- cp = skip_tree_prefix(first.buf, first.len);
+ cp = skip_tree_prefix(state, first.buf, first.len);
if (!cp)
goto free_and_fail1;
strbuf_remove(&first, 0, cp - first.buf);
@@ -1147,7 +1226,7 @@ static char *git_header_name(const char *line, int llen)
if (*second == '"') {
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail1;
- cp = skip_tree_prefix(sp.buf, sp.len);
+ cp = skip_tree_prefix(state, sp.buf, sp.len);
if (!cp)
goto free_and_fail1;
/* They must match, otherwise ignore */
@@ -1158,7 +1237,7 @@ static char *git_header_name(const char *line, int llen)
}
/* unquoted second */
- cp = skip_tree_prefix(second, line + llen - second);
+ cp = skip_tree_prefix(state, second, line + llen - second);
if (!cp)
goto free_and_fail1;
if (line + llen - cp != first.len ||
@@ -1173,7 +1252,7 @@ static char *git_header_name(const char *line, int llen)
}
/* unquoted first name */
- name = skip_tree_prefix(line, llen);
+ name = skip_tree_prefix(state, line, llen);
if (!name)
return NULL;
@@ -1189,7 +1268,7 @@ static char *git_header_name(const char *line, int llen)
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail2;
- np = skip_tree_prefix(sp.buf, sp.len);
+ np = skip_tree_prefix(state, sp.buf, sp.len);
if (!np)
goto free_and_fail2;
@@ -1233,7 +1312,7 @@ static char *git_header_name(const char *line, int llen)
*/
if (!name[len + 1])
return NULL; /* no postimage name */
- second = skip_tree_prefix(name + len + 1,
+ second = skip_tree_prefix(state, name + len + 1,
line_len - (len + 1));
if (!second)
return NULL;
@@ -1249,7 +1328,11 @@ static char *git_header_name(const char *line, int llen)
}
/* Verify that we recognize the lines following a git header */
-static int parse_git_header(const char *line, int len, unsigned int size, struct patch *patch)
+static int parse_git_header(struct apply_state *state,
+ const char *line,
+ int len,
+ unsigned int size,
+ struct patch *patch)
{
unsigned long offset;
@@ -1263,20 +1346,20 @@ static int parse_git_header(const char *line, int len, unsigned int size, struct
* or removing or adding empty files), so we get
* the default name from the header.
*/
- patch->def_name = git_header_name(line, len);
- if (patch->def_name && root.len) {
- char *s = xstrfmt("%s%s", root.buf, patch->def_name);
+ patch->def_name = git_header_name(state, line, len);
+ if (patch->def_name && state->root.len) {
+ char *s = xstrfmt("%s%s", state->root.buf, patch->def_name);
free(patch->def_name);
patch->def_name = s;
}
line += len;
size -= len;
- linenr++;
- for (offset = len ; size > 0 ; offset += len, size -= len, line += len, linenr++) {
+ state->linenr++;
+ for (offset = len ; size > 0 ; offset += len, size -= len, line += len, state->linenr++) {
static const struct opentry {
const char *str;
- int (*fn)(const char *, struct patch *);
+ int (*fn)(struct apply_state *, const char *, struct patch *);
} optable[] = {
{ "@@ -", gitdiff_hdrend },
{ "--- ", gitdiff_oldname },
@@ -1306,7 +1389,7 @@ static int parse_git_header(const char *line, int len, unsigned int size, struct
int oplen = strlen(p->str);
if (len < oplen || memcmp(p->str, line, oplen))
continue;
- if (p->fn(line + oplen, patch) < 0)
+ if (p->fn(state, line + oplen, patch) < 0)
return offset;
break;
}
@@ -1431,7 +1514,11 @@ static int parse_fragment_header(const char *line, int len, struct fragment *fra
return offset;
}
-static int find_header(const char *line, unsigned long size, int *hdrsize, struct patch *patch)
+static int find_header(struct apply_state *state,
+ const char *line,
+ unsigned long size,
+ int *hdrsize,
+ struct patch *patch)
{
unsigned long offset, len;
@@ -1440,7 +1527,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
patch->is_new = patch->is_delete = -1;
patch->old_mode = patch->new_mode = 0;
patch->old_name = patch->new_name = NULL;
- for (offset = 0; size > 0; offset += len, size -= len, line += len, linenr++) {
+ for (offset = 0; size > 0; offset += len, size -= len, line += len, state->linenr++) {
unsigned long nextlen;
len = linelen(line, size);
@@ -1461,7 +1548,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
if (parse_fragment_header(line, len, &dummy) < 0)
continue;
die(_("patch fragment without header at line %d: %.*s"),
- linenr, (int)len-1, line);
+ state->linenr, (int)len-1, line);
}
if (size < len + 6)
@@ -1472,7 +1559,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
* or mode change, so we handle that specially
*/
if (!memcmp("diff --git ", line, 11)) {
- int git_hdr_len = parse_git_header(line, len, size, patch);
+ int git_hdr_len = parse_git_header(state, line, len, size, patch);
if (git_hdr_len <= len)
continue;
if (!patch->old_name && !patch->new_name) {
@@ -1481,14 +1568,14 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
"%d leading pathname component (line %d)",
"git diff header lacks filename information when removing "
"%d leading pathname components (line %d)",
- p_value),
- p_value, linenr);
+ state->p_value),
+ state->p_value, state->linenr);
patch->old_name = xstrdup(patch->def_name);
patch->new_name = xstrdup(patch->def_name);
}
if (!patch->is_delete && !patch->new_name)
die("git diff header lacks filename information "
- "(line %d)", linenr);
+ "(line %d)", state->linenr);
patch->is_toplevel_relative = 1;
*hdrsize = git_hdr_len;
return offset;
@@ -1508,37 +1595,44 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
continue;
/* Ok, we'll consider it a patch */
- parse_traditional_patch(line, line+len, patch);
+ parse_traditional_patch(state, line, line+len, patch);
*hdrsize = len + nextlen;
- linenr += 2;
+ state->linenr += 2;
return offset;
}
return -1;
}
-static void record_ws_error(unsigned result, const char *line, int len, int linenr)
+static void record_ws_error(struct apply_state *state,
+ unsigned result,
+ const char *line,
+ int len,
+ int linenr)
{
char *err;
if (!result)
return;
- whitespace_error++;
- if (squelch_whitespace_errors &&
- squelch_whitespace_errors < whitespace_error)
+ state->whitespace_error++;
+ if (state->squelch_whitespace_errors &&
+ state->squelch_whitespace_errors < state->whitespace_error)
return;
err = whitespace_error_string(result);
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
- patch_input_file, linenr, err, len, line);
+ state->patch_input_file, linenr, err, len, line);
free(err);
}
-static void check_whitespace(const char *line, int len, unsigned ws_rule)
+static void check_whitespace(struct apply_state *state,
+ const char *line,
+ int len,
+ unsigned ws_rule)
{
unsigned result = ws_check(line + 1, len - 1, ws_rule);
- record_ws_error(result, line + 1, len - 2, linenr);
+ record_ws_error(state, result, line + 1, len - 2, state->linenr);
}
/*
@@ -1547,8 +1641,11 @@ static void check_whitespace(const char *line, int len, unsigned ws_rule)
* between a "---" that is part of a patch, and a "---" that starts
* the next patch is to look at the line counts..
*/
-static int parse_fragment(const char *line, unsigned long size,
- struct patch *patch, struct fragment *fragment)
+static int parse_fragment(struct apply_state *state,
+ const char *line,
+ unsigned long size,
+ struct patch *patch,
+ struct fragment *fragment)
{
int added, deleted;
int len = linelen(line, size), offset;
@@ -1568,11 +1665,11 @@ static int parse_fragment(const char *line, unsigned long size,
/* Parse the thing.. */
line += len;
size -= len;
- linenr++;
+ state->linenr++;
added = deleted = 0;
for (offset = len;
0 < size;
- offset += len, size -= len, line += len, linenr++) {
+ offset += len, size -= len, line += len, state->linenr++) {
if (!oldlines && !newlines)
break;
len = linelen(line, size);
@@ -1588,22 +1685,22 @@ static int parse_fragment(const char *line, unsigned long size,
if (!deleted && !added)
leading++;
trailing++;
- if (!apply_in_reverse &&
- ws_error_action == correct_ws_error)
- check_whitespace(line, len, patch->ws_rule);
+ if (!state->apply_in_reverse &&
+ state->ws_error_action == correct_ws_error)
+ check_whitespace(state, line, len, patch->ws_rule);
break;
case '-':
- if (apply_in_reverse &&
- ws_error_action != nowarn_ws_error)
- check_whitespace(line, len, patch->ws_rule);
+ if (state->apply_in_reverse &&
+ state->ws_error_action != nowarn_ws_error)
+ check_whitespace(state, line, len, patch->ws_rule);
deleted++;
oldlines--;
trailing = 0;
break;
case '+':
- if (!apply_in_reverse &&
- ws_error_action != nowarn_ws_error)
- check_whitespace(line, len, patch->ws_rule);
+ if (!state->apply_in_reverse &&
+ state->ws_error_action != nowarn_ws_error)
+ check_whitespace(state, line, len, patch->ws_rule);
added++;
newlines--;
trailing = 0;
@@ -1657,7 +1754,10 @@ static int parse_fragment(const char *line, unsigned long size,
* The (fragment->patch, fragment->size) pair points into the memory given
* by the caller, not a copy, when we return.
*/
-static int parse_single_patch(const char *line, unsigned long size, struct patch *patch)
+static int parse_single_patch(struct apply_state *state,
+ const char *line,
+ unsigned long size,
+ struct patch *patch)
{
unsigned long offset = 0;
unsigned long oldlines = 0, newlines = 0, context = 0;
@@ -1668,10 +1768,10 @@ static int parse_single_patch(const char *line, unsigned long size, struct patch
int len;
fragment = xcalloc(1, sizeof(*fragment));
- fragment->linenr = linenr;
- len = parse_fragment(line, size, patch, fragment);
+ fragment->linenr = state->linenr;
+ len = parse_fragment(state, line, size, patch, fragment);
if (len <= 0)
- die(_("corrupt patch at line %d"), linenr);
+ die(_("corrupt patch at line %d"), state->linenr);
fragment->patch = line;
fragment->size = len;
oldlines += fragment->oldlines;
@@ -1757,7 +1857,8 @@ static char *inflate_it(const void *data, unsigned long size,
* points at an allocated memory that the caller must free, so
* it is marked as "->free_patch = 1".
*/
-static struct fragment *parse_binary_hunk(char **buf_p,
+static struct fragment *parse_binary_hunk(struct apply_state *state,
+ char **buf_p,
unsigned long *sz_p,
int *status_p,
int *used_p)
@@ -1799,13 +1900,13 @@ static struct fragment *parse_binary_hunk(char **buf_p,
else
return NULL;
- linenr++;
+ state->linenr++;
buffer += llen;
while (1) {
int byte_length, max_byte_length, newsize;
llen = linelen(buffer, size);
used += llen;
- linenr++;
+ state->linenr++;
if (llen == 1) {
/* consume the blank line */
buffer++;
@@ -1859,7 +1960,7 @@ static struct fragment *parse_binary_hunk(char **buf_p,
free(data);
*status_p = -1;
error(_("corrupt binary patch at line %d: %.*s"),
- linenr-1, llen-1, buffer);
+ state->linenr-1, llen-1, buffer);
return NULL;
}
@@ -1868,7 +1969,10 @@ static struct fragment *parse_binary_hunk(char **buf_p,
* -1 in case of error,
* the length of the parsed binary patch otherwise
*/
-static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
+static int parse_binary(struct apply_state *state,
+ char *buffer,
+ unsigned long size,
+ struct patch *patch)
{
/*
* We have read "GIT binary patch\n"; what follows is a line
@@ -1889,15 +1993,15 @@ static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
int status;
int used, used_1;
- forward = parse_binary_hunk(&buffer, &size, &status, &used);
+ forward = parse_binary_hunk(state, &buffer, &size, &status, &used);
if (!forward && !status)
/* there has to be one hunk (forward hunk) */
- return error(_("unrecognized binary patch at line %d"), linenr-1);
+ return error(_("unrecognized binary patch at line %d"), state->linenr-1);
if (status)
/* otherwise we already gave an error message */
return status;
- reverse = parse_binary_hunk(&buffer, &size, &status, &used_1);
+ reverse = parse_binary_hunk(state, &buffer, &size, &status, &used_1);
if (reverse)
used += used_1;
else if (status) {
@@ -1915,53 +2019,53 @@ static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
return used;
}
-static void prefix_one(char **name)
+static void prefix_one(struct apply_state *state, char **name)
{
char *old_name = *name;
if (!old_name)
return;
- *name = xstrdup(prefix_filename(prefix, prefix_length, *name));
+ *name = xstrdup(prefix_filename(state->prefix, state->prefix_length, *name));
free(old_name);
}
-static void prefix_patch(struct patch *p)
+static void prefix_patch(struct apply_state *state, struct patch *p)
{
- if (!prefix || p->is_toplevel_relative)
+ if (!state->prefix || p->is_toplevel_relative)
return;
- prefix_one(&p->new_name);
- prefix_one(&p->old_name);
+ prefix_one(state, &p->new_name);
+ prefix_one(state, &p->old_name);
}
/*
* include/exclude
*/
-static struct string_list limit_by_name;
-static int has_include;
-static void add_name_limit(const char *name, int exclude)
+static void add_name_limit(struct apply_state *state,
+ const char *name,
+ int exclude)
{
struct string_list_item *it;
- it = string_list_append(&limit_by_name, name);
+ it = string_list_append(&state->limit_by_name, name);
it->util = exclude ? NULL : (void *) 1;
}
-static int use_patch(struct patch *p)
+static int use_patch(struct apply_state *state, struct patch *p)
{
const char *pathname = p->new_name ? p->new_name : p->old_name;
int i;
/* Paths outside are not touched regardless of "--include" */
- if (0 < prefix_length) {
+ if (0 < state->prefix_length) {
int pathlen = strlen(pathname);
- if (pathlen <= prefix_length ||
- memcmp(prefix, pathname, prefix_length))
+ if (pathlen <= state->prefix_length ||
+ memcmp(state->prefix, pathname, state->prefix_length))
return 0;
}
/* See if it matches any of exclude/include rule */
- for (i = 0; i < limit_by_name.nr; i++) {
- struct string_list_item *it = &limit_by_name.items[i];
+ for (i = 0; i < state->limit_by_name.nr; i++) {
+ struct string_list_item *it = &state->limit_by_name.items[i];
if (!wildmatch(it->string, pathname, 0, NULL))
return (it->util != NULL);
}
@@ -1971,7 +2075,7 @@ static int use_patch(struct patch *p)
* not used. Otherwise, we saw bunch of exclude rules (or none)
* and such a path is used.
*/
- return !has_include;
+ return !state->has_include;
}
@@ -1982,25 +2086,27 @@ static int use_patch(struct patch *p)
* Return the number of bytes consumed, so that the caller can call us
* again for the next patch.
*/
-static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
+static int parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch)
{
int hdrsize, patchsize;
- int offset = find_header(buffer, size, &hdrsize, patch);
+ int offset = find_header(state, buffer, size, &hdrsize, patch);
if (offset < 0)
return offset;
- prefix_patch(patch);
+ prefix_patch(state, patch);
- if (!use_patch(patch))
+ if (!use_patch(state, patch))
patch->ws_rule = 0;
else
patch->ws_rule = whitespace_rule(patch->new_name
? patch->new_name
: patch->old_name);
- patchsize = parse_single_patch(buffer + offset + hdrsize,
- size - offset - hdrsize, patch);
+ patchsize = parse_single_patch(state,
+ buffer + offset + hdrsize,
+ size - offset - hdrsize,
+ patch);
if (!patchsize) {
static const char git_binary[] = "GIT binary patch\n";
@@ -2010,8 +2116,8 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
if (llen == sizeof(git_binary) - 1 &&
!memcmp(git_binary, buffer + hd, llen)) {
int used;
- linenr++;
- used = parse_binary(buffer + hd + llen,
+ state->linenr++;
+ used = parse_binary(state, buffer + hd + llen,
size - hd - llen, patch);
if (used < 0)
return -1;
@@ -2031,7 +2137,7 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
int len = strlen(binhdr[i]);
if (len < size - hd &&
!memcmp(binhdr[i], buffer + hd, len)) {
- linenr++;
+ state->linenr++;
patch->is_binary = 1;
patchsize = llen;
break;
@@ -2043,9 +2149,9 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
* without metadata change. A binary patch appears
* empty to us here.
*/
- if ((apply || check) &&
+ if ((state->apply || state->check) &&
(!patch->is_binary && !metadata_changes(patch)))
- die(_("patch with only garbage at line %d"), linenr);
+ die(_("patch with only garbage at line %d"), state->linenr);
}
return offset + hdrsize + patchsize;
@@ -2083,7 +2189,7 @@ static const char pluses[] =
static const char minuses[]=
"----------------------------------------------------------------------";
-static void show_stats(struct patch *patch)
+static void show_stats(struct apply_state *state, struct patch *patch)
{
struct strbuf qname = STRBUF_INIT;
char *cp = patch->new_name ? patch->new_name : patch->old_name;
@@ -2094,7 +2200,7 @@ static void show_stats(struct patch *patch)
/*
* "scale" the filename
*/
- max = max_len;
+ max = state->max_len;
if (max > 50)
max = 50;
@@ -2117,13 +2223,13 @@ static void show_stats(struct patch *patch)
/*
* scale the add/delete
*/
- max = max + max_change > 70 ? 70 - max : max_change;
+ max = max + state->max_change > 70 ? 70 - max : state->max_change;
add = patch->lines_added;
del = patch->lines_deleted;
- if (max_change > 0) {
- int total = ((add + del) * max + max_change / 2) / max_change;
- add = (add * max + max_change / 2) / max_change;
+ if (state->max_change > 0) {
+ int total = ((add + del) * max + state->max_change / 2) / state->max_change;
+ add = (add * max + state->max_change / 2) / state->max_change;
del = total - add;
}
printf("%5d %.*s%.*s\n", patch->lines_added + patch->lines_deleted,
@@ -2194,17 +2300,17 @@ static void update_pre_post_images(struct image *preimage,
fixed = preimage->buf;
for (i = reduced = ctx = 0; i < postimage->nr; i++) {
- size_t len = postimage->line[i].len;
+ size_t l_len = postimage->line[i].len;
if (!(postimage->line[i].flag & LINE_COMMON)) {
/* an added line -- no counterparts in preimage */
- memmove(new, old, len);
- old += len;
- new += len;
+ memmove(new, old, l_len);
+ old += l_len;
+ new += l_len;
continue;
}
/* a common context -- skip it in the original postimage */
- old += len;
+ old += l_len;
/* and find the corresponding one in the fixed preimage */
while (ctx < preimage->nr &&
@@ -2223,11 +2329,11 @@ static void update_pre_post_images(struct image *preimage,
}
/* and copy it in, while fixing the line length */
- len = preimage->line[ctx].len;
- memcpy(new, fixed, len);
- new += len;
- fixed += len;
- postimage->line[i].len = len;
+ l_len = preimage->line[ctx].len;
+ memcpy(new, fixed, l_len);
+ new += l_len;
+ fixed += l_len;
+ postimage->line[i].len = l_len;
ctx++;
}
@@ -2242,7 +2348,76 @@ static void update_pre_post_images(struct image *preimage,
postimage->nr -= reduced;
}
-static int match_fragment(struct image *img,
+static int line_by_line_fuzzy_match(struct image *img,
+ struct image *preimage,
+ struct image *postimage,
+ unsigned long try,
+ int try_lno,
+ int preimage_limit)
+{
+ int i;
+ size_t imgoff = 0;
+ size_t preoff = 0;
+ size_t postlen = postimage->len;
+ size_t extra_chars;
+ char *buf;
+ char *preimage_eof;
+ char *preimage_end;
+ struct strbuf fixed;
+ char *fixed_buf;
+ size_t fixed_len;
+
+ for (i = 0; i < preimage_limit; i++) {
+ size_t prelen = preimage->line[i].len;
+ size_t imglen = img->line[try_lno+i].len;
+
+ if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
+ preimage->buf + preoff, prelen))
+ return 0;
+ if (preimage->line[i].flag & LINE_COMMON)
+ postlen += imglen - prelen;
+ imgoff += imglen;
+ preoff += prelen;
+ }
+
+ /*
+ * Ok, the preimage matches with whitespace fuzz.
+ *
+ * imgoff now holds the true length of the target that
+ * matches the preimage before the end of the file.
+ *
+ * Count the number of characters in the preimage that fall
+ * beyond the end of the file and make sure that all of them
+ * are whitespace characters. (This can only happen if
+ * we are removing blank lines at the end of the file.)
+ */
+ buf = preimage_eof = preimage->buf + preoff;
+ for ( ; i < preimage->nr; i++)
+ preoff += preimage->line[i].len;
+ preimage_end = preimage->buf + preoff;
+ for ( ; buf < preimage_end; buf++)
+ if (!isspace(*buf))
+ return 0;
+
+ /*
+ * Update the preimage and the common postimage context
+ * lines to use the same whitespace as the target.
+ * If whitespace is missing in the target (i.e.
+ * if the preimage extends beyond the end of the file),
+ * use the whitespace from the preimage.
+ */
+ extra_chars = preimage_end - preimage_eof;
+ strbuf_init(&fixed, imgoff + extra_chars);
+ strbuf_add(&fixed, img->buf + try, imgoff);
+ strbuf_add(&fixed, preimage_eof, extra_chars);
+ fixed_buf = strbuf_detach(&fixed, &fixed_len);
+ update_pre_post_images(preimage, postimage,
+ fixed_buf, fixed_len, postlen);
+ return 1;
+}
+
+static int match_fragment(struct apply_state *state,
+ struct image *img,
struct image *preimage,
struct image *postimage,
unsigned long try,
@@ -2263,7 +2438,7 @@ static int match_fragment(struct image *img,
preimage_limit = preimage->nr;
if (match_end && (preimage->nr + try_lno != img->nr))
return 0;
- } else if (ws_error_action == correct_ws_error &&
+ } else if (state->ws_error_action == correct_ws_error &&
(ws_rule & WS_BLANK_AT_EOF)) {
/*
* This hunk extends beyond the end of img, and we are
@@ -2331,63 +2506,11 @@ static int match_fragment(struct image *img,
* fuzzy matching. We collect all the line length information because
* we need it to adjust whitespace if we match.
*/
- if (ws_ignore_action == ignore_ws_change) {
- size_t imgoff = 0;
- size_t preoff = 0;
- size_t postlen = postimage->len;
- size_t extra_chars;
- char *preimage_eof;
- char *preimage_end;
- for (i = 0; i < preimage_limit; i++) {
- size_t prelen = preimage->line[i].len;
- size_t imglen = img->line[try_lno+i].len;
-
- if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
- preimage->buf + preoff, prelen))
- return 0;
- if (preimage->line[i].flag & LINE_COMMON)
- postlen += imglen - prelen;
- imgoff += imglen;
- preoff += prelen;
- }
+ if (state->ws_ignore_action == ignore_ws_change)
+ return line_by_line_fuzzy_match(img, preimage, postimage,
+ try, try_lno, preimage_limit);
- /*
- * Ok, the preimage matches with whitespace fuzz.
- *
- * imgoff now holds the true length of the target that
- * matches the preimage before the end of the file.
- *
- * Count the number of characters in the preimage that fall
- * beyond the end of the file and make sure that all of them
- * are whitespace characters. (This can only happen if
- * we are removing blank lines at the end of the file.)
- */
- buf = preimage_eof = preimage->buf + preoff;
- for ( ; i < preimage->nr; i++)
- preoff += preimage->line[i].len;
- preimage_end = preimage->buf + preoff;
- for ( ; buf < preimage_end; buf++)
- if (!isspace(*buf))
- return 0;
-
- /*
- * Update the preimage and the common postimage context
- * lines to use the same whitespace as the target.
- * If whitespace is missing in the target (i.e.
- * if the preimage extends beyond the end of the file),
- * use the whitespace from the preimage.
- */
- extra_chars = preimage_end - preimage_eof;
- strbuf_init(&fixed, imgoff + extra_chars);
- strbuf_add(&fixed, img->buf + try, imgoff);
- strbuf_add(&fixed, preimage_eof, extra_chars);
- fixed_buf = strbuf_detach(&fixed, &fixed_len);
- update_pre_post_images(preimage, postimage,
- fixed_buf, fixed_len, postlen);
- return 1;
- }
-
- if (ws_error_action != correct_ws_error)
+ if (state->ws_error_action != correct_ws_error)
return 0;
/*
@@ -2499,7 +2622,8 @@ static int match_fragment(struct image *img,
return 0;
}
-static int find_pos(struct image *img,
+static int find_pos(struct apply_state *state,
+ struct image *img,
struct image *preimage,
struct image *postimage,
int line,
@@ -2543,7 +2667,7 @@ static int find_pos(struct image *img,
try_lno = line;
for (i = 0; ; i++) {
- if (match_fragment(img, preimage, postimage,
+ if (match_fragment(state, img, preimage, postimage,
try, try_lno, ws_rule,
match_beginning, match_end))
return try_lno;
@@ -2594,7 +2718,8 @@ static void remove_last_line(struct image *img)
* apply at applied_pos (counts in line numbers) in "img".
* Update "img" to remove "preimage" and replace it with "postimage".
*/
-static void update_image(struct image *img,
+static void update_image(struct apply_state *state,
+ struct image *img,
int applied_pos,
struct image *preimage,
struct image *postimage)
@@ -2659,7 +2784,7 @@ static void update_image(struct image *img,
memcpy(img->line + applied_pos,
postimage->line,
postimage->nr * sizeof(*img->line));
- if (!allow_overlap)
+ if (!state->allow_overlap)
for (i = 0; i < postimage->nr; i++)
img->line[applied_pos + i].flag |= LINE_PATCHED;
img->nr = nr;
@@ -2670,7 +2795,8 @@ static void update_image(struct image *img,
* postimage) for the hunk. Find lines that match "preimage" in "img" and
* replace the part of "img" with "postimage" text.
*/
-static int apply_one_fragment(struct image *img, struct fragment *frag,
+static int apply_one_fragment(struct apply_state *state,
+ struct image *img, struct fragment *frag,
int inaccurate_eof, unsigned ws_rule,
int nth_fragment)
{
@@ -2715,7 +2841,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
if (len < size && patch[len] == '\\')
plen--;
first = *patch;
- if (apply_in_reverse) {
+ if (state->apply_in_reverse) {
if (first == '-')
first = '+';
else if (first == '+')
@@ -2748,17 +2874,17 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
/* Fall-through for ' ' */
case '+':
/* --no-add does not add new lines */
- if (first == '+' && no_add)
+ if (first == '+' && state->no_add)
break;
start = newlines.len;
if (first != '+' ||
- !whitespace_error ||
- ws_error_action != correct_ws_error) {
+ !state->whitespace_error ||
+ state->ws_error_action != correct_ws_error) {
strbuf_add(&newlines, patch + 1, plen);
}
else {
- ws_fix_copy(&newlines, patch + 1, plen, ws_rule, &applied_after_fixing_ws);
+ ws_fix_copy(&newlines, patch + 1, plen, ws_rule, &state->applied_after_fixing_ws);
}
add_line_info(&postimage, newlines.buf + start, newlines.len - start,
(first == '+' ? 0 : LINE_COMMON));
@@ -2771,7 +2897,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
/* Ignore it, we already handled it */
break;
default:
- if (apply_verbosely)
+ if (state->apply_verbosely)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
@@ -2812,7 +2938,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
* without leading context must match at the beginning.
*/
match_beginning = (!frag->oldpos ||
- (frag->oldpos == 1 && !unidiff_zero));
+ (frag->oldpos == 1 && !state->unidiff_zero));
/*
* A hunk without trailing lines must match at the end.
@@ -2820,7 +2946,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
* from the lack of trailing lines if the patch was generated
* with unidiff without any context.
*/
- match_end = !unidiff_zero && !trailing;
+ match_end = !state->unidiff_zero && !trailing;
pos = frag->newpos ? (frag->newpos - 1) : 0;
preimage.buf = oldlines;
@@ -2832,14 +2958,14 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
for (;;) {
- applied_pos = find_pos(img, &preimage, &postimage, pos,
+ applied_pos = find_pos(state, img, &preimage, &postimage, pos,
ws_rule, match_beginning, match_end);
if (applied_pos >= 0)
break;
/* Am I at my context limits? */
- if ((leading <= p_context) && (trailing <= p_context))
+ if ((leading <= state->p_context) && (trailing <= state->p_context))
break;
if (match_beginning || match_end) {
match_beginning = match_end = 0;
@@ -2868,10 +2994,10 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
if (new_blank_lines_at_end &&
preimage.nr + applied_pos >= img->nr &&
(ws_rule & WS_BLANK_AT_EOF) &&
- ws_error_action != nowarn_ws_error) {
- record_ws_error(WS_BLANK_AT_EOF, "+", 1,
+ state->ws_error_action != nowarn_ws_error) {
+ record_ws_error(state, WS_BLANK_AT_EOF, "+", 1,
found_new_blank_lines_at_end);
- if (ws_error_action == correct_ws_error) {
+ if (state->ws_error_action == correct_ws_error) {
while (new_blank_lines_at_end--)
remove_last_line(&postimage);
}
@@ -2882,13 +3008,13 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
* apply_patch->check_patch_list->check_patch->
* apply_data->apply_fragments->apply_one_fragment
*/
- if (ws_error_action == die_on_ws_error)
- apply = 0;
+ if (state->ws_error_action == die_on_ws_error)
+ state->apply = 0;
}
- if (apply_verbosely && applied_pos != pos) {
+ if (state->apply_verbosely && applied_pos != pos) {
int offset = applied_pos - pos;
- if (apply_in_reverse)
+ if (state->apply_in_reverse)
offset = 0 - offset;
fprintf_ln(stderr,
Q_("Hunk #%d succeeded at %d (offset %d line).",
@@ -2906,9 +3032,9 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
" to apply fragment at %d"),
leading, trailing, applied_pos+1);
- update_image(img, applied_pos, &preimage, &postimage);
+ update_image(state, img, applied_pos, &preimage, &postimage);
} else {
- if (apply_verbosely)
+ if (state->apply_verbosely)
error(_("while searching for:\n%.*s"),
(int)(old - oldlines), oldlines);
}
@@ -2922,7 +3048,9 @@ out:
return (applied_pos < 0);
}
-static int apply_binary_fragment(struct image *img, struct patch *patch)
+static int apply_binary_fragment(struct apply_state *state,
+ struct image *img,
+ struct patch *patch)
{
struct fragment *fragment = patch->fragments;
unsigned long len;
@@ -2935,7 +3063,7 @@ static int apply_binary_fragment(struct image *img, struct patch *patch)
patch->old_name);
/* Binary patch is irreversible without the optional second hunk */
- if (apply_in_reverse) {
+ if (state->apply_in_reverse) {
if (!fragment->next)
return error("cannot reverse-apply a binary patch "
"without the reverse hunk to '%s'",
@@ -2968,7 +3096,9 @@ static int apply_binary_fragment(struct image *img, struct patch *patch)
* but the preimage prepared by the caller in "img" is freed here
* or in the helper function apply_binary_fragment() this calls.
*/
-static int apply_binary(struct image *img, struct patch *patch)
+static int apply_binary(struct apply_state *state,
+ struct image *img,
+ struct patch *patch)
{
const char *name = patch->old_name ? patch->old_name : patch->new_name;
unsigned char sha1[20];
@@ -3029,7 +3159,7 @@ static int apply_binary(struct image *img, struct patch *patch)
* apply the patch data to it, which is stored
* in the patch->fragments->{patch,size}.
*/
- if (apply_binary_fragment(img, patch))
+ if (apply_binary_fragment(state, img, patch))
return error(_("binary patch does not apply to '%s'"),
name);
@@ -3043,7 +3173,7 @@ static int apply_binary(struct image *img, struct patch *patch)
return 0;
}
-static int apply_fragments(struct image *img, struct patch *patch)
+static int apply_fragments(struct apply_state *state, struct image *img, struct patch *patch)
{
struct fragment *frag = patch->fragments;
const char *name = patch->old_name ? patch->old_name : patch->new_name;
@@ -3052,13 +3182,13 @@ static int apply_fragments(struct image *img, struct patch *patch)
int nth = 0;
if (patch->is_binary)
- return apply_binary(img, patch);
+ return apply_binary(state, img, patch);
while (frag) {
nth++;
- if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule, nth)) {
+ if (apply_one_fragment(state, img, frag, inaccurate_eof, ws_rule, nth)) {
error(_("patch failed: %s:%ld"), name, frag->oldpos);
- if (!apply_with_reject)
+ if (!state->apply_with_reject)
return -1;
frag->rejected = 1;
}
@@ -3093,14 +3223,14 @@ static int read_file_or_gitlink(const struct cache_entry *ce, struct strbuf *buf
return read_blob_object(buf, ce->sha1, ce->ce_mode);
}
-static struct patch *in_fn_table(const char *name)
+static struct patch *in_fn_table(struct apply_state *state, const char *name)
{
struct string_list_item *item;
if (name == NULL)
return NULL;
- item = string_list_lookup(&fn_table, name);
+ item = string_list_lookup(&state->fn_table, name);
if (item != NULL)
return (struct patch *)item->util;
@@ -3132,7 +3262,7 @@ static int was_deleted(struct patch *patch)
return patch == PATH_WAS_DELETED;
}
-static void add_to_fn_table(struct patch *patch)
+static void add_to_fn_table(struct apply_state *state, struct patch *patch)
{
struct string_list_item *item;
@@ -3142,7 +3272,7 @@ static void add_to_fn_table(struct patch *patch)
* file creations and copies
*/
if (patch->new_name != NULL) {
- item = string_list_insert(&fn_table, patch->new_name);
+ item = string_list_insert(&state->fn_table, patch->new_name);
item->util = patch;
}
@@ -3151,12 +3281,12 @@ static void add_to_fn_table(struct patch *patch)
* later chunks shouldn't patch old names
*/
if ((patch->new_name == NULL) || (patch->is_rename)) {
- item = string_list_insert(&fn_table, patch->old_name);
+ item = string_list_insert(&state->fn_table, patch->old_name);
item->util = PATH_WAS_DELETED;
}
}
-static void prepare_fn_table(struct patch *patch)
+static void prepare_fn_table(struct apply_state *state, struct patch *patch)
{
/*
* store information about incoming file deletion
@@ -3164,7 +3294,7 @@ static void prepare_fn_table(struct patch *patch)
while (patch) {
if ((patch->new_name == NULL) || (patch->is_rename)) {
struct string_list_item *item;
- item = string_list_insert(&fn_table, patch->old_name);
+ item = string_list_insert(&state->fn_table, patch->old_name);
item->util = PATH_TO_BE_DELETED;
}
patch = patch->next;
@@ -3185,7 +3315,9 @@ static int checkout_target(struct index_state *istate,
return 0;
}
-static struct patch *previous_patch(struct patch *patch, int *gone)
+static struct patch *previous_patch(struct apply_state *state,
+ struct patch *patch,
+ int *gone)
{
struct patch *previous;
@@ -3193,7 +3325,7 @@ static struct patch *previous_patch(struct patch *patch, int *gone)
if (patch->is_copy || patch->is_rename)
return NULL; /* "git" patches do not depend on the order */
- previous = in_fn_table(patch->old_name);
+ previous = in_fn_table(state, patch->old_name);
if (!previous)
return NULL;
@@ -3218,15 +3350,16 @@ static int verify_index_match(const struct cache_entry *ce, struct stat *st)
#define SUBMODULE_PATCH_WITHOUT_INDEX 1
-static int load_patch_target(struct strbuf *buf,
+static int load_patch_target(struct apply_state *state,
+ struct strbuf *buf,
const struct cache_entry *ce,
struct stat *st,
const char *name,
unsigned expected_mode)
{
- if (cached || check_index) {
+ if (state->cached || state->check_index) {
if (read_file_or_gitlink(ce, buf))
- return error(_("read of %s failed"), name);
+ return error(_("failed to read %s"), name);
} else if (name) {
if (S_ISGITLINK(expected_mode)) {
if (ce)
@@ -3237,7 +3370,7 @@ static int load_patch_target(struct strbuf *buf,
return error(_("reading from '%s' beyond a symbolic link"), name);
} else {
if (read_old_data(st, name, buf))
- return error(_("read of %s failed"), name);
+ return error(_("failed to read %s"), name);
}
}
return 0;
@@ -3250,7 +3383,8 @@ static int load_patch_target(struct strbuf *buf,
* applying a non-git patch that incrementally updates the tree,
* we read from the result of a previous diff.
*/
-static int load_preimage(struct image *image,
+static int load_preimage(struct apply_state *state,
+ struct image *image,
struct patch *patch, struct stat *st,
const struct cache_entry *ce)
{
@@ -3260,7 +3394,7 @@ static int load_preimage(struct image *image,
struct patch *previous;
int status;
- previous = previous_patch(patch, &status);
+ previous = previous_patch(state, patch, &status);
if (status)
return error(_("path %s has been renamed/deleted"),
patch->old_name);
@@ -3268,7 +3402,7 @@ static int load_preimage(struct image *image,
/* We have a patched copy in memory; use that. */
strbuf_add(&buf, previous->result, previous->resultsize);
} else {
- status = load_patch_target(&buf, ce, st,
+ status = load_patch_target(state, &buf, ce, st,
patch->old_name, patch->old_mode);
if (status < 0)
return status;
@@ -3282,7 +3416,7 @@ static int load_preimage(struct image *image,
free_fragment_list(patch->fragments);
patch->fragments = NULL;
} else if (status) {
- return error(_("read of %s failed"), patch->old_name);
+ return error(_("failed to read %s"), patch->old_name);
}
}
@@ -3327,7 +3461,9 @@ static int three_way_merge(struct image *image,
* the current contents of the new_name. In no cases other than that
* this function will be called.
*/
-static int load_current(struct image *image, struct patch *patch)
+static int load_current(struct apply_state *state,
+ struct image *image,
+ struct patch *patch)
{
struct strbuf buf = STRBUF_INIT;
int status, pos;
@@ -3354,7 +3490,7 @@ static int load_current(struct image *image, struct patch *patch)
if (verify_index_match(ce, &st))
return error(_("%s: does not match index"), name);
- status = load_patch_target(&buf, ce, &st, name, mode);
+ status = load_patch_target(state, &buf, ce, &st, name, mode);
if (status < 0)
return status;
else if (status)
@@ -3364,8 +3500,11 @@ static int load_current(struct image *image, struct patch *patch)
return 0;
}
-static int try_threeway(struct image *image, struct patch *patch,
- struct stat *st, const struct cache_entry *ce)
+static int try_threeway(struct apply_state *state,
+ struct image *image,
+ struct patch *patch,
+ struct stat *st,
+ const struct cache_entry *ce)
{
unsigned char pre_sha1[20], post_sha1[20], our_sha1[20];
struct strbuf buf = STRBUF_INIT;
@@ -3391,7 +3530,7 @@ static int try_threeway(struct image *image, struct patch *patch,
img = strbuf_detach(&buf, &len);
prepare_image(&tmp_image, img, len, 1);
/* Apply the patch to get the post image */
- if (apply_fragments(&tmp_image, patch) < 0) {
+ if (apply_fragments(state, &tmp_image, patch) < 0) {
clear_image(&tmp_image);
return -1;
}
@@ -3401,11 +3540,11 @@ static int try_threeway(struct image *image, struct patch *patch,
/* our_sha1[] is ours */
if (patch->is_new) {
- if (load_current(&tmp_image, patch))
+ if (load_current(state, &tmp_image, patch))
return error("cannot read the current contents of '%s'",
patch->new_name);
} else {
- if (load_preimage(&tmp_image, patch, st, ce))
+ if (load_preimage(state, &tmp_image, patch, st, ce))
return error("cannot read the current contents of '%s'",
patch->old_name);
}
@@ -3435,22 +3574,23 @@ static int try_threeway(struct image *image, struct patch *patch,
return 0;
}
-static int apply_data(struct patch *patch, struct stat *st, const struct cache_entry *ce)
+static int apply_data(struct apply_state *state, struct patch *patch,
+ struct stat *st, const struct cache_entry *ce)
{
struct image image;
- if (load_preimage(&image, patch, st, ce) < 0)
+ if (load_preimage(state, &image, patch, st, ce) < 0)
return -1;
if (patch->direct_to_threeway ||
- apply_fragments(&image, patch) < 0) {
+ apply_fragments(state, &image, patch) < 0) {
/* Note: with --reject, apply_fragments() returns 0 */
- if (!threeway || try_threeway(&image, patch, st, ce) < 0)
+ if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0)
return -1;
}
patch->result = image.buf;
patch->resultsize = image.len;
- add_to_fn_table(patch);
+ add_to_fn_table(state, patch);
free(image.line_allocated);
if (0 < patch->is_delete && patch->resultsize)
@@ -3470,7 +3610,10 @@ static int apply_data(struct patch *patch, struct stat *st, const struct cache_e
* check_patch() separately makes sure (and errors out otherwise) that
* the path the patch creates does not exist in the current tree.
*/
-static int check_preimage(struct patch *patch, struct cache_entry **ce, struct stat *st)
+static int check_preimage(struct apply_state *state,
+ struct patch *patch,
+ struct cache_entry **ce,
+ struct stat *st)
{
const char *old_name = patch->old_name;
struct patch *previous = NULL;
@@ -3481,19 +3624,19 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
return 0;
assert(patch->is_new <= 0);
- previous = previous_patch(patch, &status);
+ previous = previous_patch(state, patch, &status);
if (status)
return error(_("path %s has been renamed/deleted"), old_name);
if (previous) {
st_mode = previous->new_mode;
- } else if (!cached) {
+ } else if (!state->cached) {
stat_ret = lstat(old_name, st);
if (stat_ret && errno != ENOENT)
return error(_("%s: %s"), old_name, strerror(errno));
}
- if (check_index && !previous) {
+ if (state->check_index && !previous) {
int pos = cache_name_pos(old_name, strlen(old_name));
if (pos < 0) {
if (patch->is_new < 0)
@@ -3505,9 +3648,9 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
if (checkout_target(&the_index, *ce, st))
return -1;
}
- if (!cached && verify_index_match(*ce, st))
+ if (!state->cached && verify_index_match(*ce, st))
return error(_("%s: does not match index"), old_name);
- if (cached)
+ if (state->cached)
st_mode = (*ce)->ce_mode;
} else if (stat_ret < 0) {
if (patch->is_new < 0)
@@ -3515,7 +3658,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
return error(_("%s: %s"), old_name, strerror(errno));
}
- if (!cached && !previous)
+ if (!state->cached && !previous)
st_mode = ce_mode_from_stat(*ce, st->st_mode);
if (patch->is_new < 0)
@@ -3543,15 +3686,17 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
#define EXISTS_IN_INDEX 1
#define EXISTS_IN_WORKTREE 2
-static int check_to_create(const char *new_name, int ok_if_exists)
+static int check_to_create(struct apply_state *state,
+ const char *new_name,
+ int ok_if_exists)
{
struct stat nst;
- if (check_index &&
+ if (state->check_index &&
cache_name_pos(new_name, strlen(new_name)) >= 0 &&
!ok_if_exists)
return EXISTS_IN_INDEX;
- if (cached)
+ if (state->cached)
return 0;
if (!lstat(new_name, &nst)) {
@@ -3574,56 +3719,46 @@ static int check_to_create(const char *new_name, int ok_if_exists)
return 0;
}
-/*
- * We need to keep track of how symlinks in the preimage are
- * manipulated by the patches. A patch to add a/b/c where a/b
- * is a symlink should not be allowed to affect the directory
- * the symlink points at, but if the same patch removes a/b,
- * it is perfectly fine, as the patch removes a/b to make room
- * to create a directory a/b so that a/b/c can be created.
- */
-static struct string_list symlink_changes;
-#define SYMLINK_GOES_AWAY 01
-#define SYMLINK_IN_RESULT 02
-
-static uintptr_t register_symlink_changes(const char *path, uintptr_t what)
+static uintptr_t register_symlink_changes(struct apply_state *state,
+ const char *path,
+ uintptr_t what)
{
struct string_list_item *ent;
- ent = string_list_lookup(&symlink_changes, path);
+ ent = string_list_lookup(&state->symlink_changes, path);
if (!ent) {
- ent = string_list_insert(&symlink_changes, path);
+ ent = string_list_insert(&state->symlink_changes, path);
ent->util = (void *)0;
}
ent->util = (void *)(what | ((uintptr_t)ent->util));
return (uintptr_t)ent->util;
}
-static uintptr_t check_symlink_changes(const char *path)
+static uintptr_t check_symlink_changes(struct apply_state *state, const char *path)
{
struct string_list_item *ent;
- ent = string_list_lookup(&symlink_changes, path);
+ ent = string_list_lookup(&state->symlink_changes, path);
if (!ent)
return 0;
return (uintptr_t)ent->util;
}
-static void prepare_symlink_changes(struct patch *patch)
+static void prepare_symlink_changes(struct apply_state *state, struct patch *patch)
{
for ( ; patch; patch = patch->next) {
if ((patch->old_name && S_ISLNK(patch->old_mode)) &&
(patch->is_rename || patch->is_delete))
/* the symlink at patch->old_name is removed */
- register_symlink_changes(patch->old_name, SYMLINK_GOES_AWAY);
+ register_symlink_changes(state, patch->old_name, SYMLINK_GOES_AWAY);
if (patch->new_name && S_ISLNK(patch->new_mode))
/* the symlink at patch->new_name is created or remains */
- register_symlink_changes(patch->new_name, SYMLINK_IN_RESULT);
+ register_symlink_changes(state, patch->new_name, SYMLINK_IN_RESULT);
}
}
-static int path_is_beyond_symlink_1(struct strbuf *name)
+static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *name)
{
do {
unsigned int change;
@@ -3633,7 +3768,7 @@ static int path_is_beyond_symlink_1(struct strbuf *name)
if (!name->len)
break;
name->buf[name->len] = '\0';
- change = check_symlink_changes(name->buf);
+ change = check_symlink_changes(state, name->buf);
if (change & SYMLINK_IN_RESULT)
return 1;
if (change & SYMLINK_GOES_AWAY)
@@ -3644,7 +3779,7 @@ static int path_is_beyond_symlink_1(struct strbuf *name)
continue;
/* otherwise, check the preimage */
- if (check_index) {
+ if (state->check_index) {
struct cache_entry *ce;
ce = cache_file_exists(name->buf, name->len, ignore_case);
@@ -3659,14 +3794,14 @@ static int path_is_beyond_symlink_1(struct strbuf *name)
return 0;
}
-static int path_is_beyond_symlink(const char *name_)
+static int path_is_beyond_symlink(struct apply_state *state, const char *name_)
{
int ret;
struct strbuf name = STRBUF_INIT;
assert(*name_ != '\0');
strbuf_addstr(&name, name_);
- ret = path_is_beyond_symlink_1(&name);
+ ret = path_is_beyond_symlink_1(state, &name);
strbuf_release(&name);
return ret;
@@ -3693,7 +3828,7 @@ static void die_on_unsafe_path(struct patch *patch)
* Check and apply the patch in-core; leave the result in patch->result
* for the caller to write it out to the final destination.
*/
-static int check_patch(struct patch *patch)
+static int check_patch(struct apply_state *state, struct patch *patch)
{
struct stat st;
const char *old_name = patch->old_name;
@@ -3706,7 +3841,7 @@ static int check_patch(struct patch *patch)
patch->rejected = 1; /* we will drop this after we succeed */
- status = check_preimage(patch, &ce, &st);
+ status = check_preimage(state, patch, &ce, &st);
if (status)
return status;
old_name = patch->old_name;
@@ -3725,7 +3860,7 @@ static int check_patch(struct patch *patch)
* B and rename from A to B is handled the same way by asking
* was_deleted().
*/
- if ((tpatch = in_fn_table(new_name)) &&
+ if ((tpatch = in_fn_table(state, new_name)) &&
(was_deleted(tpatch) || to_be_deleted(tpatch)))
ok_if_exists = 1;
else
@@ -3733,9 +3868,9 @@ static int check_patch(struct patch *patch)
if (new_name &&
((0 < patch->is_new) || patch->is_rename || patch->is_copy)) {
- int err = check_to_create(new_name, ok_if_exists);
+ int err = check_to_create(state, new_name, ok_if_exists);
- if (err && threeway) {
+ if (err && state->threeway) {
patch->direct_to_threeway = 1;
} else switch (err) {
case 0:
@@ -3776,7 +3911,7 @@ static int check_patch(struct patch *patch)
}
}
- if (!unsafe_paths)
+ if (!state->unsafe_paths)
die_on_unsafe_path(patch);
/*
@@ -3788,27 +3923,27 @@ static int check_patch(struct patch *patch)
* is not deposited to a path that is beyond a symbolic link
* here.
*/
- if (!patch->is_delete && path_is_beyond_symlink(patch->new_name))
+ if (!patch->is_delete && path_is_beyond_symlink(state, patch->new_name))
return error(_("affected file '%s' is beyond a symbolic link"),
patch->new_name);
- if (apply_data(patch, &st, ce) < 0)
+ if (apply_data(state, patch, &st, ce) < 0)
return error(_("%s: patch does not apply"), name);
patch->rejected = 0;
return 0;
}
-static int check_patch_list(struct patch *patch)
+static int check_patch_list(struct apply_state *state, struct patch *patch)
{
int err = 0;
- prepare_symlink_changes(patch);
- prepare_fn_table(patch);
+ prepare_symlink_changes(state, patch);
+ prepare_fn_table(state, patch);
while (patch) {
- if (apply_verbosely)
+ if (state->apply_verbosely)
say_patch_name(stderr,
_("Checking patch %s..."), patch);
- err |= check_patch(patch);
+ err |= check_patch(state, patch);
patch = patch->next;
}
return err;
@@ -3912,7 +4047,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
discard_index(&result);
}
-static void stat_patch_list(struct patch *patch)
+static void stat_patch_list(struct apply_state *state, struct patch *patch)
{
int files, adds, dels;
@@ -3920,13 +4055,14 @@ static void stat_patch_list(struct patch *patch)
files++;
adds += patch->lines_added;
dels += patch->lines_deleted;
- show_stats(patch);
+ show_stats(state, patch);
}
print_stat_summary(stdout, files, adds, dels);
}
-static void numstat_patch_list(struct patch *patch)
+static void numstat_patch_list(struct apply_state *state,
+ struct patch *patch)
{
for ( ; patch; patch = patch->next) {
const char *name;
@@ -3935,7 +4071,7 @@ static void numstat_patch_list(struct patch *patch)
printf("-\t-\t");
else
printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
- write_name_quoted(name, stdout, line_termination);
+ write_name_quoted(name, stdout, state->line_termination);
}
}
@@ -4017,49 +4153,53 @@ static void summary_patch_list(struct patch *patch)
}
}
-static void patch_stats(struct patch *patch)
+static void patch_stats(struct apply_state *state, struct patch *patch)
{
int lines = patch->lines_added + patch->lines_deleted;
- if (lines > max_change)
- max_change = lines;
+ if (lines > state->max_change)
+ state->max_change = lines;
if (patch->old_name) {
int len = quote_c_style(patch->old_name, NULL, NULL, 0);
if (!len)
len = strlen(patch->old_name);
- if (len > max_len)
- max_len = len;
+ if (len > state->max_len)
+ state->max_len = len;
}
if (patch->new_name) {
int len = quote_c_style(patch->new_name, NULL, NULL, 0);
if (!len)
len = strlen(patch->new_name);
- if (len > max_len)
- max_len = len;
+ if (len > state->max_len)
+ state->max_len = len;
}
}
-static void remove_file(struct patch *patch, int rmdir_empty)
+static void remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
{
- if (update_index) {
+ if (state->update_index) {
if (remove_file_from_cache(patch->old_name) < 0)
die(_("unable to remove %s from index"), patch->old_name);
}
- if (!cached) {
+ if (!state->cached) {
if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
remove_path(patch->old_name);
}
}
}
-static void add_index_file(const char *path, unsigned mode, void *buf, unsigned long size)
+static void add_index_file(struct apply_state *state,
+ const char *path,
+ unsigned mode,
+ void *buf,
+ unsigned long size)
{
struct stat st;
struct cache_entry *ce;
int namelen = strlen(path);
unsigned ce_size = cache_entry_size(namelen);
- if (!update_index)
+ if (!state->update_index)
return;
ce = xcalloc(1, ce_size);
@@ -4074,7 +4214,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
get_sha1_hex(s, ce->sha1))
die(_("corrupt patch for submodule %s"), path);
} else {
- if (!cached) {
+ if (!state->cached) {
if (lstat(path, &st) < 0)
die_errno(_("unable to stat newly created file '%s'"),
path);
@@ -4126,9 +4266,13 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
* which is true 99% of the time anyway. If they don't,
* we create them and try again.
*/
-static void create_one_file(char *path, unsigned mode, const char *buf, unsigned long size)
+static void create_one_file(struct apply_state *state,
+ char *path,
+ unsigned mode,
+ const char *buf,
+ unsigned long size)
{
- if (cached)
+ if (state->cached)
return;
if (!try_create_file(path, mode, buf, size))
return;
@@ -4169,13 +4313,14 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
die_errno(_("unable to write file '%s' mode %o"), path, mode);
}
-static void add_conflicted_stages_file(struct patch *patch)
+static void add_conflicted_stages_file(struct apply_state *state,
+ struct patch *patch)
{
int stage, namelen;
unsigned ce_size, mode;
struct cache_entry *ce;
- if (!update_index)
+ if (!state->update_index)
return;
namelen = strlen(patch->new_name);
ce_size = cache_entry_size(namelen);
@@ -4196,7 +4341,7 @@ static void add_conflicted_stages_file(struct patch *patch)
}
}
-static void create_file(struct patch *patch)
+static void create_file(struct apply_state *state, struct patch *patch)
{
char *path = patch->new_name;
unsigned mode = patch->new_mode;
@@ -4205,25 +4350,27 @@ static void create_file(struct patch *patch)
if (!mode)
mode = S_IFREG | 0644;
- create_one_file(path, mode, buf, size);
+ create_one_file(state, path, mode, buf, size);
if (patch->conflicted_threeway)
- add_conflicted_stages_file(patch);
+ add_conflicted_stages_file(state, patch);
else
- add_index_file(path, mode, buf, size);
+ add_index_file(state, path, mode, buf, size);
}
/* phase zero is to remove, phase one is to create */
-static void write_out_one_result(struct patch *patch, int phase)
+static void write_out_one_result(struct apply_state *state,
+ struct patch *patch,
+ int phase)
{
if (patch->is_delete > 0) {
if (phase == 0)
- remove_file(patch, 1);
+ remove_file(state, patch, 1);
return;
}
if (patch->is_new > 0 || patch->is_copy) {
if (phase == 1)
- create_file(patch);
+ create_file(state, patch);
return;
}
/*
@@ -4231,12 +4378,12 @@ static void write_out_one_result(struct patch *patch, int phase)
* thing: remove the old, write the new
*/
if (phase == 0)
- remove_file(patch, patch->is_rename);
+ remove_file(state, patch, patch->is_rename);
if (phase == 1)
- create_file(patch);
+ create_file(state, patch);
}
-static int write_out_one_reject(struct patch *patch)
+static int write_out_one_reject(struct apply_state *state, struct patch *patch)
{
FILE *rej;
char namebuf[PATH_MAX];
@@ -4251,7 +4398,7 @@ static int write_out_one_reject(struct patch *patch)
}
if (!cnt) {
- if (apply_verbosely)
+ if (state->apply_verbosely)
say_patch_name(stderr,
_("Applied patch %s cleanly."), patch);
return 0;
@@ -4307,7 +4454,7 @@ static int write_out_one_reject(struct patch *patch)
return -1;
}
-static int write_out_results(struct patch *list)
+static int write_out_results(struct apply_state *state, struct patch *list)
{
int phase;
int errs = 0;
@@ -4320,9 +4467,9 @@ static int write_out_results(struct patch *list)
if (l->rejected)
errs = 1;
else {
- write_out_one_result(l, phase);
+ write_out_one_result(state, l, phase);
if (phase == 1) {
- if (write_out_one_reject(l))
+ if (write_out_one_reject(state, l))
errs = 1;
if (l->conflicted_threeway) {
string_list_append(&cpath, l->new_name);
@@ -4353,14 +4500,17 @@ static struct lock_file lock_file;
#define INACCURATE_EOF (1<<0)
#define RECOUNT (1<<1)
-static int apply_patch(int fd, const char *filename, int options)
+static int apply_patch(struct apply_state *state,
+ int fd,
+ const char *filename,
+ int options)
{
size_t offset;
struct strbuf buf = STRBUF_INIT; /* owns the patch text */
struct patch *list = NULL, **listp = &list;
int skipped_patch = 0;
- patch_input_file = filename;
+ state->patch_input_file = filename;
read_patch_file(&buf, fd);
offset = 0;
while (offset < buf.len) {
@@ -4370,20 +4520,20 @@ static int apply_patch(int fd, const char *filename, int options)
patch = xcalloc(1, sizeof(*patch));
patch->inaccurate_eof = !!(options & INACCURATE_EOF);
patch->recount = !!(options & RECOUNT);
- nr = parse_chunk(buf.buf + offset, buf.len - offset, patch);
+ nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch);
if (nr < 0) {
free_patch(patch);
break;
}
- if (apply_in_reverse)
+ if (state->apply_in_reverse)
reverse_patches(patch);
- if (use_patch(patch)) {
- patch_stats(patch);
+ if (use_patch(state, patch)) {
+ patch_stats(state, patch);
*listp = patch;
listp = &patch->next;
}
else {
- if (apply_verbosely)
+ if (state->apply_verbosely)
say_patch_name(stderr, _("Skipped patch '%s'."), patch);
free_patch(patch);
skipped_patch++;
@@ -4394,45 +4544,45 @@ static int apply_patch(int fd, const char *filename, int options)
if (!list && !skipped_patch)
die(_("unrecognized input"));
- if (whitespace_error && (ws_error_action == die_on_ws_error))
- apply = 0;
+ if (state->whitespace_error && (state->ws_error_action == die_on_ws_error))
+ state->apply = 0;
- update_index = check_index && apply;
- if (update_index && newfd < 0)
- newfd = hold_locked_index(&lock_file, 1);
+ state->update_index = state->check_index && state->apply;
+ if (state->update_index && state->newfd < 0)
+ state->newfd = hold_locked_index(state->lock_file, 1);
- if (check_index) {
+ if (state->check_index) {
if (read_cache() < 0)
die(_("unable to read index file"));
}
- if ((check || apply) &&
- check_patch_list(list) < 0 &&
- !apply_with_reject)
+ if ((state->check || state->apply) &&
+ check_patch_list(state, list) < 0 &&
+ !state->apply_with_reject)
exit(1);
- if (apply && write_out_results(list)) {
- if (apply_with_reject)
+ if (state->apply && write_out_results(state, list)) {
+ if (state->apply_with_reject)
exit(1);
/* with --3way, we still need to write the index out */
return 1;
}
- if (fake_ancestor)
- build_fake_ancestor(list, fake_ancestor);
+ if (state->fake_ancestor)
+ build_fake_ancestor(list, state->fake_ancestor);
- if (diffstat)
- stat_patch_list(list);
+ if (state->diffstat)
+ stat_patch_list(state, list);
- if (numstat)
- numstat_patch_list(list);
+ if (state->numstat)
+ numstat_patch_list(state, list);
- if (summary)
+ if (state->summary)
summary_patch_list(list);
free_patch_list(list);
strbuf_release(&buf);
- string_list_clear(&fn_table, 0);
+ string_list_clear(&state->fn_table, 0);
return 0;
}
@@ -4446,220 +4596,284 @@ static void git_apply_config(void)
static int option_parse_exclude(const struct option *opt,
const char *arg, int unset)
{
- add_name_limit(arg, 1);
+ struct apply_state *state = opt->value;
+ add_name_limit(state, arg, 1);
return 0;
}
static int option_parse_include(const struct option *opt,
const char *arg, int unset)
{
- add_name_limit(arg, 0);
- has_include = 1;
+ struct apply_state *state = opt->value;
+ add_name_limit(state, arg, 0);
+ state->has_include = 1;
return 0;
}
static int option_parse_p(const struct option *opt,
- const char *arg, int unset)
+ const char *arg,
+ int unset)
{
- p_value = atoi(arg);
- p_value_known = 1;
+ struct apply_state *state = opt->value;
+ state->p_value = atoi(arg);
+ state->p_value_known = 1;
return 0;
}
static int option_parse_space_change(const struct option *opt,
- const char *arg, int unset)
+ const char *arg, int unset)
{
+ struct apply_state *state = opt->value;
if (unset)
- ws_ignore_action = ignore_ws_none;
+ state->ws_ignore_action = ignore_ws_none;
else
- ws_ignore_action = ignore_ws_change;
+ state->ws_ignore_action = ignore_ws_change;
return 0;
}
static int option_parse_whitespace(const struct option *opt,
const char *arg, int unset)
{
- const char **whitespace_option = opt->value;
-
- *whitespace_option = arg;
- parse_whitespace_option(arg);
+ struct apply_state *state = opt->value;
+ state->whitespace_option = arg;
+ parse_whitespace_option(state, arg);
return 0;
}
static int option_parse_directory(const struct option *opt,
const char *arg, int unset)
{
- strbuf_reset(&root);
- strbuf_addstr(&root, arg);
- strbuf_complete(&root, '/');
+ struct apply_state *state = opt->value;
+ strbuf_reset(&state->root);
+ strbuf_addstr(&state->root, arg);
+ strbuf_complete(&state->root, '/');
return 0;
}
-int cmd_apply(int argc, const char **argv, const char *prefix_)
+static void init_apply_state(struct apply_state *state,
+ const char *prefix,
+ struct lock_file *lock_file)
+{
+ memset(state, 0, sizeof(*state));
+ state->prefix = prefix;
+ state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
+ state->lock_file = lock_file;
+ state->newfd = -1;
+ state->apply = 1;
+ state->line_termination = '\n';
+ state->p_value = 1;
+ state->p_context = UINT_MAX;
+ state->squelch_whitespace_errors = 5;
+ state->ws_error_action = warn_on_ws_error;
+ state->ws_ignore_action = ignore_ws_none;
+ state->linenr = 1;
+ string_list_init(&state->fn_table, 0);
+ string_list_init(&state->limit_by_name, 0);
+ string_list_init(&state->symlink_changes, 0);
+ strbuf_init(&state->root, 0);
+
+ git_apply_config();
+ if (apply_default_whitespace)
+ parse_whitespace_option(state, apply_default_whitespace);
+ if (apply_default_ignorewhitespace)
+ parse_ignorewhitespace_option(state, apply_default_ignorewhitespace);
+}
+
+static void clear_apply_state(struct apply_state *state)
+{
+ string_list_clear(&state->limit_by_name, 0);
+ string_list_clear(&state->symlink_changes, 0);
+ strbuf_release(&state->root);
+
+ /* &state->fn_table is cleared at the end of apply_patch() */
+}
+
+static void check_apply_state(struct apply_state *state, int force_apply)
+{
+ int is_not_gitdir = !startup_info->have_repository;
+
+ if (state->apply_with_reject && state->threeway)
+ die("--reject and --3way cannot be used together.");
+ if (state->cached && state->threeway)
+ die("--cached and --3way cannot be used together.");
+ if (state->threeway) {
+ if (is_not_gitdir)
+ die(_("--3way outside a repository"));
+ state->check_index = 1;
+ }
+ if (state->apply_with_reject)
+ state->apply = state->apply_verbosely = 1;
+ if (!force_apply && (state->diffstat || state->numstat || state->summary || state->check || state->fake_ancestor))
+ state->apply = 0;
+ if (state->check_index && is_not_gitdir)
+ die(_("--index outside a repository"));
+ if (state->cached) {
+ if (is_not_gitdir)
+ die(_("--cached outside a repository"));
+ state->check_index = 1;
+ }
+ if (state->check_index)
+ state->unsafe_paths = 0;
+ if (!state->lock_file)
+ die("BUG: state->lock_file should not be NULL");
+}
+
+static int apply_all_patches(struct apply_state *state,
+ int argc,
+ const char **argv,
+ int options)
{
int i;
int errs = 0;
- int is_not_gitdir = !startup_info->have_repository;
- int force_apply = 0;
+ int read_stdin = 1;
+
+ for (i = 0; i < argc; i++) {
+ const char *arg = argv[i];
+ int fd;
+
+ if (!strcmp(arg, "-")) {
+ errs |= apply_patch(state, 0, "<stdin>", options);
+ read_stdin = 0;
+ continue;
+ } else if (0 < state->prefix_length)
+ arg = prefix_filename(state->prefix,
+ state->prefix_length,
+ arg);
+
+ fd = open(arg, O_RDONLY);
+ if (fd < 0)
+ die_errno(_("can't open patch '%s'"), arg);
+ read_stdin = 0;
+ set_default_whitespace_mode(state);
+ errs |= apply_patch(state, fd, arg, options);
+ close(fd);
+ }
+ set_default_whitespace_mode(state);
+ if (read_stdin)
+ errs |= apply_patch(state, 0, "<stdin>", options);
+
+ if (state->whitespace_error) {
+ if (state->squelch_whitespace_errors &&
+ state->squelch_whitespace_errors < state->whitespace_error) {
+ int squelched =
+ state->whitespace_error - state->squelch_whitespace_errors;
+ warning(Q_("squelched %d whitespace error",
+ "squelched %d whitespace errors",
+ squelched),
+ squelched);
+ }
+ if (state->ws_error_action == die_on_ws_error)
+ die(Q_("%d line adds whitespace errors.",
+ "%d lines add whitespace errors.",
+ state->whitespace_error),
+ state->whitespace_error);
+ if (state->applied_after_fixing_ws && state->apply)
+ warning("%d line%s applied after"
+ " fixing whitespace errors.",
+ state->applied_after_fixing_ws,
+ state->applied_after_fixing_ws == 1 ? "" : "s");
+ else if (state->whitespace_error)
+ warning(Q_("%d line adds whitespace errors.",
+ "%d lines add whitespace errors.",
+ state->whitespace_error),
+ state->whitespace_error);
+ }
+
+ if (state->update_index) {
+ if (write_locked_index(&the_index, state->lock_file, COMMIT_LOCK))
+ die(_("Unable to write new index file"));
+ state->newfd = -1;
+ }
+
+ return !!errs;
+}
- const char *whitespace_option = NULL;
+int cmd_apply(int argc, const char **argv, const char *prefix)
+{
+ int force_apply = 0;
+ int options = 0;
+ int ret;
+ struct apply_state state;
struct option builtin_apply_options[] = {
- { OPTION_CALLBACK, 0, "exclude", NULL, N_("path"),
+ { OPTION_CALLBACK, 0, "exclude", &state, N_("path"),
N_("don't apply changes matching the given path"),
0, option_parse_exclude },
- { OPTION_CALLBACK, 0, "include", NULL, N_("path"),
+ { OPTION_CALLBACK, 0, "include", &state, N_("path"),
N_("apply changes matching the given path"),
0, option_parse_include },
- { OPTION_CALLBACK, 'p', NULL, NULL, N_("num"),
+ { OPTION_CALLBACK, 'p', NULL, &state, N_("num"),
N_("remove <num> leading slashes from traditional diff paths"),
0, option_parse_p },
- OPT_BOOL(0, "no-add", &no_add,
+ OPT_BOOL(0, "no-add", &state.no_add,
N_("ignore additions made by the patch")),
- OPT_BOOL(0, "stat", &diffstat,
+ OPT_BOOL(0, "stat", &state.diffstat,
N_("instead of applying the patch, output diffstat for the input")),
OPT_NOOP_NOARG(0, "allow-binary-replacement"),
OPT_NOOP_NOARG(0, "binary"),
- OPT_BOOL(0, "numstat", &numstat,
+ OPT_BOOL(0, "numstat", &state.numstat,
N_("show number of added and deleted lines in decimal notation")),
- OPT_BOOL(0, "summary", &summary,
+ OPT_BOOL(0, "summary", &state.summary,
N_("instead of applying the patch, output a summary for the input")),
- OPT_BOOL(0, "check", &check,
+ OPT_BOOL(0, "check", &state.check,
N_("instead of applying the patch, see if the patch is applicable")),
- OPT_BOOL(0, "index", &check_index,
+ OPT_BOOL(0, "index", &state.check_index,
N_("make sure the patch is applicable to the current index")),
- OPT_BOOL(0, "cached", &cached,
+ OPT_BOOL(0, "cached", &state.cached,
N_("apply a patch without touching the working tree")),
- OPT_BOOL(0, "unsafe-paths", &unsafe_paths,
+ OPT_BOOL(0, "unsafe-paths", &state.unsafe_paths,
N_("accept a patch that touches outside the working area")),
OPT_BOOL(0, "apply", &force_apply,
N_("also apply the patch (use with --stat/--summary/--check)")),
- OPT_BOOL('3', "3way", &threeway,
+ OPT_BOOL('3', "3way", &state.threeway,
N_( "attempt three-way merge if a patch does not apply")),
- OPT_FILENAME(0, "build-fake-ancestor", &fake_ancestor,
+ OPT_FILENAME(0, "build-fake-ancestor", &state.fake_ancestor,
N_("build a temporary index based on embedded index information")),
/* Think twice before adding "--nul" synonym to this */
- OPT_SET_INT('z', NULL, &line_termination,
+ OPT_SET_INT('z', NULL, &state.line_termination,
N_("paths are separated with NUL character"), '\0'),
- OPT_INTEGER('C', NULL, &p_context,
+ OPT_INTEGER('C', NULL, &state.p_context,
N_("ensure at least <n> lines of context match")),
- { OPTION_CALLBACK, 0, "whitespace", &whitespace_option, N_("action"),
+ { OPTION_CALLBACK, 0, "whitespace", &state, N_("action"),
N_("detect new or modified lines that have whitespace errors"),
0, option_parse_whitespace },
- { OPTION_CALLBACK, 0, "ignore-space-change", NULL, NULL,
+ { OPTION_CALLBACK, 0, "ignore-space-change", &state, NULL,
N_("ignore changes in whitespace when finding context"),
PARSE_OPT_NOARG, option_parse_space_change },
- { OPTION_CALLBACK, 0, "ignore-whitespace", NULL, NULL,
+ { OPTION_CALLBACK, 0, "ignore-whitespace", &state, NULL,
N_("ignore changes in whitespace when finding context"),
PARSE_OPT_NOARG, option_parse_space_change },
- OPT_BOOL('R', "reverse", &apply_in_reverse,
+ OPT_BOOL('R', "reverse", &state.apply_in_reverse,
N_("apply the patch in reverse")),
- OPT_BOOL(0, "unidiff-zero", &unidiff_zero,
+ OPT_BOOL(0, "unidiff-zero", &state.unidiff_zero,
N_("don't expect at least one line of context")),
- OPT_BOOL(0, "reject", &apply_with_reject,
+ OPT_BOOL(0, "reject", &state.apply_with_reject,
N_("leave the rejected hunks in corresponding *.rej files")),
- OPT_BOOL(0, "allow-overlap", &allow_overlap,
+ OPT_BOOL(0, "allow-overlap", &state.allow_overlap,
N_("allow overlapping hunks")),
- OPT__VERBOSE(&apply_verbosely, N_("be verbose")),
+ OPT__VERBOSE(&state.apply_verbosely, N_("be verbose")),
OPT_BIT(0, "inaccurate-eof", &options,
N_("tolerate incorrectly detected missing new-line at the end of file"),
INACCURATE_EOF),
OPT_BIT(0, "recount", &options,
N_("do not trust the line counts in the hunk headers"),
RECOUNT),
- { OPTION_CALLBACK, 0, "directory", NULL, N_("root"),
+ { OPTION_CALLBACK, 0, "directory", &state, N_("root"),
N_("prepend <root> to all filenames"),
0, option_parse_directory },
OPT_END()
};
- prefix = prefix_;
- prefix_length = prefix ? strlen(prefix) : 0;
- git_apply_config();
- if (apply_default_whitespace)
- parse_whitespace_option(apply_default_whitespace);
- if (apply_default_ignorewhitespace)
- parse_ignorewhitespace_option(apply_default_ignorewhitespace);
+ init_apply_state(&state, prefix, &lock_file);
- argc = parse_options(argc, argv, prefix, builtin_apply_options,
+ argc = parse_options(argc, argv, state.prefix, builtin_apply_options,
apply_usage, 0);
- if (apply_with_reject && threeway)
- die("--reject and --3way cannot be used together.");
- if (cached && threeway)
- die("--cached and --3way cannot be used together.");
- if (threeway) {
- if (is_not_gitdir)
- die(_("--3way outside a repository"));
- check_index = 1;
- }
- if (apply_with_reject)
- apply = apply_verbosely = 1;
- if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
- apply = 0;
- if (check_index && is_not_gitdir)
- die(_("--index outside a repository"));
- if (cached) {
- if (is_not_gitdir)
- die(_("--cached outside a repository"));
- check_index = 1;
- }
- if (check_index)
- unsafe_paths = 0;
+ check_apply_state(&state, force_apply);
- for (i = 0; i < argc; i++) {
- const char *arg = argv[i];
- int fd;
+ ret = apply_all_patches(&state, argc, argv, options);
- if (!strcmp(arg, "-")) {
- errs |= apply_patch(0, "<stdin>", options);
- read_stdin = 0;
- continue;
- } else if (0 < prefix_length)
- arg = prefix_filename(prefix, prefix_length, arg);
+ clear_apply_state(&state);
- fd = open(arg, O_RDONLY);
- if (fd < 0)
- die_errno(_("can't open patch '%s'"), arg);
- read_stdin = 0;
- set_default_whitespace_mode(whitespace_option);
- errs |= apply_patch(fd, arg, options);
- close(fd);
- }
- set_default_whitespace_mode(whitespace_option);
- if (read_stdin)
- errs |= apply_patch(0, "<stdin>", options);
- if (whitespace_error) {
- if (squelch_whitespace_errors &&
- squelch_whitespace_errors < whitespace_error) {
- int squelched =
- whitespace_error - squelch_whitespace_errors;
- warning(Q_("squelched %d whitespace error",
- "squelched %d whitespace errors",
- squelched),
- squelched);
- }
- if (ws_error_action == die_on_ws_error)
- die(Q_("%d line adds whitespace errors.",
- "%d lines add whitespace errors.",
- whitespace_error),
- whitespace_error);
- if (applied_after_fixing_ws && apply)
- warning("%d line%s applied after"
- " fixing whitespace errors.",
- applied_after_fixing_ws,
- applied_after_fixing_ws == 1 ? "" : "s");
- else if (whitespace_error)
- warning(Q_("%d line adds whitespace errors.",
- "%d lines add whitespace errors.",
- whitespace_error),
- whitespace_error);
- }
-
- if (update_index) {
- if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
- die(_("Unable to write new index file"));
- }
-
- return !!errs;
+ return ret;
}
diff --git a/builtin/blame.c b/builtin/blame.c
index 759d84aff..2ed83e16b 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -56,7 +56,7 @@ static int show_progress;
static struct date_mode blame_date_mode = { DATE_ISO8601 };
static size_t blame_date_width;
-static struct string_list mailmap;
+static struct string_list mailmap = STRING_LIST_INIT_NODUP;
#ifndef DEBUG
#define DEBUG 0
@@ -134,7 +134,7 @@ struct progress_info {
int blamed_lines;
};
-static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b, long ctxlen,
+static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b,
xdl_emit_hunk_consume_func_t hunk_func, void *cb_data)
{
xpparam_t xpp = {0};
@@ -142,7 +142,6 @@ static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b, long ctxlen,
xdemitcb_t ecb = {NULL};
xpp.flags = xdl_opts;
- xecfg.ctxlen = ctxlen;
xecfg.hunk_func = hunk_func;
ecb.priv = cb_data;
return xdi_diff(file_a, file_b, &xpp, &xecfg, &ecb);
@@ -980,7 +979,7 @@ static void pass_blame_to_parent(struct scoreboard *sb,
fill_origin_blob(&sb->revs->diffopt, target, &file_o);
num_get_patch++;
- if (diff_hunks(&file_p, &file_o, 0, blame_chunk_cb, &d))
+ if (diff_hunks(&file_p, &file_o, blame_chunk_cb, &d))
die("unable to generate diff (%s -> %s)",
oid_to_hex(&parent->commit->object.oid),
oid_to_hex(&target->commit->object.oid));
@@ -1129,7 +1128,7 @@ static void find_copy_in_blob(struct scoreboard *sb,
* file_p partially may match that image.
*/
memset(split, 0, sizeof(struct blame_entry [3]));
- if (diff_hunks(file_p, &file_o, 1, handle_split_cb, &d))
+ if (diff_hunks(file_p, &file_o, handle_split_cb, &d))
die("unable to generate diff (%s)",
oid_to_hex(&parent->commit->object.oid));
/* remainder, if any, all match the preimage */
@@ -2425,8 +2424,7 @@ static struct commit *find_single_final(struct rev_info *revs,
struct object *obj = revs->pending.objects[i].item;
if (obj->flags & UNINTERESTING)
continue;
- while (obj->type == OBJ_TAG)
- obj = deref_tag(obj, NULL, 0);
+ obj = deref_tag(obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
@@ -2461,8 +2459,7 @@ static char *prepare_initial(struct scoreboard *sb)
struct object *obj = revs->pending.objects[i].item;
if (!(obj->flags & UNINTERESTING))
continue;
- while (obj->type == OBJ_TAG)
- obj = deref_tag(obj, NULL, 0);
+ obj = deref_tag(obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (sb->final)
@@ -2522,12 +2519,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
enum object_type type;
struct commit *final_commit = NULL;
- static struct string_list range_list;
- static int output_option = 0, opt = 0;
- static int show_stats = 0;
- static const char *revs_file = NULL;
- static const char *contents_from = NULL;
- static const struct option options[] = {
+ struct string_list range_list = STRING_LIST_INIT_NODUP;
+ int output_option = 0, opt = 0;
+ int show_stats = 0;
+ const char *revs_file = NULL;
+ const char *contents_from = NULL;
+ const struct option options[] = {
OPT_BOOL(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")),
OPT_BOOL('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")),
OPT_BOOL(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")),
diff --git a/builtin/branch.c b/builtin/branch.c
index 2ecde53bf..12203fdcc 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -614,9 +614,9 @@ static int edit_branch_description(const char *branch_name)
if (!buf.len || buf.buf[buf.len-1] != '\n')
strbuf_addch(&buf, '\n');
strbuf_commented_addf(&buf,
- "Please edit the description for the branch\n"
- " %s\n"
- "Lines starting with '%c' will be stripped.\n",
+ _("Please edit the description for the branch\n"
+ " %s\n"
+ "Lines starting with '%c' will be stripped.\n"),
branch_name, comment_line_char);
if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
strbuf_release(&buf);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 3398c61e9..27c1a0524 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -276,7 +276,7 @@ static int checkout_paths(const struct checkout_opts *opts,
hold_locked_index(lock_file, 1);
if (read_cache_preload(&opts->pathspec) < 0)
- return error(_("corrupt index file"));
+ return error(_("index file corrupt"));
if (opts->source_tree)
read_tree_some(opts->source_tree, &opts->pathspec);
@@ -470,7 +470,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
hold_locked_index(lock_file, 1);
if (read_cache_preload(NULL) < 0)
- return error(_("corrupt index file"));
+ return error(_("index file corrupt"));
resolve_undo_clear();
if (opts->force) {
@@ -548,7 +548,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
* entries in the index.
*/
- add_files_to_cache(NULL, NULL, 0);
+ add_files_to_cache(NULL, NULL, 0, 0);
/*
* NEEDSWORK: carrying over local changes
* when branches have different end-of-line
@@ -1138,7 +1138,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT_STRING('B', NULL, &opts.new_branch_force, N_("branch"),
N_("create/reset and checkout a branch")),
OPT_BOOL('l', NULL, &opts.new_branch_log, N_("create reflog for new branch")),
- OPT_BOOL(0, "detach", &opts.force_detach, N_("detach the HEAD at named commit")),
+ OPT_BOOL(0, "detach", &opts.force_detach, N_("detach HEAD at named commit")),
OPT_SET_INT('t', "track", &opts.track, N_("set upstream info for new branch"),
BRANCH_TRACK_EXPLICIT),
OPT_STRING(0, "orphan", &opts.new_orphan_branch, N_("new-branch"), N_("new unparented branch")),
diff --git a/builtin/clone.c b/builtin/clone.c
index 5f867e67d..31ea247e3 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -40,7 +40,7 @@ static const char * const builtin_clone_usage[] = {
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
static int option_local = -1, option_no_hardlinks, option_shared, option_recursive;
-static int option_shallow_submodules = -1;
+static int option_shallow_submodules;
static char *option_template, *option_depth;
static char *option_origin = NULL;
static char *option_branch = NULL;
@@ -49,8 +49,8 @@ static char *option_upload_pack = "git-upload-pack";
static int option_verbosity;
static int option_progress = -1;
static enum transport_family family;
-static struct string_list option_config;
-static struct string_list option_reference;
+static struct string_list option_config = STRING_LIST_INIT_NODUP;
+static struct string_list option_reference = STRING_LIST_INIT_NODUP;
static int option_dissociate;
static int max_jobs = -1;
@@ -738,8 +738,7 @@ static int checkout(void)
struct argv_array args = ARGV_ARRAY_INIT;
argv_array_pushl(&args, "submodule", "update", "--init", "--recursive", NULL);
- if (option_shallow_submodules == 1
- || (option_shallow_submodules == -1 && option_depth))
+ if (option_shallow_submodules == 1)
argv_array_push(&args, "--depth=1");
if (max_jobs != -1)
diff --git a/builtin/commit.c b/builtin/commit.c
index 443ff9196..1f6dbcd0d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -92,8 +92,9 @@ N_("If you wish to skip this commit, use:\n"
"Then \"git cherry-pick --continue\" will resume cherry-picking\n"
"the remaining commits.\n");
+static GIT_PATH_FUNC(git_path_commit_editmsg, "COMMIT_EDITMSG")
+
static const char *use_message_buffer;
-static const char commit_editmsg[] = "COMMIT_EDITMSG";
static struct lock_file index_lock; /* real index */
static struct lock_file false_lock; /* used only for partial commits */
static enum {
@@ -386,7 +387,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
*/
if (all || (also && pathspec.nr)) {
hold_locked_index(&index_lock, 1);
- add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
+ add_files_to_cache(also ? prefix : NULL, &pathspec, 0, 0);
refresh_cache_or_die(refresh_flags);
update_main_cache_tree(WRITE_TREE_SILENT);
if (write_locked_index(&the_index, &index_lock, CLOSE_LOCK))
@@ -714,7 +715,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
char *buffer;
buffer = strstr(use_message_buffer, "\n\n");
if (buffer)
- strbuf_addstr(&sb, buffer + 2);
+ strbuf_addstr(&sb, skip_blank_lines(buffer + 2));
hook_arg1 = "commit";
hook_arg2 = use_message;
} else if (fixup_message) {
@@ -772,9 +773,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
hook_arg2 = "";
}
- s->fp = fopen_for_writing(git_path(commit_editmsg));
+ s->fp = fopen_for_writing(git_path_commit_editmsg());
if (s->fp == NULL)
- die_errno(_("could not open '%s'"), git_path(commit_editmsg));
+ die_errno(_("could not open '%s'"), git_path_commit_editmsg());
/* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
old_display_comment_prefix = s->display_comment_prefix;
@@ -951,7 +952,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
}
if (run_commit_hook(use_editor, index_file, "prepare-commit-msg",
- git_path(commit_editmsg), hook_arg1, hook_arg2, NULL))
+ git_path_commit_editmsg(), hook_arg1, hook_arg2, NULL))
return 0;
if (use_editor) {
@@ -959,7 +960,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
const char *env[2] = { NULL };
env[0] = index;
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
- if (launch_editor(git_path(commit_editmsg), NULL, env)) {
+ if (launch_editor(git_path_commit_editmsg(), NULL, env)) {
fprintf(stderr,
_("Please supply the message using either -m or -F option.\n"));
exit(1);
@@ -967,7 +968,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
}
if (!no_verify &&
- run_commit_hook(use_editor, index_file, "commit-msg", git_path(commit_editmsg), NULL)) {
+ run_commit_hook(use_editor, index_file, "commit-msg", git_path_commit_editmsg(), NULL)) {
return 0;
}
@@ -1738,7 +1739,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
/* Finally, get the commit message */
strbuf_reset(&sb);
- if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
+ if (strbuf_read_file(&sb, git_path_commit_editmsg(), 0) < 0) {
int saved_errno = errno;
rollback_index_files();
die(_("could not read commit message: %s"), strerror(saved_errno));
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 1582ca718..f896aa1f8 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1005,7 +1005,7 @@ static int get_remote_group(const char *key, const char *value, void *priv)
size_t wordlen = strcspn(value, " \t\n");
if (wordlen >= 1)
- string_list_append(g->list,
+ string_list_append_nodup(g->list,
xstrndup(value, wordlen));
value += wordlen + (value[wordlen] != '\0');
}
@@ -1143,7 +1143,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
int cmd_fetch(int argc, const char **argv, const char *prefix)
{
int i;
- struct string_list list = STRING_LIST_INIT_NODUP;
+ struct string_list list = STRING_LIST_INIT_DUP;
struct remote *remote;
int result = 0;
struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
@@ -1226,8 +1226,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
argv_array_clear(&options);
}
- /* All names were strdup()ed or strndup()ed */
- list.strdup_strings = 1;
string_list_clear(&list, 0);
close_all_packs();
diff --git a/builtin/gc.c b/builtin/gc.c
index c583aad6e..332bcf7e7 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -177,7 +177,7 @@ static int too_many_packs(void)
*/
cnt++;
}
- return gc_auto_pack_limit <= cnt;
+ return gc_auto_pack_limit < cnt;
}
static void add_repack_all_option(void)
diff --git a/builtin/grep.c b/builtin/grep.c
index 462e60790..ae738312a 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -386,7 +386,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
for (nr = 0; nr < active_nr; nr++) {
const struct cache_entry *ce = active_cache[nr];
- if (!S_ISREG(ce->ce_mode) || ce_intent_to_add(ce))
+ if (!S_ISREG(ce->ce_mode))
continue;
if (!ce_path_match(ce, pathspec, NULL))
continue;
@@ -396,7 +396,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
* cache version instead
*/
if (cached || (ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) {
- if (ce_stage(ce))
+ if (ce_stage(ce) || ce_intent_to_add(ce))
continue;
hit |= grep_sha1(opt, ce->sha1, ce->name, 0, ce->name);
}
diff --git a/builtin/init-db.c b/builtin/init-db.c
index b2d8d40a6..3a45f0bcf 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -397,13 +397,16 @@ int init_db(const char *template_dir, unsigned int flags)
if (!(flags & INIT_DB_QUIET)) {
int len = strlen(git_dir);
- /* TRANSLATORS: The first '%s' is either "Reinitialized
- existing" or "Initialized empty", the second " shared" or
- "", and the last '%s%s' is the verbatim directory name. */
- printf(_("%s%s Git repository in %s%s\n"),
- reinit ? _("Reinitialized existing") : _("Initialized empty"),
- get_shared_repository() ? _(" shared") : "",
- git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+ if (reinit)
+ printf(get_shared_repository()
+ ? _("Reinitialized existing shared Git repository in %s%s\n")
+ : _("Reinitialized existing Git repository in %s%s\n"),
+ git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+ else
+ printf(get_shared_repository()
+ ? _("Initialized empty shared Git repository in %s%s\n")
+ : _("Initialized empty Git repository in %s%s\n"),
+ git_dir, len && git_dir[len-1] != '/' ? "/" : "");
}
return 0;
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
index b99ae4be8..175f14797 100644
--- a/builtin/interpret-trailers.c
+++ b/builtin/interpret-trailers.c
@@ -20,7 +20,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
{
int in_place = 0;
int trim_empty = 0;
- struct string_list trailers = STRING_LIST_INIT_DUP;
+ struct string_list trailers = STRING_LIST_INIT_NODUP;
struct option options[] = {
OPT_BOOL(0, "in-place", &in_place, N_("edit files in place")),
diff --git a/builtin/log.c b/builtin/log.c
index 1a6903b3f..fd1652f52 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -33,6 +33,7 @@ static const char *default_date_mode = NULL;
static int default_abbrev_commit;
static int default_show_root = 1;
static int default_follow;
+static int default_show_signature;
static int decoration_style;
static int decoration_given;
static int use_mailmap_config;
@@ -119,6 +120,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
rev->abbrev_commit = default_abbrev_commit;
rev->show_root_diff = default_show_root;
rev->subject_prefix = fmt_patch_subject_prefix;
+ rev->show_signature = default_show_signature;
DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
if (default_date_mode)
@@ -418,6 +420,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
use_mailmap_config = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "log.showsignature")) {
+ default_show_signature = git_config_bool(var, value);
+ return 0;
+ }
if (grep_config(var, value, cb) < 0)
return -1;
@@ -684,9 +690,9 @@ static int auto_number = 1;
static char *default_attach = NULL;
-static struct string_list extra_hdr;
-static struct string_list extra_to;
-static struct string_list extra_cc;
+static struct string_list extra_hdr = STRING_LIST_INIT_NODUP;
+static struct string_list extra_to = STRING_LIST_INIT_NODUP;
+static struct string_list extra_cc = STRING_LIST_INIT_NODUP;
static void add_header(const char *value)
{
@@ -962,7 +968,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
struct pretty_print_context pp = {0};
struct commit *head = list[0];
- if (rev->commit_format != CMIT_FMT_EMAIL)
+ if (!cmit_fmt_is_mail(rev->commit_format))
die(_("Cover letter needs email format"));
committer = git_committer_info(0);
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 4859ede38..30681681c 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -45,6 +45,19 @@ static int is_from_line(const char *line, int len)
static struct strbuf buf = STRBUF_INIT;
static int keep_cr;
+static int mboxrd;
+
+static int is_gtfrom(const struct strbuf *buf)
+{
+ size_t min = strlen(">From ");
+ size_t ngt;
+
+ if (buf->len < min)
+ return 0;
+
+ ngt = strspn(buf->buf, ">");
+ return ngt && starts_with(buf->buf + ngt, "From ");
+}
/* Called with the first line (potentially partial)
* already in buf[] -- normally that should begin with
@@ -77,6 +90,9 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
strbuf_addch(&buf, '\n');
}
+ if (mboxrd && is_gtfrom(&buf))
+ strbuf_remove(&buf, 0, 1);
+
if (fwrite(buf.buf, 1, buf.len, output) != buf.len)
die_errno("cannot write output");
@@ -271,6 +287,8 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
keep_cr = 1;
} else if ( arg[1] == 'o' && arg[2] ) {
dir = arg+2;
+ } else if (!strcmp(arg, "--mboxrd")) {
+ mboxrd = 1;
} else if ( arg[1] == '-' && !arg[2] ) {
argp++; /* -- marks end of options */
break;
diff --git a/builtin/merge.c b/builtin/merge.c
index b555a1bf9..d82f6c19a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -211,7 +211,7 @@ static struct option builtin_merge_options[] = {
PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
OPT_BOOL(0, "verify-signatures", &verify_signatures,
- N_("Verify that the named commit has a valid GPG signature")),
+ N_("verify that the named commit has a valid GPG signature")),
OPT_CALLBACK('s', "strategy", &use_strategies, N_("strategy"),
N_("merge strategy to use"), option_parse_strategy),
OPT_CALLBACK('X', "strategy-option", &xopts, N_("option=value"),
@@ -1014,7 +1014,7 @@ static int default_edit_option(void)
if (e) {
int v = git_config_maybe_bool(name, e);
if (v < 0)
- die("Bad value '%s' in environment '%s'", e, name);
+ die(_("Bad value '%s' in environment '%s'"), e, name);
return v;
}
@@ -1115,7 +1115,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
if (!commit) {
if (ptr)
*ptr = '\0';
- die("not something we can merge in %s: %s",
+ die(_("not something we can merge in %s: %s"),
filename, merge_names->buf + pos);
}
remotes = &commit_list_insert(commit, remotes)->next;
@@ -1149,7 +1149,7 @@ static struct commit_list *collect_parents(struct commit *head_commit,
struct commit *commit = get_merge_parent(argv[i]);
if (!commit)
help_unknown_ref(argv[i], "merge",
- "not something we can merge");
+ _("not something we can merge"));
remotes = &commit_list_insert(commit, remotes)->next;
}
remoteheads = reduce_parents(head_commit, head_subsumed, remoteheads);
@@ -1421,7 +1421,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* If head can reach all the merge then we are up to date.
* but first the most common case of merging one remote.
*/
- finish_up_to_date("Already up-to-date.");
+ finish_up_to_date(_("Already up-to-date."));
goto done;
} else if (fast_forward != FF_NO && !remoteheads->next &&
!common->next &&
@@ -1506,7 +1506,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}
}
if (up_to_date) {
- finish_up_to_date("Already up-to-date. Yeeah!");
+ finish_up_to_date(_("Already up-to-date. Yeeah!"));
goto done;
}
}
diff --git a/builtin/notes.c b/builtin/notes.c
index c65b59ad9..057205176 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -749,7 +749,7 @@ static int git_config_get_notes_strategy(const char *key,
if (git_config_get_string(key, &value))
return 1;
if (parse_notes_merge_strategy(value, strategy))
- git_die_config(key, "unknown notes merge strategy %s", value);
+ git_die_config(key, _("unknown notes merge strategy %s"), value);
free(value);
return 0;
@@ -788,15 +788,15 @@ static int merge(int argc, const char **argv, const char *prefix)
if (strategy || do_commit + do_abort == 0)
do_merge = 1;
if (do_merge + do_commit + do_abort != 1) {
- error("cannot mix --commit, --abort or -s/--strategy");
+ error(_("cannot mix --commit, --abort or -s/--strategy"));
usage_with_options(git_notes_merge_usage, options);
}
if (do_merge && argc != 1) {
- error("Must specify a notes ref to merge");
+ error(_("Must specify a notes ref to merge"));
usage_with_options(git_notes_merge_usage, options);
} else if (!do_merge && argc) {
- error("too many parameters");
+ error(_("too many parameters"));
usage_with_options(git_notes_merge_usage, options);
}
@@ -817,7 +817,7 @@ static int merge(int argc, const char **argv, const char *prefix)
if (strategy) {
if (parse_notes_merge_strategy(strategy, &o.strategy)) {
- error("Unknown -s/--strategy: %s", strategy);
+ error(_("Unknown -s/--strategy: %s"), strategy);
usage_with_options(git_notes_merge_usage, options);
}
} else {
@@ -857,11 +857,11 @@ static int merge(int argc, const char **argv, const char *prefix)
die(_("A notes merge into %s is already in-progress at %s"),
default_notes_ref(), wt->path);
if (create_symref("NOTES_MERGE_REF", default_notes_ref(), NULL))
- die("Failed to store link to current notes ref (%s)",
+ die(_("Failed to store link to current notes ref (%s)"),
default_notes_ref());
- printf("Automatic notes merge failed. Fix conflicts in %s and "
- "commit the result with 'git notes merge --commit', or "
- "abort the merge with 'git notes merge --abort'.\n",
+ printf(_("Automatic notes merge failed. Fix conflicts in %s and "
+ "commit the result with 'git notes merge --commit', or "
+ "abort the merge with 'git notes merge --abort'.\n"),
git_path(NOTES_MERGE_WORKTREE));
}
@@ -934,8 +934,8 @@ static int prune(int argc, const char **argv, const char *prefix)
struct notes_tree *t;
int show_only = 0, verbose = 0;
struct option options[] = {
- OPT__DRY_RUN(&show_only, "do not remove, show only"),
- OPT__VERBOSE(&verbose, "report pruned notes"),
+ OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
+ OPT__VERBOSE(&verbose, N_("report pruned notes")),
OPT_END()
};
@@ -964,7 +964,7 @@ static int get_ref(int argc, const char **argv, const char *prefix)
git_notes_get_ref_usage, 0);
if (argc) {
- error("too many parameters");
+ error(_("too many parameters"));
usage_with_options(git_notes_get_ref_usage, options);
}
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 8f5e358e2..a2f8cfdec 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -44,6 +44,7 @@ static int non_empty;
static int reuse_delta = 1, reuse_object = 1;
static int keep_unreachable, unpack_unreachable, include_tag;
static unsigned long unpack_unreachable_expiration;
+static int pack_loose_unreachable;
static int local;
static int incremental;
static int ignore_packed_keep;
@@ -2378,6 +2379,32 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
free(in_pack.array);
}
+static int add_loose_object(const unsigned char *sha1, const char *path,
+ void *data)
+{
+ enum object_type type = sha1_object_info(sha1, NULL);
+
+ if (type < 0) {
+ warning("loose object at %s could not be examined", path);
+ return 0;
+ }
+
+ add_object_entry(sha1, type, "", 0);
+ return 0;
+}
+
+/*
+ * We actually don't even have to worry about reachability here.
+ * add_object_entry will weed out duplicates, so we just add every
+ * loose object we find.
+ */
+static void add_unreachable_loose_objects(void)
+{
+ for_each_loose_file_in_objdir(get_object_directory(),
+ add_loose_object,
+ NULL, NULL, NULL);
+}
+
static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
{
static struct packed_git *last_found = (void *)1;
@@ -2547,6 +2574,8 @@ static void get_object_list(int ac, const char **av)
if (keep_unreachable)
add_objects_in_unpacked_packs(&revs);
+ if (pack_loose_unreachable)
+ add_unreachable_loose_objects();
if (unpack_unreachable)
loosen_unused_packed_objects(&revs);
@@ -2647,6 +2676,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
N_("include tag objects that refer to objects to be packed")),
OPT_BOOL(0, "keep-unreachable", &keep_unreachable,
N_("keep unreachable objects")),
+ OPT_BOOL(0, "pack-loose-unreachable", &pack_loose_unreachable,
+ N_("pack loose unreachable objects")),
{ OPTION_CALLBACK, 0, "unpack-unreachable", NULL, N_("time"),
N_("unpack unreachable objects newer than <time>"),
PARSE_OPT_OPTARG, option_parse_unpack_unreachable },
diff --git a/builtin/pull.c b/builtin/pull.c
index 897a7f4e4..398aae16c 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -855,7 +855,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
git_config(git_pull_config, NULL);
if (read_cache_unmerged())
- die_resolve_conflict("Pull");
+ die_resolve_conflict("pull");
if (file_exists(git_path("MERGE_HEAD")))
die_conclude_merge();
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index a744437b5..15c323a7c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1775,9 +1775,20 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
const char *argv_gc_auto[] = {
"gc", "--auto", "--quiet", NULL,
};
- int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR;
+ struct child_process proc = CHILD_PROCESS_INIT;
+
+ proc.no_stdin = 1;
+ proc.stdout_to_stderr = 1;
+ proc.err = use_sideband ? -1 : 0;
+ proc.git_cmd = 1;
+ proc.argv = argv_gc_auto;
+
close_all_packs();
- run_command_v_opt(argv_gc_auto, opt);
+ if (!start_command(&proc)) {
+ if (use_sideband)
+ copy_to_sideband(proc.err, -1, NULL);
+ finish_command(&proc);
+ }
}
if (auto_update_server_info)
update_server_info(0);
diff --git a/builtin/remote.c b/builtin/remote.c
index d33766be3..a4d9c1a8e 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -247,7 +247,7 @@ struct branch_info {
enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
};
-static struct string_list branch_list;
+static struct string_list branch_list = STRING_LIST_INIT_NODUP;
static const char *abbrev_ref(const char *name, const char *prefix)
{
@@ -952,7 +952,7 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
struct show_info *show_info = cb_data;
struct branch_info *branch_info = item->util;
struct string_list *merge = &branch_info->merge;
- const char *also;
+ int width = show_info->width + 4;
int i;
if (branch_info->rebase && branch_info->merge.nr > 1) {
@@ -963,19 +963,18 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
printf(" %-*s ", show_info->width, item->string);
if (branch_info->rebase) {
- printf_ln(_(branch_info->rebase == INTERACTIVE_REBASE ?
- "rebases interactively onto remote %s" :
- "rebases onto remote %s"), merge->items[0].string);
+ printf_ln(branch_info->rebase == INTERACTIVE_REBASE
+ ? _("rebases interactively onto remote %s")
+ : _("rebases onto remote %s"), merge->items[0].string);
return 0;
} else if (show_info->any_rebase) {
printf_ln(_(" merges with remote %s"), merge->items[0].string);
- also = _(" and with remote");
+ width++;
} else {
printf_ln(_("merges with remote %s"), merge->items[0].string);
- also = _(" and with remote");
}
for (i = 1; i < merge->nr; i++)
- printf(" %-*s %s %s\n", show_info->width, "", also,
+ printf(_("%-*s and with remote %s\n"), width, "",
merge->items[i].string);
return 0;
@@ -1158,11 +1157,11 @@ static int show(int argc, const char **argv)
the one in " Fetch URL: %s" translation */
printf_ln(_(" Push URL: %s"), url[i]);
if (!i)
- printf_ln(_(" Push URL: %s"), "(no URL)");
+ printf_ln(_(" Push URL: %s"), _("(no URL)"));
if (no_query)
- printf_ln(_(" HEAD branch: %s"), "(not queried)");
+ printf_ln(_(" HEAD branch: %s"), _("(not queried)"));
else if (!states.heads.nr)
- printf_ln(_(" HEAD branch: %s"), "(unknown)");
+ printf_ln(_(" HEAD branch: %s"), _("(unknown)"));
else if (states.heads.nr == 1)
printf_ln(_(" HEAD branch: %s"), states.heads.items[0].string);
else {
diff --git a/builtin/repack.c b/builtin/repack.c
index 858db38f5..80dd06b4a 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -146,6 +146,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
int pack_everything = 0;
int delete_redundant = 0;
const char *unpack_unreachable = NULL;
+ int keep_unreachable = 0;
const char *window = NULL, *window_memory = NULL;
const char *depth = NULL;
const char *max_pack_size = NULL;
@@ -175,6 +176,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
N_("write bitmap index")),
OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
N_("with -A, do not loosen objects older than this")),
+ OPT_BOOL('k', "keep-unreachable", &keep_unreachable,
+ N_("with -a, repack unreachable objects")),
OPT_STRING(0, "window", &window, N_("n"),
N_("size of the window used for delta compression")),
OPT_STRING(0, "window-memory", &window_memory, N_("bytes"),
@@ -196,6 +199,10 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
if (delete_redundant && repository_format_precious_objects)
die(_("cannot delete packs in a precious-objects repo"));
+ if (keep_unreachable &&
+ (unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
+ die(_("--keep-unreachable and -A are incompatible"));
+
if (pack_kept_objects < 0)
pack_kept_objects = write_bitmaps;
@@ -239,6 +246,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
} else if (pack_everything & LOOSEN_UNREACHABLE) {
argv_array_push(&cmd.args,
"--unpack-unreachable");
+ } else if (keep_unreachable) {
+ argv_array_push(&cmd.args, "--keep-unreachable");
+ argv_array_push(&cmd.args, "--pack-loose-unreachable");
} else {
argv_array_push(&cmd.env_array, "GIT_REF_PARANOIA=1");
}
@@ -378,7 +388,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
item->string,
exts[ext].name);
if (remove_path(fname))
- warning(_("removing '%s' failed"), fname);
+ warning(_("failed to remove '%s'"), fname);
free(fname);
}
}
diff --git a/builtin/reset.c b/builtin/reset.c
index acd627886..5c6206bc1 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -103,7 +103,7 @@ static void print_new_head_line(struct commit *commit)
if (body) {
const char *eol;
size_t len;
- body += 2;
+ body = skip_blank_lines(body + 2);
eol = strchr(body, '\n');
len = eol ? eol - body : strlen(body);
printf(" %.*s\n", (int) len, body);
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index be8054791..25fa8a6ae 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -233,11 +233,11 @@ void shortlog_init(struct shortlog *log)
int cmd_shortlog(int argc, const char **argv, const char *prefix)
{
- static struct shortlog log;
- static struct rev_info rev;
+ struct shortlog log = { STRING_LIST_INIT_NODUP };
+ struct rev_info rev;
int nongit = !startup_info->have_repository;
- static const struct option options[] = {
+ const struct option options[] = {
OPT_BOOL('n', "numbered", &log.sort_by_number,
N_("sort output according to the number of commits per author")),
OPT_BOOL('s', "summary", &log.summary,
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c7deb5578..b22352b6e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -590,10 +590,14 @@ struct submodule_update_clone {
/* If we want to stop as fast as possible and return an error */
unsigned quickstop : 1;
+
+ /* failed clones to be retried again */
+ const struct cache_entry **failed_clones;
+ int failed_clones_nr, failed_clones_alloc;
};
#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
SUBMODULE_UPDATE_STRATEGY_INIT, 0, -1, NULL, NULL, NULL, NULL, \
- STRING_LIST_INIT_DUP, 0}
+ STRING_LIST_INIT_DUP, 0, NULL, 0, 0}
static void next_submodule_warn_missing(struct submodule_update_clone *suc,
@@ -718,23 +722,47 @@ cleanup:
static int update_clone_get_next_task(struct child_process *child,
struct strbuf *err,
void *suc_cb,
- void **void_task_cb)
+ void **idx_task_cb)
{
struct submodule_update_clone *suc = suc_cb;
+ const struct cache_entry *ce;
+ int index;
for (; suc->current < suc->list.nr; suc->current++) {
- const struct cache_entry *ce = suc->list.entries[suc->current];
+ ce = suc->list.entries[suc->current];
if (prepare_to_clone_next_submodule(ce, child, suc, err)) {
+ int *p = xmalloc(sizeof(*p));
+ *p = suc->current;
+ *idx_task_cb = p;
suc->current++;
return 1;
}
}
+
+ /*
+ * The loop above tried cloning each submodule once, now try the
+ * stragglers again, which we can imagine as an extension of the
+ * entry list.
+ */
+ index = suc->current - suc->list.nr;
+ if (index < suc->failed_clones_nr) {
+ int *p;
+ ce = suc->failed_clones[index];
+ if (!prepare_to_clone_next_submodule(ce, child, suc, err))
+ die("BUG: ce was a submodule before?");
+ p = xmalloc(sizeof(*p));
+ *p = suc->current;
+ *idx_task_cb = p;
+ suc->current ++;
+ return 1;
+ }
+
return 0;
}
static int update_clone_start_failure(struct strbuf *err,
void *suc_cb,
- void *void_task_cb)
+ void *idx_task_cb)
{
struct submodule_update_clone *suc = suc_cb;
suc->quickstop = 1;
@@ -744,15 +772,39 @@ static int update_clone_start_failure(struct strbuf *err,
static int update_clone_task_finished(int result,
struct strbuf *err,
void *suc_cb,
- void *void_task_cb)
+ void *idx_task_cb)
{
+ const struct cache_entry *ce;
struct submodule_update_clone *suc = suc_cb;
+ int *idxP = *(int**)idx_task_cb;
+ int idx = *idxP;
+ free(idxP);
+
if (!result)
return 0;
- suc->quickstop = 1;
- return 1;
+ if (idx < suc->list.nr) {
+ ce = suc->list.entries[idx];
+ strbuf_addf(err, _("Failed to clone '%s'. Retry scheduled"),
+ ce->name);
+ strbuf_addch(err, '\n');
+ ALLOC_GROW(suc->failed_clones,
+ suc->failed_clones_nr + 1,
+ suc->failed_clones_alloc);
+ suc->failed_clones[suc->failed_clones_nr++] = ce;
+ return 0;
+ } else {
+ idx = suc->current - suc->list.nr;
+ ce = suc->failed_clones[idx];
+ strbuf_addf(err, _("Failed to clone '%s' a second time, aborting"),
+ ce->name);
+ strbuf_addch(err, '\n');
+ suc->quickstop = 1;
+ return 1;
+ }
+
+ return 0;
}
static int update_clone(int argc, const char **argv, const char *prefix)
diff --git a/builtin/worktree.c b/builtin/worktree.c
index e3199a22e..e86684468 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -13,8 +13,8 @@
static const char * const worktree_usage[] = {
N_("git worktree add [<options>] <path> [<branch>]"),
- N_("git worktree prune [<options>]"),
N_("git worktree list [<options>]"),
+ N_("git worktree prune [<options>]"),
NULL
};
@@ -95,7 +95,7 @@ static void prune_worktrees(void)
if (!dir)
return;
while ((d = readdir(dir)) != NULL) {
- if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
+ if (is_dot_or_dotdot(d->d_name))
continue;
strbuf_reset(&reason);
if (!prune_worktree(d->d_name, &reason))
@@ -262,7 +262,7 @@ static int add_worktree(const char *path, const char *refname,
*/
strbuf_reset(&sb);
strbuf_addf(&sb, "%s/HEAD", sb_repo.buf);
- write_file(sb.buf, "0000000000000000000000000000000000000000");
+ write_file(sb.buf, sha1_to_hex(null_sha1));
strbuf_reset(&sb);
strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
write_file(sb.buf, "../..");
@@ -337,7 +337,7 @@ static int add(int ac, const char **av, const char *prefix)
if (ac < 1 || ac > 2)
usage_with_options(worktree_usage, options);
- path = prefix ? prefix_filename(prefix, strlen(prefix), av[0]) : av[0];
+ path = prefix_filename(prefix, strlen(prefix), av[0]);
branch = ac < 2 ? "HEAD" : av[1];
if (!strcmp(branch, "-"))
@@ -470,6 +470,8 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
if (ac < 2)
usage_with_options(worktree_usage, options);
+ if (!prefix)
+ prefix = "";
if (!strcmp(av[1], "add"))
return add(ac - 1, av + 1, prefix);
if (!strcmp(av[1], "prune"))
diff --git a/cache.h b/cache.h
index 6049f8671..f1dc289d0 100644
--- a/cache.h
+++ b/cache.h
@@ -367,8 +367,8 @@ extern void free_name_hash(struct index_state *istate);
#define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
#define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
#define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
-#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))
-#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))
+#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags), 0)
+#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags), 0)
#define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
#define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
@@ -581,8 +581,8 @@ extern int remove_file_from_index(struct index_state *, const char *path);
#define ADD_CACHE_IGNORE_ERRORS 4
#define ADD_CACHE_IGNORE_REMOVAL 8
#define ADD_CACHE_INTENT 16
-extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
-extern int add_file_to_index(struct index_state *, const char *path, int flags);
+extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags, int force_mode);
+extern int add_file_to_index(struct index_state *, const char *path, int flags, int force_mode);
extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options);
extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
@@ -1604,6 +1604,16 @@ extern const char *get_log_output_encoding(void);
extern const char *get_commit_output_encoding(void);
extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data);
+
+enum config_scope {
+ CONFIG_SCOPE_UNKNOWN = 0,
+ CONFIG_SCOPE_SYSTEM,
+ CONFIG_SCOPE_GLOBAL,
+ CONFIG_SCOPE_REPO,
+ CONFIG_SCOPE_CMDLINE,
+};
+
+extern enum config_scope current_config_scope(void);
extern const char *current_config_origin_type(void);
extern const char *current_config_name(void);
@@ -1696,6 +1706,8 @@ extern int ignore_untracked_cache_config;
struct key_value_info {
const char *filename;
int linenr;
+ const char *origin_type;
+ enum config_scope scope;
};
extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
@@ -1721,7 +1733,6 @@ extern int copy_file(const char *dst, const char *src, int mode);
extern int copy_file_with_time(const char *dst, const char *src, int mode);
extern void write_or_die(int fd, const void *buf, size_t count);
-extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
extern void fsync_or_die(int fd, const char *);
@@ -1772,7 +1783,7 @@ void packet_trace_identity(const char *prog);
* return 0 if success, 1 - if addition of a file failed and
* ADD_FILES_IGNORE_ERRORS was specified in flags
*/
-int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags);
+int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags, int force_mode);
/* diff.c */
extern int diff_auto_refresh_index;
diff --git a/color.c b/color.c
index 8f85153d0..81c267672 100644
--- a/color.c
+++ b/color.c
@@ -123,19 +123,34 @@ static int parse_color(struct color *out, const char *name, int len)
return -1;
}
-static int parse_attr(const char *name, int len)
+static int parse_attr(const char *name, size_t len)
{
- static const int attr_values[] = { 1, 2, 4, 5, 7,
- 22, 22, 24, 25, 27 };
- static const char * const attr_names[] = {
- "bold", "dim", "ul", "blink", "reverse",
- "nobold", "nodim", "noul", "noblink", "noreverse"
+ static const struct {
+ const char *name;
+ size_t len;
+ int val, neg;
+ } attrs[] = {
+#define ATTR(x, val, neg) { (x), sizeof(x)-1, (val), (neg) }
+ ATTR("bold", 1, 22),
+ ATTR("dim", 2, 22),
+ ATTR("italic", 3, 23),
+ ATTR("ul", 4, 24),
+ ATTR("blink", 5, 25),
+ ATTR("reverse", 7, 27),
+ ATTR("strike", 9, 29)
+#undef ATTR
};
+ int negate = 0;
int i;
- for (i = 0; i < ARRAY_SIZE(attr_names); i++) {
- const char *str = attr_names[i];
- if (!strncasecmp(name, str, len) && !str[len])
- return attr_values[i];
+
+ if (skip_prefix_mem(name, len, "no", &name, &len)) {
+ skip_prefix_mem(name, len, "-", &name, &len);
+ negate = 1;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(attrs); i++) {
+ if (attrs[i].len == len && !memcmp(attrs[i].name, name, len))
+ return negate ? attrs[i].neg : attrs[i].val;
}
return -1;
}
diff --git a/color.h b/color.h
index e155d13f7..90627650f 100644
--- a/color.h
+++ b/color.h
@@ -3,26 +3,24 @@
struct strbuf;
-/* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
-/* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */
/*
* The maximum length of ANSI color sequence we would generate:
* - leading ESC '[' 2
- * - attr + ';' 3 * 10 (e.g. "1;")
+ * - attr + ';' 2 * num_attr (e.g. "1;")
+ * - no-attr + ';' 3 * num_attr (e.g. "22;")
* - fg color + ';' 17 (e.g. "38;2;255;255;255;")
* - bg color + ';' 17 (e.g. "48;2;255;255;255;")
* - terminating 'm' NUL 2
*
- * The above overcounts attr (we only use 5 not 8) and one semicolon
- * but it is close enough.
+ * The above overcounts by one semicolon but it is close enough.
+ *
+ * The space for attributes is also slightly overallocated, as
+ * the negation for some attributes is the same (e.g., nobold and nodim).
+ *
+ * We allocate space for 7 attributes.
*/
-#define COLOR_MAXLEN 70
+#define COLOR_MAXLEN 75
-/*
- * IMPORTANT: Due to the way these color codes are emulated on Windows,
- * write them only using printf(), fprintf(), and fputs(). In particular,
- * do not use puts() or write().
- */
#define GIT_COLOR_NORMAL ""
#define GIT_COLOR_RESET "\033[m"
#define GIT_COLOR_BOLD "\033[1m"
diff --git a/commit.c b/commit.c
index 3f4f371e5..2a90e3751 100644
--- a/commit.c
+++ b/commit.c
@@ -414,7 +414,7 @@ int find_commit_subject(const char *commit_buffer, const char **subject)
while (*p && (*p != '\n' || p[1] != '\n'))
p++;
if (*p) {
- p += 2;
+ p = skip_blank_lines(p + 2);
for (eol = p; *eol && *eol != '\n'; eol++)
; /* do nothing */
} else
@@ -1092,9 +1092,14 @@ static int do_sign_commit(struct strbuf *buf, const char *keyid)
{
struct strbuf sig = STRBUF_INIT;
int inspos, copypos;
+ const char *eoh;
/* find the end of the header */
- inspos = strstr(buf->buf, "\n\n") - buf->buf + 1;
+ eoh = strstr(buf->buf, "\n\n");
+ if (!eoh)
+ inspos = buf->len;
+ else
+ inspos = eoh - buf->buf + 1;
if (!keyid || !*keyid)
keyid = get_signing_key();
diff --git a/commit.h b/commit.h
index b06db4d5d..3b88c8889 100644
--- a/commit.h
+++ b/commit.h
@@ -131,11 +131,17 @@ enum cmit_fmt {
CMIT_FMT_FULLER,
CMIT_FMT_ONELINE,
CMIT_FMT_EMAIL,
+ CMIT_FMT_MBOXRD,
CMIT_FMT_USERFORMAT,
CMIT_FMT_UNSPECIFIED
};
+static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
+{
+ return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
+}
+
struct pretty_print_context {
/*
* Callers should tweak these to change the behavior of pp_* functions.
@@ -161,6 +167,7 @@ struct pretty_print_context {
* should not be counted on by callers.
*/
struct string_list in_body_headers;
+ int graph_width;
};
struct userformat_want {
@@ -177,6 +184,7 @@ extern const char *format_subject(struct strbuf *sb, const char *msg,
const char *line_separator);
extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);
extern int commit_format_is_empty(enum cmit_fmt);
+extern const char *skip_blank_lines(const char *msg);
extern void format_commit_message(const struct commit *commit,
const char *format, struct strbuf *sb,
const struct pretty_print_context *context);
diff --git a/compat/mingw.c b/compat/mingw.c
index a8218e6f0..2b5467dea 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2162,7 +2162,7 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)
return -1;
}
-static void setup_windows_environment()
+static void setup_windows_environment(void)
{
char *tmp = getenv("TMPDIR");
@@ -2204,7 +2204,7 @@ typedef struct {
extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,
_startupinfo *si);
-static NORETURN void die_startup()
+static NORETURN void die_startup(void)
{
fputs("fatal: not enough memory for initialization", stderr);
exit(128);
@@ -2224,7 +2224,7 @@ static char *wcstoutfdup_startup(char *buffer, const wchar_t *wcs, size_t len)
return memcpy(malloc_startup(len), buffer, len);
}
-void mingw_startup()
+void mingw_startup(void)
{
int i, maxlen, argc;
char *buffer;
diff --git a/compat/mingw.h b/compat/mingw.h
index 69bb43dc3..9a8803b87 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -532,8 +532,8 @@ extern CRITICAL_SECTION pinfo_cs;
* A replacement of main() that adds win32 specific initialization.
*/
-void mingw_startup();
-#define main(c,v) dummy_decl_mingw_main(); \
+void mingw_startup(void);
+#define main(c,v) dummy_decl_mingw_main(void); \
static int mingw_main(c,v); \
int main(int argc, char **argv) \
{ \
diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c
index fba598639..d8bde06f1 100644
--- a/compat/regex/regcomp.c
+++ b/compat/regex/regcomp.c
@@ -18,8 +18,6 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
-#include <stdint.h>
-
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
static void re_compile_fastmap_iter (regex_t *bufp,
diff --git a/compat/regex/regex.c b/compat/regex/regex.c
index 6aaae0032..5cb23e5d5 100644
--- a/compat/regex/regex.c
+++ b/compat/regex/regex.c
@@ -60,6 +60,7 @@
GNU regex allows. Include it before <regex.h>, which correctly
#undefs RE_DUP_MAX and sets it to the right value. */
#include <limits.h>
+#include <stdint.h>
#ifdef GAWK
#undef alloca
diff --git a/compat/winansi.c b/compat/winansi.c
index 3be60ce1c..db4a5b0a3 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -492,7 +492,7 @@ static inline ioinfo* _pioinfo(int fd)
(fd & (IOINFO_ARRAY_ELTS - 1)) * sizeof_ioinfo);
}
-static int init_sizeof_ioinfo()
+static int init_sizeof_ioinfo(void)
{
int istty, wastty;
/* don't init twice */
diff --git a/config.c b/config.c
index f51c56bf9..bea937e4e 100644
--- a/config.c
+++ b/config.c
@@ -38,7 +38,33 @@ struct config_source {
long (*do_ftell)(struct config_source *c);
};
+/*
+ * These variables record the "current" config source, which
+ * can be accessed by parsing callbacks.
+ *
+ * The "cf" variable will be non-NULL only when we are actually parsing a real
+ * config source (file, blob, cmdline, etc).
+ *
+ * The "current_config_kvi" variable will be non-NULL only when we are feeding
+ * cached config from a configset into a callback.
+ *
+ * They should generally never be non-NULL at the same time. If they are both
+ * NULL, then we aren't parsing anything (and depending on the function looking
+ * at the variables, it's either a bug for it to be called in the first place,
+ * or it's a function which can be reused for non-config purposes, and should
+ * fall back to some sane behavior).
+ */
static struct config_source *cf;
+static struct key_value_info *current_config_kvi;
+
+/*
+ * Similar to the variables above, this gives access to the "scope" of the
+ * current value (repo, global, etc). For cached values, it can be found via
+ * the current_config_kvi as above. During parsing, the current value can be
+ * found in this variable. It's not part of "cf" because it transcends a single
+ * file (i.e., a file included from .git/config is still in "repo" scope).
+ */
+static enum config_scope current_parsing_scope;
static int zlib_compression_seen;
@@ -131,7 +157,9 @@ static int handle_path_include(const char *path, struct config_include_data *inc
if (!access_or_die(path, R_OK, 0)) {
if (++inc->depth > MAX_INCLUDE_DEPTH)
die(include_depth_advice, MAX_INCLUDE_DEPTH, path,
- cf && cf->name ? cf->name : "the command line");
+ !cf ? "<unknown>" :
+ cf->name ? cf->name :
+ "the command line");
ret = git_config_from_file(git_config_include, path, inc);
inc->depth--;
}
@@ -205,32 +233,40 @@ int git_config_parse_parameter(const char *text,
int git_config_from_parameters(config_fn_t fn, void *data)
{
const char *env = getenv(CONFIG_DATA_ENVIRONMENT);
+ int ret = 0;
char *envw;
const char **argv = NULL;
int nr = 0, alloc = 0;
int i;
+ struct config_source source;
if (!env)
return 0;
+
+ memset(&source, 0, sizeof(source));
+ source.prev = cf;
+ cf = &source;
+
/* sq_dequote will write over it */
envw = xstrdup(env);
if (sq_dequote_to_argv(envw, &argv, &nr, &alloc) < 0) {
- free(envw);
- return error("bogus format in " CONFIG_DATA_ENVIRONMENT);
+ ret = error("bogus format in " CONFIG_DATA_ENVIRONMENT);
+ goto out;
}
for (i = 0; i < nr; i++) {
if (git_config_parse_parameter(argv[i], fn, data) < 0) {
- free(argv);
- free(envw);
- return -1;
+ ret = -1;
+ goto out;
}
}
+out:
free(argv);
free(envw);
- return nr > 0;
+ cf = source.prev;
+ return ret;
}
static int get_next_char(void)
@@ -1197,47 +1233,36 @@ int git_config_system(void)
static int do_git_config_sequence(config_fn_t fn, void *data)
{
- int ret = 0, found = 0;
+ int ret = 0;
char *xdg_config = xdg_config_home("config");
char *user_config = expand_user_path("~/.gitconfig");
char *repo_config = git_pathdup("config");
- if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
+ current_parsing_scope = CONFIG_SCOPE_SYSTEM;
+ if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0))
ret += git_config_from_file(fn, git_etc_gitconfig(),
data);
- found += 1;
- }
- if (xdg_config && !access_or_die(xdg_config, R_OK, ACCESS_EACCES_OK)) {
+ current_parsing_scope = CONFIG_SCOPE_GLOBAL;
+ if (xdg_config && !access_or_die(xdg_config, R_OK, ACCESS_EACCES_OK))
ret += git_config_from_file(fn, xdg_config, data);
- found += 1;
- }
- if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK)) {
+ if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK))
ret += git_config_from_file(fn, user_config, data);
- found += 1;
- }
- if (repo_config && !access_or_die(repo_config, R_OK, 0)) {
+ current_parsing_scope = CONFIG_SCOPE_REPO;
+ if (repo_config && !access_or_die(repo_config, R_OK, 0))
ret += git_config_from_file(fn, repo_config, data);
- found += 1;
- }
- switch (git_config_from_parameters(fn, data)) {
- case -1: /* error */
+ current_parsing_scope = CONFIG_SCOPE_CMDLINE;
+ if (git_config_from_parameters(fn, data) < 0)
die(_("unable to parse command-line config"));
- break;
- case 0: /* found nothing */
- break;
- default: /* found at least one item */
- found++;
- break;
- }
+ current_parsing_scope = CONFIG_SCOPE_UNKNOWN;
free(xdg_config);
free(user_config);
free(repo_config);
- return ret == 0 ? found : ret;
+ return ret;
}
int git_config_with_options(config_fn_t fn, void *data,
@@ -1272,7 +1297,7 @@ static void git_config_raw(config_fn_t fn, void *data)
if (git_config_with_options(fn, data, NULL, 1) < 0)
/*
* git_config_with_options() normally returns only
- * positive values, as most errors are fatal, and
+ * zero, as most errors are fatal, and
* non-fatal potential errors are guarded by "if"
* statements that are entered only when no error is
* possible.
@@ -1281,7 +1306,7 @@ static void git_config_raw(config_fn_t fn, void *data)
* something went really wrong and we should stop
* immediately.
*/
- die(_("unknown error occured while reading the configuration files"));
+ die(_("unknown error occurred while reading the configuration files"));
}
static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)
@@ -1290,16 +1315,20 @@ static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)
struct string_list *values;
struct config_set_element *entry;
struct configset_list *list = &cs->list;
- struct key_value_info *kv_info;
for (i = 0; i < list->nr; i++) {
entry = list->items[i].e;
value_index = list->items[i].value_index;
values = &entry->value_list;
- if (fn(entry->key, values->items[value_index].string, data) < 0) {
- kv_info = values->items[value_index].util;
- git_die_config_linenr(entry->key, kv_info->filename, kv_info->linenr);
- }
+
+ current_config_kvi = values->items[value_index].util;
+
+ if (fn(entry->key, values->items[value_index].string, data) < 0)
+ git_die_config_linenr(entry->key,
+ current_config_kvi->filename,
+ current_config_kvi->linenr);
+
+ current_config_kvi = NULL;
}
}
@@ -1356,14 +1385,19 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha
l_item->e = e;
l_item->value_index = e->value_list.nr - 1;
- if (cf) {
+ if (!cf)
+ die("BUG: configset_add_value has no source");
+ if (cf->name) {
kv_info->filename = strintern(cf->name);
kv_info->linenr = cf->linenr;
+ kv_info->origin_type = strintern(cf->origin_type);
} else {
/* for values read from `git_config_from_parameters()` */
kv_info->filename = NULL;
kv_info->linenr = -1;
+ kv_info->origin_type = NULL;
}
+ kv_info->scope = current_parsing_scope;
si->util = kv_info;
return 0;
@@ -2442,10 +2476,32 @@ int parse_config_key(const char *var,
const char *current_config_origin_type(void)
{
- return cf && cf->origin_type ? cf->origin_type : "command line";
+ const char *type;
+ if (current_config_kvi)
+ type = current_config_kvi->origin_type;
+ else if(cf)
+ type = cf->origin_type;
+ else
+ die("BUG: current_config_origin_type called outside config callback");
+ return type ? type : "command line";
}
const char *current_config_name(void)
{
- return cf && cf->name ? cf->name : "";
+ const char *name;
+ if (current_config_kvi)
+ name = current_config_kvi->filename;
+ else if (cf)
+ name = cf->name;
+ else
+ die("BUG: current_config_name called outside config callback");
+ return name ? name : "";
+}
+
+enum config_scope current_config_scope(void)
+{
+ if (current_config_kvi)
+ return current_config_kvi->scope;
+ else
+ return current_parsing_scope;
}
diff --git a/connect.c b/connect.c
index c53f3f1c5..722dc3fc5 100644
--- a/connect.c
+++ b/connect.c
@@ -658,6 +658,19 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
static struct child_process no_fork = CHILD_PROCESS_INIT;
+static const char *get_ssh_command(void)
+{
+ const char *ssh;
+
+ if ((ssh = getenv("GIT_SSH_COMMAND")))
+ return ssh;
+
+ if (!git_config_get_string_const("core.sshcommand", &ssh))
+ return ssh;
+
+ return NULL;
+}
+
/*
* This returns a dummy child_process if the transport protocol does not
* need fork(2), or a struct child_process object if it does. Once done,
@@ -758,7 +771,7 @@ struct child_process *git_connect(int fd[2], const char *url,
return NULL;
}
- ssh = getenv("GIT_SSH_COMMAND");
+ ssh = get_ssh_command();
if (!ssh) {
const char *base;
char *ssh_dup;
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 34024754d..37888f4e5 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -803,6 +803,50 @@ __git_find_on_cmdline ()
done
}
+# Echo the value of an option set on the command line or config
+#
+# $1: short option name
+# $2: long option name including =
+# $3: list of possible values
+# $4: config string (optional)
+#
+# example:
+# result="$(__git_get_option_value "-d" "--do-something=" \
+# "yes no" "core.doSomething")"
+#
+# result is then either empty (no option set) or "yes" or "no"
+#
+# __git_get_option_value requires 3 arguments
+__git_get_option_value ()
+{
+ local c short_opt long_opt val
+ local result= values config_key word
+
+ short_opt="$1"
+ long_opt="$2"
+ values="$3"
+ config_key="$4"
+
+ ((c = $cword - 1))
+ while [ $c -ge 0 ]; do
+ word="${words[c]}"
+ for val in $values; do
+ if [ "$short_opt$val" = "$word" ] ||
+ [ "$long_opt$val" = "$word" ]; then
+ result="$val"
+ break 2
+ fi
+ done
+ ((c--))
+ done
+
+ if [ -n "$config_key" ] && [ -z "$result" ]; then
+ result="$(git --git-dir="$(__gitdir)" config "$config_key")"
+ fi
+
+ echo "$result"
+}
+
__git_has_doubledash ()
{
local c=1
@@ -1098,6 +1142,8 @@ _git_clone ()
esac
}
+__git_untracked_file_modes="all no normal"
+
_git_commit ()
{
case "$prev" in
@@ -1119,7 +1165,7 @@ _git_commit ()
return
;;
--untracked-files=*)
- __gitcomp "all no normal" "" "${cur##--untracked-files=}"
+ __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
return
;;
--*)
@@ -1780,6 +1826,56 @@ _git_stage ()
_git_add
}
+_git_status ()
+{
+ local complete_opt
+ local untracked_state
+
+ case "$cur" in
+ --ignore-submodules=*)
+ __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
+ return
+ ;;
+ --untracked-files=*)
+ __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
+ return
+ ;;
+ --column=*)
+ __gitcomp "
+ always never auto column row plain dense nodense
+ " "" "${cur##--column=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --short --branch --porcelain --long --verbose
+ --untracked-files= --ignore-submodules= --ignored
+ --column= --no-column
+ "
+ return
+ ;;
+ esac
+
+ untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
+ "$__git_untracked_file_modes" "status.showUntrackedFiles")"
+
+ case "$untracked_state" in
+ no)
+ # --ignored option does not matter
+ complete_opt=
+ ;;
+ all|normal|*)
+ complete_opt="--cached --directory --no-empty-directory --others"
+
+ if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
+ complete_opt="$complete_opt --ignored --exclude=*"
+ fi
+ ;;
+ esac
+
+ __git_complete_index_file "$complete_opt"
+}
+
__git_config_get_set_variables ()
{
local prevword word config_file= c=$cword
@@ -2595,6 +2691,29 @@ _git_whatchanged ()
_git_log
}
+_git_worktree ()
+{
+ local subcommands="add list prune"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ else
+ case "$subcommand,$cur" in
+ add,--*)
+ __gitcomp "--detach"
+ ;;
+ list,--*)
+ __gitcomp "--porcelain"
+ ;;
+ prune,--*)
+ __gitcomp "--dry-run --expire --verbose"
+ ;;
+ *)
+ ;;
+ esac
+ fi
+}
+
__git_main ()
{
local i c=1 command __git_dir
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 64219e631..97eacd783 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -355,8 +355,8 @@ __git_ps1 ()
# incorrect.)
#
local ps1_expanded=yes
- [ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
- [ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no
+ [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
+ [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
local repo_info rev_parse_exit_code
repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
@@ -368,7 +368,7 @@ __git_ps1 ()
return $exit
fi
- local short_sha
+ local short_sha=""
if [ "$rev_parse_exit_code" = "0" ]; then
short_sha="${repo_info##*$'\n'}"
repo_info="${repo_info%$'\n'*}"
diff --git a/contrib/credential/gnome-keyring/Makefile b/contrib/credential/gnome-keyring/Makefile
index c3c7c98aa..22c19df94 100644
--- a/contrib/credential/gnome-keyring/Makefile
+++ b/contrib/credential/gnome-keyring/Makefile
@@ -4,12 +4,13 @@ all:: $(MAIN)
CC = gcc
RM = rm -f
CFLAGS = -g -O2 -Wall
+PKG_CONFIG = pkg-config
-include ../../../config.mak.autogen
-include ../../../config.mak
-INCS:=$(shell pkg-config --cflags gnome-keyring-1 glib-2.0)
-LIBS:=$(shell pkg-config --libs gnome-keyring-1 glib-2.0)
+INCS:=$(shell $(PKG_CONFIG) --cflags gnome-keyring-1 glib-2.0)
+LIBS:=$(shell $(PKG_CONFIG) --libs gnome-keyring-1 glib-2.0)
SRCS:=$(MAIN).c
OBJS:=$(SRCS:.c=.o)
diff --git a/date.c b/date.c
index 7c9f76998..4c7aa9ba8 100644
--- a/date.c
+++ b/date.c
@@ -74,6 +74,8 @@ static int local_tzoffset(unsigned long time)
localtime_r(&t, &tm);
t_local = tm_to_time_t(&tm);
+ if (t_local == -1)
+ return 0; /* error; just use +0000 */
if (t_local < t) {
eastwest = -1;
offset = t - t_local;
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 822f85703..642cce1ac 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -45,6 +45,7 @@ my ($diff_new_color) =
my $normal_color = $repo->get_color("", "reset");
my $diff_algorithm = $repo->config('diff.algorithm');
+my $diff_compaction_heuristic = $repo->config_bool('diff.compactionheuristic');
my $diff_filter = $repo->config('interactive.difffilter');
my $use_readkey = 0;
@@ -749,6 +750,9 @@ sub parse_diff {
if (defined $diff_algorithm) {
splice @diff_cmd, 1, 0, "--diff-algorithm=${diff_algorithm}";
}
+ if ($diff_compaction_heuristic) {
+ splice @diff_cmd, 1, 0, "--compaction-heuristic";
+ }
if (defined $patch_mode_revision) {
push @diff_cmd, get_diff_reference($patch_mode_revision);
}
diff --git a/git-bisect.sh b/git-bisect.sh
index 5d1cb00d8..ae3cb013e 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -33,7 +33,6 @@ Please use "git help bisect" to get the full man page.'
OPTIONS_SPEC=
. git-sh-setup
-. git-sh-i18n
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
@@ -275,10 +274,11 @@ bisect_state() {
check_and_set_terms $state
case "$#,$state" in
0,*)
- die "$(gettext "Please call 'bisect_state' with at least one argument.")" ;;
+ die "Please call 'bisect_state' with at least one argument." ;;
1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip)
- rev=$(git rev-parse --verify $(bisect_head)) ||
- die "$(gettext "Bad rev input: $(bisect_head)")"
+ bisected_head=$(bisect_head)
+ rev=$(git rev-parse --verify "$bisected_head") ||
+ die "$(eval_gettext "Bad rev input: \$bisected_head")"
bisect_write "$state" "$rev"
check_expected_revs "$rev" ;;
2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip)
diff --git a/git-compat-util.h b/git-compat-util.h
index 49d4029b8..c99cddc54 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -474,6 +474,23 @@ static inline int skip_prefix(const char *str, const char *prefix,
}
/*
+ * Like skip_prefix, but promises never to read past "len" bytes of the input
+ * buffer, and returns the remaining number of bytes in "out" via "outlen".
+ */
+static inline int skip_prefix_mem(const char *buf, size_t len,
+ const char *prefix,
+ const char **out, size_t *outlen)
+{
+ size_t prefix_len = strlen(prefix);
+ if (prefix_len <= len && !memcmp(buf, prefix, prefix_len)) {
+ *out = buf + prefix_len;
+ *outlen = len - prefix_len;
+ return 1;
+ }
+ return 0;
+}
+
+/*
* If buf ends with suffix, return 1 and subtract the length of the suffix
* from *len. Otherwise, return 0 and leave *len untouched.
*/
diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index dc2fd1b5a..308eafd1d 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -5,14 +5,11 @@
# Resolve two or more trees.
#
+. git-sh-setup
+
LF='
'
-die () {
- echo >&2 "$*"
- exit 1
-}
-
# The first parameters up to -- are merge bases; the rest are heads.
bases= head= remotes= sep_seen=
for arg
@@ -46,7 +43,7 @@ esac
if ! git diff-index --quiet --cached HEAD --
then
- echo "Error: Your local changes to the following files would be overwritten by merge"
+ gettextln "Error: Your local changes to the following files would be overwritten by merge"
git diff-index --cached --name-only HEAD -- | sed -e 's/^/ /'
exit 2
fi
@@ -61,8 +58,8 @@ do
# We allow only last one to have a hand-resolvable
# conflicts. Last round failed and we still had
# a head to merge.
- echo "Automated merge did not work."
- echo "Should not be doing an Octopus."
+ gettextln "Automated merge did not work."
+ gettextln "Should not be doing an Octopus."
exit 2
esac
@@ -73,11 +70,11 @@ do
eval pretty_name=\${GITHEAD_$SHA1_UP:-$pretty_name}
fi
common=$(git merge-base --all $SHA1 $MRC) ||
- die "Unable to find common commit with $pretty_name"
+ die "$(eval_gettext "Unable to find common commit with \$pretty_name")"
case "$LF$common$LF" in
*"$LF$SHA1$LF"*)
- echo "Already up-to-date with $pretty_name"
+ eval_gettextln "Already up-to-date with \$pretty_name"
continue
;;
esac
@@ -89,7 +86,7 @@ do
# tree as the intermediate result of the merge.
# We still need to count this as part of the parent set.
- echo "Fast-forwarding to: $pretty_name"
+ eval_gettextln "Fast-forwarding to: \$pretty_name"
git read-tree -u -m $head $SHA1 || exit
MRC=$SHA1 MRT=$(git write-tree)
continue
@@ -97,12 +94,12 @@ do
NON_FF_MERGE=1
- echo "Trying simple merge with $pretty_name"
+ eval_gettextln "Trying simple merge with \$pretty_name"
git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2
next=$(git write-tree 2>/dev/null)
if test $? -ne 0
then
- echo "Simple merge did not work, trying automatic merge."
+ gettextln "Simple merge did not work, trying automatic merge."
git-merge-index -o git-merge-one-file -a ||
OCTOPUS_FAILURE=1
next=$(git write-tree 2>/dev/null)
diff --git a/git-p4.py b/git-p4.py
index b6593cf9a..b123aa272 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2674,7 +2674,7 @@ class P4Sync(Command, P4UserMap):
return True
hasPrefix = [p for p in self.branchPrefixes
if p4PathStartsWith(path, p)]
- if hasPrefix and self.verbose:
+ if not hasPrefix and self.verbose:
print('Ignoring file outside of prefix: {0}'.format(path))
return hasPrefix
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 9ae898bc1..375239341 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -9,8 +9,8 @@
# below were not inside any function, and expected to return
# to the function that dot-sourced us.
#
-# However, FreeBSD /bin/sh misbehaves on such a construct and
-# continues to run the statements that follow such a "return".
+# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a
+# construct and continue to run the statements that follow such a "return".
# As a work-around, we introduce an extra layer of a function
# here, and immediately call it after defining it.
git_rebase__am () {
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 6e96abcc3..ded459563 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -128,7 +128,7 @@ mark_action_done () {
if test "$last_count" != "$new_count"
then
last_count=$new_count
- printf "Rebasing (%d/%d)\r" $new_count $total
+ eval_gettext "Rebasing (\$new_count/\$total)"; printf "\r"
test -z "$verbose" || echo
fi
}
@@ -144,29 +144,28 @@ reschedule_last_action () {
}
append_todo_help () {
- git stripspace --comment-lines >>"$todo" <<\EOF
-
+ gettext "
Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
- f, fixup = like "squash", but discard this commit's log message
+ f, fixup = like \"squash\", but discard this commit's log message
x, exec = run command (the rest of the line) using shell
d, drop = remove commit
These lines can be re-ordered; they are executed from top to bottom.
+" | git stripspace --comment-lines >>"$todo"
-EOF
if test $(get_missing_commit_check_level) = error
then
- git stripspace --comment-lines >>"$todo" <<\EOF
+ gettext "
Do not remove any line. Use 'drop' explicitly to remove a commit.
-EOF
+" | git stripspace --comment-lines >>"$todo"
else
- git stripspace --comment-lines >>"$todo" <<\EOF
+ gettext "
If you remove a line here THAT COMMIT WILL BE LOST.
-EOF
+" | git stripspace --comment-lines >>"$todo"
fi
}
@@ -200,18 +199,20 @@ exit_with_patch () {
make_patch $1
git rev-parse --verify HEAD > "$amend"
gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")}
- warn "You can amend the commit now, with"
- warn
- warn " git commit --amend $gpg_sign_opt_quoted"
- warn
- warn "Once you are satisfied with your changes, run"
- warn
- warn " git rebase --continue"
+ warn "$(eval_gettext "\
+You can amend the commit now, with
+
+ git commit --amend \$gpg_sign_opt_quoted
+
+Once you are satisfied with your changes, run
+
+ git rebase --continue")"
warn
exit $2
}
die_abort () {
+ apply_autostash
rm -rf "$state_dir"
die "$1"
}
@@ -221,10 +222,12 @@ has_action () {
}
is_empty_commit() {
- tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null ||
- die "$1: not a commit that can be picked")
- ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null ||
- ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904)
+ tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null) || {
+ sha1=$1
+ die "$(eval_gettext "\$sha1: not a commit that can be picked")"
+ }
+ ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null) ||
+ ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
test "$tree" = "$ptree"
}
@@ -260,7 +263,7 @@ pick_one () {
case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
case "$force_rebase" in '') ;; ?*) ff= ;; esac
- output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
+ output git rev-parse --verify $sha1 || die "$(eval_gettext "Invalid commit name: \$sha1")"
if is_empty_commit "$sha1"
then
@@ -302,7 +305,7 @@ pick_one_preserving_merges () {
git rev-parse HEAD > "$rewritten"/$current_commit
done <"$state_dir"/current-commit
rm "$state_dir"/current-commit ||
- die "Cannot write current commit's replacement sha1"
+ die "$(gettext "Cannot write current commit's replacement sha1")"
fi
fi
@@ -354,9 +357,9 @@ pick_one_preserving_merges () {
done
case $fast_forward in
t)
- output warn "Fast-forward to $sha1"
+ output warn "$(eval_gettext "Fast-forward to \$sha1")"
output git reset --hard $sha1 ||
- die "Cannot fast-forward to $sha1"
+ die "$(eval_gettext "Cannot fast-forward to \$sha1")"
;;
f)
first_parent=$(expr "$new_parents" : ' \([^ ]*\)')
@@ -365,12 +368,12 @@ pick_one_preserving_merges () {
then
# detach HEAD to current parent
output git checkout $first_parent 2> /dev/null ||
- die "Cannot move HEAD to $first_parent"
+ die "$(eval_gettext "Cannot move HEAD to \$first_parent")"
fi
case "$new_parents" in
' '*' '*)
- test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
+ test "a$1" = a-n && die "$(eval_gettext "Refusing to squash a merge: \$sha1")"
# redo merge
author_script_content=$(get_author_ident_from_commit $sha1)
@@ -384,7 +387,7 @@ pick_one_preserving_merges () {
$merge_args $strategy_args -m "$msg_content" $new_parents'
then
printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
- die_with_patch $sha1 "Error redoing merge $sha1"
+ die_with_patch $sha1 "$(eval_gettext "Error redoing merge \$sha1")"
fi
echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
;;
@@ -392,19 +395,59 @@ pick_one_preserving_merges () {
output eval git cherry-pick \
${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \
"$strategy_args" "$@" ||
- die_with_patch $sha1 "Could not pick $sha1"
+ die_with_patch $sha1 "$(eval_gettext "Could not pick \$sha1")"
;;
esac
;;
esac
}
-nth_string () {
- case "$1" in
- *1[0-9]|*[04-9]) echo "$1"th;;
- *1) echo "$1"st;;
- *2) echo "$1"nd;;
- *3) echo "$1"rd;;
+this_nth_commit_message () {
+ n=$1
+ case "$n" in
+ 1) gettext "This is the 1st commit message:";;
+ 2) gettext "This is the 2nd commit message:";;
+ 3) gettext "This is the 3rd commit message:";;
+ 4) gettext "This is the 4th commit message:";;
+ 5) gettext "This is the 5th commit message:";;
+ 6) gettext "This is the 6th commit message:";;
+ 7) gettext "This is the 7th commit message:";;
+ 8) gettext "This is the 8th commit message:";;
+ 9) gettext "This is the 9th commit message:";;
+ 10) gettext "This is the 10th commit message:";;
+ # TRANSLATORS: if the language you are translating into
+ # doesn't allow you to compose a sentence in this fashion,
+ # consider translating as if this and the following few strings
+ # were "This is the commit message ${n}:"
+ *1[0-9]|*[04-9]) eval_gettext "This is the \${n}th commit message:";;
+ *1) eval_gettext "This is the \${n}st commit message:";;
+ *2) eval_gettext "This is the \${n}nd commit message:";;
+ *3) eval_gettext "This is the \${n}rd commit message:";;
+ *) eval_gettext "This is the commit message \${n}:";;
+ esac
+}
+skip_nth_commit_message () {
+ n=$1
+ case "$n" in
+ 1) gettext "The 1st commit message will be skipped:";;
+ 2) gettext "The 2nd commit message will be skipped:";;
+ 3) gettext "The 3rd commit message will be skipped:";;
+ 4) gettext "The 4th commit message will be skipped:";;
+ 5) gettext "The 5th commit message will be skipped:";;
+ 6) gettext "The 6th commit message will be skipped:";;
+ 7) gettext "The 7th commit message will be skipped:";;
+ 8) gettext "The 8th commit message will be skipped:";;
+ 9) gettext "The 9th commit message will be skipped:";;
+ 10) gettext "The 10th commit message will be skipped:";;
+ # TRANSLATORS: if the language you are translating into
+ # doesn't allow you to compose a sentence in this fashion,
+ # consider translating as if this and the following few strings
+ # were "The commit message ${n} will be skipped:"
+ *1[0-9]|*[04-9]) eval_gettext "The \${n}th commit message will be skipped:";;
+ *1) eval_gettext "The \${n}st commit message will be skipped:";;
+ *2) eval_gettext "The \${n}nd commit message will be skipped:";;
+ *3) eval_gettext "The \${n}rd commit message will be skipped:";;
+ *) eval_gettext "The commit message \${n} will be skipped:";;
esac
}
@@ -412,20 +455,23 @@ update_squash_messages () {
if test -f "$squash_msg"; then
mv "$squash_msg" "$squash_msg".bak || exit
count=$(($(sed -n \
- -e "1s/^. This is a combination of \(.*\) commits\./\1/p" \
+ -e "1s/^$comment_char.*\([0-9][0-9]*\).*/\1/p" \
-e "q" < "$squash_msg".bak)+1))
{
- printf '%s\n' "$comment_char This is a combination of $count commits."
+ printf '%s\n' "$comment_char $(eval_ngettext \
+ "This is a combination of \$count commit." \
+ "This is a combination of \$count commits." \
+ $count)"
sed -e 1d -e '2,/^./{
/^$/d
}' <"$squash_msg".bak
} >"$squash_msg"
else
- commit_message HEAD > "$fixup_msg" || die "Cannot write $fixup_msg"
+ commit_message HEAD > "$fixup_msg" || die "$(gettext "Cannot write \$fixup_msg")"
count=2
{
- printf '%s\n' "$comment_char This is a combination of 2 commits."
- printf '%s\n' "$comment_char The first commit's message is:"
+ printf '%s\n' "$comment_char $(gettext "This is a combination of 2 commits.")"
+ printf '%s\n' "$comment_char $(gettext "This is the 1st commit message:")"
echo
cat "$fixup_msg"
} >"$squash_msg"
@@ -434,13 +480,13 @@ update_squash_messages () {
squash)
rm -f "$fixup_msg"
echo
- printf '%s\n' "$comment_char This is the $(nth_string $count) commit message:"
+ printf '%s\n' "$comment_char $(this_nth_commit_message $count)"
echo
commit_message $2
;;
fixup)
echo
- printf '%s\n' "$comment_char The $(nth_string $count) commit message will be skipped:"
+ printf '%s\n' "$comment_char $(skip_nth_commit_message $count)"
echo
# Change the space after the comment character to TAB:
commit_message $2 | git stripspace --comment-lines | sed -e 's/ / /'
@@ -459,12 +505,14 @@ peek_next_command () {
# messages, effectively causing the combined commit to be used as the
# new basis for any further squash/fixups. Args: sha1 rest
die_failed_squash() {
+ sha1=$1
+ rest=$2
mv "$squash_msg" "$msg" || exit
rm -f "$fixup_msg"
cp "$msg" "$GIT_DIR"/MERGE_MSG || exit
warn
- warn "Could not apply $1... $2"
- die_with_patch $1 ""
+ warn "$(eval_gettext "Could not apply \$sha1... \$rest")"
+ die_with_patch $sha1 ""
}
flush_rewritten_pending() {
@@ -488,6 +536,8 @@ record_in_rewritten() {
}
do_pick () {
+ sha1=$1
+ rest=$2
if test "$(git rev-parse HEAD)" = "$squash_onto"
then
# Set the correct commit message and author info on the
@@ -499,15 +549,15 @@ do_pick () {
# resolve before manually running git commit --amend then git
# rebase --continue.
git commit --allow-empty --allow-empty-message --amend \
- --no-post-rewrite -n -q -C $1 &&
- pick_one -n $1 &&
+ --no-post-rewrite -n -q -C $sha1 &&
+ pick_one -n $sha1 &&
git commit --allow-empty --allow-empty-message \
- --amend --no-post-rewrite -n -q -C $1 \
+ --amend --no-post-rewrite -n -q -C $sha1 \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
- die_with_patch $1 "Could not apply $1... $2"
+ die_with_patch $sha1 "$(eval_gettext "Could not apply \$sha1... \$rest")"
else
- pick_one $1 ||
- die_with_patch $1 "Could not apply $1... $2"
+ pick_one $sha1 ||
+ die_with_patch $sha1 "$(eval_gettext "Could not apply \$sha1... \$rest")"
fi
}
@@ -535,10 +585,11 @@ do_next () {
mark_action_done
do_pick $sha1 "$rest"
git commit --amend --no-post-rewrite ${gpg_sign_opt:+"$gpg_sign_opt"} || {
- warn "Could not amend commit after successfully picking $sha1... $rest"
- warn "This is most likely due to an empty commit message, or the pre-commit hook"
- warn "failed. If the pre-commit hook failed, you may need to resolve the issue before"
- warn "you are able to reword the commit."
+ warn "$(eval_gettext "\
+Could not amend commit after successfully picking \$sha1... \$rest
+This is most likely due to an empty commit message, or the pre-commit hook
+failed. If the pre-commit hook failed, you may need to resolve the issue before
+you are able to reword the commit.")"
exit_with_patch $sha1 1
}
record_in_rewritten $sha1
@@ -549,7 +600,7 @@ do_next () {
mark_action_done
do_pick $sha1 "$rest"
sha1_abbrev=$(git rev-parse --short $sha1)
- warn "Stopped at $sha1_abbrev... $rest"
+ warn "$(eval_gettext "Stopped at \$sha1_abbrev... \$rest")"
exit_with_patch $sha1 0
;;
squash|s|fixup|f)
@@ -564,7 +615,7 @@ do_next () {
comment_for_reflog $squash_style
test -f "$done" && has_action "$done" ||
- die "Cannot '$squash_style' without a previous commit"
+ die "$(eval_gettext "Cannot '\$squash_style' without a previous commit")"
mark_action_done
update_squash_messages $squash_style $sha1
@@ -606,7 +657,7 @@ do_next () {
x|"exec")
read -r command rest < "$todo"
mark_action_done
- printf 'Executing: %s\n' "$rest"
+ eval_gettextln "Executing: \$rest"
"${SHELL:-@SHELL_PATH@}" -c "$rest" # Actual execution
status=$?
# Run in subshell because require_clean_work_tree can die.
@@ -614,13 +665,14 @@ do_next () {
(require_clean_work_tree "rebase" 2>/dev/null) || dirty=t
if test "$status" -ne 0
then
- warn "Execution failed: $rest"
+ warn "$(eval_gettext "Execution failed: \$rest")"
test "$dirty" = f ||
- warn "and made changes to the index and/or the working tree"
+ warn "$(gettext "and made changes to the index and/or the working tree")"
- warn "You can fix the problem, and then run"
- warn
- warn " git rebase --continue"
+ warn "$(gettext "\
+You can fix the problem, and then run
+
+ git rebase --continue")"
warn
if test $status -eq 127 # command not found
then
@@ -629,18 +681,20 @@ do_next () {
exit "$status"
elif test "$dirty" = t
then
- warn "Execution succeeded: $rest"
- warn "but left changes to the index and/or the working tree"
- warn "Commit or stash your changes, and then run"
- warn
- warn " git rebase --continue"
+ # TRANSLATORS: after these lines is a command to be issued by the user
+ warn "$(eval_gettext "\
+Execution succeeded: \$rest
+but left changes to the index and/or the working tree
+Commit or stash your changes, and then run
+
+ git rebase --continue")"
warn
exit 1
fi
;;
*)
- warn "Unknown command: $command $sha1 $rest"
- fixtodo="Please fix this using 'git rebase --edit-todo'."
+ warn "$(eval_gettext "Unknown command: \$command \$sha1 \$rest")"
+ fixtodo="$(gettext "Please fix this using 'git rebase --edit-todo'.")"
if git rev-parse --verify -q "$sha1" >/dev/null
then
die_with_patch $sha1 "$fixtodo"
@@ -675,7 +729,7 @@ do_next () {
"$hook" rebase < "$rewritten_list"
true # we don't care if this hook failed
fi &&
- warn "Successfully rebased and updated $head_name."
+ warn "$(eval_gettext "Successfully rebased and updated \$head_name.")"
return 1 # not failure; just to break the do_rest loop
}
@@ -722,7 +776,7 @@ skip_unnecessary_picks () {
record_in_rewritten "$onto"
;;
esac ||
- die "Could not skip unnecessary pick commands"
+ die "$(gettext "Could not skip unnecessary pick commands")"
}
transform_todo_ids () {
@@ -880,9 +934,9 @@ check_commit_sha () {
if test $badsha -ne 0
then
line="$(sed -n -e "${2}p" "$3")"
- warn "Warning: the SHA-1 is missing or isn't" \
- "a commit in the following line:"
- warn " - $line"
+ warn "$(eval_gettext "\
+Warning: the SHA-1 is missing or isn't a commit in the following line:
+ - \$line")"
warn
fi
@@ -913,9 +967,9 @@ check_bad_cmd_and_sha () {
;;
*)
line="$(sed -n -e "${lineno}p" "$1")"
- warn "Warning: the command isn't recognized" \
- "in the following line:"
- warn " - $line"
+ warn "$(eval_gettext "\
+Warning: the command isn't recognized in the following line:
+ - \$line")"
warn
retval=1
;;
@@ -952,7 +1006,7 @@ warn_lines () {
# Switch to the branch in $into and notify it in the reflog
checkout_onto () {
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
- output git checkout $onto || die_abort "could not detach HEAD"
+ output git checkout $onto || die_abort "$(gettext "could not detach HEAD")"
git update-ref ORIG_HEAD $orig_head
}
@@ -990,28 +1044,26 @@ check_todo_list () {
then
test "$check_level" = error && raise_error=t
- warn "Warning: some commits may have been dropped" \
- "accidentally."
- warn "Dropped commits (newer to older):"
+ warn "$(gettext "\
+Warning: some commits may have been dropped accidentally.
+Dropped commits (newer to older):")"
# Make the list user-friendly and display
opt="--no-walk=sorted --format=oneline --abbrev-commit --stdin"
git rev-list $opt <"$todo".miss | warn_lines
- warn "To avoid this message, use \"drop\" to" \
- "explicitly remove a commit."
- warn
- warn "Use 'git config rebase.missingCommitsCheck' to change" \
- "the level of warnings."
- warn "The possible behaviours are: ignore, warn, error."
+ warn "$(gettext "\
+To avoid this message, use \"drop\" to explicitly remove a commit.
+
+Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
+The possible behaviours are: ignore, warn, error.")"
warn
fi
;;
ignore)
;;
*)
- warn "Unrecognized setting $check_level for option" \
- "rebase.missingCommitsCheck. Ignoring."
+ warn "$(eval_gettext "Unrecognized setting \$check_level for option rebase.missingCommitsCheck. Ignoring.")"
;;
esac
@@ -1028,8 +1080,8 @@ check_todo_list () {
# placed before the commit of the next action
checkout_onto
- warn "You can fix this with 'git rebase --edit-todo'."
- die "Or you can abort the rebase with 'git rebase --abort'."
+ warn "$(gettext "You can fix this with 'git rebase --edit-todo'.")"
+ die "$(gettext "Or you can abort the rebase with 'git rebase --abort'.")"
fi
}
@@ -1038,8 +1090,8 @@ check_todo_list () {
# below were not inside any function, and expected to return
# to the function that dot-sourced us.
#
-# However, FreeBSD /bin/sh misbehaves on such a construct and
-# continues to run the statements that follow such a "return".
+# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a
+# construct and continue to run the statements that follow such a "return".
# As a work-around, we introduce an extra layer of a function
# here, and immediately call it after defining it.
git_rebase__interactive () {
@@ -1053,41 +1105,43 @@ continue)
test ! -f "$GIT_DIR"/CHERRY_PICK_HEAD ||
rm "$GIT_DIR"/CHERRY_PICK_HEAD ||
- die "Could not remove CHERRY_PICK_HEAD"
+ die "$(gettext "Could not remove CHERRY_PICK_HEAD")"
else
if ! test -f "$author_script"
then
gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")}
- die "You have staged changes in your working tree. If these changes are meant to be
+ die "$(eval_gettext "\
+You have staged changes in your working tree.
+If these changes are meant to be
squashed into the previous commit, run:
- git commit --amend $gpg_sign_opt_quoted
+ git commit --amend \$gpg_sign_opt_quoted
If they are meant to go into a new commit, run:
- git commit $gpg_sign_opt_quoted
+ git commit \$gpg_sign_opt_quoted
In both case, once you're done, continue with:
git rebase --continue
-"
+")"
fi
. "$author_script" ||
- die "Error trying to find the author identity to amend commit"
+ die "$(gettext "Error trying to find the author identity to amend commit")"
if test -f "$amend"
then
current_head=$(git rev-parse --verify HEAD)
test "$current_head" = $(cat "$amend") ||
- die "\
-You have uncommitted changes in your working tree. Please, commit them
-first and then run 'git rebase --continue' again."
+ die "$(gettext "\
+You have uncommitted changes in your working tree. Please commit them
+first and then run 'git rebase --continue' again.")"
do_with_author git commit --amend --no-verify -F "$msg" -e \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
- die "Could not commit staged changes."
+ die "$(gettext "Could not commit staged changes.")"
else
do_with_author git commit --no-verify -F "$msg" -e \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
- die "Could not commit staged changes."
+ die "$(gettext "Could not commit staged changes.")"
fi
fi
@@ -1111,16 +1165,15 @@ edit-todo)
mv -f "$todo".new "$todo"
collapse_todo_ids
append_todo_help
- git stripspace --comment-lines >>"$todo" <<\EOF
-
+ gettext "
You are editing the todo file of an ongoing interactive rebase.
To continue rebase after editing, run:
git rebase --continue
-EOF
+" | git stripspace --comment-lines >>"$todo"
git_sequence_editor "$todo" ||
- die "Could not execute editor"
+ die "$(gettext "Could not execute editor")"
expand_todo_ids
exit
@@ -1128,7 +1181,7 @@ EOF
esac
git var GIT_COMMITTER_IDENT >/dev/null ||
- die "You need to set your committer info first"
+ die "$(gettext "You need to set your committer info first")"
comment_for_reflog start
@@ -1136,15 +1189,15 @@ if test ! -z "$switch_to"
then
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
output git checkout "$switch_to" -- ||
- die "Could not checkout $switch_to"
+ die "$(eval_gettext "Could not checkout \$switch_to")"
comment_for_reflog start
fi
-orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
-mkdir -p "$state_dir" || die "Could not create temporary $state_dir"
+orig_head=$(git rev-parse --verify HEAD) || die "$(gettext "No HEAD?")"
+mkdir -p "$state_dir" || die "$(eval_gettext "Could not create temporary \$state_dir")"
-: > "$state_dir"/interactive || die "Could not mark as interactive"
+: > "$state_dir"/interactive || die "$(gettext "Could not mark as interactive")"
write_basic_state
if test t = "$preserve_merges"
then
@@ -1154,12 +1207,12 @@ then
for c in $(git merge-base --all $orig_head $upstream)
do
echo $onto > "$rewritten"/$c ||
- die "Could not init rewritten commits"
+ die "$(gettext "Could not init rewritten commits")"
done
else
mkdir "$rewritten" &&
echo $onto > "$rewritten"/root ||
- die "Could not init rewritten commits"
+ die "$(gettext "Could not init rewritten commits")"
fi
# No cherry-pick because our first pass is to determine
# parents to rewrite and skipping dropped commits would
@@ -1258,18 +1311,20 @@ todocount=${todocount##* }
cat >>"$todo" <<EOF
-$comment_char Rebase $shortrevisions onto $shortonto ($todocount command(s))
+$comment_char $(eval_ngettext \
+ "Rebase \$shortrevisions onto \$shortonto (\$todocount command)" \
+ "Rebase \$shortrevisions onto \$shortonto (\$todocount commands)" \
+ "$todocount")
EOF
append_todo_help
-git stripspace --comment-lines >>"$todo" <<\EOF
-
+gettext "
However, if you remove everything, the rebase will be aborted.
-EOF
+" | git stripspace --comment-lines >>"$todo"
if test -z "$keep_empty"
then
- printf '%s\n' "$comment_char Note that empty commits are commented out" >>"$todo"
+ printf '%s\n' "$comment_char $(gettext "Note that empty commits are commented out")" >>"$todo"
fi
@@ -1279,7 +1334,7 @@ has_action "$todo" ||
cp "$todo" "$todo".backup
collapse_todo_ids
git_sequence_editor "$todo" ||
- die_abort "Could not execute editor"
+ die_abort "$(gettext "Could not execute editor")"
has_action "$todo" ||
return 2
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
index 8d43db906..06a4723d4 100644
--- a/git-rebase--merge.sh
+++ b/git-rebase--merge.sh
@@ -107,8 +107,8 @@ finish_rb_merge () {
# below were not inside any function, and expected to return
# to the function that dot-sourced us.
#
-# However, FreeBSD /bin/sh misbehaves on such a construct and
-# continues to run the statements that follow such a "return".
+# However, older (9.x) versions of FreeBSD /bin/sh misbehave on such a
+# construct and continue to run the statements that follow such a "return".
# As a work-around, we introduce an extra layer of a function
# here, and immediately call it after defining it.
git_rebase__merge () {
diff --git a/git-rebase.sh b/git-rebase.sh
index 44ede367a..04f6e44bc 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -45,7 +45,6 @@ skip! skip current patch and continue
edit-todo! edit the todo list during an interactive rebase
"
. git-sh-setup
-. git-sh-i18n
set_reflog_action rebase
require_work_tree_exists
cd_to_toplevel
@@ -154,7 +153,7 @@ move_to_original_branch () {
git symbolic-ref \
-m "rebase finished: returning to $head_name" \
HEAD $head_name ||
- die "$(gettext "Could not move back to $head_name")"
+ die "$(eval_gettext "Could not move back to \$head_name")"
;;
esac
}
@@ -449,7 +448,7 @@ then
then
. git-parse-remote
error_on_missing_default_upstream "rebase" "rebase" \
- "against" "git rebase <branch>"
+ "against" "git rebase $(gettext '<branch>')"
fi
test "$fork_point" = auto && fork_point=t
diff --git a/git-send-email.perl b/git-send-email.perl
index 69587856d..da81be40c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -621,6 +621,8 @@ if (@rev_list_opts) {
push @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);
}
+@files = handle_backup_files(@files);
+
if ($validate) {
foreach my $f (@files) {
unless (-p $f) {
@@ -1727,6 +1729,44 @@ sub validate_patch {
return;
}
+sub handle_backup {
+ my ($last, $lastlen, $file, $known_suffix) = @_;
+ my ($suffix, $skip);
+
+ $skip = 0;
+ if (defined $last &&
+ ($lastlen < length($file)) &&
+ (substr($file, 0, $lastlen) eq $last) &&
+ ($suffix = substr($file, $lastlen)) !~ /^[a-z0-9]/i) {
+ if (defined $known_suffix && $suffix eq $known_suffix) {
+ print "Skipping $file with backup suffix '$known_suffix'.\n";
+ $skip = 1;
+ } else {
+ my $answer = ask("Do you really want to send $file? (y|N): ",
+ valid_re => qr/^(?:y|n)/i,
+ default => 'n');
+ $skip = ($answer ne 'y');
+ if ($skip) {
+ $known_suffix = $suffix;
+ }
+ }
+ }
+ return ($skip, $known_suffix);
+}
+
+sub handle_backup_files {
+ my @file = @_;
+ my ($last, $lastlen, $known_suffix, $skip, @result);
+ for my $file (@file) {
+ ($skip, $known_suffix) = handle_backup($last, $lastlen,
+ $file, $known_suffix);
+ push @result, $file unless $skip;
+ $last = $file;
+ $lastlen = length($file);
+ }
+ return @result;
+}
+
sub file_has_nonascii {
my $fn = shift;
open(my $fh, '<', $fn)
diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index e6c3116e1..1ef1889db 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -53,6 +53,13 @@ gettext_without_eval_gettext)
git sh-i18n--envsubst "$1"
)
}
+
+ eval_ngettext () {
+ ngettext "$1" "$2" "$3" | (
+ export PATH $(git sh-i18n--envsubst --variables "$2");
+ git sh-i18n--envsubst "$2"
+ )
+ }
;;
poison)
# Emit garbage so that tests that incorrectly rely on translatable
@@ -64,6 +71,10 @@ poison)
eval_gettext () {
printf "%s" "# GETTEXT POISON #"
}
+
+ eval_ngettext () {
+ printf "%s" "# GETTEXT POISON #"
+ }
;;
*)
gettext () {
@@ -76,6 +87,13 @@ poison)
git sh-i18n--envsubst "$1"
)
}
+
+ eval_ngettext () {
+ (test "$3" = 1 && printf "%s" "$1" || printf "%s" "$2") | (
+ export PATH $(git sh-i18n--envsubst --variables "$2");
+ git sh-i18n--envsubst "$2"
+ )
+ }
;;
esac
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index c48139a49..0c34aa62f 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -2,6 +2,9 @@
# to set up some variables pointing at the normal git directories and
# a few helper shell functions.
+# Source git-sh-i18n for gettext support.
+. git-sh-i18n
+
# Having this variable in your environment would break scripts because
# you would cause "cd" to be taken to unexpected places. If you
# like CDPATH, define it for your interactive shell sessions without
@@ -83,16 +86,16 @@ if test -n "$OPTIONS_SPEC"; then
else
dashless=$(basename -- "$0" | sed -e 's/-/ /')
usage() {
- die "usage: $dashless $USAGE"
+ die "$(eval_gettext "usage: \$dashless \$USAGE")"
}
if [ -z "$LONG_USAGE" ]
then
- LONG_USAGE="usage: $dashless $USAGE"
+ LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE")"
else
- LONG_USAGE="usage: $dashless $USAGE
+ LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE
-$LONG_USAGE"
+$LONG_USAGE")"
fi
case "$1" in
@@ -160,8 +163,8 @@ git_pager() {
else
GIT_PAGER=cat
fi
- : ${LESS=-FRX}
- : ${LV=-c}
+ : "${LESS=-FRX}"
+ : "${LV=-c}"
export LESS LV
eval "$GIT_PAGER" '"$@"'
@@ -182,7 +185,7 @@ is_bare_repository () {
cd_to_toplevel () {
cdup=$(git rev-parse --show-toplevel) &&
cd "$cdup" || {
- echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
+ gettextln "Cannot chdir to \$cdup, the toplevel of the working tree" >&2
exit 1
}
}
@@ -190,13 +193,16 @@ cd_to_toplevel () {
require_work_tree_exists () {
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
- die "fatal: $0 cannot be used without a working tree."
+ program_name=$0
+ die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
fi
}
require_work_tree () {
- test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
- die "fatal: $0 cannot be used without a working tree."
+ test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true || {
+ program_name=$0
+ die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
+ }
}
require_clean_work_tree () {
@@ -206,24 +212,49 @@ require_clean_work_tree () {
if ! git diff-files --quiet --ignore-submodules
then
- echo >&2 "Cannot $1: You have unstaged changes."
+ action=$1
+ case "$action" in
+ rebase)
+ gettextln "Cannot rebase: You have unstaged changes." >&2
+ ;;
+ "rewrite branches")
+ gettextln "Cannot rewrite branches: You have unstaged changes." >&2
+ ;;
+ "pull with rebase")
+ gettextln "Cannot pull with rebase: You have unstaged changes." >&2
+ ;;
+ *)
+ eval_gettextln "Cannot \$action: You have unstaged changes." >&2
+ ;;
+ esac
err=1
fi
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
then
- if [ $err = 0 ]
+ if test $err = 0
then
- echo >&2 "Cannot $1: Your index contains uncommitted changes."
+ action=$1
+ case "$action" in
+ rebase)
+ gettextln "Cannot rebase: Your index contains uncommitted changes." >&2
+ ;;
+ "pull with rebase")
+ gettextln "Cannot pull with rebase: Your index contains uncommitted changes." >&2
+ ;;
+ *)
+ eval_gettextln "Cannot \$action: Your index contains uncommitted changes." >&2
+ ;;
+ esac
else
- echo >&2 "Additionally, your index contains uncommitted changes."
+ gettextln "Additionally, your index contains uncommitted changes." >&2
fi
err=1
fi
- if [ $err = 1 ]
+ if test $err = 1
then
- test -n "$2" && echo >&2 "$2"
+ test -n "$2" && echo "$2" >&2
exit 1
fi
}
@@ -336,15 +367,15 @@ git_dir_init () {
then
test -z "$(git rev-parse --show-cdup)" || {
exit=$?
- echo >&2 "You need to run this command from the toplevel of the working tree."
+ gettextln "You need to run this command from the toplevel of the working tree." >&2
exit $exit
}
fi
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
- echo >&2 "Unable to determine absolute path of git directory"
+ gettextln "Unable to determine absolute path of git directory" >&2
exit 1
}
- : ${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}
+ : "${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}"
}
if test -z "$NONGIT_OK"
diff --git a/git-stash.sh b/git-stash.sh
index c7509e8da..22fb8bcba 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -15,7 +15,6 @@ SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
START_DIR=$(pwd)
. git-sh-setup
-. git-sh-i18n
require_work_tree
cd_to_toplevel
diff --git a/git-submodule.sh b/git-submodule.sh
index b39ac106e..4ec7546f1 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -16,7 +16,6 @@ USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <re
OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. git-sh-setup
-. git-sh-i18n
. git-parse-remote
require_work_tree
wt_prefix=$(git rev-parse --show-prefix)
@@ -240,14 +239,15 @@ Use -f if you really want to add it." >&2
then
if test -z "$force"
then
- echo >&2 "$(eval_gettext "A git directory for '\$sm_name' is found locally with remote(s):")"
+ eval_gettextln >&2 "A git directory for '\$sm_name' is found locally with remote(s):"
GIT_DIR=".git/modules/$sm_name" GIT_WORK_TREE=. git remote -v | grep '(fetch)' | sed -e s,^," ", -e s,' (fetch)',, >&2
- echo >&2 "$(eval_gettext "If you want to reuse this local git directory instead of cloning again from")"
- echo >&2 " $realrepo"
- echo >&2 "$(eval_gettext "use the '--force' option. If the local git directory is not the correct repo")"
- die "$(eval_gettext "or you are unsure what this means choose another name with the '--name' option.")"
+ die "$(eval_gettextln "\
+If you want to reuse this local git directory instead of cloning again from
+ \$realrepo
+use the '--force' option. If the local git directory is not the correct repo
+or you are unsure what this means choose another name with the '--name' option.")"
else
- echo "$(eval_gettext "Reactivating local git directory for submodule '\$sm_name'.")"
+ eval_gettextln "Reactivating local git directory for submodule '\$sm_name'."
fi
fi
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${depth:+"$depth"} || exit
@@ -438,8 +438,9 @@ cmd_deinit()
# Protect submodules containing a .git directory
if test -d "$sm_path/.git"
then
- echo >&2 "$(eval_gettext "Submodule work tree '\$displaypath' contains a .git directory")"
- die "$(eval_gettext "(use 'rm -rf' if you really want to remove it including all of its history)")"
+ die "$(eval_gettext "\
+Submodule work tree '\$displaypath' contains a .git directory
+(use 'rm -rf' if you really want to remove it including all of its history)")"
fi
if test -z "$force"
@@ -624,7 +625,7 @@ cmd_update()
remote_name=$(sanitize_submodule_env; cd "$sm_path" && get_default_remote)
sha1=$(sanitize_submodule_env; cd "$sm_path" &&
git rev-parse --verify "${remote_name}/${branch}") ||
- die "$(eval_gettext "Unable to find current ${remote_name}/${branch} revision in submodule path '\$sm_path'")"
+ die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
fi
if test "$subsha1" != "$sha1" || test -n "$force"
@@ -648,7 +649,7 @@ cmd_update()
# not be reachable from any of the refs
is_tip_reachable "$sm_path" "$sha1" ||
fetch_in_submodule "$sm_path" "$sha1" ||
- die "$(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain $sha1. Direct fetching of that commit failed.")"
+ die "$(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain \$sha1. Direct fetching of that commit failed.")"
fi
must_die_on_failure=
@@ -705,7 +706,7 @@ cmd_update()
if test $res -gt 0
then
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$displaypath'")"
- if test $res -eq 1
+ if test $res -ne 2
then
err="${err};$die_msg"
continue
diff --git a/git-svn.perl b/git-svn.perl
index 05eced06c..f609e54ce 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -507,7 +507,10 @@ sub init_subdir {
sub cmd_clone {
my ($url, $path) = @_;
- if (!defined $path &&
+ if (!$url) {
+ die "SVN repository location required ",
+ "as a command-line argument\n";
+ } elsif (!defined $path &&
(defined $_trunk || @_branches || @_tags ||
defined $_stdlayout) &&
$url !~ m#^[a-z\+]+://#) {
diff --git a/gpg-interface.c b/gpg-interface.c
index c4b1e8c78..08356f92e 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -3,6 +3,7 @@
#include "strbuf.h"
#include "gpg-interface.h"
#include "sigchain.h"
+#include "tempfile.h"
static char *configured_signing_key;
static const char *gpg_program = "gpg";
@@ -150,42 +151,30 @@ const char *get_signing_key(void)
int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key)
{
struct child_process gpg = CHILD_PROCESS_INIT;
- const char *args[4];
- ssize_t len;
+ int ret;
size_t i, j, bottom;
+ struct strbuf gpg_status = STRBUF_INIT;
- gpg.argv = args;
- gpg.in = -1;
- gpg.out = -1;
- args[0] = gpg_program;
- args[1] = "-bsau";
- args[2] = signing_key;
- args[3] = NULL;
+ argv_array_pushl(&gpg.args,
+ gpg_program,
+ "--status-fd=2",
+ "-bsau", signing_key,
+ NULL);
- if (start_command(&gpg))
- return error(_("could not run gpg."));
+ bottom = signature->len;
/*
* When the username signingkey is bad, program could be terminated
* because gpg exits without reading and then write gets SIGPIPE.
*/
sigchain_push(SIGPIPE, SIG_IGN);
-
- if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
- close(gpg.in);
- close(gpg.out);
- finish_command(&gpg);
- return error(_("gpg did not accept the data"));
- }
- close(gpg.in);
-
- bottom = signature->len;
- len = strbuf_read(signature, gpg.out, 1024);
- close(gpg.out);
-
+ ret = pipe_command(&gpg, buffer->buf, buffer->len,
+ signature, 1024, &gpg_status, 0);
sigchain_pop(SIGPIPE);
- if (finish_command(&gpg) || !len || len < 0)
+ ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
+ strbuf_release(&gpg_status);
+ if (ret)
return error(_("gpg failed to sign the data"));
/* Strip CR from the line endings, in case we are on Windows. */
@@ -210,50 +199,38 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
struct strbuf *gpg_output, struct strbuf *gpg_status)
{
struct child_process gpg = CHILD_PROCESS_INIT;
- const char *args_gpg[] = {NULL, "--status-fd=1", "--verify", "FILE", "-", NULL};
- char path[PATH_MAX];
+ static struct tempfile temp;
int fd, ret;
struct strbuf buf = STRBUF_INIT;
- struct strbuf *pbuf = &buf;
- args_gpg[0] = gpg_program;
- fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
+ fd = mks_tempfile_t(&temp, ".git_vtag_tmpXXXXXX");
if (fd < 0)
- return error_errno(_("could not create temporary file '%s'"), path);
- if (write_in_full(fd, signature, signature_size) < 0)
- return error_errno(_("failed writing detached signature to '%s'"), path);
+ return error_errno(_("could not create temporary file"));
+ if (write_in_full(fd, signature, signature_size) < 0) {
+ error_errno(_("failed writing detached signature to '%s'"),
+ temp.filename.buf);
+ delete_tempfile(&temp);
+ return -1;
+ }
close(fd);
- gpg.argv = args_gpg;
- gpg.in = -1;
- gpg.out = -1;
- if (gpg_output)
- gpg.err = -1;
- args_gpg[3] = path;
- if (start_command(&gpg)) {
- unlink(path);
- return error(_("could not run gpg."));
- }
+ argv_array_pushl(&gpg.args,
+ gpg_program,
+ "--status-fd=1",
+ "--verify", temp.filename.buf, "-",
+ NULL);
- sigchain_push(SIGPIPE, SIG_IGN);
- write_in_full(gpg.in, payload, payload_size);
- close(gpg.in);
+ if (!gpg_status)
+ gpg_status = &buf;
- if (gpg_output) {
- strbuf_read(gpg_output, gpg.err, 0);
- close(gpg.err);
- }
- if (gpg_status)
- pbuf = gpg_status;
- strbuf_read(pbuf, gpg.out, 0);
- close(gpg.out);
-
- ret = finish_command(&gpg);
+ sigchain_push(SIGPIPE, SIG_IGN);
+ ret = pipe_command(&gpg, payload, payload_size,
+ gpg_status, 0, gpg_output, 0);
sigchain_pop(SIGPIPE);
- unlink_or_warn(path);
+ delete_tempfile(&temp);
- ret |= !strstr(pbuf->buf, "\n[GNUPG:] GOODSIG ");
+ ret |= !strstr(gpg_status->buf, "\n[GNUPG:] GOODSIG ");
strbuf_release(&buf); /* no matter it was used or not */
return ret;
diff --git a/graph.c b/graph.c
index 8ad8ba362..dd1720148 100644
--- a/graph.c
+++ b/graph.c
@@ -669,6 +669,13 @@ static void graph_output_padding_line(struct git_graph *graph,
graph_pad_horizontally(graph, sb, graph->num_new_columns * 2);
}
+
+int graph_width(struct git_graph *graph)
+{
+ return graph->width;
+}
+
+
static void graph_output_skip_line(struct git_graph *graph, struct strbuf *sb)
{
/*
diff --git a/graph.h b/graph.h
index 0be62bd8b..3f48c19b6 100644
--- a/graph.h
+++ b/graph.h
@@ -68,6 +68,11 @@ int graph_next_line(struct git_graph *graph, struct strbuf *sb);
/*
+ * Return current width of the graph in on-screen characters.
+ */
+int graph_width(struct git_graph *graph);
+
+/*
* graph_show_*: helper functions for printing to stdout
*/
diff --git a/help.c b/help.c
index 19328ea99..2ff3b5a77 100644
--- a/help.c
+++ b/help.c
@@ -419,6 +419,12 @@ int cmd_version(int argc, const char **argv, const char *prefix)
* with external projects that rely on the output of "git version".
*/
printf("git version %s\n", git_version_string);
+ while (*++argv) {
+ if (!strcmp(*argv, "--build-options")) {
+ printf("sizeof-long: %d\n", (int)sizeof(long));
+ /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
+ }
+ }
return 0;
}
diff --git a/http.c b/http.c
index df6dd0159..d8b2bec86 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,7 @@
#include "gettext.h"
#include "transport.h"
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
#if LIBCURL_VERSION_NUM >= 0x070a08
long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
#else
@@ -477,6 +478,125 @@ static void set_curl_keepalive(CURL *c)
}
#endif
+static void redact_sensitive_header(struct strbuf *header)
+{
+ const char *sensitive_header;
+
+ if (skip_prefix(header->buf, "Authorization:", &sensitive_header) ||
+ skip_prefix(header->buf, "Proxy-Authorization:", &sensitive_header)) {
+ /* The first token is the type, which is OK to log */
+ while (isspace(*sensitive_header))
+ sensitive_header++;
+ while (*sensitive_header && !isspace(*sensitive_header))
+ sensitive_header++;
+ /* Everything else is opaque and possibly sensitive */
+ strbuf_setlen(header, sensitive_header - header->buf);
+ strbuf_addstr(header, " <redacted>");
+ }
+}
+
+static void curl_dump_header(const char *text, unsigned char *ptr, size_t size, int hide_sensitive_header)
+{
+ struct strbuf out = STRBUF_INIT;
+ struct strbuf **headers, **header;
+
+ strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+ text, (long)size, (long)size);
+ trace_strbuf(&trace_curl, &out);
+ strbuf_reset(&out);
+ strbuf_add(&out, ptr, size);
+ headers = strbuf_split_max(&out, '\n', 0);
+
+ for (header = headers; *header; header++) {
+ if (hide_sensitive_header)
+ redact_sensitive_header(*header);
+ strbuf_insert((*header), 0, text, strlen(text));
+ strbuf_insert((*header), strlen(text), ": ", 2);
+ strbuf_rtrim((*header));
+ strbuf_addch((*header), '\n');
+ trace_strbuf(&trace_curl, (*header));
+ }
+ strbuf_list_free(headers);
+ strbuf_release(&out);
+}
+
+static void curl_dump_data(const char *text, unsigned char *ptr, size_t size)
+{
+ size_t i;
+ struct strbuf out = STRBUF_INIT;
+ unsigned int width = 60;
+
+ strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+ text, (long)size, (long)size);
+ trace_strbuf(&trace_curl, &out);
+
+ for (i = 0; i < size; i += width) {
+ size_t w;
+
+ strbuf_reset(&out);
+ strbuf_addf(&out, "%s: ", text);
+ for (w = 0; (w < width) && (i + w < size); w++) {
+ unsigned char ch = ptr[i + w];
+
+ strbuf_addch(&out,
+ (ch >= 0x20) && (ch < 0x80)
+ ? ch : '.');
+ }
+ strbuf_addch(&out, '\n');
+ trace_strbuf(&trace_curl, &out);
+ }
+ strbuf_release(&out);
+}
+
+static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size, void *userp)
+{
+ const char *text;
+ enum { NO_FILTER = 0, DO_FILTER = 1 };
+
+ switch (type) {
+ case CURLINFO_TEXT:
+ trace_printf_key(&trace_curl, "== Info: %s", data);
+ default: /* we ignore unknown types by default */
+ return 0;
+
+ case CURLINFO_HEADER_OUT:
+ text = "=> Send header";
+ curl_dump_header(text, (unsigned char *)data, size, DO_FILTER);
+ break;
+ case CURLINFO_DATA_OUT:
+ text = "=> Send data";
+ curl_dump_data(text, (unsigned char *)data, size);
+ break;
+ case CURLINFO_SSL_DATA_OUT:
+ text = "=> Send SSL data";
+ curl_dump_data(text, (unsigned char *)data, size);
+ break;
+ case CURLINFO_HEADER_IN:
+ text = "<= Recv header";
+ curl_dump_header(text, (unsigned char *)data, size, NO_FILTER);
+ break;
+ case CURLINFO_DATA_IN:
+ text = "<= Recv data";
+ curl_dump_data(text, (unsigned char *)data, size);
+ break;
+ case CURLINFO_SSL_DATA_IN:
+ text = "<= Recv SSL data";
+ curl_dump_data(text, (unsigned char *)data, size);
+ break;
+ }
+ return 0;
+}
+
+void setup_curl_trace(CURL *handle)
+{
+ if (!trace_want(&trace_curl))
+ return;
+ curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);
+ curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
+}
+
+
static CURL *get_curl_handle(void)
{
CURL *result = curl_easy_init();
@@ -575,9 +695,9 @@ static CURL *get_curl_handle(void)
warning("protocol restrictions not applied to curl redirects because\n"
"your curl version is too old (>= 7.19.4)");
#endif
-
if (getenv("GIT_CURL_VERBOSE"))
- curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
+ curl_easy_setopt(result, CURLOPT_VERBOSE, 1L);
+ setup_curl_trace(result);
curl_easy_setopt(result, CURLOPT_USERAGENT,
user_agent ? user_agent : git_user_agent());
diff --git a/http.h b/http.h
index 36f558bfb..5ab9d9c32 100644
--- a/http.h
+++ b/http.h
@@ -225,4 +225,6 @@ extern int finish_http_object_request(struct http_object_request *freq);
extern void abort_http_object_request(struct http_object_request *freq);
extern void release_http_object_request(struct http_object_request *freq);
+/* setup routine for curl_easy_setopt CURLOPT_DEBUGFUNCTION */
+void setup_curl_trace(CURL *handle);
#endif /* HTTP_H */
diff --git a/imap-send.c b/imap-send.c
index 938c69158..50377c5b8 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1443,6 +1443,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ setup_curl_trace(curl);
return curl;
}
diff --git a/line-log.c b/line-log.c
index e62a7f4ac..a30c89a30 100644
--- a/line-log.c
+++ b/line-log.c
@@ -480,8 +480,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
struct object *obj = revs->pending.objects[i].item;
if (obj->flags & UNINTERESTING)
continue;
- while (obj->type == OBJ_TAG)
- obj = deref_tag(obj, NULL, 0);
+ obj = deref_tag(obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
if (commit)
diff --git a/log-tree.c b/log-tree.c
index cf2402735..d0062e678 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -603,7 +603,7 @@ void show_log(struct rev_info *opt)
* Print header line of header..
*/
- if (opt->commit_format == CMIT_FMT_EMAIL) {
+ if (cmit_fmt_is_mail(opt->commit_format)) {
log_write_email_headers(opt, commit, &ctx.subject, &extra_headers,
&ctx.need_8bit_cte);
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
@@ -687,6 +687,8 @@ void show_log(struct rev_info *opt)
ctx.output_encoding = get_log_output_encoding();
if (opt->from_ident.mail_begin && opt->from_ident.name_begin)
ctx.from_ident = &opt->from_ident;
+ if (opt->graph)
+ ctx.graph_width = graph_width(opt->graph);
pretty_print_commit(&ctx, commit, &msgbuf);
if (opt->add_signoff)
@@ -694,7 +696,7 @@ void show_log(struct rev_info *opt)
if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
ctx.notes_message && *ctx.notes_message) {
- if (ctx.fmt == CMIT_FMT_EMAIL) {
+ if (cmit_fmt_is_mail(ctx.fmt)) {
strbuf_addstr(&msgbuf, "---\n");
opt->shown_dashes = 1;
}
diff --git a/notes.c b/notes.c
index e4e4854d6..df4660fe6 100644
--- a/notes.c
+++ b/notes.c
@@ -70,7 +70,7 @@ struct non_note {
struct notes_tree default_notes_tree;
-static struct string_list display_notes_refs;
+static struct string_list display_notes_refs = STRING_LIST_INIT_NODUP;
static struct notes_tree **display_notes_trees;
static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 239898d94..ba5acf311 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -144,7 +144,7 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset)
if (!arg)
return -1;
- string_list_append(v, xstrdup(arg));
+ string_list_append(v, arg);
return 0;
}
diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index d94d01cfd..018beb85a 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -97,8 +97,12 @@ sub resolve_local_globs {
"existing: $existing\n",
" globbed: $refname\n";
}
- my $u = (::cmt_metadata("$refname"))[0] or die
- "$refname: no associated commit metadata\n";
+ my $u = (::cmt_metadata("$refname"))[0];
+ if (!defined($u)) {
+ warn
+"W: $refname: no associated commit metadata from SVN, skipping\n";
+ next;
+ }
$u =~ s!^\Q$url\E(/|$)!! or die
"$refname: '$url' not found in '$u'\n";
if ($pathname ne $u) {
@@ -1905,15 +1909,22 @@ sub make_log_entry {
my @parents = @$parents;
my $props = $ed->{dir_prop}{$self->path};
- if ( $props->{"svk:merge"} ) {
- $self->find_extra_svk_parents($props->{"svk:merge"}, \@parents);
- }
- if ( $props->{"svn:mergeinfo"} ) {
- my $mi_changes = $self->mergeinfo_changes
- ($parent_path, $parent_rev,
- $self->path, $rev,
- $props->{"svn:mergeinfo"});
- $self->find_extra_svn_parents($mi_changes, \@parents);
+ if ($self->follow_parent) {
+ my $tickets = $props->{"svk:merge"};
+ if ($tickets) {
+ $self->find_extra_svk_parents($tickets, \@parents);
+ }
+
+ my $mergeinfo_prop = $props->{"svn:mergeinfo"};
+ if ($mergeinfo_prop) {
+ my $mi_changes = $self->mergeinfo_changes(
+ $parent_path,
+ $parent_rev,
+ $self->path,
+ $rev,
+ $mergeinfo_prop);
+ $self->find_extra_svn_parents($mi_changes, \@parents);
+ }
}
open my $un, '>>', "$self->{dir}/unhandled.log" or croak $!;
diff --git a/po/is.po b/po/is.po
index 8692a8b5b..b8b34fd65 100644
--- a/po/is.po
+++ b/po/is.po
@@ -7,14 +7,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Git\n"
"Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2010-09-20 14:44+0000\n"
-"PO-Revision-Date: 2010-06-05 19:06 +0000\n"
-"Last-Translator: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n"
+"POT-Creation-Date: 2016-06-17 18:55+0000\n"
+"PO-Revision-Date: 2016-06-17 19:17+0000\n"
+"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Git Mailing List <git@vger.kernel.org>\n"
"Language: is\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.5\n"
#. TRANSLATORS: This is a test. You don't need to translate it.
#: t/t0200/test.c:5
@@ -72,22 +73,31 @@ msgstr "TILRAUN: Perl tilraunastrengur"
msgid "TEST: A Perl test variable %s"
msgstr "TILRAUN: Perl tilraunastrengur með breytunni %s"
-#. TRANSLATORS: The first '%s' is either "Reinitialized
-#. existing" or "Initialized empty", the second " shared" or
-#. "", and the last '%s%s' is the verbatim directory name.
-#: builtin/init-db.c:355
+#: builtin/init-db.c:402
#, c-format
-msgid "%s%s Git repository in %s%s\n"
-msgstr "%s%s Git lind í %s%s\n"
+msgid "Reinitialized existing shared Git repository in %s%s\n"
+msgstr "Endurgerði Git lind í %s%s\n"
-#: builtin/init-db.c:356
-msgid "Reinitialized existing"
-msgstr "Endurgerði"
+#: builtin/init-db.c:403
+#, c-format
+msgid "Reinitialized existing Git repository in %s%s\n"
+msgstr "Endurgerði Git lind í %s%s\n"
+
+#: builtin/init-db.c:407
+#, c-format
+msgid "Initialized empty shared Git repository in %s%s\n"
+msgstr "Bjó til tóma sameiginlega Git lind í %s%s\n"
+
+#: builtin/init-db.c:408
+#, c-format
+msgid "Initialized empty Git repository in %s%s\n"
+msgstr "Bjó til tóma Git lind í %s%s\n"
+
+#~ msgid "Reinitialized existing"
+#~ msgstr "Endurgerði"
-#: builtin/init-db.c:356
-msgid "Initialized empty"
-msgstr "Bjó til tóma"
+#~ msgid "Initialized empty"
+#~ msgstr "Bjó til tóma"
-#: builtin/init-db.c:357
-msgid " shared"
-msgstr " sameiginlega"
+#~ msgid " shared"
+#~ msgstr " sameiginlega"
diff --git a/pretty.c b/pretty.c
index c3ec43022..9fa42c2b4 100644
--- a/pretty.c
+++ b/pretty.c
@@ -92,6 +92,7 @@ static void setup_commit_formats(void)
{ "medium", CMIT_FMT_MEDIUM, 0, 8 },
{ "short", CMIT_FMT_SHORT, 0, 0 },
{ "email", CMIT_FMT_EMAIL, 0, 0 },
+ { "mboxrd", CMIT_FMT_MBOXRD, 0, 0 },
{ "fuller", CMIT_FMT_FULLER, 0, 8 },
{ "full", CMIT_FMT_FULL, 0, 8 },
{ "oneline", CMIT_FMT_ONELINE, 1, 0 }
@@ -444,7 +445,7 @@ void pp_user_info(struct pretty_print_context *pp,
if (pp->mailmap)
map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
- if (pp->fmt == CMIT_FMT_EMAIL) {
+ if (cmit_fmt_is_mail(pp->fmt)) {
if (pp->from_ident && ident_cmp(pp->from_ident, &ident)) {
struct strbuf buf = STRBUF_INIT;
@@ -494,6 +495,7 @@ void pp_user_info(struct pretty_print_context *pp,
show_ident_date(&ident, &pp->date_mode));
break;
case CMIT_FMT_EMAIL:
+ case CMIT_FMT_MBOXRD:
strbuf_addf(sb, "Date: %s\n",
show_ident_date(&ident, DATE_MODE(RFC2822)));
break;
@@ -507,7 +509,7 @@ void pp_user_info(struct pretty_print_context *pp,
}
}
-static int is_empty_line(const char *line, int *len_p)
+static int is_blank_line(const char *line, int *len_p)
{
int len = *len_p;
while (len && isspace(line[len - 1]))
@@ -516,14 +518,14 @@ static int is_empty_line(const char *line, int *len_p)
return !len;
}
-static const char *skip_empty_lines(const char *msg)
+const char *skip_blank_lines(const char *msg)
{
for (;;) {
int linelen = get_one_line(msg);
int ll = linelen;
if (!linelen)
break;
- if (!is_empty_line(msg, &ll))
+ if (!is_blank_line(msg, &ll))
break;
msg += linelen;
}
@@ -535,7 +537,7 @@ static void add_merge_info(const struct pretty_print_context *pp,
{
struct commit_list *parent = commit->parents;
- if ((pp->fmt == CMIT_FMT_ONELINE) || (pp->fmt == CMIT_FMT_EMAIL) ||
+ if ((pp->fmt == CMIT_FMT_ONELINE) || (cmit_fmt_is_mail(pp->fmt)) ||
!parent || !parent->next)
return;
@@ -875,7 +877,7 @@ const char *format_subject(struct strbuf *sb, const char *msg,
int linelen = get_one_line(line);
msg += linelen;
- if (!linelen || is_empty_line(line, &linelen))
+ if (!linelen || is_blank_line(line, &linelen))
break;
if (!sb)
@@ -894,11 +896,11 @@ static void parse_commit_message(struct format_commit_context *c)
const char *msg = c->message + c->message_off;
const char *start = c->message;
- msg = skip_empty_lines(msg);
+ msg = skip_blank_lines(msg);
c->subject_off = msg - start;
msg = format_subject(NULL, msg, NULL);
- msg = skip_empty_lines(msg);
+ msg = skip_blank_lines(msg);
c->body_off = msg - start;
c->commit_message_parsed = 1;
@@ -1022,9 +1024,15 @@ static size_t parse_padding_placeholder(struct strbuf *sb,
int width;
if (!end || end == start)
return 0;
- width = strtoul(start, &next, 10);
+ width = strtol(start, &next, 10);
if (next == start || width == 0)
return 0;
+ if (width < 0) {
+ if (to_column)
+ width += term_columns();
+ if (width < 0)
+ return 0;
+ }
c->padding = to_column ? -width : width;
c->flush_type = flush_type;
@@ -1299,6 +1307,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
if (!start)
start = sb->buf;
occupied = utf8_strnwidth(start, -1, 1);
+ occupied += c->pretty_ctx->graph_width;
padding = (-padding) - occupied;
}
while (1) {
@@ -1614,7 +1623,7 @@ void pp_title_line(struct pretty_print_context *pp,
if (pp->after_subject) {
strbuf_addstr(sb, pp->after_subject);
}
- if (pp->fmt == CMIT_FMT_EMAIL) {
+ if (cmit_fmt_is_mail(pp->fmt)) {
strbuf_addch(sb, '\n');
}
@@ -1697,6 +1706,16 @@ static void pp_handle_indent(struct pretty_print_context *pp,
strbuf_add(sb, line, linelen);
}
+static int is_mboxrd_from(const char *line, int len)
+{
+ /*
+ * a line matching /^From $/ here would only have len == 4
+ * at this point because is_empty_line would've trimmed all
+ * trailing space
+ */
+ return len > 4 && starts_with(line + strspn(line, ">"), "From ");
+}
+
void pp_remainder(struct pretty_print_context *pp,
const char **msg_p,
struct strbuf *sb,
@@ -1711,7 +1730,7 @@ void pp_remainder(struct pretty_print_context *pp,
if (!linelen)
break;
- if (is_empty_line(line, &linelen)) {
+ if (is_blank_line(line, &linelen)) {
if (first)
continue;
if (pp->fmt == CMIT_FMT_SHORT)
@@ -1725,8 +1744,13 @@ void pp_remainder(struct pretty_print_context *pp,
else if (pp->expand_tabs_in_log)
strbuf_add_tabexpand(sb, pp->expand_tabs_in_log,
line, linelen);
- else
+ else {
+ if (pp->fmt == CMIT_FMT_MBOXRD &&
+ is_mboxrd_from(line, linelen))
+ strbuf_addch(sb, '>');
+
strbuf_add(sb, line, linelen);
+ }
strbuf_addch(sb, '\n');
}
}
@@ -1750,14 +1774,14 @@ void pretty_print_commit(struct pretty_print_context *pp,
encoding = get_log_output_encoding();
msg = reencoded = logmsg_reencode(commit, NULL, encoding);
- if (pp->fmt == CMIT_FMT_ONELINE || pp->fmt == CMIT_FMT_EMAIL)
+ if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
indent = 0;
/*
* We need to check and emit Content-type: to mark it
* as 8-bit if we haven't done so.
*/
- if (pp->fmt == CMIT_FMT_EMAIL && need_8bit_cte == 0) {
+ if (cmit_fmt_is_mail(pp->fmt) && need_8bit_cte == 0) {
int i, ch, in_body;
for (in_body = i = 0; (ch = msg[i]); i++) {
@@ -1782,10 +1806,10 @@ void pretty_print_commit(struct pretty_print_context *pp,
}
/* Skip excess blank lines at the beginning of body, if any... */
- msg = skip_empty_lines(msg);
+ msg = skip_blank_lines(msg);
/* These formats treat the title line specially. */
- if (pp->fmt == CMIT_FMT_ONELINE || pp->fmt == CMIT_FMT_EMAIL)
+ if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
pp_title_line(pp, &msg, sb, encoding, need_8bit_cte);
beginning_of_body = sb->len;
@@ -1802,7 +1826,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
* format. Make sure we did not strip the blank line
* between the header and the body.
*/
- if (pp->fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
+ if (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body)
strbuf_addch(sb, '\n');
unuse_commit_buffer(commit, reencoded);
diff --git a/read-cache.c b/read-cache.c
index d9fb78bc5..db2776605 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -630,7 +630,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
hashcpy(ce->sha1, sha1);
}
-int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags)
+int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags, int force_mode)
{
int size, namelen, was_same;
mode_t st_mode = st->st_mode;
@@ -659,7 +659,9 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
else
ce->ce_flags |= CE_INTENT_TO_ADD;
- if (trust_executable_bit && has_symlinks)
+ if (S_ISREG(st_mode) && force_mode)
+ ce->ce_mode = create_ce_mode(force_mode);
+ else if (trust_executable_bit && has_symlinks)
ce->ce_mode = create_ce_mode(st_mode);
else {
/* If there is an existing entry, pick the mode bits and type
@@ -720,12 +722,13 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
return 0;
}
-int add_file_to_index(struct index_state *istate, const char *path, int flags)
+int add_file_to_index(struct index_state *istate, const char *path,
+ int flags, int force_mode)
{
struct stat st;
if (lstat(path, &st))
die_errno("unable to stat '%s'", path);
- return add_to_index(istate, path, &st, flags);
+ return add_to_index(istate, path, &st, flags, force_mode);
}
struct cache_entry *make_cache_entry(unsigned int mode,
diff --git a/reflog-walk.c b/reflog-walk.c
index 0ebd1da5c..a246af276 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -241,6 +241,12 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
logobj = parse_object(reflog->osha1);
} while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT));
+ if (!logobj && commit_reflog->recno >= 0 && is_null_sha1(reflog->osha1)) {
+ /* a root commit, but there are still more entries to show */
+ reflog = &commit_reflog->reflogs->items[commit_reflog->recno];
+ logobj = parse_object(reflog->nsha1);
+ }
+
if (!logobj || logobj->type != OBJ_COMMIT) {
commit_info->commit = NULL;
commit->parents = NULL;
diff --git a/refs.h b/refs.h
index 9230d4714..56089d572 100644
--- a/refs.h
+++ b/refs.h
@@ -345,7 +345,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
* msg -- a message describing the change (for the reflog).
*
* err -- a strbuf for receiving a description of any error that
- * might have occured.
+ * might have occurred.
*
* The functions make internal copies of refname and msg, so the
* caller retains ownership of these parameters.
diff --git a/revision.c b/revision.c
index 2f6006287..edba5b79b 100644
--- a/revision.c
+++ b/revision.c
@@ -1871,6 +1871,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->notes_opt.use_default_notes = 1;
} else if (!strcmp(arg, "--show-signature")) {
revs->show_signature = 1;
+ } else if (!strcmp(arg, "--no-show-signature")) {
+ revs->show_signature = 0;
} else if (!strcmp(arg, "--show-linear-break") ||
starts_with(arg, "--show-linear-break=")) {
if (starts_with(arg, "--show-linear-break="))
diff --git a/run-command.c b/run-command.c
index af0c8a10d..33bc63a1d 100644
--- a/run-command.c
+++ b/run-command.c
@@ -864,19 +864,161 @@ int run_hook_le(const char *const *env, const char *name, ...)
return ret;
}
-int capture_command(struct child_process *cmd, struct strbuf *buf, size_t hint)
+struct io_pump {
+ /* initialized by caller */
+ int fd;
+ int type; /* POLLOUT or POLLIN */
+ union {
+ struct {
+ const char *buf;
+ size_t len;
+ } out;
+ struct {
+ struct strbuf *buf;
+ size_t hint;
+ } in;
+ } u;
+
+ /* returned by pump_io */
+ int error; /* 0 for success, otherwise errno */
+
+ /* internal use */
+ struct pollfd *pfd;
+};
+
+static int pump_io_round(struct io_pump *slots, int nr, struct pollfd *pfd)
+{
+ int pollsize = 0;
+ int i;
+
+ for (i = 0; i < nr; i++) {
+ struct io_pump *io = &slots[i];
+ if (io->fd < 0)
+ continue;
+ pfd[pollsize].fd = io->fd;
+ pfd[pollsize].events = io->type;
+ io->pfd = &pfd[pollsize++];
+ }
+
+ if (!pollsize)
+ return 0;
+
+ if (poll(pfd, pollsize, -1) < 0) {
+ if (errno == EINTR)
+ return 1;
+ die_errno("poll failed");
+ }
+
+ for (i = 0; i < nr; i++) {
+ struct io_pump *io = &slots[i];
+
+ if (io->fd < 0)
+ continue;
+
+ if (!(io->pfd->revents & (POLLOUT|POLLIN|POLLHUP|POLLERR|POLLNVAL)))
+ continue;
+
+ if (io->type == POLLOUT) {
+ ssize_t len = xwrite(io->fd,
+ io->u.out.buf, io->u.out.len);
+ if (len < 0) {
+ io->error = errno;
+ close(io->fd);
+ io->fd = -1;
+ } else {
+ io->u.out.buf += len;
+ io->u.out.len -= len;
+ if (!io->u.out.len) {
+ close(io->fd);
+ io->fd = -1;
+ }
+ }
+ }
+
+ if (io->type == POLLIN) {
+ ssize_t len = strbuf_read_once(io->u.in.buf,
+ io->fd, io->u.in.hint);
+ if (len < 0)
+ io->error = errno;
+ if (len <= 0) {
+ close(io->fd);
+ io->fd = -1;
+ }
+ }
+ }
+
+ return 1;
+}
+
+static int pump_io(struct io_pump *slots, int nr)
+{
+ struct pollfd *pfd;
+ int i;
+
+ for (i = 0; i < nr; i++)
+ slots[i].error = 0;
+
+ ALLOC_ARRAY(pfd, nr);
+ while (pump_io_round(slots, nr, pfd))
+ ; /* nothing */
+ free(pfd);
+
+ /* There may be multiple errno values, so just pick the first. */
+ for (i = 0; i < nr; i++) {
+ if (slots[i].error) {
+ errno = slots[i].error;
+ return -1;
+ }
+ }
+ return 0;
+}
+
+
+int pipe_command(struct child_process *cmd,
+ const char *in, size_t in_len,
+ struct strbuf *out, size_t out_hint,
+ struct strbuf *err, size_t err_hint)
{
- cmd->out = -1;
+ struct io_pump io[3];
+ int nr = 0;
+
+ if (in)
+ cmd->in = -1;
+ if (out)
+ cmd->out = -1;
+ if (err)
+ cmd->err = -1;
+
if (start_command(cmd) < 0)
return -1;
- if (strbuf_read(buf, cmd->out, hint) < 0) {
- close(cmd->out);
+ if (in) {
+ io[nr].fd = cmd->in;
+ io[nr].type = POLLOUT;
+ io[nr].u.out.buf = in;
+ io[nr].u.out.len = in_len;
+ nr++;
+ }
+ if (out) {
+ io[nr].fd = cmd->out;
+ io[nr].type = POLLIN;
+ io[nr].u.in.buf = out;
+ io[nr].u.in.hint = out_hint;
+ nr++;
+ }
+ if (err) {
+ io[nr].fd = cmd->err;
+ io[nr].type = POLLIN;
+ io[nr].u.in.buf = err;
+ io[nr].u.in.hint = err_hint;
+ nr++;
+ }
+
+ if (pump_io(io, nr) < 0) {
finish_command(cmd); /* throw away exit code */
return -1;
}
- close(cmd->out);
return finish_command(cmd);
}
diff --git a/run-command.h b/run-command.h
index 11f76b04e..50666497a 100644
--- a/run-command.h
+++ b/run-command.h
@@ -79,17 +79,34 @@ int run_command_v_opt(const char **argv, int opt);
int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env);
/**
- * Execute the given command, capturing its stdout in the given strbuf.
+ * Execute the given command, sending "in" to its stdin, and capturing its
+ * stdout and stderr in the "out" and "err" strbufs. Any of the three may
+ * be NULL to skip processing.
+ *
* Returns -1 if starting the command fails or reading fails, and otherwise
- * returns the exit code of the command. The output collected in the
- * buffer is kept even if the command returns a non-zero exit. The hint field
- * gives a starting size for the strbuf allocation.
+ * returns the exit code of the command. Any output collected in the
+ * buffers is kept even if the command returns a non-zero exit. The hint fields
+ * gives starting sizes for the strbuf allocations.
*
* The fields of "cmd" should be set up as they would for a normal run_command
- * invocation. But note that there is no need to set cmd->out; the function
- * sets it up for the caller.
+ * invocation. But note that there is no need to set the in, out, or err
+ * fields; pipe_command handles that automatically.
+ */
+int pipe_command(struct child_process *cmd,
+ const char *in, size_t in_len,
+ struct strbuf *out, size_t out_hint,
+ struct strbuf *err, size_t err_hint);
+
+/**
+ * Convenience wrapper around pipe_command for the common case
+ * of capturing only stdout.
*/
-int capture_command(struct child_process *cmd, struct strbuf *buf, size_t hint);
+static inline int capture_command(struct child_process *cmd,
+ struct strbuf *out,
+ size_t hint)
+{
+ return pipe_command(cmd, NULL, 0, out, hint, NULL, 0);
+}
/*
* The purpose of the following functions is to feed a pipe by running
diff --git a/send-pack.c b/send-pack.c
index 37ee04ea3..299d30384 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -36,18 +36,15 @@ int option_parse_push_signed(const struct option *opt,
die("bad %s argument: %s", opt->long_name, arg);
}
-static int feed_object(const unsigned char *sha1, int fd, int negative)
+static void feed_object(const unsigned char *sha1, FILE *fh, int negative)
{
- char buf[42];
-
if (negative && !has_sha1_file(sha1))
- return 1;
+ return;
- memcpy(buf + negative, sha1_to_hex(sha1), 40);
if (negative)
- buf[0] = '^';
- buf[40 + negative] = '\n';
- return write_or_whine(fd, buf, 41 + negative, "send-pack: send refs");
+ putc('^', fh);
+ fputs(sha1_to_hex(sha1), fh);
+ putc('\n', fh);
}
/*
@@ -73,6 +70,7 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
NULL,
};
struct child_process po = CHILD_PROCESS_INIT;
+ FILE *po_in;
int i;
i = 4;
@@ -97,21 +95,22 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
* We feed the pack-objects we just spawned with revision
* parameters by writing to the pipe.
*/
+ po_in = xfdopen(po.in, "w");
for (i = 0; i < extra->nr; i++)
- if (!feed_object(extra->sha1[i], po.in, 1))
- break;
+ feed_object(extra->sha1[i], po_in, 1);
while (refs) {
- if (!is_null_oid(&refs->old_oid) &&
- !feed_object(refs->old_oid.hash, po.in, 1))
- break;
- if (!is_null_oid(&refs->new_oid) &&
- !feed_object(refs->new_oid.hash, po.in, 0))
- break;
+ if (!is_null_oid(&refs->old_oid))
+ feed_object(refs->old_oid.hash, po_in, 1);
+ if (!is_null_oid(&refs->new_oid))
+ feed_object(refs->new_oid.hash, po_in, 0);
refs = refs->next;
}
- close(po.in);
+ fflush(po_in);
+ if (ferror(po_in))
+ die_errno("error writing to pack-objects");
+ fclose(po_in);
if (args->stateless_rpc) {
char *buf = xmalloc(LARGE_PACKET_MAX);
diff --git a/sequencer.c b/sequencer.c
index 4687ad4b8..cdfac82b1 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -190,7 +190,7 @@ static void write_message(struct strbuf *msgbuf, const char *filename)
die_errno(_("Could not write to %s"), filename);
strbuf_release(msgbuf);
if (commit_lock_file(&msg_file) < 0)
- die(_("Error wrapping up %s"), filename);
+ die(_("Error wrapping up %s."), filename);
}
static struct tree *empty_tree(void)
@@ -225,7 +225,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
if (checkout_fast_forward(from, to, 1))
exit(128); /* the callee should have complained already */
- strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
+ strbuf_addf(&sb, _("%s: fast-forward"), action_name(opts));
transaction = ref_transaction_begin(&err);
if (!transaction ||
@@ -544,10 +544,8 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
* information followed by "\n\n".
*/
p = strstr(msg.message, "\n\n");
- if (p) {
- p += 2;
- strbuf_addstr(&msgbuf, p);
- }
+ if (p)
+ strbuf_addstr(&msgbuf, skip_blank_lines(p + 2));
if (opts->record_origin) {
if (!has_conforming_footer(&msgbuf, NULL, 0))
@@ -697,9 +695,14 @@ static struct commit *parse_insn_line(char *bol, char *eol, struct replay_opts *
* opts; we don't support arbitrary instructions
*/
if (action != opts->action) {
- const char *action_str;
- action_str = action == REPLAY_REVERT ? "revert" : "cherry-pick";
- error(_("Cannot %s during a %s"), action_str, action_name(opts));
+ if (action == REPLAY_REVERT)
+ error((opts->action == REPLAY_REVERT)
+ ? _("Cannot revert during a another revert.")
+ : _("Cannot revert during a cherry-pick."));
+ else
+ error((opts->action == REPLAY_REVERT)
+ ? _("Cannot cherry-pick during a revert.")
+ : _("Cannot cherry-pick during another cherry-pick."));
return NULL;
}
@@ -888,6 +891,10 @@ static int sequencer_rollback(struct replay_opts *opts)
git_path_head_file());
goto fail;
}
+ if (is_null_sha1(sha1)) {
+ error(_("cannot abort from a branch yet to be born"));
+ goto fail;
+ }
if (reset_for_rollback(sha1))
goto fail;
remove_sequencer_state();
@@ -1086,11 +1093,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
walk_revs_populate_todo(&todo_list, opts);
if (create_seq_dir() < 0)
return -1;
- if (get_sha1("HEAD", sha1)) {
- if (opts->action == REPLAY_REVERT)
- return error(_("Can't revert as initial commit"));
- return error(_("Can't cherry-pick into empty head"));
- }
+ if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
+ return error(_("Can't revert as initial commit"));
save_head(sha1_to_hex(sha1));
save_opts(opts);
return pick_commits(todo_list, opts);
diff --git a/setup.c b/setup.c
index c86bf5c9f..6d0e0c93d 100644
--- a/setup.c
+++ b/setup.c
@@ -157,8 +157,8 @@ static void NORETURN die_verify_filename(const char *prefix,
int diagnose_misspelt_rev)
{
if (!diagnose_misspelt_rev)
- die("%s: no such path in the working tree.\n"
- "Use 'git <command> -- <path>...' to specify paths that do not exist locally.",
+ die(_("%s: no such path in the working tree.\n"
+ "Use 'git <command> -- <path>...' to specify paths that do not exist locally."),
arg);
/*
* Saying "'(icase)foo' does not exist in the index" when the
@@ -170,9 +170,9 @@ static void NORETURN die_verify_filename(const char *prefix,
maybe_die_on_misspelt_object_name(arg, prefix);
/* ... or fall back the most general message. */
- die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
- "Use '--' to separate paths from revisions, like this:\n"
- "'git <command> [<revision>...] -- [<file>...]'", arg);
+ die(_("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
+ "Use '--' to separate paths from revisions, like this:\n"
+ "'git <command> [<revision>...] -- [<file>...]'"), arg);
}
@@ -220,9 +220,9 @@ void verify_non_filename(const char *prefix, const char *arg)
return; /* flag */
if (!check_filename(prefix, arg))
return;
- die("ambiguous argument '%s': both revision and filename\n"
- "Use '--' to separate paths from revisions, like this:\n"
- "'git <command> [<revision>...] -- [<file>...]'", arg);
+ die(_("ambiguous argument '%s': both revision and filename\n"
+ "Use '--' to separate paths from revisions, like this:\n"
+ "'git <command> [<revision>...] -- [<file>...]'"), arg);
}
int get_common_dir(struct strbuf *sb, const char *gitdir)
diff --git a/sideband.c b/sideband.c
index fde8adc00..1e4d684d6 100644
--- a/sideband.c
+++ b/sideband.c
@@ -13,120 +13,103 @@
* the remote died unexpectedly. A flush() concludes the stream.
*/
-#define PREFIX "remote:"
+#define PREFIX "remote: "
#define ANSI_SUFFIX "\033[K"
#define DUMB_SUFFIX " "
-#define FIX_SIZE 10 /* large enough for any of the above */
-
int recv_sideband(const char *me, int in_stream, int out)
{
- unsigned pf = strlen(PREFIX);
- unsigned sf;
- char buf[LARGE_PACKET_MAX + 2*FIX_SIZE];
- char *suffix, *term;
- int skip_pf = 0;
+ const char *term, *suffix;
+ char buf[LARGE_PACKET_MAX + 1];
+ struct strbuf outbuf = STRBUF_INIT;
+ int retval = 0;
- memcpy(buf, PREFIX, pf);
term = getenv("TERM");
if (isatty(2) && term && strcmp(term, "dumb"))
suffix = ANSI_SUFFIX;
else
suffix = DUMB_SUFFIX;
- sf = strlen(suffix);
- while (1) {
+ while (!retval) {
+ const char *b, *brk;
int band, len;
- len = packet_read(in_stream, NULL, NULL, buf + pf, LARGE_PACKET_MAX, 0);
+ len = packet_read(in_stream, NULL, NULL, buf, LARGE_PACKET_MAX, 0);
if (len == 0)
break;
if (len < 1) {
- fprintf(stderr, "%s: protocol error: no band designator\n", me);
- return SIDEBAND_PROTOCOL_ERROR;
+ strbuf_addf(&outbuf,
+ "%s%s: protocol error: no band designator",
+ outbuf.len ? "\n" : "", me);
+ retval = SIDEBAND_PROTOCOL_ERROR;
+ break;
}
- band = buf[pf] & 0xff;
+ band = buf[0] & 0xff;
+ buf[len] = '\0';
len--;
switch (band) {
case 3:
- buf[pf] = ' ';
- buf[pf+1+len] = '\0';
- fprintf(stderr, "%s\n", buf);
- return SIDEBAND_REMOTE_ERROR;
+ strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
+ PREFIX, buf + 1);
+ retval = SIDEBAND_REMOTE_ERROR;
+ break;
case 2:
- buf[pf] = ' ';
- do {
- char *b = buf;
- int brk = 0;
+ b = buf + 1;
- /*
- * If the last buffer didn't end with a line
- * break then we should not print a prefix
- * this time around.
- */
- if (skip_pf) {
- b += pf+1;
- } else {
- len += pf+1;
- brk += pf+1;
- }
-
- /* Look for a line break. */
- for (;;) {
- brk++;
- if (brk > len) {
- brk = 0;
- break;
- }
- if (b[brk-1] == '\n' ||
- b[brk-1] == '\r')
- break;
- }
+ /*
+ * Append a suffix to each nonempty line to clear the
+ * end of the screen line.
+ *
+ * The output is accumulated in a buffer and
+ * each line is printed to stderr using
+ * write(2) to ensure inter-process atomicity.
+ */
+ while ((brk = strpbrk(b, "\n\r"))) {
+ int linelen = brk - b;
- /*
- * Let's insert a suffix to clear the end
- * of the screen line if a line break was
- * found. Also, if we don't skip the
- * prefix, then a non-empty string must be
- * present too.
- */
- if (brk > (skip_pf ? 0 : (pf+1 + 1))) {
- char save[FIX_SIZE];
- memcpy(save, b + brk, sf);
- b[brk + sf - 1] = b[brk - 1];
- memcpy(b + brk - 1, suffix, sf);
- fprintf(stderr, "%.*s", brk + sf, b);
- memcpy(b + brk, save, sf);
- len -= brk;
+ if (!outbuf.len)
+ strbuf_addstr(&outbuf, PREFIX);
+ if (linelen > 0) {
+ strbuf_addf(&outbuf, "%.*s%s%c",
+ linelen, b, suffix, *brk);
} else {
- int l = brk ? brk : len;
- fprintf(stderr, "%.*s", l, b);
- len -= l;
+ strbuf_addch(&outbuf, *brk);
}
+ xwrite(2, outbuf.buf, outbuf.len);
+ strbuf_reset(&outbuf);
- skip_pf = !brk;
- memmove(buf + pf+1, b + brk, len);
- } while (len);
- continue;
+ b = brk + 1;
+ }
+
+ if (*b)
+ strbuf_addf(&outbuf, "%s%s",
+ outbuf.len ? "" : PREFIX, b);
+ break;
case 1:
- write_or_die(out, buf + pf+1, len);
- continue;
+ write_or_die(out, buf + 1, len);
+ break;
default:
- fprintf(stderr, "%s: protocol error: bad band #%d\n",
- me, band);
- return SIDEBAND_PROTOCOL_ERROR;
+ strbuf_addf(&outbuf, "%s%s: protocol error: bad band #%d",
+ outbuf.len ? "\n" : "", me, band);
+ retval = SIDEBAND_PROTOCOL_ERROR;
+ break;
}
}
- return 0;
+
+ if (outbuf.len) {
+ strbuf_addch(&outbuf, '\n');
+ xwrite(2, outbuf.buf, outbuf.len);
+ }
+ strbuf_release(&outbuf);
+ return retval;
}
/*
* fd is connected to the remote side; send the sideband data
* over multiplexed packet stream.
*/
-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
{
- ssize_t ssz = sz;
const char *p = data;
while (sz) {
@@ -148,5 +131,4 @@ ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet
p += n;
sz -= n;
}
- return ssz;
}
diff --git a/sideband.h b/sideband.h
index e46bed0b0..7a8146f16 100644
--- a/sideband.h
+++ b/sideband.h
@@ -5,6 +5,6 @@
#define SIDEBAND_REMOTE_ERROR -1
int recv_sideband(const char *me, int in_stream, int out);
-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);
+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);
#endif
diff --git a/strbuf.h b/strbuf.h
index 798740531..83c5c9853 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -377,6 +377,8 @@ extern ssize_t strbuf_read_once(struct strbuf *, int fd, size_t hint);
/**
* Read the contents of a file, specified by its path. The third argument
* can be used to give a hint about the file size, to avoid reallocs.
+ * Return the number of bytes read or a negative value if some error
+ * occurred while opening or reading the file.
*/
extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
diff --git a/submodule.c b/submodule.c
index 4532b11d6..abc2ac2a1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -17,7 +17,7 @@
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
static int parallel_jobs = 1;
-static struct string_list changed_submodule_paths;
+static struct string_list changed_submodule_paths = STRING_LIST_INIT_NODUP;
static int initialized_fetch_ref_tips;
static struct sha1_array ref_tips_before_fetch;
static struct sha1_array ref_tips_after_fetch;
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 6a7755221..509aeef40 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -25,6 +25,9 @@
* ascending order of priority from a config_set
* constructed from files entered as arguments.
*
+ * iterate -> iterate over all values using git_config(), and print some
+ * data for each
+ *
* Examples:
*
* To print the value with highest priority for key "foo.bAr Baz.rock":
@@ -32,6 +35,36 @@
*
*/
+static const char *scope_name(enum config_scope scope)
+{
+ switch (scope) {
+ case CONFIG_SCOPE_SYSTEM:
+ return "system";
+ case CONFIG_SCOPE_GLOBAL:
+ return "global";
+ case CONFIG_SCOPE_REPO:
+ return "repo";
+ case CONFIG_SCOPE_CMDLINE:
+ return "cmdline";
+ default:
+ return "unknown";
+ }
+}
+static int iterate_cb(const char *var, const char *value, void *data)
+{
+ static int nr;
+
+ if (nr++)
+ putchar('\n');
+
+ printf("key=%s\n", var);
+ printf("value=%s\n", value ? value : "(null)");
+ printf("origin=%s\n", current_config_origin_type());
+ printf("name=%s\n", current_config_name());
+ printf("scope=%s\n", scope_name(current_config_scope()));
+
+ return 0;
+}
int main(int argc, char **argv)
{
@@ -134,6 +167,9 @@ int main(int argc, char **argv)
printf("Value not found for \"%s\"\n", argv[2]);
goto exit1;
}
+ } else if (!strcmp(argv[1], "iterate")) {
+ git_config(iterate_cb, NULL);
+ goto exit0;
}
die("%s: Please check the syntax and the function name", argv[0]);
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 63f373557..d9ab36090 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,11 +1,12 @@
#include "cache.h"
static const char *usage_msg = "\n"
-" test-date show [time_t]...\n"
+" test-date relative [time_t]...\n"
+" test-date show:<format> [time_t]...\n"
" test-date parse [date]...\n"
" test-date approxidate [date]...\n";
-static void show_dates(char **argv, struct timeval *now)
+static void show_relative_dates(char **argv, struct timeval *now)
{
struct strbuf buf = STRBUF_INIT;
@@ -17,6 +18,29 @@ static void show_dates(char **argv, struct timeval *now)
strbuf_release(&buf);
}
+static void show_dates(char **argv, const char *format)
+{
+ struct date_mode mode;
+
+ parse_date_format(format, &mode);
+ for (; *argv; argv++) {
+ char *arg = *argv;
+ time_t t;
+ int tz;
+
+ /*
+ * Do not use our normal timestamp parsing here, as the point
+ * is to test the formatting code in isolation.
+ */
+ t = strtol(arg, &arg, 10);
+ while (*arg == ' ')
+ arg++;
+ tz = atoi(arg);
+
+ printf("%s -> %s\n", *argv, show_date(t, tz, &mode));
+ }
+}
+
static void parse_dates(char **argv, struct timeval *now)
{
struct strbuf result = STRBUF_INIT;
@@ -61,8 +85,10 @@ int main(int argc, char **argv)
argv++;
if (!*argv)
usage(usage_msg);
- if (!strcmp(*argv, "show"))
- show_dates(argv+1, &now);
+ if (!strcmp(*argv, "relative"))
+ show_relative_dates(argv+1, &now);
+ else if (skip_prefix(*argv, "show:", &x))
+ show_dates(argv+1, x);
else if (!strcmp(*argv, "parse"))
parse_dates(argv+1, &now);
else if (!strcmp(*argv, "approxidate"))
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 8a1235d03..2c63298fa 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -12,7 +12,7 @@ static int dry_run = 0, quiet = 0;
static char *string = NULL;
static char *file = NULL;
static int ambiguous;
-static struct string_list list;
+static struct string_list list = STRING_LIST_INIT_NODUP;
static struct {
int called;
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index f9f3e5fd8..ac2cbee25 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -180,6 +180,7 @@ start_httpd() {
if test $? -ne 0
then
trap 'die' EXIT
+ cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
test_skip_or_die $GIT_TEST_HTTPD "web server setup failed"
fi
}
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 9a96e1566..25a77ee5c 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -29,6 +29,7 @@ set_fake_editor () {
*/COMMIT_EDITMSG)
test -z "$EXPECT_HEADER_COUNT" ||
test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
+ test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" ||
exit
test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
diff --git a/t/perf/README b/t/perf/README
index 8848c1461..49ea4349b 100644
--- a/t/perf/README
+++ b/t/perf/README
@@ -115,8 +115,16 @@ After that you will want to use some of the following:
At least one of the first two is required!
-You can use test_expect_success as usual. For actual performance
-tests, use
+You can use test_expect_success as usual. In both test_expect_success
+and in test_perf, running "git" points to the version that is being
+perf-tested. The $MODERN_GIT variable points to the git wrapper for the
+currently checked-out version (i.e., the one that matches the t/perf
+scripts you are running). This is useful if your setup uses commands
+that only work with newer versions of git than what you might want to
+test (but obviously your new commands must still create a state that can
+be used by the older version of git you are testing).
+
+For actual performance tests, use
test_perf 'descriptive string' '
command1 &&
diff --git a/t/perf/p4211-line-log.sh b/t/perf/p4211-line-log.sh
index 3d074b0e4..b7ff68d4f 100755
--- a/t/perf/p4211-line-log.sh
+++ b/t/perf/p4211-line-log.sh
@@ -23,11 +23,11 @@ test_perf 'git log --follow (baseline for -M)' '
git log --oneline --follow -- "$file" >/dev/null
'
-test_perf 'git log -L' '
- git log -L 1:"$file" >/dev/null
+test_perf 'git log -L (renames off)' '
+ git log --no-renames -L 1:"$file" >/dev/null
'
-test_perf 'git log -M -L' '
+test_perf 'git log -L (renames on)' '
git log -M -L 1:"$file" >/dev/null
'
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 18c363ea7..46f08ee08 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -52,6 +52,9 @@ TEST_NO_MALLOC_CHECK=t
# need to export them for test_perf subshells
export TEST_DIRECTORY TRASH_DIRECTORY GIT_BUILD_DIR GIT_TEST_CMP
+MODERN_GIT=$GIT_BUILD_DIR/bin-wrappers/git
+export MODERN_GIT
+
perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
mkdir -p "$perf_results_dir"
rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests
@@ -81,7 +84,7 @@ test_perf_create_repo_from () {
repo="$1"
source="$2"
source_git="$(git -C "$source" rev-parse --git-dir)"
- objects_dir="$(git -C "$source" rev-parse --git-path objects)"
+ objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)"
mkdir -p "$repo/.git"
(
cd "$source" &&
@@ -127,11 +130,15 @@ test_checkout_worktree () {
# Performance tests should never fail. If they do, stop immediately
immediate=t
+# Perf tests require GNU time
+case "$(uname -s)" in Darwin) GTIME="${GTIME:-gtime}";; esac
+GTIME="${GTIME:-/usr/bin/time}"
+
test_run_perf_ () {
test_cleanup=:
test_export_="test_cleanup"
export test_cleanup test_export_
- /usr/bin/time -f "%E %U %S" -o test_time.$i "$SHELL" -c '
+ "$GTIME" -f "%E %U %S" -o test_time.$i "$SHELL" -c '
. '"$TEST_DIRECTORY"/test-lib-functions.sh'
test_export () {
[ $# != 0 ] || return 0
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index fac098613..4c8cf5851 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -6,26 +6,52 @@ test_description='test date parsing and printing'
# arbitrary reference time: 2009-08-30 19:20:00
TEST_DATE_NOW=1251660000; export TEST_DATE_NOW
-check_show() {
+check_relative() {
t=$(($TEST_DATE_NOW - $1))
echo "$t -> $2" >expect
test_expect_${3:-success} "relative date ($2)" "
- test-date show $t >actual &&
+ test-date relative $t >actual &&
test_i18ncmp expect actual
"
}
-check_show 5 '5 seconds ago'
-check_show 300 '5 minutes ago'
-check_show 18000 '5 hours ago'
-check_show 432000 '5 days ago'
-check_show 1728000 '3 weeks ago'
-check_show 13000000 '5 months ago'
-check_show 37500000 '1 year, 2 months ago'
-check_show 55188000 '1 year, 9 months ago'
-check_show 630000000 '20 years ago'
-check_show 31449600 '12 months ago'
-check_show 62985600 '2 years ago'
+check_relative 5 '5 seconds ago'
+check_relative 300 '5 minutes ago'
+check_relative 18000 '5 hours ago'
+check_relative 432000 '5 days ago'
+check_relative 1728000 '3 weeks ago'
+check_relative 13000000 '5 months ago'
+check_relative 37500000 '1 year, 2 months ago'
+check_relative 55188000 '1 year, 9 months ago'
+check_relative 630000000 '20 years ago'
+check_relative 31449600 '12 months ago'
+check_relative 62985600 '2 years ago'
+
+check_show () {
+ format=$1
+ time=$2
+ expect=$3
+ test_expect_success $4 "show date ($format:$time)" '
+ echo "$time -> $expect" >expect &&
+ test-date show:$format "$time" >actual &&
+ test_cmp expect actual
+ '
+}
+
+# arbitrary but sensible time for examples
+TIME='1466000000 +0200'
+check_show iso8601 "$TIME" '2016-06-15 16:13:20 +0200'
+check_show iso8601-strict "$TIME" '2016-06-15T16:13:20+02:00'
+check_show rfc2822 "$TIME" 'Wed, 15 Jun 2016 16:13:20 +0200'
+check_show short "$TIME" '2016-06-15'
+check_show default "$TIME" 'Wed Jun 15 16:13:20 2016 +0200'
+check_show raw "$TIME" '1466000000 +0200'
+check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000'
+
+# arbitrary time absurdly far in the future
+FUTURE="5758122296 -0400"
+check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" LONG_IS_64BIT
+check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" LONG_IS_64BIT
check_parse() {
echo "$1 -> $2" >expect
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index b425f3a0d..d27f438bf 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -34,7 +34,7 @@ expect_from_stdin () {
test_stderr () {
expected="$1"
expect_in stderr "$1" &&
- test_cmp "$HOME/expected-stderr" "$HOME/stderr"
+ test_i18ncmp "$HOME/expected-stderr" "$HOME/stderr"
}
broken_c_unquote () {
@@ -47,7 +47,7 @@ broken_c_unquote_verbose () {
stderr_contains () {
regexp="$1"
- if grep "$regexp" "$HOME/stderr"
+ if test_i18ngrep "$regexp" "$HOME/stderr"
then
return 0
else
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index 0c74beedd..e5fa235d3 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -244,10 +244,10 @@ test_expect_success 'print errors when failed to update worktree' '
error: The following untracked working tree files would be overwritten by checkout:
sub/added
sub/addedtoo
-Please move or remove them before you can switch branches.
+Please move or remove them before you switch branches.
Aborting
EOF
- test_cmp expected actual
+ test_i18ncmp expected actual
'
test_expect_success 'checkout without --ignore-skip-worktree-bits' '
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index d934a2441..923bfc5a2 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -886,7 +886,7 @@ test_expect_success !MINGW 'get --path copes with unset $HOME' '
git config --get --path path.normal >>result &&
git config --get --path path.trailingtilde >>result
) &&
- grep "[Ff]ailed to expand.*~/" msg &&
+ test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
test_cmp expect result
'
@@ -1126,7 +1126,7 @@ test_expect_success 'barf on syntax error' '
key garbage
EOF
test_must_fail git config --get section.key >actual 2>error &&
- grep " line 3 " error
+ test_i18ngrep " line 3 " error
'
test_expect_success 'barf on incomplete section header' '
@@ -1136,7 +1136,7 @@ test_expect_success 'barf on incomplete section header' '
key = value
EOF
test_must_fail git config --get section.key >actual 2>error &&
- grep " line 2 " error
+ test_i18ngrep " line 2 " error
'
test_expect_success 'barf on incomplete string' '
@@ -1146,7 +1146,7 @@ test_expect_success 'barf on incomplete string' '
key = "value string
EOF
test_must_fail git config --get section.key >actual 2>error &&
- grep " line 3 " error
+ test_i18ngrep " line 3 " error
'
test_expect_success 'urlmatch' '
diff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh
index 3c6791e6b..eed31ffa3 100755
--- a/t/t1307-config-blob.sh
+++ b/t/t1307-config-blob.sh
@@ -61,10 +61,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '
git commit -m broken &&
test_must_fail git config --blob=HEAD:config some.value 2>err &&
-
- # just grep for our token as the exact error message is likely to
- # change or be internationalized
- grep "HEAD:config" err
+ test_i18ngrep "HEAD:config" err
'
test_expect_success 'can parse blob ending with CR' '
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index 005d66dbe..7655c94c2 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -197,14 +197,14 @@ test_expect_success 'proper error on error in default config files' '
echo "[" >>.git/config &&
echo "fatal: bad config line 34 in file .git/config" >expect &&
test_expect_code 128 test-config get_value foo.bar 2>actual &&
- test_cmp expect actual
+ test_i18ncmp expect actual
'
test_expect_success 'proper error on error in custom config files' '
echo "[" >>syntax-error &&
echo "fatal: bad config line 1 in file syntax-error" >expect &&
test_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual &&
- test_cmp expect actual
+ test_i18ncmp expect actual
'
test_expect_success 'check line errors for malformed values' '
@@ -229,4 +229,39 @@ test_expect_success 'error on modifying repo config without repo' '
)
'
+cmdline_config="'foo.bar=from-cmdline'"
+test_expect_success 'iteration shows correct origins' '
+ echo "[foo]bar = from-repo" >.git/config &&
+ echo "[foo]bar = from-home" >.gitconfig &&
+ if test_have_prereq MINGW
+ then
+ # Use Windows path (i.e. *not* $HOME)
+ HOME_GITCONFIG=$(pwd)/.gitconfig
+ else
+ # Do not get fooled by symbolic links, i.e. $HOME != $(pwd)
+ HOME_GITCONFIG=$HOME/.gitconfig
+ fi &&
+ cat >expect <<-EOF &&
+ key=foo.bar
+ value=from-home
+ origin=file
+ name=$HOME_GITCONFIG
+ scope=global
+
+ key=foo.bar
+ value=from-repo
+ origin=file
+ name=.git/config
+ scope=repo
+
+ key=foo.bar
+ value=from-cmdline
+ origin=command line
+ name=
+ scope=cmdline
+ EOF
+ GIT_CONFIG_PARAMETERS=$cmdline_config test-config iterate >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index af1b20dd5..75fa6548c 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -361,7 +361,7 @@ test_expect_success 'stdin test setup' '
test_expect_success '-z fails without --stdin' '
test_must_fail git update-ref -z $m $m $m 2>err &&
- grep "usage: git update-ref" err
+ test_i18ngrep "usage: git update-ref" err
'
test_expect_success 'stdin works with no input' '
diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
index 417eecc3a..ca3fa406c 100755
--- a/t/t1401-symbolic-ref.sh
+++ b/t/t1401-symbolic-ref.sh
@@ -110,7 +110,7 @@ test_expect_success 'symbolic-ref writes reflog entry' '
update
create
EOF
- git log --format=%gs -g >actual &&
+ git log --format=%gs -g -2 >actual &&
test_cmp expect actual
'
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 9cf91dc6d..dd2be049e 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -348,4 +348,26 @@ test_expect_success 'reflog expire operates on symref not referrent' '
git reflog expire --expire=all the_symref
'
+test_expect_success 'continue walking past root commits' '
+ git init orphanage &&
+ (
+ cd orphanage &&
+ cat >expect <<-\EOF &&
+ HEAD@{0} commit (initial): orphan2-1
+ HEAD@{1} commit: orphan1-2
+ HEAD@{2} commit (initial): orphan1-1
+ HEAD@{3} commit (initial): initial
+ EOF
+ test_commit initial &&
+ git reflog &&
+ git checkout --orphan orphan1 &&
+ test_commit orphan1-1 &&
+ test_commit orphan1-2 &&
+ git checkout --orphan orphan2 &&
+ test_commit orphan2-1 &&
+ git log -g --format="%gd %gs" >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 86c2ff255..79a0251ef 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -106,7 +106,7 @@ test_expect_success 'incorrect revision id' '
test_must_fail git rev-parse foobar:file.txt 2>error &&
grep "Invalid object name '"'"'foobar'"'"'." error &&
test_must_fail git rev-parse foobar 2> error &&
- grep "unknown revision or path not in the working tree." error
+ test_i18ngrep "unknown revision or path not in the working tree." error
'
test_expect_success 'incorrect file in sha1:path' '
diff --git a/t/t2010-checkout-ambiguous.sh b/t/t2010-checkout-ambiguous.sh
index 87bdf9c96..e76e84afb 100755
--- a/t/t2010-checkout-ambiguous.sh
+++ b/t/t2010-checkout-ambiguous.sh
@@ -49,7 +49,7 @@ test_expect_success 'disambiguate checking out from a tree-ish' '
test_expect_success 'accurate error message with more than one ref' '
test_must_fail git checkout HEAD master -- 2>actual &&
- grep 2 actual &&
+ test_i18ngrep 2 actual &&
test_i18ngrep "one reference expected, 2 given" actual
'
diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
index 274126236..2131fb2a5 100755
--- a/t/t2018-checkout-branch.sh
+++ b/t/t2018-checkout-branch.sh
@@ -124,7 +124,7 @@ test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
git checkout branch2 &&
echo >expect "fatal: A branch named '\''branch1'\'' already exists." &&
test_must_fail git checkout -b @{-1} 2>actual &&
- test_cmp expect actual
+ test_i18ncmp expect actual
'
test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh
index cccd7d923..c8de6d8a1 100755
--- a/t/t2300-cd-to-toplevel.sh
+++ b/t/t2300-cd-to-toplevel.sh
@@ -4,11 +4,19 @@ test_description='cd_to_toplevel'
. ./test-lib.sh
+EXEC_PATH="$(git --exec-path)"
+test_have_prereq !MINGW ||
+case "$EXEC_PATH" in
+[A-Za-z]:/*)
+ EXEC_PATH="/${EXEC_PATH%%:*}${EXEC_PATH#?:}"
+ ;;
+esac
+
test_cd_to_toplevel () {
test_expect_success $3 "$2" '
(
cd '"'$1'"' &&
- PATH="$(git --exec-path):$PATH" &&
+ PATH="$EXEC_PATH:$PATH" &&
. git-sh-setup &&
cd_to_toplevel &&
[ "$(pwd -P)" = "$TOPLEVEL" ]
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index f3e3b6cf2..ac9c76479 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -550,7 +550,7 @@ If you wanted to make '"'master'"' track '"'origin/master'"', do this:
git branch -d origin/master
git branch --set-upstream-to origin/master
EOF
- test_cmp expected actual
+ test_i18ncmp expected actual
'
test_expect_success '--set-upstream with two args only shows the deprecation message' '
@@ -559,7 +559,7 @@ test_expect_success '--set-upstream with two args only shows the deprecation mes
cat >expected <<EOF &&
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
EOF
- test_cmp expected actual
+ test_i18ncmp expected actual
'
test_expect_success '--set-upstream with one arg only shows the deprecation message if the branch existed' '
@@ -568,7 +568,7 @@ test_expect_success '--set-upstream with one arg only shows the deprecation mess
cat >expected <<EOF &&
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
EOF
- test_cmp expected actual
+ test_i18ncmp expected actual
'
test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index 912a6635a..7f3ec4724 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -156,7 +156,7 @@ test_expect_success 'branch --merged with --verbose' '
* topic 2c939f4 [ahead 1] foo
zzz c77a0a9 second on master
EOF
- test_cmp expect actual
+ test_i18ncmp expect actual
'
test_done
diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh
index d5572121d..696743632 100755
--- a/t/t3310-notes-merge-manual-resolve.sh
+++ b/t/t3310-notes-merge-manual-resolve.sh
@@ -178,7 +178,7 @@ test_expect_success 'merge z into m (== y) with default ("manual") resolver => C
git config core.notesRef refs/notes/m &&
test_must_fail git notes merge z >output &&
# Output should point to where to resolve conflicts
- grep -q "\\.git/NOTES_MERGE_WORKTREE" output &&
+ test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
ls .git/NOTES_MERGE_WORKTREE >output_conflicts &&
test_cmp expect_conflicts output_conflicts &&
@@ -381,7 +381,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol
git config core.notesRef refs/notes/m &&
test_must_fail git notes merge z >output &&
# Output should point to where to resolve conflicts
- grep -q "\\.git/NOTES_MERGE_WORKTREE" output &&
+ test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
ls .git/NOTES_MERGE_WORKTREE >output_conflicts &&
test_cmp expect_conflicts output_conflicts &&
@@ -415,7 +415,7 @@ git rev-parse refs/notes/z > pre_merge_z
test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' '
test_must_fail git notes merge z >output &&
# Output should point to where to resolve conflicts
- grep -q "\\.git/NOTES_MERGE_WORKTREE" output &&
+ test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
ls .git/NOTES_MERGE_WORKTREE >output_conflicts &&
test_cmp expect_conflicts output_conflicts &&
@@ -496,7 +496,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol
git update-ref refs/notes/m refs/notes/y &&
test_must_fail git notes merge z >output &&
# Output should point to where to resolve conflicts
- grep -q "\\.git/NOTES_MERGE_WORKTREE" output &&
+ test_i18ngrep "\\.git/NOTES_MERGE_WORKTREE" output &&
# Inspect merge conflicts
ls .git/NOTES_MERGE_WORKTREE >output_conflicts &&
test_cmp expect_conflicts output_conflicts &&
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index 1f71d589f..6e0511596 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -52,7 +52,7 @@ test_expect_success 'merge z into y while mid-merge in another workdir fails' '
cd worktree &&
git config core.notesRef refs/notes/y &&
test_must_fail git notes merge z 2>err &&
- grep "A notes merge into refs/notes/y is already in-progress at" err
+ test_i18ngrep "A notes merge into refs/notes/y is already in-progress at" err
) &&
test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
'
@@ -62,7 +62,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
cd worktree2 &&
git config core.notesRef refs/notes/x &&
test_must_fail git notes merge z 2>&1 >out &&
- grep "Automatic notes merge failed" out &&
+ test_i18ngrep "Automatic notes merge failed" out &&
grep -v "A notes merge into refs/notes/x is already in-progress in" out
) &&
echo "ref: refs/notes/x" >expect &&
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 47b568266..f5fd15e55 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -136,8 +136,8 @@ test_expect_success 'setup: recover' '
test_expect_success 'Show verbose error when HEAD could not be detached' '
>B &&
test_must_fail git rebase topic 2>output.err >output.out &&
- grep "The following untracked working tree files would be overwritten by checkout:" output.err &&
- grep B output.err
+ test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" output.err &&
+ test_i18ngrep B output.err
'
rm -f B
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 66348f11d..3532c482f 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -60,7 +60,7 @@ test_expect_success 'setup' '
test_commit P fileP
'
-# "exec" commands are ran with the user shell by default, but this may
+# "exec" commands are run with the user shell by default, but this may
# be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
# to create a file. Unsetting SHELL avoids such non-portable behavior
# in tests. It must be exported for it to take effect where needed.
@@ -219,9 +219,9 @@ test_expect_success 'abort with error when new base cannot be checked out' '
git commit -m "remove file in base" &&
set_fake_editor &&
test_must_fail git rebase -i master > output 2>&1 &&
- grep "The following untracked working tree files would be overwritten by checkout:" \
+ test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
output &&
- grep "file1" output &&
+ test_i18ngrep "file1" output &&
test_path_is_missing .git/rebase-merge &&
git reset --hard HEAD^
'
@@ -540,7 +540,7 @@ test_expect_success 'clean error after failed "exec"' '
echo "edited again" > file7 &&
git add file7 &&
test_must_fail git rebase --continue 2>error &&
- grep "You have staged changes in your working tree." error
+ test_i18ngrep "You have staged changes in your working tree." error
'
test_expect_success 'rebase a detached HEAD' '
@@ -1060,7 +1060,7 @@ test_expect_success 'todo count' '
EOF
test_set_editor "$(pwd)/dump-raw.sh" &&
git rebase -i HEAD~4 >actual &&
- grep "^# Rebase ..* onto ..* ([0-9]" actual
+ test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
'
test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
@@ -1160,7 +1160,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
FAKE_LINES="1 2 3 4" \
git rebase -i --root 2>actual &&
test D = $(git cat-file commit HEAD | sed -ne \$p) &&
- test_cmp expect actual
+ test_i18ncmp expect actual
'
cat >expect <<EOF
@@ -1181,7 +1181,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
set_fake_editor &&
FAKE_LINES="1 2 3 4" \
git rebase -i --root 2>actual &&
- test_cmp expect actual &&
+ test_i18ncmp expect actual &&
test D = $(git cat-file commit HEAD | sed -ne \$p)
'
@@ -1205,7 +1205,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
set_fake_editor &&
test_must_fail env FAKE_LINES="1 2 4" \
git rebase -i --root 2>actual &&
- test_cmp expect actual &&
+ test_i18ncmp expect actual &&
cp .git/rebase-merge/git-rebase-todo.backup \
.git/rebase-merge/git-rebase-todo &&
FAKE_LINES="1 2 drop 3 4 drop 5" \
@@ -1228,7 +1228,7 @@ test_expect_success 'static check of bad command' '
set_fake_editor &&
test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
git rebase -i --root 2>actual &&
- test_cmp expect actual &&
+ test_i18ncmp expect actual &&
FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
git rebase --continue &&
test E = $(git cat-file commit HEAD | sed -ne \$p) &&
@@ -1263,7 +1263,7 @@ test_expect_success 'static check of bad SHA-1' '
set_fake_editor &&
test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
git rebase -i --root 2>actual &&
- test_cmp expect actual &&
+ test_i18ncmp expect actual &&
FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
git rebase --continue &&
test E = $(git cat-file commit HEAD | sed -ne \$p)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 944154b2e..532ff5cbd 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -192,4 +192,35 @@ test_expect_success 'abort rebase -i with --autostash' '
test_cmp expected file0
'
+test_expect_success 'restore autostash on editor failure' '
+ test_when_finished "git reset --hard" &&
+ echo uncommitted-content >file0 &&
+ (
+ test_set_editor "false" &&
+ test_must_fail git rebase -i --autostash HEAD^
+ ) &&
+ echo uncommitted-content >expected &&
+ test_cmp expected file0
+'
+
+test_expect_success 'autostash is saved on editor failure with conflict' '
+ test_when_finished "git reset --hard" &&
+ echo uncommitted-content >file0 &&
+ (
+ write_script abort-editor.sh <<-\EOF &&
+ echo conflicting-content >file0
+ exit 1
+ EOF
+ test_set_editor "$(pwd)/abort-editor.sh" &&
+ test_must_fail git rebase -i --autostash HEAD^ &&
+ rm -f abort-editor.sh
+ ) &&
+ echo conflicting-content >expected &&
+ test_cmp expected file0 &&
+ git checkout file0 &&
+ git stash pop &&
+ echo uncommitted-content >expected &&
+ test_cmp expected file0
+'
+
test_done
diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh
new file mode 100755
index 000000000..3780877e4
--- /dev/null
+++ b/t/t3427-rebase-subtree.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+test_description='git rebase tests for -Xsubtree
+
+This test runs git rebase and tests the subtree strategy.
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-rebase.sh
+
+commit_message() {
+ git log --pretty=format:%s -1 "$1"
+}
+
+test_expect_success 'setup' '
+ test_commit README &&
+ mkdir files &&
+ (
+ cd files &&
+ git init &&
+ test_commit master1 &&
+ test_commit master2 &&
+ test_commit master3
+ ) &&
+ git fetch files master &&
+ git branch files-master FETCH_HEAD &&
+ git read-tree --prefix=files_subtree files-master &&
+ git checkout -- files_subtree &&
+ tree=$(git write-tree) &&
+ head=$(git rev-parse HEAD) &&
+ rev=$(git rev-parse --verify files-master^0) &&
+ commit=$(git commit-tree -p $head -p $rev -m "Add subproject master" $tree) &&
+ git update-ref HEAD $commit &&
+ (
+ cd files_subtree &&
+ test_commit master4
+ ) &&
+ test_commit files_subtree/master5
+'
+
+# FAILURE: Does not preserve master4.
+test_expect_failure 'Rebase -Xsubtree --preserve-merges --onto commit 4' '
+ reset_rebase &&
+ git checkout -b rebase-preserve-merges-4 master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
+ verbose test "$(commit_message HEAD~)" = "files_subtree/master4"
+'
+
+# FAILURE: Does not preserve master5.
+test_expect_failure 'Rebase -Xsubtree --preserve-merges --onto commit 5' '
+ reset_rebase &&
+ git checkout -b rebase-preserve-merges-5 master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
+ verbose test "$(commit_message HEAD)" = "files_subtree/master5"
+'
+
+# FAILURE: Does not preserve master4.
+test_expect_failure 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 4' '
+ reset_rebase &&
+ git checkout -b rebase-keep-empty-4 master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
+ verbose test "$(commit_message HEAD~2)" = "files_subtree/master4"
+'
+
+# FAILURE: Does not preserve master5.
+test_expect_failure 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 5' '
+ reset_rebase &&
+ git checkout -b rebase-keep-empty-5 master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
+ verbose test "$(commit_message HEAD~)" = "files_subtree/master5"
+'
+
+# FAILURE: Does not preserve Empty.
+test_expect_failure 'Rebase -Xsubtree --keep-empty --preserve-merges --onto empty commit' '
+ reset_rebase &&
+ git checkout -b rebase-keep-empty-empty master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
+ verbose test "$(commit_message HEAD)" = "Empty commit"
+'
+
+# FAILURE: fatal: Could not parse object
+test_expect_failure 'Rebase -Xsubtree --onto commit 4' '
+ reset_rebase &&
+ git checkout -b rebase-onto-4 master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --onto files-master master &&
+ verbose test "$(commit_message HEAD~2)" = "files_subtree/master4"
+'
+
+# FAILURE: fatal: Could not parse object
+test_expect_failure 'Rebase -Xsubtree --onto commit 5' '
+ reset_rebase &&
+ git checkout -b rebase-onto-5 master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --onto files-master master &&
+ verbose test "$(commit_message HEAD~)" = "files_subtree/master5"
+'
+# FAILURE: fatal: Could not parse object
+test_expect_failure 'Rebase -Xsubtree --onto empty commit' '
+ reset_rebase &&
+ git checkout -b rebase-onto-empty master &&
+ git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
+ git commit -m "Empty commit" --allow-empty &&
+ git rebase -Xsubtree=files_subtree --onto files-master master &&
+ verbose test "$(commit_message HEAD)" = "Empty commit"
+'
+
+test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index f14a66535..4865304eb 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -332,4 +332,34 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
test_i18ncmp expect.err actual.err
'
+test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
+ echo foo >foo1 &&
+ git add --chmod=+x foo1 &&
+ case "$(git ls-files --stage foo1)" in
+ 100755" "*foo1) echo pass;;
+ *) echo fail; git ls-files --stage foo1; (exit 1);;
+ esac
+'
+
+test_expect_success 'git add --chmod=-x stages an executable file with -x' '
+ echo foo >xfoo1 &&
+ chmod 755 xfoo1 &&
+ git add --chmod=-x xfoo1 &&
+ case "$(git ls-files --stage xfoo1)" in
+ 100644" "*xfoo1) echo pass;;
+ *) echo fail; git ls-files --stage xfoo1; (exit 1);;
+ esac
+'
+
+test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
+ git config core.filemode 1 &&
+ git config core.symlinks 1 &&
+ echo foo >foo2 &&
+ git add --chmod=+x foo2 &&
+ case "$(git ls-files --stage foo2)" in
+ 100755" "*foo2) echo pass;;
+ *) echo fail; git ls-files --stage foo2; (exit 1);;
+ esac
+'
+
test_done
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 805dc9012..1206c4839 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1565,4 +1565,45 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
test_cmp expected actual
'
+test_expect_success 'format-patch --pretty=mboxrd' '
+ sp=" " &&
+ cat >msg <<-INPUT_END &&
+ mboxrd should escape the body
+
+ From could trip up a loose mbox parser
+ >From extra escape for reversibility
+ >>From extra escape for reversibility 2
+ from lower case not escaped
+ Fromm bad speling not escaped
+ From with leading space not escaped
+
+ F
+ From
+ From$sp
+ From $sp
+ From $sp
+ INPUT_END
+
+ cat >expect <<-INPUT_END &&
+ >From could trip up a loose mbox parser
+ >>From extra escape for reversibility
+ >>>From extra escape for reversibility 2
+ from lower case not escaped
+ Fromm bad speling not escaped
+ From with leading space not escaped
+
+ F
+ From
+ From
+ From
+ From
+ INPUT_END
+
+ C=$(git commit-tree HEAD^^{tree} -p HEAD <msg) &&
+ git format-patch --pretty=mboxrd --stdout -1 $C~1..$C >patch &&
+ git grep -h --no-index -A11 \
+ "^>From could trip up a loose mbox parser" patch >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
index 2b32c4fbe..ec78c5e3a 100755
--- a/t/t4026-color.sh
+++ b/t/t4026-color.sh
@@ -50,14 +50,19 @@ test_expect_success 'attr negation' '
color "nobold nodim noul noblink noreverse" "[22;24;25;27m"
'
+test_expect_success '"no-" variant of negation' '
+ color "no-bold no-blink" "[22;25m"
+'
+
test_expect_success 'long color specification' '
color "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m"
'
test_expect_success 'absurdly long color specification' '
color \
- "#ffffff #ffffff bold nobold dim nodim ul noul blink noblink reverse noreverse" \
- "[1;2;4;5;7;22;24;25;27;38;2;255;255;255;48;2;255;255;255m"
+ "#ffffff #ffffff bold nobold dim nodim italic noitalic
+ ul noul blink noblink reverse noreverse strike nostrike" \
+ "[1;2;3;4;5;7;9;22;23;24;25;27;29;38;2;255;255;255;48;2;255;255;255m"
'
test_expect_success '0-7 are aliases for basic ANSI color names' '
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index b41bd1726..9ce9424d1 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -957,4 +957,24 @@ test_expect_success 'am -s unexpected trailer block' '
test_cmp expect actual
'
+test_expect_success 'am --patch-format=mboxrd handles mboxrd' '
+ rm -fr .git/rebase-apply &&
+ git checkout -f first &&
+ echo mboxrd >>file &&
+ git add file &&
+ cat >msg <<-\INPUT_END &&
+ mboxrd should escape the body
+
+ From could trip up a loose mbox parser
+ >From extra escape for reversibility
+ INPUT_END
+ git commit -F msg &&
+ git format-patch --pretty=mboxrd --stdout -1 >mboxrd1 &&
+ grep "^>From could trip up a loose mbox parser" mboxrd1 &&
+ git checkout -f first &&
+ git am --patch-format=mboxrd mboxrd1 &&
+ git cat-file commit HEAD | tail -n4 >out &&
+ test_cmp msg out
+'
+
test_done
diff --git a/t/t4153-am-resume-override-opts.sh b/t/t4153-am-resume-override-opts.sh
index 7c013d84d..8ea22d1bc 100755
--- a/t/t4153-am-resume-override-opts.sh
+++ b/t/t4153-am-resume-override-opts.sh
@@ -53,7 +53,7 @@ test_expect_success '--no-quiet overrides --quiet' '
# Applying side1 will be quiet.
test_must_fail git am --quiet side[123].eml >out &&
test_path_is_dir .git/rebase-apply &&
- ! test_i18ngrep "^Applying: " out &&
+ test_i18ngrep ! "^Applying: " out &&
echo side1 >file &&
git add file &&
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 128ba9353..803e1e6b8 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -860,12 +860,15 @@ test_expect_success 'dotdot is a parent directory' '
test_cmp expect actual
'
-test_expect_success GPG 'log --graph --show-signature' '
+test_expect_success GPG 'setup signed branch' '
test_when_finished "git reset --hard && git checkout master" &&
git checkout -b signed master &&
echo foo >foo &&
git add foo &&
- git commit -S -m signed_commit &&
+ git commit -S -m signed_commit
+'
+
+test_expect_success GPG 'log --graph --show-signature' '
git log --graph --show-signature -n1 signed >actual &&
grep "^| gpg: Signature made" actual &&
grep "^| gpg: Good signature" actual
@@ -890,6 +893,31 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
grep "^| | gpg: Good signature" actual
'
+test_expect_success GPG '--no-show-signature overrides --show-signature' '
+ git log -1 --show-signature --no-show-signature signed >actual &&
+ ! grep "^gpg:" actual
+'
+
+test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
+ test_config log.showsignature true &&
+ git log -1 signed >actual &&
+ grep "gpg: Signature made" actual &&
+ grep "gpg: Good signature" actual
+'
+
+test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
+ test_config log.showsignature true &&
+ git log -1 --no-show-signature signed >actual &&
+ ! grep "^gpg:" actual
+'
+
+test_expect_success GPG '--show-signature overrides log.showsignature=false' '
+ test_config log.showsignature false &&
+ git log -1 --show-signature signed >actual &&
+ grep "gpg: Signature made" actual &&
+ grep "gpg: Good signature" actual
+'
+
test_expect_success 'log --graph --no-walk is forbidden' '
test_must_fail git log --graph --no-walk
'
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 7398605e7..d9f62425b 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -176,6 +176,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'left alignment formatting at the nth column' '
+ COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
+ qz_to_tab_space <<EOF >expected &&
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
@@ -308,6 +319,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting at the nth column' '
+ COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
+ qz_to_tab_space <<EOF >expected &&
+$head1 message two
+$head2 message one
+$head3 add bar
+$head4 $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
@@ -319,6 +341,19 @@ EOF
test_cmp expected actual
'
+# Note: Space between 'message' and 'two' should be in the same column
+# as in previous test.
+test_expect_success 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' '
+ git -c i18n.logOutputEncoding=$test_encoding log --graph --pretty="tformat:%h %>|(40)%s" >actual &&
+ iconv -f utf-8 -t $test_encoding >expected <<EOF&&
+* $head1 message two
+* $head2 message one
+* $head3 add bar
+* $head4 $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting with no padding' '
git log --pretty="tformat:%>(1)%s" >actual &&
cat <<EOF >expected &&
@@ -330,6 +365,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'right alignment formatting with no padding and with --graph' '
+ git log --graph --pretty="tformat:%>(1)%s" >actual &&
+ cat <<EOF >expected &&
+* message two
+* message one
+* add bar
+* $(commit_msg)
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
@@ -373,6 +419,17 @@ EOF
test_cmp expected actual
'
+test_expect_success 'center alignment formatting at the nth column' '
+ COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
+ qz_to_tab_space <<EOF >expected &&
+$head1 message two Z
+$head2 message one Z
+$head3 add bar Z
+$head4 $(commit_msg) Z
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh
index d8f23f488..001343e2f 100755
--- a/t/t4208-log-magic-pathspec.sh
+++ b/t/t4208-log-magic-pathspec.sh
@@ -18,7 +18,7 @@ test_expect_success '"git log :/" should not be ambiguous' '
test_expect_success '"git log :/a" should be ambiguous (applied both rev and worktree)' '
: >a &&
test_must_fail git log :/a 2>error &&
- grep ambiguous error
+ test_i18ngrep ambiguous error
'
test_expect_success '"git log :/a -- " should not be ambiguous' '
@@ -31,7 +31,7 @@ test_expect_success '"git log -- :/a" should not be ambiguous' '
test_expect_success '"git log :" should be ambiguous' '
test_must_fail git log : 2>error &&
- grep ambiguous error
+ test_i18ngrep ambiguous error
'
test_expect_success 'git log -- :' '
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 4b68bbafb..80b238734 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -319,4 +319,78 @@ test_expect_success 'catch non-matching pathspec' '
test_must_fail git archive -v HEAD -- "*.abc" >/dev/null
'
+# Pull the size and date of each entry in a tarfile using the system tar.
+#
+# We'll pull out only the year from the date; that avoids any question of
+# timezones impacting the result (as long as we keep our test times away from a
+# year boundary; our reference times are all in August).
+#
+# The output of tar_info is expected to be "<size> <year>", both in decimal. It
+# ignores the return value of tar. We have to do this, because some of our test
+# input is only partial (the real data is 64GB in some cases).
+tar_info () {
+ "$TAR" tvf "$1" |
+ awk '{
+ split($4, date, "-")
+ print $3 " " date[1]
+ }'
+}
+
+# See if our system tar can handle a tar file with huge sizes and dates far in
+# the future, and that we can actually parse its output.
+#
+# The reference file was generated by GNU tar, and the magic time and size are
+# both octal 01000000000001, which overflows normal ustar fields.
+test_lazy_prereq TAR_HUGE '
+ echo "68719476737 4147" >expect &&
+ tar_info "$TEST_DIRECTORY"/t5000/huge-and-future.tar >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success LONG_IS_64BIT 'set up repository with huge blob' '
+ obj_d=19 &&
+ obj_f=f9c8273ec45a8938e6999cb59b3ff66739902a &&
+ obj=${obj_d}${obj_f} &&
+ mkdir -p .git/objects/$obj_d &&
+ cp "$TEST_DIRECTORY"/t5000/$obj .git/objects/$obj_d/$obj_f &&
+ rm -f .git/index &&
+ git update-index --add --cacheinfo 100644,$obj,huge &&
+ git commit -m huge
+'
+
+# We expect git to die with SIGPIPE here (otherwise we
+# would generate the whole 64GB).
+test_expect_success LONG_IS_64BIT 'generate tar with huge size' '
+ {
+ git archive HEAD
+ echo $? >exit-code
+ } | test_copy_bytes 4096 >huge.tar &&
+ echo 141 >expect &&
+ test_cmp expect exit-code
+'
+
+test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our huge size' '
+ echo 68719476737 >expect &&
+ tar_info huge.tar | cut -d" " -f1 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success LONG_IS_64BIT 'set up repository with far-future commit' '
+ rm -f .git/index &&
+ echo content >file &&
+ git add file &&
+ GIT_COMMITTER_DATE="@68719476737 +0000" \
+ git commit -m "tempori parendum"
+'
+
+test_expect_success LONG_IS_64BIT 'generate tar with future mtime' '
+ git archive HEAD >future.tar
+'
+
+test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our future mtime' '
+ echo 4147 >expect &&
+ tar_info future.tar | cut -d" " -f2 >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902a b/t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902a
new file mode 100644
index 000000000..5cbe9ec31
--- /dev/null
+++ b/t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902a
Binary files differ
diff --git a/t/t5000/huge-and-future.tar b/t/t5000/huge-and-future.tar
new file mode 100644
index 000000000..63155e185
--- /dev/null
+++ b/t/t5000/huge-and-future.tar
Binary files differ
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 85b3df5e3..1a5a54623 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -111,4 +111,35 @@ test_expect_success 'mailinfo on message with quoted >From' '
test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.expect quoted-from/msg
'
+test_expect_success 'mailinfo unescapes with --mboxrd' '
+ mkdir mboxrd &&
+ git mailsplit -omboxrd --mboxrd \
+ "$TEST_DIRECTORY"/t5100/sample.mboxrd >last &&
+ test x"$(cat last)" = x2 &&
+ for i in 0001 0002
+ do
+ git mailinfo mboxrd/msg mboxrd/patch \
+ <mboxrd/$i >mboxrd/out &&
+ test_cmp "$TEST_DIRECTORY"/t5100/${i}mboxrd mboxrd/msg
+ done &&
+ sp=" " &&
+ echo "From " >expect &&
+ echo "From " >>expect &&
+ echo >> expect &&
+ cat >sp <<-INPUT_END &&
+ From mboxrd Mon Sep 17 00:00:00 2001
+ From: trailing spacer <sp@example.com>
+ Subject: [PATCH] a commit with trailing space
+
+ From$sp
+ >From$sp
+
+ INPUT_END
+
+ git mailsplit -f2 -omboxrd --mboxrd <sp >last &&
+ test x"$(cat last)" = x1 &&
+ git mailinfo mboxrd/msg mboxrd/patch <mboxrd/0003 &&
+ test_cmp expect mboxrd/msg
+'
+
test_done
diff --git a/t/t5100/0001mboxrd b/t/t5100/0001mboxrd
new file mode 100644
index 000000000..494ec554b
--- /dev/null
+++ b/t/t5100/0001mboxrd
@@ -0,0 +1,4 @@
+From the beginning, mbox should have been mboxrd
+>From escaped
+From not mangled but this line should have been escaped
+
diff --git a/t/t5100/0002mboxrd b/t/t5100/0002mboxrd
new file mode 100644
index 000000000..71343d41f
--- /dev/null
+++ b/t/t5100/0002mboxrd
@@ -0,0 +1,5 @@
+ >From unchanged
+ From also unchanged
+no trailing space, no escaping necessary and '>' was intended:
+>From
+
diff --git a/t/t5100/sample.mboxrd b/t/t5100/sample.mboxrd
new file mode 100644
index 000000000..79ad5ae0e
--- /dev/null
+++ b/t/t5100/sample.mboxrd
@@ -0,0 +1,19 @@
+From mboxrd Mon Sep 17 00:00:00 2001
+From: mboxrd writer <mboxrd@example.com>
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+Subject: [PATCH] a commit with escaped From lines
+
+>From the beginning, mbox should have been mboxrd
+>>From escaped
+From not mangled but this line should have been escaped
+
+From mboxrd Mon Sep 17 00:00:00 2001
+From: mboxrd writer <mboxrd@example.com>
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+Subject: [PATCH 2/2] another with fake From lines
+
+ >From unchanged
+ From also unchanged
+no trailing space, no escaping necessary and '>' was intended:
+>From
+
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index dd2e6ce34..8198d8eb0 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1182,7 +1182,7 @@ test_expect_success 'extra args: setup' '
test_extra_arg () {
test_expect_success "extra args: $*" "
test_must_fail git remote $* bogus_extra_arg 2>actual &&
- grep '^usage:' actual
+ test_i18ngrep '^usage:' actual
"
}
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 454d89639..88076da1e 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -644,7 +644,7 @@ test_expect_success 'fetch --prune prints the remotes url' '
git fetch --prune origin 2>&1 | head -n1 >../actual
) &&
echo "From ${D}/." >expect &&
- test_cmp expect actual
+ test_i18ncmp expect actual
'
test_expect_success 'branchname D/F conflict resolved by --prune' '
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 3159956fd..37ebbcfbb 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -211,7 +211,7 @@ test_expect_success 'fail if the index has unresolved entries' '
test -n "$(git ls-files -u)" &&
cp file expected &&
test_must_fail git pull . second 2>err &&
- test_i18ngrep "Pull is not possible because you have unmerged files" err &&
+ test_i18ngrep "Pulling is not possible because you have unmerged files." err &&
test_cmp expected file &&
git add file &&
test -z "$(git ls-files -u)" &&
diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh
index 3683df13a..d6981ba30 100755
--- a/t/t5523-push-upstream.sh
+++ b/t/t5523-push-upstream.sh
@@ -75,7 +75,7 @@ test_expect_success TTY 'progress messages go to tty' '
ensure_fresh_upstream &&
test_terminal git push -u upstream master >out 2>err &&
- grep "Writing objects" err
+ test_i18ngrep "Writing objects" err
'
test_expect_success 'progress messages do not go to non-tty' '
@@ -83,7 +83,7 @@ test_expect_success 'progress messages do not go to non-tty' '
# skip progress messages, since stderr is non-tty
git push -u upstream master >out 2>err &&
- ! grep "Writing objects" err
+ test_i18ngrep ! "Writing objects" err
'
test_expect_success 'progress messages go to non-tty (forced)' '
@@ -91,22 +91,22 @@ test_expect_success 'progress messages go to non-tty (forced)' '
# force progress messages to stderr, even though it is non-tty
git push -u --progress upstream master >out 2>err &&
- grep "Writing objects" err
+ test_i18ngrep "Writing objects" err
'
test_expect_success TTY 'push -q suppresses progress' '
ensure_fresh_upstream &&
test_terminal git push -u -q upstream master >out 2>err &&
- ! grep "Writing objects" err
+ test_i18ngrep ! "Writing objects" err
'
test_expect_success TTY 'push --no-progress suppresses progress' '
ensure_fresh_upstream &&
test_terminal git push -u --no-progress upstream master >out 2>err &&
- ! grep "Unpacking objects" err &&
- ! grep "Writing objects" err
+ test_i18ngrep ! "Unpacking objects" err &&
+ test_i18ngrep ! "Writing objects" err
'
test_expect_success TTY 'quiet push' '
diff --git a/t/t5536-fetch-conflicts.sh b/t/t5536-fetch-conflicts.sh
index 6c5d3a4ce..2e42cf331 100755
--- a/t/t5536-fetch-conflicts.sh
+++ b/t/t5536-fetch-conflicts.sh
@@ -22,8 +22,8 @@ verify_stderr () {
cat >expected &&
# We're not interested in the error
# "fatal: The remote end hung up unexpectedly":
- grep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
- test_cmp expected actual
+ test_i18ngrep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
+ test_i18ncmp expected actual
}
test_expect_success 'setup' '
diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
index fd7d06b9a..ca6becfe3 100755
--- a/t/t5541-http-push-smart.sh
+++ b/t/t5541-http-push-smart.sh
@@ -119,7 +119,7 @@ test_expect_success 'rejected update prints status' '
git commit -m dev2 &&
test_must_fail git push origin dev2 2>act &&
sed -e "/^remote: /s/ *$//" <act >cmp &&
- test_cmp exp cmp
+ test_i18ncmp exp cmp
'
rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
@@ -219,7 +219,7 @@ test_expect_success TTY 'push shows progress when stderr is a tty' '
cd "$ROOT_PATH"/test_repo_clone &&
test_commit noisy &&
test_terminal git push >output 2>&1 &&
- grep "^Writing objects" output
+ test_i18ngrep "^Writing objects" output
'
test_expect_success TTY 'push --quiet silences status and progress' '
@@ -233,16 +233,16 @@ test_expect_success TTY 'push --no-progress silences progress but not status' '
cd "$ROOT_PATH"/test_repo_clone &&
test_commit no-progress &&
test_terminal git push --no-progress >output 2>&1 &&
- grep "^To http" output &&
- ! grep "^Writing objects"
+ test_i18ngrep "^To http" output &&
+ test_i18ngrep ! "^Writing objects"
'
test_expect_success 'push --progress shows progress to non-tty' '
cd "$ROOT_PATH"/test_repo_clone &&
test_commit progress &&
git push --progress >output 2>&1 &&
- grep "^To http" output &&
- grep "^Writing objects" output
+ test_i18ngrep "^To http" output &&
+ test_i18ngrep "^Writing objects" output
'
test_expect_success 'http push gives sane defaults to reflog' '
diff --git a/t/t5544-pack-objects-hook.sh b/t/t5544-pack-objects-hook.sh
new file mode 100755
index 000000000..4357af152
--- /dev/null
+++ b/t/t5544-pack-objects-hook.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+test_description='test custom script in place of pack-objects'
+. ./test-lib.sh
+
+test_expect_success 'create some history to fetch' '
+ test_commit one &&
+ test_commit two
+'
+
+test_expect_success 'create debugging hook script' '
+ write_script .git/hook <<-\EOF
+ echo >&2 "hook running"
+ echo "$*" >hook.args
+ cat >hook.stdin
+ "$@" <hook.stdin >hook.stdout
+ cat hook.stdout
+ EOF
+'
+
+clear_hook_results () {
+ rm -rf .git/hook.* dst.git
+}
+
+test_expect_success 'hook runs via global config' '
+ clear_hook_results &&
+ test_config_global uploadpack.packObjectsHook ./hook &&
+ git clone --no-local . dst.git 2>stderr &&
+ grep "hook running" stderr
+'
+
+test_expect_success 'hook outputs are sane' '
+ # check that we recorded a usable pack
+ git index-pack --stdin <.git/hook.stdout &&
+
+ # check that we recorded args and stdin. We do not check
+ # the full argument list or the exact pack contents, as it would make
+ # the test brittle. So just sanity check that we could replay
+ # the packing procedure.
+ grep "^git" .git/hook.args &&
+ $(cat .git/hook.args) <.git/hook.stdin >replay
+'
+
+test_expect_success 'hook runs from -c config' '
+ clear_hook_results &&
+ git clone --no-local \
+ -u "git -c uploadpack.packObjectsHook=./hook upload-pack" \
+ . dst.git 2>stderr &&
+ grep "hook running" stderr
+'
+
+test_expect_success 'hook does not run from repo config' '
+ clear_hook_results &&
+ test_config uploadpack.packObjectsHook "./hook" &&
+ git clone --no-local . dst.git 2>stderr &&
+ ! grep "hook running" stderr &&
+ test_path_is_missing .git/hook.args &&
+ test_path_is_missing .git/hook.stdin &&
+ test_path_is_missing .git/hook.stdout
+'
+
+test_done
diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules.sh
index 32d83e269..a87d32965 100755
--- a/t/t5614-clone-submodules.sh
+++ b/t/t5614-clone-submodules.sh
@@ -25,61 +25,46 @@ test_expect_success 'setup' '
test_expect_success 'nonshallow clone implies nonshallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 3 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 3 lines
'
-test_expect_success 'shallow clone implies shallow submodule' '
+test_expect_success 'shallow clone with shallow submodule' '
+ test_when_finished "rm -rf super_clone" &&
+ git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 2 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 1 lines
+'
+
+test_expect_success 'shallow clone does not imply shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 2 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 1 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 2 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 3 lines
'
test_expect_success 'shallow clone with non shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 2 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 2 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 3 lines
'
test_expect_success 'non shallow clone with shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 1 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 3 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 1 lines
'
test_expect_success 'clone follows shallow recommendation' '
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index e74662ba5..86d1380b9 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -362,7 +362,7 @@ test_expect_success 'bisect starting with a detached HEAD' '
test_expect_success 'bisect errors out if bad and good are mistaken' '
git bisect reset &&
test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error &&
- grep "mistook good and bad" rev_list_error &&
+ test_i18ngrep "mistook good and bad" rev_list_error &&
git bisect reset
'
@@ -404,7 +404,7 @@ test_expect_success 'side branch creation' '
test_expect_success 'good merge base when good and bad are siblings' '
git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt &&
- grep "merge base must be tested" my_bisect_log.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
grep $HASH4 my_bisect_log.txt &&
git bisect good > my_bisect_log.txt &&
test_must_fail grep "merge base must be tested" my_bisect_log.txt &&
@@ -413,7 +413,7 @@ test_expect_success 'good merge base when good and bad are siblings' '
'
test_expect_success 'skipped merge base when good and bad are siblings' '
git bisect start "$SIDE_HASH7" "$HASH7" > my_bisect_log.txt &&
- grep "merge base must be tested" my_bisect_log.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
grep $HASH4 my_bisect_log.txt &&
git bisect skip > my_bisect_log.txt 2>&1 &&
grep "warning" my_bisect_log.txt &&
@@ -423,11 +423,11 @@ test_expect_success 'skipped merge base when good and bad are siblings' '
test_expect_success 'bad merge base when good and bad are siblings' '
git bisect start "$HASH7" HEAD > my_bisect_log.txt &&
- grep "merge base must be tested" my_bisect_log.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
grep $HASH4 my_bisect_log.txt &&
test_must_fail git bisect bad > my_bisect_log.txt 2>&1 &&
- grep "merge base $HASH4 is bad" my_bisect_log.txt &&
- grep "fixed between $HASH4 and \[$SIDE_HASH7\]" my_bisect_log.txt &&
+ test_i18ngrep "merge base $HASH4 is bad" my_bisect_log.txt &&
+ test_i18ngrep "fixed between $HASH4 and \[$SIDE_HASH7\]" my_bisect_log.txt &&
git bisect reset
'
@@ -460,9 +460,9 @@ test_expect_success 'many merge bases creation' '
test_expect_success 'good merge bases when good and bad are siblings' '
git bisect start "$B_HASH" "$A_HASH" > my_bisect_log.txt &&
- grep "merge base must be tested" my_bisect_log.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
git bisect good > my_bisect_log2.txt &&
- grep "merge base must be tested" my_bisect_log2.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log2.txt &&
{
{
grep "$SIDE_HASH5" my_bisect_log.txt &&
@@ -477,14 +477,14 @@ test_expect_success 'good merge bases when good and bad are siblings' '
test_expect_success 'optimized merge base checks' '
git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt &&
- grep "merge base must be tested" my_bisect_log.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
grep "$HASH4" my_bisect_log.txt &&
git bisect good > my_bisect_log2.txt &&
test -f ".git/BISECT_ANCESTORS_OK" &&
test "$HASH6" = $(git rev-parse --verify HEAD) &&
git bisect bad > my_bisect_log3.txt &&
git bisect good "$A_HASH" > my_bisect_log4.txt &&
- grep "merge base must be tested" my_bisect_log4.txt &&
+ test_i18ngrep "merge base must be tested" my_bisect_log4.txt &&
test_must_fail test -f ".git/BISECT_ANCESTORS_OK"
'
@@ -562,7 +562,7 @@ test_expect_success 'skipping away from skipped commit' '
test_expect_success 'erroring out when using bad path parameters' '
test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt &&
- grep "bad path parameters" error.txt
+ test_i18ngrep "bad path parameters" error.txt
'
test_expect_success 'test bisection on bare repo - --no-checkout specified' '
@@ -803,7 +803,7 @@ test_expect_success 'bisect terms needs 0 or 1 argument' '
test_must_fail git bisect terms 1 2 &&
test_must_fail git bisect terms 2>actual &&
echo "no terms defined" >expected &&
- test_cmp expected actual
+ test_i18ncmp expected actual
'
test_expect_success 'bisect terms shows good/bad after start' '
@@ -875,7 +875,7 @@ test_expect_success 'bisect start --term-* does store terms' '
Your current terms are two for the old state
and one for the new state.
EOF
- test_cmp expected actual &&
+ test_i18ncmp expected actual &&
git bisect terms --term-bad >actual &&
echo one >expected &&
test_cmp expected actual &&
diff --git a/t/t6301-for-each-ref-errors.sh b/t/t6301-for-each-ref-errors.sh
index cdb67a03b..c734ce238 100755
--- a/t/t6301-for-each-ref-errors.sh
+++ b/t/t6301-for-each-ref-errors.sh
@@ -20,8 +20,8 @@ test_expect_success 'Broken refs are reported correctly' '
test_when_finished "rm -f .git/$r" &&
echo "warning: ignoring broken ref $r" >broken-err &&
git for-each-ref >out 2>err &&
- test_cmp full-list out &&
- test_cmp broken-err err
+ test_i18ncmp full-list out &&
+ test_i18ncmp broken-err err
'
test_expect_success 'NULL_SHA1 refs are reported correctly' '
@@ -31,10 +31,10 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '
echo "warning: ignoring broken ref $r" >zeros-err &&
git for-each-ref >out 2>err &&
test_cmp full-list out &&
- test_cmp zeros-err err &&
+ test_i18ncmp zeros-err err &&
git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
test_cmp brief-list brief-out &&
- test_cmp zeros-err brief-err
+ test_i18ncmp zeros-err brief-err
'
test_expect_success 'Missing objects are reported correctly' '
@@ -43,7 +43,7 @@ test_expect_success 'Missing objects are reported correctly' '
test_when_finished "rm -f .git/$r" &&
echo "fatal: missing object $MISSING for $r" >missing-err &&
test_must_fail git for-each-ref 2>err &&
- test_cmp missing-err err &&
+ test_i18ncmp missing-err err &&
(
cat brief-list &&
echo "$MISSING $r"
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index f9b7d79af..8b0f71a2a 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1202,10 +1202,17 @@ test_expect_success GPG,RFC1991 \
# try to sign with bad user.signingkey
git config user.signingkey BobTheMouse
test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured' \
+ 'git tag -s fails if gpg is misconfigured (bad key)' \
'test_must_fail git tag -s -m tail tag-gpg-failure'
git config --unset user.signingkey
+# try to produce invalid signature
+test_expect_success GPG \
+ 'git tag -s fails if gpg is misconfigured (bad signature format)' \
+ 'test_config gpg.program echo &&
+ test_must_fail git tag -s -m tail tag-gpg-failure'
+
+
# try to verify without gpg:
rm -rf gpghome
diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh
index a971884cf..38b389053 100755
--- a/t/t7063-status-untracked-cache.sh
+++ b/t/t7063-status-untracked-cache.sh
@@ -643,7 +643,7 @@ test_expect_success 'test ident field is working' '
cp -R done dthree dtwo four three ../other_worktree &&
GIT_WORK_TREE=../other_worktree git status 2>../err &&
echo "warning: Untracked cache is disabled on this system or location." >../expect &&
- test_cmp ../expect ../err
+ test_i18ncmp ../expect ../err
'
test_done
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 98bcfe21a..86f23be34 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -66,14 +66,14 @@ test_expect_success 'reset --hard message' '
hex=$(git log -1 --format="%h") &&
git reset --hard > .actual &&
echo HEAD is now at $hex $(commit_msg) > .expected &&
- test_cmp .expected .actual
+ test_i18ncmp .expected .actual
'
test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
hex=$(git log -1 --format="%h") &&
git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
- test_cmp .expected .actual
+ test_i18ncmp .expected .actual
'
>.diff_expect
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 885923610..d4b217b0e 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -257,7 +257,7 @@ test_expect_success 'checkout to detach HEAD' '
git checkout -f renamer && git clean -f &&
git checkout renamer^ 2>messages &&
test_i18ngrep "HEAD is now at 7329388" messages &&
- test_line_count -gt 1 messages &&
+ (test_line_count -gt 1 messages || test -n "$GETTEXT_POISON") &&
H=$(git rev-parse --verify HEAD) &&
M=$(git show-ref -s --verify refs/heads/master) &&
test "z$H" = "z$M" &&
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 3570f7bb8..b77cce8e4 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -942,7 +942,7 @@ test_expect_success 'submodule deinit from subdirectory' '
cd sub &&
git submodule deinit ../init >../output
) &&
- grep "\\.\\./init" output &&
+ test_i18ngrep "\\.\\./init" output &&
test -z "$(git config --get-regexp "submodule\.example\.")" &&
test -n "$(git config --get-regexp "submodule\.example2\.")" &&
test -f example2/.git &&
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 5503ec067..0726799e7 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -157,7 +157,7 @@ test_expect_success '"git submodule sync" should update submodule URLs - subdire
cd sub &&
git submodule sync >../../output
) &&
- grep "\\.\\./submodule" output &&
+ test_i18ngrep "\\.\\./submodule" output &&
test -d "$(
cd super-clone/submodule &&
git config remote.origin.url
@@ -188,7 +188,7 @@ test_expect_success '"git submodule sync --recursive" should update all submodul
cd sub &&
git submodule sync --recursive >../../output
) &&
- grep "\\.\\./submodule/sub-submodule" output &&
+ test_i18ngrep "\\.\\./submodule/sub-submodule" output &&
test -d "$(
cd super-clone/submodule &&
git config remote.origin.url
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 5f278799d..88e9750ab 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -136,8 +136,8 @@ test_expect_success 'submodule update --init --recursive from subdirectory' '
cd tmp &&
git submodule update --init --recursive ../super >../../actual 2>../../actual2
) &&
- test_cmp expect actual &&
- test_cmp expect2 actual2
+ test_i18ncmp expect actual &&
+ test_i18ncmp expect2 actual2
'
apos="'";
@@ -370,7 +370,7 @@ test_expect_success 'submodule update - command in .git/config catches failure'
(cd super &&
test_must_fail git submodule update submodule 2>../actual
) &&
- test_cmp actual expect
+ test_i18ncmp actual expect
'
cat << EOF >expect
@@ -388,7 +388,7 @@ test_expect_success 'submodule update - command in .git/config catches failure -
mkdir tmp && cd tmp &&
test_must_fail git submodule update ../submodule 2>../../actual
) &&
- test_cmp actual expect
+ test_i18ncmp actual expect
'
cat << EOF >expect
@@ -408,7 +408,7 @@ test_expect_success 'recursive submodule update - command in .git/config catches
mkdir -p tmp && cd tmp &&
test_must_fail git submodule update --recursive ../super 2>../../actual
) &&
- test_cmp actual expect
+ test_i18ncmp actual expect
'
test_expect_success 'submodule init does not copy command into .git/config' '
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index c3ed7cb51..b3bdd162a 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1377,7 +1377,7 @@ EOF
git config --add -f .gitmodules submodule.subname.ignore all &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status > output &&
- test_cmp expect output &&
+ test_i18ncmp expect output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1387,7 +1387,7 @@ test_expect_success '.git/config ignore=all suppresses unstaged submodule summar
git config --add submodule.subname.ignore all &&
git config --add submodule.subname.path sm &&
git status > output &&
- test_cmp expect output &&
+ test_i18ncmp expect output &&
git config --remove-section submodule.subname &&
git config -f .gitmodules --remove-section submodule.subname
'
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 4177a8609..6e839f548 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -210,4 +210,11 @@ test_expect_success GPG 'show lack of signature with custom format' '
test_cmp expect actual
'
+test_expect_success GPG 'log.showsignature behaves like --show-signature' '
+ test_config log.showsignature true &&
+ git show initial >actual &&
+ grep "gpg: Signature made" actual &&
+ grep "gpg: Good signature" actual
+'
+
test_done
diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh
index 758a623cd..9444d6a9b 100755
--- a/t/t7607-merge-overwrite.sh
+++ b/t/t7607-merge-overwrite.sh
@@ -115,7 +115,7 @@ cat >expect <<\EOF
error: The following untracked working tree files would be overwritten by merge:
sub
sub2
-Please move or remove them before you can merge.
+Please move or remove them before you merge.
Aborting
EOF
@@ -125,7 +125,7 @@ test_expect_success 'will not overwrite untracked file in leading path' '
cp important sub &&
cp important sub2 &&
test_must_fail git merge sub 2>out &&
- test_cmp out expect &&
+ test_i18ncmp out expect &&
test_path_is_missing .git/MERGE_HEAD &&
test_cmp important sub &&
test_cmp important sub2 &&
diff --git a/t/t7609-merge-co-error-msgs.sh b/t/t7609-merge-co-error-msgs.sh
index 6729cb379..f80bdb81e 100755
--- a/t/t7609-merge-co-error-msgs.sh
+++ b/t/t7609-merge-co-error-msgs.sh
@@ -31,7 +31,7 @@ error: The following untracked working tree files would be overwritten by merge:
four
three
two
-Please move or remove them before you can merge.
+Please move or remove them before you merge.
Aborting
EOF
@@ -53,10 +53,10 @@ error: Your local changes to the following files would be overwritten by merge:
four
three
two
-Please commit your changes or stash them before you can merge.
+Please commit your changes or stash them before you merge.
error: The following untracked working tree files would be overwritten by merge:
five
-Please move or remove them before you can merge.
+Please move or remove them before you merge.
Aborting
EOF
@@ -72,7 +72,7 @@ cat >expect <<\EOF
error: Your local changes to the following files would be overwritten by checkout:
rep/one
rep/two
-Please commit your changes or stash them before you can switch branches.
+Please commit your changes or stash them before you switch branches.
Aborting
EOF
@@ -94,7 +94,7 @@ cat >expect <<\EOF
error: Your local changes to the following files would be overwritten by checkout:
rep/one
rep/two
-Please commit your changes or stash them before you can switch branches.
+Please commit your changes or stash them before you switch branches.
Aborting
EOF
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index b66e38386..987573c41 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -122,4 +122,32 @@ test_expect_success 'keep packed objects found only in index' '
git cat-file blob :file
'
+test_expect_success 'repack -k keeps unreachable packed objects' '
+ # create packed-but-unreachable object
+ sha1=$(echo unreachable-packed | git hash-object -w --stdin) &&
+ pack=$(echo $sha1 | git pack-objects .git/objects/pack/pack) &&
+ git prune-packed &&
+
+ # -k should keep it
+ git repack -adk &&
+ git cat-file -p $sha1 &&
+
+ # and double check that without -k it would have been removed
+ git repack -ad &&
+ test_must_fail git cat-file -p $sha1
+'
+
+test_expect_success 'repack -k packs unreachable loose objects' '
+ # create loose unreachable object
+ sha1=$(echo would-be-deleted-loose | git hash-object -w --stdin) &&
+ objpath=.git/objects/$(echo $sha1 | sed "s,..,&/,") &&
+ test_path_is_file $objpath &&
+
+ # and confirm that the loose object goes away, but we can
+ # still access it (ergo, it is packed)
+ git repack -adk &&
+ test_path_is_missing $objpath &&
+ git cat-file -p $sha1
+'
+
test_done
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 7ce4cd753..42a292983 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -446,7 +446,7 @@ write_script .git/CHECK_SYMLINKS <<\EOF
for f in file file2 sub/sub
do
echo "$f"
- readlink "$2/$f"
+ ls -ld "$2/$f" | sed -e 's/.* -> //'
done >actual
EOF
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 960425a4e..cf3f9ec63 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -177,7 +177,7 @@ do
test_expect_success "grep -c $L (no /dev/null)" '
! git grep -c test $H | grep /dev/null
- '
+ '
test_expect_success "grep --max-depth -1 $L" '
{
@@ -355,7 +355,7 @@ test_expect_success 'grep -l -C' '
cat >expected <<EOF
file:5
EOF
-test_expect_success 'grep -l -C' '
+test_expect_success 'grep -c -C' '
git grep -c -C1 foo >actual &&
test_cmp expected actual
'
@@ -1377,4 +1377,62 @@ test_expect_success 'grep --color -e A --and -e B -p with context' '
test_cmp expected actual
'
+test_expect_success 'grep can find things only in the work tree' '
+ : >work-tree-only &&
+ git add work-tree-only &&
+ test_when_finished "git rm -f work-tree-only" &&
+ echo "find in work tree" >work-tree-only &&
+ git grep --quiet "find in work tree" &&
+ test_must_fail git grep --quiet --cached "find in work tree" &&
+ test_must_fail git grep --quiet "find in work tree" HEAD
+'
+
+test_expect_success 'grep can find things only in the work tree (i-t-a)' '
+ echo "intend to add this" >intend-to-add &&
+ git add -N intend-to-add &&
+ test_when_finished "git rm -f intend-to-add" &&
+ git grep --quiet "intend to add this" &&
+ test_must_fail git grep --quiet --cached "intend to add this" &&
+ test_must_fail git grep --quiet "intend to add this" HEAD
+'
+
+test_expect_success 'grep does not search work tree with assume unchanged' '
+ echo "intend to add this" >intend-to-add &&
+ git add -N intend-to-add &&
+ git update-index --assume-unchanged intend-to-add &&
+ test_when_finished "git rm -f intend-to-add" &&
+ test_must_fail git grep --quiet "intend to add this" &&
+ test_must_fail git grep --quiet --cached "intend to add this" &&
+ test_must_fail git grep --quiet "intend to add this" HEAD
+'
+
+test_expect_success 'grep can find things only in the index' '
+ echo "only in the index" >cache-this &&
+ git add cache-this &&
+ rm cache-this &&
+ test_when_finished "git rm --cached cache-this" &&
+ test_must_fail git grep --quiet "only in the index" &&
+ git grep --quiet --cached "only in the index" &&
+ test_must_fail git grep --quiet "only in the index" HEAD
+'
+
+test_expect_success 'grep does not report i-t-a with -L --cached' '
+ echo "intend to add this" >intend-to-add &&
+ git add -N intend-to-add &&
+ test_when_finished "git rm -f intend-to-add" &&
+ git ls-files | grep -v "^intend-to-add\$" >expected &&
+ git grep -L --cached "nonexistent_string" >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'grep does not report i-t-a and assume unchanged with -L' '
+ echo "intend to add this" >intend-to-add-assume-unchanged &&
+ git add -N intend-to-add-assume-unchanged &&
+ test_when_finished "git rm -f intend-to-add-assume-unchanged" &&
+ git update-index --assume-unchanged intend-to-add-assume-unchanged &&
+ git ls-files | grep -v "^intend-to-add-assume-unchanged\$" >expected &&
+ git grep -L "nonexistent_string" >actual &&
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/t8008-blame-formats.sh b/t/t8008-blame-formats.sh
index 29f84a6dd..92c8e792d 100755
--- a/t/t8008-blame-formats.sh
+++ b/t/t8008-blame-formats.sh
@@ -87,4 +87,21 @@ test_expect_success 'blame --line-porcelain output' '
test_cmp expect actual
'
+test_expect_success '--porcelain detects first non-blank line as subject' '
+ (
+ GIT_INDEX_FILE=.git/tmp-index &&
+ export GIT_INDEX_FILE &&
+ echo "This is it" >single-file &&
+ git add single-file &&
+ tree=$(git write-tree) &&
+ commit=$(printf "%s\n%s\n%s\n\n\n \noneline\n\nbody\n" \
+ "tree $tree" \
+ "author A <a@b.c> 123456789 +0000" \
+ "committer C <c@d.e> 123456789 +0000" |
+ git hash-object -w -t commit --stdin) &&
+ git blame --porcelain $commit -- single-file >output &&
+ grep "^summary oneline$" output
+ )
+'
+
test_done
diff --git a/t/t9003-help-autocorrect.sh b/t/t9003-help-autocorrect.sh
index dfe95c923..b1c7919c4 100755
--- a/t/t9003-help-autocorrect.sh
+++ b/t/t9003-help-autocorrect.sh
@@ -31,10 +31,10 @@ test_expect_success 'autocorrect showing candidates' '
git config help.autocorrect 0 &&
test_must_fail git lfg 2>actual &&
- sed -e "1,/^Did you mean this/d" actual | grep lgf &&
+ grep "^ lgf" actual &&
test_must_fail git distimdist 2>actual &&
- sed -e "1,/^Did you mean this/d" actual | grep distimdistim
+ grep "^ distimdistim" actual
'
test_expect_success 'autocorrect running commands' '
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 74d740de4..2e0ba3ebd 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -7,23 +7,6 @@ test_description='test git fast-import utility'
. ./test-lib.sh
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
-# Print $1 bytes from stdin to stdout.
-#
-# This could be written as "head -c $1", but IRIX "head" does not
-# support the -c option.
-head_c () {
- perl -e '
- my $len = $ARGV[1];
- while ($len > 0) {
- my $s;
- my $nread = sysread(STDIN, $s, $len);
- die "cannot read: $!" unless defined($nread);
- print $s;
- $len -= $nread;
- }
- ' - "$1"
-}
-
verify_packs () {
for p in .git/objects/pack/*.pack
do
@@ -2481,7 +2464,7 @@ test_expect_success PIPE 'R: copy using cat-file' '
read blob_id type size <&3 &&
echo "$blob_id $type $size" >response &&
- head_c $size >blob <&3 &&
+ test_copy_bytes $size >blob <&3 &&
read newline <&3 &&
cat <<-EOF &&
@@ -2524,7 +2507,7 @@ test_expect_success PIPE 'R: print blob mid-commit' '
EOF
read blob_id type size <&3 &&
- head_c $size >actual <&3 &&
+ test_copy_bytes $size >actual <&3 &&
read newline <&3 &&
echo
@@ -2559,7 +2542,7 @@ test_expect_success PIPE 'R: print staged blob within commit' '
echo "cat-blob $to_get" &&
read blob_id type size <&3 &&
- head_c $size >actual <&3 &&
+ test_copy_bytes $size >actual <&3 &&
read newline <&3 &&
echo deleteall
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 48884d520..90856d67e 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -961,3 +961,17 @@ test_env () {
done
)
}
+
+# Read up to "$1" bytes (or to EOF) from stdin and write them to stdout.
+test_copy_bytes () {
+ perl -e '
+ my $len = $ARGV[1];
+ while ($len > 0) {
+ my $s;
+ my $nread = sysread(STDIN, $s, $len);
+ die "cannot read: $!" unless defined($nread);
+ print $s;
+ $len -= $nread;
+ }
+ ' - "$1"
+}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0055ebba4..11201e9cf 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1111,3 +1111,12 @@ run_with_limited_cmdline () {
}
test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true'
+
+build_option () {
+ git version --build-options |
+ sed -ne "s/^$1: //p"
+}
+
+test_lazy_prereq LONG_IS_64BIT '
+ test 8 -le "$(build_option sizeof-long)"
+'
diff --git a/transport-helper.c b/transport-helper.c
index bd666b29e..420874360 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1038,7 +1038,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
(*tail)->status |= REF_STATUS_UPTODATE;
if (read_ref((*tail)->name,
(*tail)->old_oid.hash) < 0)
- die(N_("Could not read ref %s"),
+ die(_("Could not read ref %s"),
(*tail)->name);
}
}
diff --git a/transport.c b/transport.c
index 095e61f0a..59b911e5f 100644
--- a/transport.c
+++ b/transport.c
@@ -59,7 +59,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
localname + 11, transport->remote->name,
remotename);
else
- printf("Would set upstream of '%s' to '%s' of '%s'\n",
+ printf(_("Would set upstream of '%s' to '%s' of '%s'\n"),
localname + 11, remotename + 11,
transport->remote->name);
}
@@ -148,7 +148,7 @@ static int set_git_option(struct git_transport_options *opts,
char *end;
opts->depth = strtol(value, &end, 0);
if (*end)
- die("transport: invalid depth option '%s'", value);
+ die(_("transport: invalid depth option '%s'"), value);
}
return 0;
}
@@ -767,19 +767,19 @@ static void die_with_unpushed_submodules(struct string_list *needs_pushing)
{
int i;
- fprintf(stderr, "The following submodule paths contain changes that can\n"
- "not be found on any remote:\n");
+ fprintf(stderr, _("The following submodule paths contain changes that can\n"
+ "not be found on any remote:\n"));
for (i = 0; i < needs_pushing->nr; i++)
printf(" %s\n", needs_pushing->items[i].string);
- fprintf(stderr, "\nPlease try\n\n"
- " git push --recurse-submodules=on-demand\n\n"
- "or cd to the path and use\n\n"
- " git push\n\n"
- "to push them to a remote.\n\n");
+ fprintf(stderr, _("\nPlease try\n\n"
+ " git push --recurse-submodules=on-demand\n\n"
+ "or cd to the path and use\n\n"
+ " git push\n\n"
+ "to push them to a remote.\n\n"));
string_list_clear(needs_pushing, 0);
- die("Aborting.");
+ die(_("Aborting."));
}
static int run_pre_push_hook(struct transport *transport,
diff --git a/tree-diff.c b/tree-diff.c
index edb4de9b7..e164e532b 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -14,6 +14,16 @@
*/
#define S_IFXMIN_NEQ S_DIFFTREE_IFXMIN_NEQ
+#define FAST_ARRAY_ALLOC(x, nr) do { \
+ if ((nr) <= 2) \
+ (x) = xalloca((nr) * sizeof(*(x))); \
+ else \
+ ALLOC_ARRAY((x), nr); \
+} while(0)
+#define FAST_ARRAY_FREE(x, nr) do { \
+ if ((nr) > 2) \
+ free((x)); \
+} while(0)
static struct combine_diff_path *ll_diff_tree_paths(
struct combine_diff_path *p, const unsigned char *sha1,
@@ -265,7 +275,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
if (recurse) {
const unsigned char **parents_sha1;
- parents_sha1 = xalloca(nparent * sizeof(parents_sha1[0]));
+ FAST_ARRAY_ALLOC(parents_sha1, nparent);
for (i = 0; i < nparent; ++i) {
/* same rule as in emitthis */
int tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ);
@@ -277,7 +287,7 @@ 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, sha1, parents_sha1, nparent, base, opt);
- xalloca_free(parents_sha1);
+ FAST_ARRAY_FREE(parents_sha1, nparent);
}
strbuf_setlen(base, old_baselen);
@@ -402,8 +412,8 @@ static struct combine_diff_path *ll_diff_tree_paths(
void *ttree, **tptree;
int i;
- tp = xalloca(nparent * sizeof(tp[0]));
- tptree = xalloca(nparent * sizeof(tptree[0]));
+ FAST_ARRAY_ALLOC(tp, nparent);
+ FAST_ARRAY_ALLOC(tptree, nparent);
/*
* load parents first, as they are probably already cached.
@@ -531,8 +541,8 @@ static struct combine_diff_path *ll_diff_tree_paths(
free(ttree);
for (i = nparent-1; i >= 0; i--)
free(tptree[i]);
- xalloca_free(tptree);
- xalloca_free(tp);
+ FAST_ARRAY_FREE(tptree, nparent);
+ FAST_ARRAY_FREE(tp, nparent);
return p;
}
diff --git a/unpack-trees.c b/unpack-trees.c
index 6bc9512a4..11c37fbc5 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -62,17 +62,17 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
if (!strcmp(cmd, "checkout"))
msg = advice_commit_before_merge
? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
- "Please commit your changes or stash them before you can switch branches.")
+ "Please commit your changes or stash them before you switch branches.")
: _("Your local changes to the following files would be overwritten by checkout:\n%%s");
else if (!strcmp(cmd, "merge"))
msg = advice_commit_before_merge
? _("Your local changes to the following files would be overwritten by merge:\n%%s"
- "Please commit your changes or stash them before you can merge.")
+ "Please commit your changes or stash them before you merge.")
: _("Your local changes to the following files would be overwritten by merge:\n%%s");
else
msg = advice_commit_before_merge
? _("Your local changes to the following files would be overwritten by %s:\n%%s"
- "Please commit your changes or stash them before you can %s.")
+ "Please commit your changes or stash them before you %s.")
: _("Your local changes to the following files would be overwritten by %s:\n%%s");
msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] =
xstrfmt(msg, cmd, cmd);
@@ -83,34 +83,34 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
if (!strcmp(cmd, "checkout"))
msg = advice_commit_before_merge
? _("The following untracked working tree files would be removed by checkout:\n%%s"
- "Please move or remove them before you can switch branches.")
+ "Please move or remove them before you switch branches.")
: _("The following untracked working tree files would be removed by checkout:\n%%s");
else if (!strcmp(cmd, "merge"))
msg = advice_commit_before_merge
? _("The following untracked working tree files would be removed by merge:\n%%s"
- "Please move or remove them before you can merge.")
+ "Please move or remove them before you merge.")
: _("The following untracked working tree files would be removed by merge:\n%%s");
else
msg = advice_commit_before_merge
? _("The following untracked working tree files would be removed by %s:\n%%s"
- "Please move or remove them before you can %s.")
+ "Please move or remove them before you %s.")
: _("The following untracked working tree files would be removed by %s:\n%%s");
msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = xstrfmt(msg, cmd, cmd);
if (!strcmp(cmd, "checkout"))
msg = advice_commit_before_merge
? _("The following untracked working tree files would be overwritten by checkout:\n%%s"
- "Please move or remove them before you can switch branches.")
+ "Please move or remove them before you switch branches.")
: _("The following untracked working tree files would be overwritten by checkout:\n%%s");
else if (!strcmp(cmd, "merge"))
msg = advice_commit_before_merge
? _("The following untracked working tree files would be overwritten by merge:\n%%s"
- "Please move or remove them before you can merge.")
+ "Please move or remove them before you merge.")
: _("The following untracked working tree files would be overwritten by merge:\n%%s");
else
msg = advice_commit_before_merge
? _("The following untracked working tree files would be overwritten by %s:\n%%s"
- "Please move or remove them before you can %s.")
+ "Please move or remove them before you %s.")
: _("The following untracked working tree files would be overwritten by %s:\n%%s");
msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = xstrfmt(msg, cmd, cmd);
diff --git a/upload-pack.c b/upload-pack.c
index 9e03c278b..f93787003 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -56,26 +56,28 @@ static int keepalive = 5;
static int use_sideband;
static int advertise_refs;
static int stateless_rpc;
+static const char *pack_objects_hook;
static void reset_timeout(void)
{
alarm(timeout);
}
-static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
+static void send_client_data(int fd, const char *data, ssize_t sz)
{
- if (use_sideband)
- return send_sideband(1, fd, data, sz, use_sideband);
+ if (use_sideband) {
+ send_sideband(1, fd, data, sz, use_sideband);
+ return;
+ }
if (fd == 3)
/* emergency quit */
fd = 2;
if (fd == 2) {
/* XXX: are we happy to lose stuff here? */
xwrite(fd, data, sz);
- return sz;
+ return;
}
write_or_die(fd, data, sz);
- return sz;
}
static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
@@ -97,6 +99,14 @@ static void create_pack_file(void)
int i;
FILE *pipe_fd;
+ if (!pack_objects_hook)
+ pack_objects.git_cmd = 1;
+ else {
+ argv_array_push(&pack_objects.args, pack_objects_hook);
+ argv_array_push(&pack_objects.args, "git");
+ pack_objects.use_shell = 1;
+ }
+
if (shallow_nr) {
argv_array_push(&pack_objects.args, "--shallow-file");
argv_array_push(&pack_objects.args, "");
@@ -119,7 +129,6 @@ static void create_pack_file(void)
pack_objects.in = -1;
pack_objects.out = -1;
pack_objects.err = -1;
- pack_objects.git_cmd = 1;
if (start_command(&pack_objects))
die("git upload-pack: unable to fork git-pack-objects");
@@ -233,9 +242,7 @@ static void create_pack_file(void)
}
else
buffered = -1;
- sz = send_client_data(1, data, sz);
- if (sz < 0)
- goto fail;
+ send_client_data(1, data, sz);
}
/*
@@ -262,9 +269,7 @@ static void create_pack_file(void)
/* flush the data */
if (0 <= buffered) {
data[0] = buffered;
- sz = send_client_data(1, data, 1);
- if (sz < 0)
- goto fail;
+ send_client_data(1, data, 1);
fprintf(stderr, "flushed.\n");
}
if (use_sideband)
@@ -816,6 +821,9 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
keepalive = git_config_int(var, value);
if (!keepalive)
keepalive = -1;
+ } else if (current_config_scope() != CONFIG_SCOPE_REPO) {
+ if (!strcmp("uploadpack.packobjectshook", var))
+ return git_config_string(&pack_objects_hook, var, value);
}
return parse_hide_refs_config(var, value, "uploadpack");
}
diff --git a/worktree.c b/worktree.c
index 199b1ef94..e2a94e047 100644
--- a/worktree.c
+++ b/worktree.c
@@ -153,21 +153,19 @@ done:
static void mark_current_worktree(struct worktree **worktrees)
{
- struct strbuf git_dir = STRBUF_INIT;
- struct strbuf path = STRBUF_INIT;
+ char *git_dir = xstrdup(absolute_path(get_git_dir()));
int i;
- strbuf_addstr(&git_dir, absolute_path(get_git_dir()));
for (i = 0; worktrees[i]; i++) {
struct worktree *wt = worktrees[i];
- strbuf_addstr(&path, absolute_path(get_worktree_git_dir(wt)));
- wt->is_current = !fspathcmp(git_dir.buf, path.buf);
- strbuf_reset(&path);
- if (wt->is_current)
+ const char *wt_git_dir = get_worktree_git_dir(wt);
+
+ if (!fspathcmp(git_dir, absolute_path(wt_git_dir))) {
+ wt->is_current = 1;
break;
+ }
}
- strbuf_release(&git_dir);
- strbuf_release(&path);
+ free(git_dir);
}
struct worktree **get_worktrees(void)
@@ -189,7 +187,7 @@ struct worktree **get_worktrees(void)
if (dir) {
while ((d = readdir(dir)) != NULL) {
struct worktree *linked = NULL;
- if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
+ if (is_dot_or_dotdot(d->d_name))
continue;
if ((linked = get_linked_worktree(d->d_name))) {
diff --git a/wrapper.c b/wrapper.c
index 5dc4e15aa..26db215f0 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -227,6 +227,24 @@ int xopen(const char *path, int oflag, ...)
}
}
+static int handle_nonblock(int fd, short poll_events, int err)
+{
+ struct pollfd pfd;
+
+ if (err != EAGAIN && err != EWOULDBLOCK)
+ return 0;
+
+ pfd.fd = fd;
+ pfd.events = poll_events;
+
+ /*
+ * no need to check for errors, here;
+ * a subsequent read/write will detect unrecoverable errors
+ */
+ poll(&pfd, 1, -1);
+ return 1;
+}
+
/*
* xread() is the same a read(), but it automatically restarts read()
* operations with a recoverable error (EAGAIN and EINTR). xread()
@@ -242,20 +260,8 @@ ssize_t xread(int fd, void *buf, size_t len)
if (nr < 0) {
if (errno == EINTR)
continue;
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
- struct pollfd pfd;
- pfd.events = POLLIN;
- pfd.fd = fd;
- /*
- * it is OK if this poll() failed; we
- * want to leave this infinite loop
- * only when read() returns with
- * success, or an expected failure,
- * which would be checked by the next
- * call to read(2).
- */
- poll(&pfd, 1, -1);
- }
+ if (handle_nonblock(fd, POLLIN, errno))
+ continue;
}
return nr;
}
@@ -273,8 +279,13 @@ ssize_t xwrite(int fd, const void *buf, size_t len)
len = MAX_IO_SIZE;
while (1) {
nr = write(fd, buf, len);
- if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
- continue;
+ if (nr < 0) {
+ if (errno == EINTR)
+ continue;
+ if (handle_nonblock(fd, POLLOUT, errno))
+ continue;
+ }
+
return nr;
}
}
diff --git a/write_or_die.c b/write_or_die.c
index 49e80aa22..981687945 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -94,14 +94,3 @@ int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
return 1;
}
-
-int write_or_whine(int fd, const void *buf, size_t count, const char *msg)
-{
- if (write_in_full(fd, buf, count) < 0) {
- fprintf(stderr, "%s: write error (%s)\n",
- msg, strerror(errno));
- return 0;
- }
-
- return 1;
-}
diff --git a/wt-status.c b/wt-status.c
index 4f27bd62a..c19b52ce8 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -263,7 +263,7 @@ static const char *wt_status_unmerged_status_string(int stagemask)
case 7:
return _("both modified:");
default:
- die(_("bug: unhandled unmerged status %x"), stagemask);
+ die("bug: unhandled unmerged status %x", stagemask);
}
}
@@ -388,7 +388,7 @@ static void wt_status_print_change_data(struct wt_status *s,
status_printf(s, color(WT_STATUS_HEADER, s), "\t");
what = wt_status_diff_status_string(status);
if (!what)
- die(_("bug: unhandled diff status %c"), status);
+ die("bug: unhandled diff status %c", status);
len = label_width - utf8_strwidth(what);
assert(len >= 0);
if (status == DIFF_STATUS_COPIED || status == DIFF_STATUS_RENAMED)
@@ -1554,7 +1554,7 @@ void wt_status_print(struct wt_status *s)
else
printf(_("nothing to commit\n"));
} else
- printf(_("nothing to commit, working directory clean\n"));
+ printf(_("nothing to commit, working tree clean\n"));
}
}