Merge branch 'ls/p4-retry-thrice'
authorJunio C Hamano <gitster@pobox.com>
Wed, 18 Jan 2017 23:12:12 +0000 (15:12 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Jan 2017 23:12:12 +0000 (15:12 -0800)
A recent updates to "git p4" was not usable for older p4 but it
could be made to work with minimum changes. Do so.

* ls/p4-retry-thrice:
git-p4: do not pass '-r 0' to p4 commands

243 files changed:
.gitignore
.travis.yml
Documentation/RelNotes/2.10.3.txt [new file with mode: 0644]
Documentation/RelNotes/2.11.1.txt [new file with mode: 0644]
Documentation/RelNotes/2.12.0.txt [new file with mode: 0644]
Documentation/config.txt
Documentation/date-formats.txt
Documentation/diff-config.txt
Documentation/diff-heuristic-options.txt
Documentation/git-branch.txt
Documentation/git-commit.txt
Documentation/git-fetch-pack.txt
Documentation/git-fetch.txt
Documentation/git-for-each-ref.txt
Documentation/git-gc.txt
Documentation/git-grep.txt
Documentation/git-merge.txt
Documentation/git-p4.txt
Documentation/git-pull.txt
Documentation/git-push.txt
Documentation/git-rebase.txt
Documentation/git-shortlog.txt
Documentation/git-submodule.txt
Documentation/git-svn.txt
Documentation/git-tag.txt
Documentation/git.txt
Documentation/gitattributes.txt
Documentation/gitcore-tutorial.txt
Documentation/gitnamespaces.txt
Documentation/pretty-formats.txt
Documentation/technical/api-submodule-config.txt
Documentation/transfer-data-leaks.txt [new file with mode: 0644]
GIT-VERSION-GEN
Makefile
README.md
RelNotes
abspath.c
apply.c
bisect.c
branch.c
builtin/add.c
builtin/am.c
builtin/blame.c
builtin/branch.c
builtin/checkout-index.c
builtin/checkout.c
builtin/clean.c
builtin/clone.c
builtin/commit.c
builtin/fetch.c
builtin/for-each-ref.c
builtin/grep.c
builtin/index-pack.c
builtin/init-db.c
builtin/merge.c
builtin/mv.c
builtin/pack-objects.c
builtin/pull.c
builtin/push.c
builtin/read-tree.c
builtin/receive-pack.c
builtin/reset.c
builtin/rev-parse.c
builtin/rm.c
builtin/shortlog.c
builtin/submodule--helper.c
builtin/tag.c
builtin/update-index.c
builtin/worktree.c
bulk-checkin.c
cache.h
commit.c
commit.h
compat/mingw.h
compat/winansi.c
config.c
config.mak.uname
contrib/completion/git-completion.bash
contrib/long-running-filter/example.pl
contrib/update-unicode/.gitignore [new file with mode: 0644]
contrib/update-unicode/README [new file with mode: 0644]
contrib/update-unicode/update_unicode.sh [new file with mode: 0755]
convert.c
diff.c
dir.c
dir.h
environment.c
fast-import.c
git-add--interactive.perl
git-difftool.perl
git-mergetool--lib.sh
git-p4.py
git-rebase--interactive.sh
git-rebase.sh
git-send-email.perl
git-sh-setup.sh
git-stash.sh
git-submodule.sh
git.c
gitk-git/Makefile
gitk-git/gitk
gitk-git/po/bg.po
gitk-git/po/ca.po
gitk-git/po/de.po
gitk-git/po/es.po
gitk-git/po/fr.po
gitk-git/po/hu.po
gitk-git/po/it.po
gitk-git/po/ja.po
gitk-git/po/pt_br.po
gitk-git/po/pt_pt.po [new file with mode: 0644]
gitk-git/po/ru.po
gitk-git/po/sv.po
gitk-git/po/vi.po
grep.c
grep.h
http-walker.c
http.c
http.h
lockfile.c
lockfile.h
mailinfo.c
merge-recursive.c
merge.c
mergetools/araxis
mergetools/bc
mergetools/codecompare
mergetools/deltawalker
mergetools/diffmerge
mergetools/diffuse
mergetools/ecmerge
mergetools/emerge
mergetools/examdiff
mergetools/kdiff3
mergetools/kompare
mergetools/meld
mergetools/opendiff
mergetools/p4merge
mergetools/tkdiff
mergetools/tortoisemerge
mergetools/vimdiff
mergetools/winmerge
mergetools/xxdiff
parse-options.c
path.c
perl/Git.pm
perl/Git/I18N.pm
perl/Git/SVN/Ra.pm
pretty.c
read-cache.c
ref-filter.c
ref-filter.h
remote-curl.c
rerere.c
sequencer.c
setup.c
sha1_file.c
shallow.c
shortlog.h
submodule-config.c
submodule-config.h
submodule.c
submodule.h
t/helper/test-scrap-cache-tree.c
t/lib-httpd/apache.conf
t/lib-proto-disable.sh
t/t0021-conversion.sh
t/t0021/rot13-filter.pl
t/t0202/test.pl
t/t1050-large.sh
t/t1308-config-set.sh
t/t2027-worktree-list.sh
t/t3030-merge-recursive.sh
t/t3203-branch-output.sh
t/t3407-rebase-abort.sh
t/t3426-rebase-submodule.sh
t/t3501-revert-cherry-pick.sh
t/t3510-cherry-pick-sequence.sh
t/t3511-cherry-pick-x.sh
t/t3600-rm.sh
t/t3903-stash.sh
t/t4013-diff-various.sh
t/t4013/diff.diff_--no-index_--raw_--abbrev=4_dir2_dir [new file with mode: 0644]
t/t4013/diff.diff_--no-index_--raw_--no-abbrev_dir2_dir [new file with mode: 0644]
t/t4013/diff.diff_--no-index_--raw_dir2_dir [new file with mode: 0644]
t/t4013/diff.diff_--raw_--abbrev=4_initial [new file with mode: 0644]
t/t4013/diff.diff_--raw_--no-abbrev_initial [new file with mode: 0644]
t/t4013/diff.diff_--raw_initial [new file with mode: 0644]
t/t4014-format-patch.sh
t/t4201-shortlog.sh
t/t4205-log-pretty-formats.sh
t/t5000-tar-tree.sh
t/t5300-pack-object.sh
t/t5315-pack-objects-compression.sh [new file with mode: 0755]
t/t5509-fetch-push-namespaces.sh
t/t5520-pull.sh
t/t5528-push-default.sh
t/t5531-deep-submodule-push.sh
t/t5547-push-quarantine.sh
t/t5550-http-fetch-dumb.sh
t/t5551-http-fetch-smart.sh
t/t5615-alternate-env.sh
t/t5802-connect-helper.sh
t/t5812-proto-disable-http.sh
t/t6101-rev-parse-parents.sh
t/t6300-for-each-ref.sh
t/t7004-tag.sh
t/t7408-submodule-reference.sh
t/t7411-submodule-config.sh
t/t7412-submodule-absorbgitdirs.sh [new file with mode: 0755]
t/t7501-commit.sh
t/t7600-merge.sh
t/t7609-merge-co-error-msgs.sh
t/t7610-mergetool.sh
t/t7800-difftool.sh
t/t7814-grep-recurse-submodules.sh [new file with mode: 0755]
t/t9100-git-svn-basic.sh
t/t9301-fast-import-notes.sh
t/t9303-fast-import-compression.sh [new file with mode: 0755]
t/t9800-git-p4-basic.sh
t/t9806-git-p4-options.sh
t/t9807-git-p4-submit.sh
t/t9824-git-p4-git-lfs.sh
t/t9830-git-p4-symlink-dir.sh [new file with mode: 0755]
t/t9902-completion.sh
t/test-lib-functions.sh
tmp-objdir.c
trailer.c
trailer.h
transport.c
transport.h
tree-walk.c
unicode_width.h
unpack-trees.c
update_unicode.sh [deleted file]
upload-pack.c
utf8.c
worktree.c
worktree.h
wt-status.c
xdiff/xdiff.h
xdiff/xdiffi.c
xdiff/xutils.c
index 05cb58a3d4ef47295fa8ef02add44a0f0dd90d1f..6722f78f9ab7e9647a3358a52e627f1c9e83f685 100644 (file)
 /config.mak.autogen
 /config.mak.append
 /configure
-/unicode
 /tags
 /TAGS
 /cscope*
index 0b2ea5c3e2daa057cb88763f1943f6a250d019d9..3843967a692d1642e43f536d5e2652b566ca554d 100644 (file)
@@ -27,8 +27,8 @@ env:
     # The Linux build installs the defined dependency versions below.
     # The OS X build installs the latest available versions. Keep that
     # in mind when you encounter a broken OS X build!
-    - LINUX_P4_VERSION="16.1"
-    - LINUX_GIT_LFS_VERSION="1.2.0"
+    - LINUX_P4_VERSION="16.2"
+    - LINUX_GIT_LFS_VERSION="1.5.2"
     - DEFAULT_TEST_TARGET=prove
     - GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
     - GIT_TEST_OPTS="--verbose-log"
diff --git a/Documentation/RelNotes/2.10.3.txt b/Documentation/RelNotes/2.10.3.txt
new file mode 100644 (file)
index 0000000..277a2a1
--- /dev/null
@@ -0,0 +1,48 @@
+Git v2.10.3 Release Notes
+=========================
+
+Fixes since v2.10.2
+-------------------
+
+ * Extract a small helper out of the function that reads the authors
+   script file "git am" internally uses.
+   This by itself is not useful until a second caller appears in the
+   future for "rebase -i" helper.
+
+ * The command-line completion script (in contrib/) learned to
+   complete "git cmd ^mas<HT>" to complete the negative end of
+   reference to "git cmd ^master".
+
+ * "git send-email" attempts to pick up valid e-mails from the
+   trailers, but people in real world write non-addresses there, like
+   "Cc: Stable <add@re.ss> # 4.8+", which broke the output depending
+   on the availability and vintage of Mail::Address perl module.
+
+ * The code that we have used for the past 10+ years to cycle
+   4-element ring buffers turns out to be not quite portable in
+   theoretical world.
+
+ * "git daemon" used fixed-length buffers to turn URL to the
+   repository the client asked for into the server side directory
+   path, using snprintf() to avoid overflowing these buffers, but
+   allowed possibly truncated paths to the directory.  This has been
+   tightened to reject such a request that causes overlong path to be
+   required to serve.
+
+ * Recent update to git-sh-setup (a library of shell functions that
+   are used by our in-tree scripted Porcelain commands) included
+   another shell library git-sh-i18n without specifying where it is,
+   relying on the $PATH.  This has been fixed to be more explicit by
+   prefixing $(git --exec-path) output in front.
+
+ * Fix for a racy false-positive test failure.
+
+ * Portability update and workaround for builds on recent Mac OS X.
+
+ * Update to the test framework made in 2.9 timeframe broke running
+   the tests under valgrind, which has been fixed.
+
+ * Improve the rule to convert "unsigned char [20]" into "struct
+   object_id *" in contrib/coccinelle/
+
+Also contains minor documentation updates and code clean-ups.
diff --git a/Documentation/RelNotes/2.11.1.txt b/Documentation/RelNotes/2.11.1.txt
new file mode 100644 (file)
index 0000000..74b193f
--- /dev/null
@@ -0,0 +1,120 @@
+Git v2.11.1 Release Notes
+=========================
+
+Fixes since v2.11
+-----------------
+
+ * The default Travis-CI configuration specifies newer P4 and GitLFS.
+
+ * The character width table has been updated to match Unicode 9.0
+
+ * Update the isatty() emulation for Windows by updating the previous
+   hack that depended on internals of (older) MSVC runtime.
+
+ * "git rev-parse --symbolic" failed with a more recent notation like
+   "HEAD^-1" and "HEAD^!".
+
+ * An empty directory in a working tree that can simply be nuked used
+   to interfere while merging or cherry-picking a change to create a
+   submodule directory there, which has been fixed..
+
+ * The code in "git push" to compute if any commit being pushed in the
+   superproject binds a commit in a submodule that hasn't been pushed
+   out was overly inefficient, making it unusable even for a small
+   project that does not have any submodule but have a reasonable
+   number of refs.
+
+ * "git push --dry-run --recurse-submodule=on-demand" wasn't
+   "--dry-run" in the submodules.
+
+ * The output from "git worktree list" was made in readdir() order,
+   and was unstable.
+
+ * mergetool.<tool>.trustExitCode configuration variable did not apply
+   to built-in tools, but now it does.
+
+ * "git p4" LFS support was broken when LFS stores an empty blob.
+
+ * Fix a corner case in merge-recursive regression that crept in
+   during 2.10 development cycle.
+
+ * Update the error messages from the dumb-http client when it fails
+   to obtain loose objects; we used to give sensible error message
+   only upon 404 but we now forbid unexpected redirects that needs to
+   be reported with something sensible.
+
+ * When diff.renames configuration is on (and with Git 2.9 and later,
+   it is enabled by default, which made it worse), "git stash"
+   misbehaved if a file is removed and another file with a very
+   similar content is added.
+
+ * "git diff --no-index" did not take "--no-abbrev" option.
+
+ * "git difftool --dir-diff" had a minor regression when started from
+   a subdirectory, which has been fixed.
+
+ * "git commit --allow-empty --only" (no pathspec) with dirty index
+   ought to be an acceptable way to create a new commit that does not
+   change any paths, but it was forbidden, perhaps because nobody
+   needed it so far.
+
+ * A pathname that begins with "//" or "\\" on Windows is special but
+   path normalization logic was unaware of it.
+
+ * "git pull --rebase", when there is no new commits on our side since
+   we forked from the upstream, should be able to fast-forward without
+   invoking "git rebase", but it didn't.
+
+ * The way to specify hotkeys to "xxdiff" that is used by "git
+   mergetool" has been modernized to match recent versions of xxdiff.
+
+ * Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
+   to where cherry-pick started while picking multiple changes, when
+   the cherry-pick stopped to ask for help from the user, and the user
+   did "git reset --hard" to a different commit in order to re-attempt
+   the operation.
+
+ * Code cleanup in shallow boundary computation.
+
+ * A recent update to receive-pack to make it easier to drop garbage
+   objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
+   have a pathname with a colon in it (no surprise!), and this in turn
+   made it impossible to push into a repository at such a path.  This
+   has been fixed by introducing a quoting mechanism used when
+   appending such a path to the colon-separated list.
+
+ * The function usage_msg_opt() has been updated to say "fatal:"
+   before the custom message programs give, when they want to die
+   with a message about wrong command line options followed by the
+   standard usage string.
+
+ * "git index-pack --stdin" needs an access to an existing repository,
+   but "git index-pack file.pack" to generate an .idx file that
+   corresponds to a packfile does not.
+
+ * Fix for NDEBUG builds.
+
+ * A lazy "git push" without refspec did not internally use a fully
+   specified refspec to perform 'current', 'simple', or 'upstream'
+   push, causing unnecessary "ambiguous ref" errors.
+
+ * "git p4" misbehaved when swapping a directory and a symbolic link.
+
+ * Even though an fix was attempted in Git 2.9.3 days, but running
+   "git difftool --dir-diff" from a subdirectory never worked. This
+   has been fixed.
+
+ * "git p4" that tracks multile p4 paths imported a single changelist
+   that touches files in these multiple paths as one commit, followed
+   by many empty commits.  This has been fixed.
+
+ * A potential but unlikely buffer overflow in Windows port has been
+   fixed.
+
+ * When the http server gives an incomplete response to a smart-http
+   rpc call, it could lead to client waiting for a full response that
+   will never come.  Teach the client side to notice this condition
+   and abort the transfer.
+
+
+Also contains various documentation updates and code clean-ups.
diff --git a/Documentation/RelNotes/2.12.0.txt b/Documentation/RelNotes/2.12.0.txt
new file mode 100644 (file)
index 0000000..f7d5e9c
--- /dev/null
@@ -0,0 +1,256 @@
+Git 2.12 Release Notes
+======================
+
+Backward compatibility notes.
+
+ * Use of an empty string that is used for 'everything matches' is
+   still warned and Git asks users to use a more explicit '.' for that
+   instead.  The hope is that existing users will not mind this
+   change, and eventually the warning can be turned into a hard error,
+   upgrading the deprecation into removal of this (mis)feature.  That
+   is not scheduled to happen in the upcoming release (yet).
+
+ * The historical argument order "git merge <msg> HEAD <commit>..."
+   has been deprecated for quite some time, and will be removed in the
+   upcoming release.
+
+
+Updates since v2.11
+-------------------
+
+UI, Workflows & Features
+
+ * Various updates to "git p4".
+
+ * "git p4" didn't interact with the internal of .git directory
+   correctly in the modern "git-worktree"-enabled world.
+
+ * "git branch --list" and friends learned "--ignore-case" option to
+   optionally sort branches and tags case insensitively.
+
+ * In addition to %(subject), %(body), "log --pretty=format:..."
+   learned a new placeholder %(trailers).
+
+ * "git rebase" learned "--quit" option, which allows a user to
+   remove the metadata left by an earlier "git rebase" that was
+   manually aborted without using "git rebase --abort".
+
+ * "git clone --reference $there --recurse-submodules $super" has been
+   taught to guess repositories usable as references for submodules of
+   $super that are embedded in $there while making a clone of the
+   superproject borrow objects from $there; extend the mechanism to
+   also allow submodules of these submodules to borrow repositories
+   embedded in these clones of the submodules embedded in the clone of
+   the superproject.
+
+ * Porcelain scripts written in Perl are getting internationalized.
+
+ * "git merge --continue" has been added as a synonym to "git commit"
+   to conclude a merge that has stopped due to conflicts.
+
+ * Finer-grained control of what protocols are allowed for transports
+   during clone/fetch/push have been enabled via a new configuration
+   mechanism.
+
+ * "git shortlog" learned "--committer" option to group commits by
+   committer, instead of author.
+
+ * GitLFS integration with "git p4" has been updated.
+
+ * The isatty() emulation for Windows has been updated to eradicate
+   the previous hack that depended on internals of (older) MSVC
+   runtime.
+
+ * Some platforms no longer understand "latin-1" that is still seen in
+   the wild in e-mail headers; replace them with "iso-8859-1" that is
+   more widely known when conversion fails from/to it.
+   (merge df3755888b jc/latin-1 later to maint).
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ * Commands that operate on a log message and add lines to the trailer
+   blocks, such as "format-patch -s", "cherry-pick (-x|-s)", and
+   "commit -s", have been taught to use the logic of and share the
+   code with "git interpret-trailer".
+
+ * The default Travis-CI configuration specifies newer P4 and GitLFS.
+
+ * The "fast hash" that had disastrous performance issues in some
+   corner cases has been retired from the internal diff.
+
+ * The character width table has been updated to match Unicode 9.0
+
+ * Update the procedure to generate "tags" for developer support.
+   (merge 046e4c1c09 jk/make-tags-find-sources-tweak later to maint).
+
+ * The codeflow of setting NOATIME and CLOEXEC on file descriptors Git
+   opens has been simplified.
+   (merge b4d065df03 jc/git-open-cloexec later to maint).
+
+ * "git diff" and its family had two experimental heuristics to shift
+   the contents of a hunk to make the patch easier to read.  One of
+   them turns out to be better than the other, so leave only the
+   "--indent-heuristic" option and remove the other one.
+   (merge 3cde4e02ee jc/retire-compaction-heuristics later to maint).
+
+ * A new submodule helper "git submodule embedgitdirs" to make it
+   easier to move embedded .git/ directory for submodules in a
+   superproject to .git/modules/ (and point the latter with the former
+   that is turned into a "gitdir:" file) has been added.
+
+
+Also contains various documentation updates and code clean-ups.
+
+Fixes since v2.10
+-----------------
+
+Unless otherwise noted, all the fixes since v2.9 in the maintenance
+track are contained in this release (see the maintenance releases'
+notes for details).
+
+ * We often decide if a session is interactive by checking if the
+   standard I/O streams are connected to a TTY, but isatty() that
+   comes with Windows incorrectly returned true if it is used on NUL
+   (i.e. an equivalent to /dev/null).  This has been fixed.
+
+ * "git svn" did not work well with path components that are "0", and
+   some configuration variable it uses were not documented.
+   (merge ea9a93dcc2 ew/svn-fixes later to maint).
+
+ * "git rev-parse --symbolic" failed with a more recent notation like
+   "HEAD^-1" and "HEAD^!".
+
+ * An empty directory in a working tree that can simply be nuked used
+   to interfere while merging or cherry-picking a change to create a
+   submodule directory there, which has been fixed..
+
+ * The code in "git push" to compute if any commit being pushed in the
+   superproject binds a commit in a submodule that hasn't been pushed
+   out was overly inefficient, making it unusable even for a small
+   project that does not have any submodule but have a reasonable
+   number of refs.
+
+ * "git push --dry-run --recurse-submodule=on-demand" wasn't
+   "--dry-run" in the submodules.
+
+ * The output from "git worktree list" was made in readdir() order,
+   and was unstable.
+
+ * mergetool.<tool>.trustExitCode configuration variable did not apply
+   to built-in tools, but now it does.
+
+ * "git p4" LFS support was broken when LFS stores an empty blob.
+
+ * A corner case in merge-recursive regression that crept in
+   during 2.10 development cycle has been fixed.
+
+ * Transport with dumb http can be fooled into following foreign URLs
+   that the end user does not intend to, especially with the server
+   side redirects and http-alternates mechanism, which can lead to
+   security issues.  Tighten the redirection and make it more obvious
+   to the end user when it happens.
+
+ * Update the error messages from the dumb-http client when it fails
+   to obtain loose objects; we used to give sensible error message
+   only upon 404 but we now forbid unexpected redirects that needs to
+   be reported with something sensible.
+
+ * When diff.renames configuration is on (and with Git 2.9 and later,
+   it is enabled by default, which made it worse), "git stash"
+   misbehaved if a file is removed and another file with a very
+   similar content is added.
+
+ * "git diff --no-index" did not take "--no-abbrev" option.
+
+ * "git difftool --dir-diff" had a minor regression when started from
+   a subdirectory, which has been fixed.
+
+ * "git commit --allow-empty --only" (no pathspec) with dirty index
+   ought to be an acceptable way to create a new commit that does not
+   change any paths, but it was forbidden, perhaps because nobody
+   needed it so far.
+
+ * Git 2.11 had a minor regression in "merge --ff-only" that competed
+   with another process that simultanously attempted to update the
+   index. We used to explain what went wrong with an error message,
+   but the new code silently failed.  The error message has been
+   resurrected.
+
+ * A pathname that begins with "//" or "\\" on Windows is special but
+   path normalization logic was unaware of it.
+
+ * "git pull --rebase", when there is no new commits on our side since
+   we forked from the upstream, should be able to fast-forward without
+   invoking "git rebase", but it didn't.
+
+ * The way to specify hotkeys to "xxdiff" that is used by "git
+   mergetool" has been modernized to match recent versions of xxdiff.
+
+ * Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
+   to where cherry-pick started while picking multiple changes, when
+   the cherry-pick stopped to ask for help from the user, and the user
+   did "git reset --hard" to a different commit in order to re-attempt
+   the operation.
+
+ * Code cleanup in shallow boundary computation.
+
+ * A recent update to receive-pack to make it easier to drop garbage
+   objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
+   have a pathname with a colon in it (no surprise!), and this in turn
+   made it impossible to push into a repository at such a path.  This
+   has been fixed by introducing a quoting mechanism used when
+   appending such a path to the colon-separated list.
+
+ * The function usage_msg_opt() has been updated to say "fatal:"
+   before the custom message programs give, when they want to die
+   with a message about wrong command line options followed by the
+   standard usage string.
+
+ * "git index-pack --stdin" needs an access to an existing repository,
+   but "git index-pack file.pack" to generate an .idx file that
+   corresponds to a packfile does not.
+
+ * Fix for NDEBUG builds.
+
+ * A lazy "git push" without refspec did not internally use a fully
+   specified refspec to perform 'current', 'simple', or 'upstream'
+   push, causing unnecessary "ambiguous ref" errors.
+
+ * "git p4" misbehaved when swapping a directory and a symbolic link.
+
+ * Even though an fix was attempted in Git 2.9.3 days, but running
+   "git difftool --dir-diff" from a subdirectory never worked. This
+   has been fixed.
+
+ * "git p4" that tracks multile p4 paths imported a single changelist
+   that touches files in these multiple paths as one commit, followed
+   by many empty commits.  This has been fixed.
+
+ * A potential but unlikely buffer overflow in Windows port has been
+   fixed.
+
+ * When the http server gives an incomplete response to a smart-http
+   rpc call, it could lead to client waiting for a full response that
+   will never come.  Teach the client side to notice this condition
+   and abort the transfer.
+
+ * Compression setting for producing packfiles were spread across
+   three codepaths, one of which did not honor any configuration.
+   Unify these so that all of them honor core.compression and
+   pack.compression variables the same way.
+   (merge 8de7eeb54b jc/compression-config later to maint).
+
+ * "git fast-import" sometimes mishandled while rebalancing notes
+   tree, which has been fixed.
+   (merge 405d7f4af6 mh/fast-import-notes-fix-new later to maint).
+
+ * Recent update to the default abbreviation length that auto-scales
+   lacked documentation update, which has been corrected.
+   (merge 48d5014dd4 jc/abbrev-autoscale-config later to maint).
+
+ * Leakage of lockfiles in the config subsystem has been fixed.
+   (merge c06fa62dfc nd/config-misc-fixes later to maint).
+
+ * Other minor doc, test and build updates and code cleanups.
+   (merge f2627d9b19 sb/submodule-config-cleanup later to maint).
index a0ab66aae70db90bd18e14ec5bc5c95007b118f7..506431267ed0ef15bce2570d3f1bf69e7268e8f0 100644 (file)
@@ -783,10 +783,11 @@ core.sparseCheckout::
        linkgit:git-read-tree[1] for more information.
 
 core.abbrev::
-       Set the length object names are abbreviated to.  If unspecified,
-       many commands abbreviate to 7 hexdigits, which may not be enough
-       for abbreviated object names to stay unique for sufficiently long
-       time.
+       Set the length object names are abbreviated to.  If
+       unspecified or set to "auto", an appropriate value is
+       computed based on the approximate number of packed objects
+       in your repository, which hopefully is enough for
+       abbreviated object names to stay unique for some time.
 
 add.ignoreErrors::
 add.ignore-errors (deprecated)::
@@ -1409,7 +1410,9 @@ gc.pruneExpire::
        Override the grace period with this config variable.  The value
        "now" may be used to disable this grace period and always prune
        unreachable objects immediately, or "never" may be used to
-       suppress pruning.
+       suppress pruning.  This feature helps prevent corruption when
+       'git gc' runs concurrently with another process writing to the
+       repository; see the "NOTES" section of linkgit:git-gc[1].
 
 gc.worktreePruneExpire::
        When 'git gc' is run, it calls
@@ -1891,6 +1894,16 @@ http.userAgent::
        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.
 
+http.followRedirects::
+       Whether git should follow HTTP redirects. If set to `true`, git
+       will transparently follow any redirect issued by a server it
+       encounters. If set to `false`, git will treat all redirects as
+       errors. If set to `initial`, git will follow redirects only for
+       the initial request to a remote, but not for subsequent
+       follow-up HTTP requests. Since git uses the redirected URL as
+       the base for the follow-up requests, this is generally
+       sufficient. The default is `initial`.
+
 http.<url>.*::
        Any of the http.* options above can be applied selectively to some URLs.
        For a config key to match a URL, each element of the config key is
@@ -2308,6 +2321,52 @@ pretty.<name>::
        Note that an alias with the same name as a built-in format
        will be silently ignored.
 
+protocol.allow::
+       If set, provide a user defined default policy for all protocols which
+       don't explicitly have a policy (`protocol.<name>.allow`).  By default,
+       if unset, known-safe protocols (http, https, git, ssh, file) have a
+       default policy of `always`, known-dangerous protocols (ext) have a
+       default policy of `never`, and all other protocols have a default
+       policy of `user`.  Supported policies:
++
+--
+
+* `always` - protocol is always able to be used.
+
+* `never` - protocol is never able to be used.
+
+* `user` - protocol is only able to be used when `GIT_PROTOCOL_FROM_USER` is
+  either unset or has a value of 1.  This policy should be used when you want a
+  protocol to be directly usable by the user but don't want it used by commands which
+  execute clone/fetch/push commands without user input, e.g. recursive
+  submodule initialization.
+
+--
+
+protocol.<name>.allow::
+       Set a policy to be used by protocol `<name>` with clone/fetch/push
+       commands. See `protocol.allow` above for the available policies.
++
+The protocol names currently used by git are:
++
+--
+  - `file`: any local file-based path (including `file://` URLs,
+    or local paths)
+
+  - `git`: the anonymous git protocol over a direct TCP
+    connection (or proxy, if configured)
+
+  - `ssh`: git over ssh (including `host:path` syntax,
+    `ssh://`, etc).
+
+  - `http`: git over http, both "smart http" and "dumb http".
+    Note that this does _not_ include `https`; if you want to configure
+    both, you must do so individually.
+
+  - any external helpers are named by their protocol (e.g., use
+    `hg` to allow the `git-remote-hg` helper)
+--
+
 pull.ff::
        By default, Git does not create an extra merge commit when merging
        a commit that is a descendant of the current commit. Instead, the
@@ -2930,6 +2989,11 @@ is omitted from the advertisements but `refs/heads/master` and
 `refs/namespaces/bar/refs/heads/master` are still advertised as so-called
 "have" lines. In order to match refs before stripping, add a `^` in front of
 the ref name. If you combine `!` and `^`, `!` must be specified first.
++
+Even if you hide refs, a client may still be able to steal the target
+objects via the techniques described in the "SECURITY" section of the
+linkgit:gitnamespaces[7] man page; it's best to keep private data in a
+separate repository.
 
 transfer.unpackLimit::
        When `fetch.unpackLimit` or `receive.unpackLimit` are
@@ -2939,7 +3003,7 @@ transfer.unpackLimit::
 uploadarchive.allowUnreachable::
        If true, allow clients to use `git archive --remote` to request
        any tree, whether reachable from the ref tips or not. See the
-       discussion in the `SECURITY` section of
+       discussion in the "SECURITY" section of
        linkgit:git-upload-archive[1] for more details. Defaults to
        `false`.
 
@@ -2953,12 +3017,23 @@ uploadpack.allowTipSHA1InWant::
        When `uploadpack.hideRefs` is in effect, allow `upload-pack`
        to accept a fetch request that asks for an object at the tip
        of a hidden ref (by default, such a request is rejected).
-       see also `uploadpack.hideRefs`.
+       See also `uploadpack.hideRefs`.  Even if this is false, a client
+       may be able to steal objects via the techniques described in the
+       "SECURITY" section of the linkgit:gitnamespaces[7] man page; it's
+       best to keep private data in a separate repository.
 
 uploadpack.allowReachableSHA1InWant::
        Allow `upload-pack` to accept a fetch request that asks for an
        object that is reachable from any ref tip. However, note that
        calculating object reachability is computationally expensive.
+       Defaults to `false`.  Even if this is false, a client may be able
+       to steal objects via the techniques described in the "SECURITY"
+       section of the linkgit:gitnamespaces[7] man page; it's best to
+       keep private data in a separate repository.
+
+uploadpack.allowAnySHA1InWant::
+       Allow `upload-pack` to accept a fetch request that asks for any
+       object at all.
        Defaults to `false`.
 
 uploadpack.keepAlive::
index 35e8da201005dee34b75c87aebf720a8f7300a9c..6926e0a4c86a0c8396d9cca4942a81bbb8e7dc85 100644 (file)
@@ -11,7 +11,7 @@ Git internal format::
        It is `<unix timestamp> <time zone offset>`, where `<unix
        timestamp>` is the number of seconds since the UNIX epoch.
        `<time zone offset>` is a positive or negative offset from UTC.
-       For example CET (which is 2 hours ahead UTC) is `+0200`.
+       For example CET (which is 1 hour ahead of UTC) is `+0100`.
 
 RFC 2822::
        The standard email format as described by RFC 2822, for example
index 58f4bd6afa12240f9e416860ac12d82776815ee9..d8570f2a75096c07d7045ddfba7f1e2e6396d000 100644 (file)
@@ -172,10 +172,8 @@ diff.tool::
 include::mergetools-diff.txt[]
 
 diff.indentHeuristic::
-diff.compactionHeuristic::
-       Set one of these options to `true` to enable one of two
-       experimental heuristics that shift diff hunk boundaries to
-       make patches easier to read.
+       Set this option to `true` to enable experimental heuristics
+       that shift diff hunk boundaries to make patches easier to read.
 
 diff.algorithm::
        Choose a diff algorithm.  The variants are as follows:
index 36cb549df97cef182d590683cf262ccc9690e3ff..d4f3d9550555cd0aaa7a35c27ee926b71bf01b41 100644 (file)
@@ -1,7 +1,5 @@
 --indent-heuristic::
 --no-indent-heuristic::
---compaction-heuristic::
---no-compaction-heuristic::
        These are to help debugging and tuning experimental heuristics
        (which are off by default) that shift diff hunk boundaries to
        make patches easier to read.
index 1fe73448f3f5a3ff48f939924156771cabfc1f77..5516a47b5490ff1e79ead61cd2229946cc1a7fe2 100644 (file)
@@ -118,6 +118,10 @@ OPTIONS
        default to color output.
        Same as `--color=never`.
 
+-i::
+--ignore-case::
+       Sorting and filtering branches are case insensitive.
+
 --column[=<options>]::
 --no-column::
        Display branch listing in columns. See configuration variable
index f2ab0ee2e7d1ff0f79c09cbd27e745f5f08d139d..4f8f20a3606201b1835affc523ff2828549d0285 100644 (file)
@@ -265,7 +265,8 @@ FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
        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.
+       already been staged. If used together with `--allow-empty`
+       paths are also not required, and an empty commit will be created.
 
 -u[<mode>]::
 --untracked-files[=<mode>]::
index d45f6adc69fef8d99d9297c04bba532cd79a1c71..f7ebe36a7b2c203e0b2f320309a5ce6250b12471 100644 (file)
@@ -119,9 +119,9 @@ be in a separate packet, and the list must end with a flush packet.
        $GIT_DIR (e.g. "HEAD", "refs/heads/master").  When
        unspecified, update from all heads the remote side has.
 +
-If the remote has enabled the options `uploadpack.allowTipSHA1InWant` or
-`uploadpack.allowReachableSHA1InWant`, they may alternatively be 40-hex
-sha1s present on the remote.
+If the remote has enabled the options `uploadpack.allowTipSHA1InWant`,
+`uploadpack.allowReachableSHA1InWant`, or `uploadpack.allowAnySHA1InWant`,
+they may alternatively be 40-hex sha1s present on the remote.
 
 SEE ALSO
 --------
index 9e4216999d69f448b50d238d22e09289c6780661..b153aefa68c8dcaa5f3600d67c5ff0010ee899af 100644 (file)
@@ -192,6 +192,8 @@ The first command fetches the `maint` branch from the repository at
 objects will eventually be removed by git's built-in housekeeping (see
 linkgit:git-gc[1]).
 
+include::transfer-data-leaks.txt[]
+
 BUGS
 ----
 Using --recurse-submodules can only fetch new commits in already checked
index f57e69bc83e33e3de3d02e339fd71066b93e7d4d..abe13f3bedaf55dbefc03d26b934351107ff50af 100644 (file)
@@ -79,6 +79,9 @@ OPTIONS
        Only list refs which contain the specified commit (HEAD if not
        specified).
 
+--ignore-case::
+       Sorting and filtering refs are case insensitive.
+
 FIELD NAMES
 -----------
 
@@ -165,6 +168,8 @@ of all lines of the commit message up to the first blank line.  The next
 line is 'contents:body', where body is all of the lines after the first
 blank line.  The optional GPG signature is `contents:signature`.  The
 first `N` lines of the message is obtained using `contents:lines=N`.
+Additionally, the trailers as interpreted by linkgit:git-interpret-trailers[1]
+are obtained as 'contents:trailers'.
 
 For sorting purposes, fields with numeric values sort in numeric order
 (`objectsize`, `authordate`, `committerdate`, `creatordate`, `taggerdate`).
index bed60f471cd5736b173a2c636717cd566c1e4511..852b72c679e4193d5fed46b926a6456ef49cc4b1 100644 (file)
@@ -63,11 +63,10 @@ automatic consolidation of packs.
 --prune=<date>::
        Prune loose objects older than date (default is 2 weeks ago,
        overridable by the config variable `gc.pruneExpire`).
-       --prune=all prunes loose objects regardless of their age (do
-       not use --prune=all unless you know exactly what you are doing.
-       Unless the repository is quiescent, you will lose newly created
-       objects that haven't been anchored with the refs and end up
-       corrupting your repository).  --prune is on by default.
+       --prune=all prunes loose objects regardless of their age and
+       increases the risk of corruption if another process is writing to
+       the repository concurrently; see "NOTES" below. --prune is on by
+       default.
 
 --no-prune::
        Do not prune any loose objects.
@@ -138,17 +137,36 @@ default is "2 weeks ago".
 Notes
 -----
 
-'git gc' tries very hard to be safe about the garbage it collects. In
+'git gc' tries very hard not to delete objects that are referenced
+anywhere in your repository. In
 particular, it will keep not only objects referenced by your current set
 of branches and tags, but also objects referenced by the index,
 remote-tracking branches, refs saved by 'git filter-branch' in
 refs/original/, or reflogs (which may reference commits in branches
 that were later amended or rewound).
-
-If you are expecting some objects to be collected and they aren't, check
+If you are expecting some objects to be deleted and they aren't, check
 all of those locations and decide whether it makes sense in your case to
 remove those references.
 
+On the other hand, when 'git gc' runs concurrently with another process,
+there is a risk of it deleting an object that the other process is using
+but hasn't created a reference to. This may just cause the other process
+to fail or may corrupt the repository if the other process later adds a
+reference to the deleted object. Git has two features that significantly
+mitigate this problem:
+
+. Any object with modification time newer than the `--prune` date is kept,
+  along with everything reachable from it.
+
+. Most operations that add an object to the database update the
+  modification time of the object if it is already present so that #1
+  applies.
+
+However, these features fall short of a complete solution, so users who
+run commands concurrently have to live with some risk of corruption (which
+seems to be low in practice) unless they turn off automatic garbage
+collection with 'git config gc.auto 0'.
+
 HOOKS
 -----
 
index 0ecea6e4912f635e2825e8c02a14aef191cd91f1..71f32f35089241bc452cfdccdc6b3e9a30f95366 100644 (file)
@@ -26,6 +26,7 @@ SYNOPSIS
           [--threads <num>]
           [-f <file>] [-e] <pattern>
           [--and|--or|--not|(|)|-e <pattern>...]
+          [--recurse-submodules] [--parent-basename <basename>]
           [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...]
           [--] [<pathspec>...]
 
@@ -88,6 +89,19 @@ OPTIONS
        mechanism.  Only useful when searching files in the current directory
        with `--no-index`.
 
+--recurse-submodules::
+       Recursively search in each submodule that has been initialized and
+       checked out in the repository.  When used in combination with the
+       <tree> option the prefix of all submodule output will be the name of
+       the parent project's <tree> object.
+
+--parent-basename <basename>::
+       For internal use only.  In order to produce uniform output with the
+       --recurse-submodules option, this option can be used to provide the
+       basename of a parent's <tree> object to a submodule so the submodule
+       can prefix its output with the parent's name rather than the SHA1 of
+       the submodule.
+
 -a::
 --text::
        Process binary files as if they were text.
index b758d5556caaeeb0a439d67c46100e5fa0d34cd4..ca3c27b88a4ea0dde17ed2e7f260ca6158a50073 100644 (file)
@@ -15,6 +15,7 @@ SYNOPSIS
        [--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
 'git merge' <msg> HEAD <commit>...
 'git merge' --abort
+'git merge' --continue
 
 DESCRIPTION
 -----------
@@ -61,6 +62,8 @@ reconstruct the original (pre-merge) changes. Therefore:
 discouraged: while possible, it may leave you in a state that is hard to
 back out of in the case of a conflict.
 
+The fourth syntax ("`git merge --continue`") can only be run after the
+merge has resulted in conflicts.
 
 OPTIONS
 -------
@@ -99,6 +102,11 @@ commit or stash your changes before running 'git merge'.
 'git merge --abort' is equivalent to 'git reset --merge' when
 `MERGE_HEAD` is present.
 
+--continue::
+       After a 'git merge' stops due to conflicts you can conclude the
+       merge by running 'git merge --continue' (see "HOW TO RESOLVE
+       CONFLICTS" section below).
+
 <commit>...::
        Commits, usually other branch heads, to merge into our branch.
        Specifying more than one commit will create a merge with
index 5352cae4b48948926b042ee5ef59ba1b148ba462..7436c64a95616d84af9922958e4ccacd0c28519a 100644 (file)
@@ -303,6 +303,15 @@ These options can be used to modify 'git p4 submit' behavior.
        submit manually or revert.  This option always stops after the
        first (oldest) commit.  Git tags are not exported to p4.
 
+--shelve::
+       Instead of submitting create a series of shelved changelists.
+       After creating each shelve, the relevant files are reverted/deleted.
+       If you have multiple commits pending multiple shelves will be created.
+
+--update-shelve CHANGELIST::
+       Update an existing shelved changelist with this commit. Implies
+       --shelve.
+
 --conflict=(ask|skip|quit)::
        Conflicts can occur when applying a commit to p4.  When this
        happens, the default behavior ("ask") is to prompt whether to
index d033b258e5ee7c6e16c7d96c6339282a849b1b02..4470e4b5747f2474868fc0322823fff6aa25b841 100644 (file)
@@ -237,6 +237,8 @@ If you tried a pull which resulted in complex conflicts and
 would want to start over, you can recover with 'git reset'.
 
 
+include::transfer-data-leaks.txt[]
+
 BUGS
 ----
 Using --recurse-submodules can only fetch new commits in already checked
index 47b77e693bca1675a4887bddb5147077d60805a0..8eefabd0d1610eadf9d459817e2457d2ce2dd6d9 100644 (file)
@@ -559,6 +559,8 @@ Commits A and B would no longer belong to a branch with a symbolic name,
 and so would be unreachable.  As such, these commits would be removed by
 a `git gc` command on the origin repository.
 
+include::transfer-data-leaks.txt[]
+
 GIT
 ---
 Part of the linkgit:git[1] suite
index de222c81af98c96678841f258342fe2cc3c426a8..67d48e68831561303c4f39f46bf105371ed0d916 100644 (file)
@@ -12,7 +12,7 @@ SYNOPSIS
        [<upstream> [<branch>]]
 'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
        --root [<branch>]
-'git rebase' --continue | --skip | --abort | --edit-todo
+'git rebase' --continue | --skip | --abort | --quit | --edit-todo
 
 DESCRIPTION
 -----------
@@ -252,6 +252,11 @@ leave out at most one of A and B, in which case it defaults to HEAD.
        will be reset to where it was when the rebase operation was
        started.
 
+--quit::
+       Abort the rebase operation but HEAD is not reset back to the
+       original branch. The index and working tree are also left
+       unchanged as a result.
+
 --keep-empty::
        Keep the commits that do not change anything from its
        parents in the result.
index 31af7f27360d277ccdc3e5bd59b4788c83934b8e..ee6c5476c1d2bf3b2a708e6152ebaba5882cc4f7 100644 (file)
@@ -47,6 +47,10 @@ OPTIONS
 
        Each pretty-printed commit will be rewrapped before it is shown.
 
+-c::
+--committer::
+       Collect and show committer identities instead of authors.
+
 -w[<width>[,<indent1>[,<indent2>]]]::
        Linewrap the output by wrapping each line at `width`.  The first
        line of each entry is indented by `indent1` spaces, and the second
index d8415734753e0d03f3f6d37bd4b76369d37f5fb0..918bd1d1bd062ae16c00509a1ac1051714f9ca51 100644 (file)
@@ -22,6 +22,7 @@ SYNOPSIS
              [commit] [--] [<path>...]
 'git submodule' [--quiet] foreach [--recursive] <command>
 'git submodule' [--quiet] sync [--recursive] [--] [<path>...]
+'git submodule' [--quiet] absorbgitdirs [--] [<path>...]
 
 
 DESCRIPTION
@@ -245,6 +246,20 @@ sync::
 If `--recursive` is specified, this command will recurse into the
 registered submodules, and sync any nested submodules within.
 
+absorbgitdirs::
+       If a git directory of a submodule is inside the submodule,
+       move the git directory of the submodule into its superprojects
+       `$GIT_DIR/modules` path and then connect the git directory and
+       its working directory by setting the `core.worktree` and adding
+       a .git file pointing to the git directory embedded in the
+       superprojects git directory.
++
+A repository that was cloned independently and later added as a submodule or
+old setups have the submodules git directory inside the submodule instead of
+embedded into the superprojects git directory.
++
+This command is recursive by default.
+
 OPTIONS
 -------
 -q::
index 5f9e65b0c4de117942babf0a14d255922d02b4ad..9bee9b0c4c53692bab569577d584797c0bd9e217 100644 (file)
@@ -664,13 +664,19 @@ creating the branch or tag.
        When retrieving svn commits into Git (as part of 'fetch', 'rebase', or
        'dcommit' operations), look for the first `From:` or `Signed-off-by:` line
        in the log message and use that as the author string.
++
+[verse]
+config key: svn.useLogAuthor
+
 --add-author-from::
        When committing to svn from Git (as part of 'commit-diff', 'set-tree' or 'dcommit'
        operations), if the existing log message doesn't already have a
        `From:` or `Signed-off-by:` line, append a `From:` line based on the
        Git commit's author string.  If you use this, then `--use-log-author`
        will retrieve a valid author string for all commits.
-
++
+[verse]
+config key: svn.addAuthorFrom
 
 ADVANCED OPTIONS
 ----------------
index 80019c584b11b35b2b14da83a31f326634bc6708..76cfe40d969bc5f37dce674f43857ec89f25ae67 100644 (file)
@@ -108,6 +108,10 @@ OPTIONS
        variable if it exists, or lexicographic order otherwise. See
        linkgit:git-config[1].
 
+-i::
+--ignore-case::
+       Sorting and filtering tags are case insensitive.
+
 --column[=<options>]::
 --no-column::
        Display tag listing in columns. See configuration variable
index af191c51b1d63d995cfba0784de36d98a23de838..4f208fab925cc00535c23c40d38ad6e3d56eeaab 100644 (file)
@@ -44,9 +44,10 @@ 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.11.0/git.html[documentation for release 2.11]
+* link:v2.11.1/git.html[documentation for release 2.11.1]
 
 * release notes for
+  link:RelNotes/2.11.1.txt[2.11.1],
   link:RelNotes/2.11.0.txt[2.11].
 
 * link:v2.10.2/git.html[documentation for release 2.10.2]
@@ -871,6 +872,12 @@ Git so take care if using a foreign front-end.
        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.
++
+       Entries that begin with `"` (double-quote) will be interpreted
+       as C-style quoted paths, removing leading and trailing
+       double-quotes and respecting backslash escapes. E.g., the value
+       `"path-with-\"-and-:-in-it":vanilla-path` has two paths:
+       `path-with-"-and-:-in-it` and `vanilla-path`.
 
 `GIT_DIR`::
        If the `GIT_DIR` environment variable is set then it
@@ -1155,30 +1162,20 @@ of clones and fetches.
        cloning a repository to make a backup).
 
 `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
-       repository. Any protocol not mentioned will be disallowed (i.e.,
-       this is a whitelist, not a blacklist). If the variable is not
-       set at all, all protocols are enabled.  The protocol names
-       currently used by git are:
-
-         - `file`: any local file-based path (including `file://` URLs,
-           or local paths)
-
-         - `git`: the anonymous git protocol over a direct TCP
-           connection (or proxy, if configured)
-
-         - `ssh`: git over ssh (including `host:path` syntax,
-           `ssh://`, etc).
-
-         - `http`: git over http, both "smart http" and "dumb http".
-           Note that this does _not_ include `https`; if you want both,
-           you should specify both as `http:https`.
-
-         - any external helpers are named by their protocol (e.g., use
-           `hg` to allow the `git-remote-hg` helper)
-
+       If set to a colon-separated list of protocols, behave as if
+       `protocol.allow` is set to `never`, and each of the listed
+       protocols has `protocol.<name>.allow` set to `always`
+       (overriding any existing configuration). In other words, any
+       protocol not mentioned will be disallowed (i.e., this is a
+       whitelist, not a blacklist). See the description of
+       `protocol.allow` in linkgit:git-config[1] for more details.
+
+`GIT_PROTOCOL_FROM_USER`::
+       Set to 0 to prevent protocols used by fetch/push/clone which are
+       configured to the `user` state.  This is useful to restrict recursive
+       submodule initialization from an untrusted repository or for programs
+       which feed potentially-untrusted URLS to git commands.  See
+       linkgit:git-config[1] for more details.
 
 Discussion[[Discussion]]
 ------------------------
index 976243a63e6ee4c4627a8a0db77bab2846d17f40..e0b66c1220a7d22ef5b8eb960a4e2e389a71f884 100644 (file)
@@ -435,7 +435,9 @@ to filter relative to the repository root. Right after the flush packet
 Git sends the content split in zero or more pkt-line packets and a
 flush packet to terminate content. Please note, that the filter
 must not send any response before it received the content and the
-final flush packet.
+final flush packet. Also note that the "value" of a "key=value" pair
+can contain the "=" character whereas the key would never contain
+that character.
 ------------------------
 packet:          git> command=smudge
 packet:          git> pathname=path/testfile.dat
index 4546fa0d751705c27c88448ec3e7beb954233280..22309cfb48a6754d6bb4831cafc2981a8da7310b 100644 (file)
@@ -25,7 +25,7 @@ you want to understand Git's internals.
 The core Git is often called "plumbing", with the prettier user
 interfaces on top of it called "porcelain". You may not want to use the
 plumbing directly very often, but it can be good to know what the
-plumbing does for when the porcelain isn't flushing.
+plumbing does when the porcelain isn't flushing.
 
 Back when this document was originally written, many porcelain
 commands were shell scripts. For simplicity, it still uses them as
@@ -1368,7 +1368,7 @@ $ git repack
 will do it for you. If you followed the tutorial examples, you
 would have accumulated about 17 objects in `.git/objects/??/`
 directories by now. 'git repack' tells you how many objects it
-packed, and stores the packed file in `.git/objects/pack`
+packed, and stores the packed file in the `.git/objects/pack`
 directory.
 
 [NOTE]
@@ -1478,7 +1478,7 @@ You can repack this private repository whenever you feel like.
 A recommended work cycle for a "subsystem maintainer" who works
 on that project and has an own "public repository" goes like this:
 
-1. Prepare your work repository, by 'git clone' the public
+1. Prepare your work repository, by running 'git clone' on the public
    repository of the "project lead". The URL used for the
    initial cloning is stored in the remote.origin.url
    configuration variable.
@@ -1543,9 +1543,9 @@ like this:
 Working with Others, Shared Repository Style
 --------------------------------------------
 
-If you are coming from CVS background, the style of cooperation
+If you are coming from CVS background, the style of cooperation
 suggested in the previous section may be new to you. You do not
-have to worry. Git supports "shared public repository" style of
+have to worry. Git supports the "shared public repository" style of
 cooperation you are probably more familiar with as well.
 
 See linkgit:gitcvs-migration[7] for the details.
@@ -1635,7 +1635,7 @@ $ git show-branch
 ++* [master~2] Pretty-print messages.
 ------------
 
-Note that you should not do Octopus because you can.  An octopus
+Note that you should not do Octopus just because you can.  An octopus
 is a valid thing to do and often makes it easier to view the
 commit history if you are merging more than two independent
 changes at the same time.  However, if you have merge conflicts
index 7685e3651ae0c63c9fe00f43957ef60648419db3..b614969ad2c12b5c4ed337617d7f4dd559a4d278 100644 (file)
@@ -61,22 +61,4 @@ For a simple local test, you can use linkgit:git-remote-ext[1]:
 git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
 ----------
 
-SECURITY
---------
-
-Anyone with access to any namespace within a repository can potentially
-access objects from any other namespace stored in the same repository.
-You can't directly say "give me object ABCD" if you don't have a ref to
-it, but you can do some other sneaky things like:
-
-. Claiming to push ABCD, at which point the server will optimize out the
-  need for you to actually send it. Now you have a ref to ABCD and can
-  fetch it (claiming not to have it, of course).
-
-. Requesting other refs, claiming that you have ABCD, at which point the
-  server may generate deltas against ABCD.
-
-None of this causes a problem if you only host public repositories, or
-if everyone who may read one namespace may also read everything in every
-other namespace (for instance, if everyone in an organization has read
-permission to every repository).
+include::transfer-data-leaks.txt[]
index 3bcee2ddb1244c7ef52888d1de2654a688f6702f..47b286b33e4edd937fe6f7cbe727713e0e61e324 100644 (file)
@@ -199,6 +199,8 @@ endif::git-rev-list[]
   than given and there are spaces on its left, use those spaces
 - '%><(<N>)', '%><|(<N>)': similar to '% <(<N>)', '%<|(<N>)'
   respectively, but padding both sides (i.e. the text is centered)
+-%(trailers): display the trailers of the body as interpreted by
+  linkgit:git-interpret-trailers[1]
 
 NOTE: Some placeholders may depend on other options given to the
 revision traversal engine. For example, the `%g*` reflog options will
index 941fa178dd866162b4d3e8cb0c23a17f03016bb5..3dce003fda008e61c7a91c85554f9a1cafe6106f 100644 (file)
@@ -47,16 +47,20 @@ Functions
        Can be passed to the config parsing infrastructure to parse
        local (worktree) submodule configurations.
 
-`const struct submodule *submodule_from_path(const unsigned char *commit_sha1, const char *path)`::
+`const struct submodule *submodule_from_path(const unsigned char *treeish_name, const char *path)`::
 
-       Lookup values for one submodule by its commit_sha1 and path.
+       Given a tree-ish in the superproject and a path, return the
+       submodule that is bound at the path in the named tree.
 
-`const struct submodule *submodule_from_name(const unsigned char *commit_sha1, const char *name)`::
+`const struct submodule *submodule_from_name(const unsigned char *treeish_name, const char *name)`::
 
        The same as above but lookup by name.
 
-If given the null_sha1 as commit_sha1 the local configuration of a
-submodule will be returned (e.g. consolidated values from local git
+Whenever a submodule configuration is parsed in `parse_submodule_config_option`
+via e.g. `gitmodules_config()`, it will overwrite the null_sha1 entry.
+So in the normal case, when HEAD:.gitmodules is parsed first and then overlayed
+with the repository configuration, the null_sha1 entry contains the local
+configuration of a submodule (e.g. consolidated values from local git
 configuration and the .gitmodules file in the worktree).
 
 For an example usage see test-submodule-config.c.
diff --git a/Documentation/transfer-data-leaks.txt b/Documentation/transfer-data-leaks.txt
new file mode 100644 (file)
index 0000000..914bacc
--- /dev/null
@@ -0,0 +1,30 @@
+SECURITY
+--------
+The fetch and push protocols are not designed to prevent one side from
+stealing data from the other repository that was not intended to be
+shared. If you have private data that you need to protect from a malicious
+peer, your best option is to store it in another repository. This applies
+to both clients and servers. In particular, namespaces on a server are not
+effective for read access control; you should only grant read access to a
+namespace to clients that you would trust with read access to the entire
+repository.
+
+The known attack vectors are as follows:
+
+. The victim sends "have" lines advertising the IDs of objects it has that
+  are not explicitly intended to be shared but can be used to optimize the
+  transfer if the peer also has them. The attacker chooses an object ID X
+  to steal and sends a ref to X, but isn't required to send the content of
+  X because the victim already has it. Now the victim believes that the
+  attacker has X, and it sends the content of X back to the attacker
+  later. (This attack is most straightforward for a client to perform on a
+  server, by creating a ref to X in the namespace the client has access
+  to and then fetching it. The most likely way for a server to perform it
+  on a client is to "merge" X into a public branch and hope that the user
+  does additional work on this branch and pushes it back to the server
+  without noticing the merge.)
+
+. As in #1, the attacker chooses an object ID X to steal. The victim sends
+  an object Y that the attacker already has, and the attacker falsely
+  claims to have X and not Y, so the victim sends Y as a delta against X.
+  The delta reveals regions of X that are similar to Y to the attacker.
index 520d6e66ec9f14ac1a2dedc84411398d8916ad15..f95b04bb365fb83c0366a7206ee700ba3f898f6c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v2.11.0
+DEF_VER=v2.11.GIT
 
 LF='
 '
@@ -12,7 +12,7 @@ if test -f version
 then
        VN=$(cat version) || VN="$DEF_VER"
 elif test -d ${GIT_DIR:-.git} -o -f .git &&
-       VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
+       VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
        case "$VN" in
        *$LF*) (exit 1) ;;
        v[0-9]*)
index f53fcc90d71b7e0ba95b94e9baf67d559085863c..d861bd9985dd41c24d5ff08a985c9d280d9dc07c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -338,11 +338,6 @@ all::
 #
 # Define NATIVE_CRLF if your platform uses CRLF for line endings.
 #
-# Define XDL_FAST_HASH to use an alternative line-hashing method in
-# the diff algorithm.  It gives a nice speedup if your processor has
-# fast unaligned word loads.  Does NOT work on big-endian systems!
-# Enabled by default on x86_64.
-#
 # Define GIT_USER_AGENT if you want to change how git identifies itself during
 # network interactions.  The default is "git/$(GIT_VERSION)".
 #
@@ -1485,10 +1480,6 @@ ifndef NO_MSGFMT_EXTENDED_OPTIONS
        MSGFMT += --check --statistics
 endif
 
-ifneq (,$(XDL_FAST_HASH))
-       BASIC_CFLAGS += -DXDL_FAST_HASH
-endif
-
 ifdef GMTIME_UNRELIABLE_ERRORS
        COMPAT_OBJS += compat/gmtime.o
        BASIC_CFLAGS += -DGMTIME_UNRELIABLE_ERRORS
@@ -2114,7 +2105,8 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
        --keyword=_ --keyword=N_ --keyword="Q_:1,2"
 XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
        --keyword=gettextln --keyword=eval_gettextln
-XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
+XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
+       --keyword=__ --keyword=N__ --keyword="__n:1,2"
 LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
 LOCALIZED_SH = $(SCRIPT_SH)
 LOCALIZED_SH += git-parse-remote.sh
@@ -2149,9 +2141,22 @@ endif
 po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
        $(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
 
-FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
-                       $(FIND) . \( -name .git -type d -prune \) \
-                               -o \( -name '*.[hcS]' -type f -print \) )
+FIND_SOURCE_FILES = ( \
+       git ls-files \
+               '*.[hcS]' \
+               '*.sh' \
+               ':!*[tp][0-9][0-9][0-9][0-9]*' \
+               ':!contrib' \
+               2>/dev/null || \
+       $(FIND) . \
+               \( -name .git -type d -prune \) \
+               -o \( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \) \
+               -o \( -name contrib -type d -prune \) \
+               -o \( -name build -type d -prune \) \
+               -o \( -name 'trash*' -type d -prune \) \
+               -o \( -name '*.[hcS]' -type f -print \) \
+               -o \( -name '*.sh' -type f -print \) \
+       )
 
 $(ETAGS_TARGET): FORCE
        $(RM) $(ETAGS_TARGET)
index bd8a918a9bcbd46590078d98a66f3d7e939df3fb..c0cd5580ea48cf4818781bb8d4d7c2d9d5d63ae6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ requests, comments and patches to git@vger.kernel.org (read
 [Documentation/SubmittingPatches][] for instructions on patch submission).
 To subscribe to the list, send an email with just "subscribe git" in
 the body to majordomo@vger.kernel.org. The mailing list archives are
-available at http://news.gmane.org/gmane.comp.version-control.git/,
+available at https://public-inbox.org/git,
 http://marc.info/?l=git and other archival sites.
 
 The maintainer frequently sends the "What's cooking" reports that
index b54330f7cdb37630dc47d6bdb71e847b8a947c17..d09c3d51093ac9e4da65e8a127b17ac9023520b5 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.11.0.txt
\ No newline at end of file
+Documentation/RelNotes/2.12.0.txt
\ No newline at end of file
index 2825de85912fc730d9a40fa66f4f83b6250a4171..1d56f5ed9f95002d018458c907625fff27472231 100644 (file)
--- a/abspath.c
+++ b/abspath.c
@@ -11,46 +11,81 @@ int is_directory(const char *path)
        return (!stat(path, &st) && S_ISDIR(st.st_mode));
 }
 
+/* removes the last path component from 'path' except if 'path' is root */
+static void strip_last_component(struct strbuf *path)
+{
+       size_t offset = offset_1st_component(path->buf);
+       size_t len = path->len;
+
+       /* Find start of the last component */
+       while (offset < len && !is_dir_sep(path->buf[len - 1]))
+               len--;
+       /* Skip sequences of multiple path-separators */
+       while (offset < len && is_dir_sep(path->buf[len - 1]))
+               len--;
+
+       strbuf_setlen(path, len);
+}
+
+/* get (and remove) the next component in 'remaining' and place it in 'next' */
+static void get_next_component(struct strbuf *next, struct strbuf *remaining)
+{
+       char *start = NULL;
+       char *end = NULL;
+
+       strbuf_reset(next);
+
+       /* look for the next component */
+       /* Skip sequences of multiple path-separators */
+       for (start = remaining->buf; is_dir_sep(*start); start++)
+               ; /* nothing */
+       /* Find end of the path component */
+       for (end = start; *end && !is_dir_sep(*end); end++)
+               ; /* nothing */
+
+       strbuf_add(next, start, end - start);
+       /* remove the component from 'remaining' */
+       strbuf_remove(remaining, 0, end - remaining->buf);
+}
+
+/* copies root part from remaining to resolved, canonicalizing it on the way */
+static void get_root_part(struct strbuf *resolved, struct strbuf *remaining)
+{
+       int offset = offset_1st_component(remaining->buf);
+
+       strbuf_reset(resolved);
+       strbuf_add(resolved, remaining->buf, offset);
+#ifdef GIT_WINDOWS_NATIVE
+       convert_slashes(resolved->buf);
+#endif
+       strbuf_remove(remaining, 0, offset);
+}
+
 /* We allow "recursive" symbolic links. Only within reason, though. */
-#define MAXDEPTH 5
+#define MAXSYMLINKS 5
 
 /*
  * Return the real path (i.e., absolute path, with symlinks resolved
  * and extra slashes removed) equivalent to the specified path.  (If
  * you want an absolute path but don't mind links, use
- * absolute_path().)  The return value is a pointer to a static
- * buffer.
+ * absolute_path().)  Places the resolved realpath in the provided strbuf.
  *
- * The input and all intermediate paths must be shorter than MAX_PATH.
  * The directory part of path (i.e., everything up to the last
  * dir_sep) must denote a valid, existing directory, but the last
  * component need not exist.  If die_on_error is set, then die with an
  * informative error message if there is a problem.  Otherwise, return
  * NULL on errors (without generating any output).
- *
- * If path is our buffer, then return path, as it's already what the
- * user wants.
  */
-static const char *real_path_internal(const char *path, int die_on_error)
+char *strbuf_realpath(struct strbuf *resolved, const char *path,
+                     int die_on_error)
 {
-       static struct strbuf sb = STRBUF_INIT;
+       struct strbuf remaining = STRBUF_INIT;
+       struct strbuf next = STRBUF_INIT;
+       struct strbuf symlink = STRBUF_INIT;
        char *retval = NULL;
-
-       /*
-        * If we have to temporarily chdir(), store the original CWD
-        * here so that we can chdir() back to it at the end of the
-        * function:
-        */
-       struct strbuf cwd = STRBUF_INIT;
-
-       int depth = MAXDEPTH;
-       char *last_elem = NULL;
+       int num_symlinks = 0;
        struct stat st;
 
-       /* We've already done it */
-       if (path == sb.buf)
-               return path;
-
        if (!*path) {
                if (die_on_error)
                        die("The empty string is not a valid path");
@@ -58,86 +93,134 @@ static const char *real_path_internal(const char *path, int die_on_error)
                        goto error_out;
        }
 
-       strbuf_reset(&sb);
-       strbuf_addstr(&sb, path);
-
-       while (depth--) {
-               if (!is_directory(sb.buf)) {
-                       char *last_slash = find_last_dir_sep(sb.buf);
-                       if (last_slash) {
-                               last_elem = xstrdup(last_slash + 1);
-                               strbuf_setlen(&sb, last_slash - sb.buf + 1);
-                       } else {
-                               last_elem = xmemdupz(sb.buf, sb.len);
-                               strbuf_reset(&sb);
-                       }
+       strbuf_addstr(&remaining, path);
+       get_root_part(resolved, &remaining);
+
+       if (!resolved->len) {
+               /* relative path; can use CWD as the initial resolved path */
+               if (strbuf_getcwd(resolved)) {
+                       if (die_on_error)
+                               die_errno("unable to get current working directory");
+                       else
+                               goto error_out;
                }
+       }
 
-               if (sb.len) {
-                       if (!cwd.len && strbuf_getcwd(&cwd)) {
+       /* Iterate over the remaining path components */
+       while (remaining.len > 0) {
+               get_next_component(&next, &remaining);
+
+               if (next.len == 0) {
+                       continue; /* empty component */
+               } else if (next.len == 1 && !strcmp(next.buf, ".")) {
+                       continue; /* '.' component */
+               } else if (next.len == 2 && !strcmp(next.buf, "..")) {
+                       /* '..' component; strip the last path component */
+                       strip_last_component(resolved);
+                       continue;
+               }
+
+               /* append the next component and resolve resultant path */
+               if (!is_dir_sep(resolved->buf[resolved->len - 1]))
+                       strbuf_addch(resolved, '/');
+               strbuf_addbuf(resolved, &next);
+
+               if (lstat(resolved->buf, &st)) {
+                       /* error out unless this was the last component */
+                       if (errno != ENOENT || remaining.len) {
                                if (die_on_error)
-                                       die_errno("Could not get current working directory");
+                                       die_errno("Invalid path '%s'",
+                                                 resolved->buf);
                                else
                                        goto error_out;
                        }
+               } else if (S_ISLNK(st.st_mode)) {
+                       ssize_t len;
+                       strbuf_reset(&symlink);
 
-                       if (chdir(sb.buf)) {
+                       if (num_symlinks++ > MAXSYMLINKS) {
                                if (die_on_error)
-                                       die_errno("Could not switch to '%s'",
-                                                 sb.buf);
+                                       die("More than %d nested symlinks "
+                                           "on path '%s'", MAXSYMLINKS, path);
                                else
                                        goto error_out;
                        }
-               }
-               if (strbuf_getcwd(&sb)) {
-                       if (die_on_error)
-                               die_errno("Could not get current working directory");
-                       else
-                               goto error_out;
-               }
-
-               if (last_elem) {
-                       if (sb.len && !is_dir_sep(sb.buf[sb.len - 1]))
-                               strbuf_addch(&sb, '/');
-                       strbuf_addstr(&sb, last_elem);
-                       free(last_elem);
-                       last_elem = NULL;
-               }
 
-               if (!lstat(sb.buf, &st) && S_ISLNK(st.st_mode)) {
-                       struct strbuf next_sb = STRBUF_INIT;
-                       ssize_t len = strbuf_readlink(&next_sb, sb.buf, 0);
+                       len = strbuf_readlink(&symlink, resolved->buf,
+                                             st.st_size);
                        if (len < 0) {
                                if (die_on_error)
                                        die_errno("Invalid symlink '%s'",
-                                                 sb.buf);
+                                                 resolved->buf);
                                else
                                        goto error_out;
                        }
-                       strbuf_swap(&sb, &next_sb);
-                       strbuf_release(&next_sb);
-               } else
-                       break;
+
+                       if (is_absolute_path(symlink.buf)) {
+                               /* absolute symlink; set resolved to root */
+                               get_root_part(resolved, &symlink);
+                       } else {
+                               /*
+                                * relative symlink
+                                * strip off the last component since it will
+                                * be replaced with the contents of the symlink
+                                */
+                               strip_last_component(resolved);
+                       }
+
+                       /*
+                        * if there are still remaining components to resolve
+                        * then append them to symlink
+                        */
+                       if (remaining.len) {
+                               strbuf_addch(&symlink, '/');
+                               strbuf_addbuf(&symlink, &remaining);
+                       }
+
+                       /*
+                        * use the symlink as the remaining components that
+                        * need to be resloved
+                        */
+                       strbuf_swap(&symlink, &remaining);
+               }
        }
 
-       retval = sb.buf;
+       retval = resolved->buf;
+
 error_out:
-       free(last_elem);
-       if (cwd.len && chdir(cwd.buf))
-               die_errno("Could not change back to '%s'", cwd.buf);
-       strbuf_release(&cwd);
+       strbuf_release(&remaining);
+       strbuf_release(&next);
+       strbuf_release(&symlink);
+
+       if (!retval)
+               strbuf_reset(resolved);
 
        return retval;
 }
 
 const char *real_path(const char *path)
 {
-       return real_path_internal(path, 1);
+       static struct strbuf realpath = STRBUF_INIT;
+       return strbuf_realpath(&realpath, path, 1);
 }
 
 const char *real_path_if_valid(const char *path)
 {
-       return real_path_internal(path, 0);
+       static struct strbuf realpath = STRBUF_INIT;
+       return strbuf_realpath(&realpath, path, 0);
+}
+
+char *real_pathdup(const char *path)
+{
+       struct strbuf realpath = STRBUF_INIT;
+       char *retval = NULL;
+
+       if (strbuf_realpath(&realpath, path, 0))
+               retval = strbuf_detach(&realpath, NULL);
+
+       strbuf_release(&realpath);
+
+       return retval;
 }
 
 /*
diff --git a/apply.c b/apply.c
index 705cf562f07098aafcd9f6e27105d2105714751f..2ed808d429969ff9516ba1bf166c3fdfa6d63ed5 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -4688,7 +4688,7 @@ static int apply_patch(struct apply_state *state,
                                                                 state->index_file,
                                                                 LOCK_DIE_ON_ERROR);
                else
-                       state->newfd = hold_locked_index(state->lock_file, 1);
+                       state->newfd = hold_locked_index(state->lock_file, LOCK_DIE_ON_ERROR);
        }
 
        if (state->check_index && read_apply_cache(state) < 0) {
index 21bc6daa4393cb33994ba2eb305354e56d166cc0..8e63c40d274d7693b0c41e702cbe9ed03b1d12ae 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -747,7 +747,7 @@ static void handle_bad_merge_base(void)
                exit(3);
        }
 
-       fprintf(stderr, _("Some %s revs are not ancestor of the %s rev.\n"
+       fprintf(stderr, _("Some %s revs are not ancestors of the %s rev.\n"
                "git bisect cannot work properly in this case.\n"
                "Maybe you mistook %s and %s revs?\n"),
                term_good, term_bad, term_good, term_bad);
index 0d459b3cfe507b3906760fbea7f35e6191366057..c431cbf6a9f08dedc791317cc1a357730bdf3515 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -348,7 +348,7 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree)
 int replace_each_worktree_head_symref(const char *oldref, const char *newref)
 {
        int ret = 0;
-       struct worktree **worktrees = get_worktrees();
+       struct worktree **worktrees = get_worktrees(0);
        int i;
 
        for (i = 0; worktrees[i]; i++) {
index e8fb80b36e7386fa9a9da91a61893c14ec696be4..9f53f020d0fc7184ac803a4346bdf426a814ed72 100644 (file)
@@ -361,7 +361,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        add_new_files = !take_worktree_changes && !refresh_only;
        require_pathspec = !(take_worktree_changes || (0 < addremove_explicit));
 
-       hold_locked_index(&lock_file, 1);
+       hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
 
        flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
                 (show_only ? ADD_CACHE_PRETEND : 0) |
index 6981f42ce986dc5a9fa76bed8364cee7c6c642aa..31fb60578f6caacfb376fe84938dda9432dcfc5a 100644 (file)
@@ -1119,7 +1119,7 @@ static void refresh_and_write_cache(void)
 {
        struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
-       hold_locked_index(lock_file, 1);
+       hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
        refresh_cache(REFRESH_QUIET);
        if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
                die(_("unable to write index file"));
@@ -1976,7 +1976,7 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)
                return -1;
 
        lock_file = xcalloc(1, sizeof(struct lock_file));
-       hold_locked_index(lock_file, 1);
+       hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
 
        refresh_cache(REFRESH_QUIET);
 
@@ -2016,7 +2016,7 @@ static int merge_tree(struct tree *tree)
                return -1;
 
        lock_file = xcalloc(1, sizeof(struct lock_file));
-       hold_locked_index(lock_file, 1);
+       hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
 
        memset(&opts, 0, sizeof(opts));
        opts.head_idx = 1;
@@ -2124,7 +2124,7 @@ static int safe_to_abort(const struct am_state *state)
 
        if (read_state_file(&sb, state, "abort-safety", 1) > 0) {
                if (get_oid_hex(sb.buf, &abort_safety))
-                       die(_("could not parse %s"), am_path(state, "abort_safety"));
+                       die(_("could not parse %s"), am_path(state, "abort-safety"));
        } else
                oidclr(&abort_safety);
 
@@ -2134,7 +2134,7 @@ static int safe_to_abort(const struct am_state *state)
        if (!oidcmp(&head, &abort_safety))
                return 1;
 
-       error(_("You seem to have moved HEAD since the last 'am' failure.\n"
+       warning(_("You seem to have moved HEAD since the last 'am' failure.\n"
                "Not rewinding to ORIG_HEAD"));
 
        return 0;
index 4ddfadb71f7ef93958e2f236e166212e8b6bda2b..ab54a5c1f48ffcb87193eafb69d45a0f8d378c5e 100644 (file)
@@ -2596,8 +2596,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
                 * and are only included here to get included in the "-h"
                 * output:
                 */
-               { OPTION_LOWLEVEL_CALLBACK, 0, "indent-heuristic", NULL, NULL, N_("Use an experimental indent-based heuristic to improve diffs"), PARSE_OPT_NOARG, parse_opt_unknown_cb },
-               { OPTION_LOWLEVEL_CALLBACK, 0, "compaction-heuristic", NULL, NULL, N_("Use an experimental blank-line-based heuristic to improve diffs"), PARSE_OPT_NOARG, parse_opt_unknown_cb },
+               { OPTION_LOWLEVEL_CALLBACK, 0, "indent-heuristic", NULL, NULL, N_("Use an experimental heuristic to improve diffs"), PARSE_OPT_NOARG, parse_opt_unknown_cb },
 
                OPT_BIT(0, "minimal", &xdl_opts, N_("Spend extra cycles to find better match"), XDF_NEED_MINIMAL),
                OPT_STRING('S', NULL, &revs_file, N_("file"), N_("Use revisions from <file> instead of calling git-rev-list")),
@@ -2645,7 +2644,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        }
 parse_done:
        no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
-       xdl_opts |= revs.diffopt.xdl_opts & (XDF_COMPACTION_HEURISTIC | XDF_INDENT_HEURISTIC);
+       xdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;
        DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
        argc = parse_options_end(&ctx);
 
index 60cc5c8e8da08e628d05f245003bc558657f6237..9d30f55b0b83cfc09294e2cb7cabdc9aa72e2508 100644 (file)
@@ -512,15 +512,6 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
        if (filter->verbose)
                maxwidth = calc_maxwidth(&array, strlen(remote_prefix));
 
-       /*
-        * If no sorting parameter is given then we default to sorting
-        * by 'refname'. This would give us an alphabetically sorted
-        * array with the 'HEAD' ref at the beginning followed by
-        * local branches 'refs/heads/...' and finally remote-tacking
-        * branches 'refs/remotes/...'.
-        */
-       if (!sorting)
-               sorting = ref_default_sorting();
        ref_array_sort(sorting, &array);
 
        for (i = 0; i < array.nr; i++)
@@ -531,7 +522,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 
 static void reject_rebase_or_bisect_branch(const char *target)
 {
-       struct worktree **worktrees = get_worktrees();
+       struct worktree **worktrees = get_worktrees(0);
        int i;
 
        for (i = 0; worktrees[i]; i++) {
@@ -645,6 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        const char *new_upstream = NULL;
        enum branch_track track;
        struct ref_filter filter;
+       int icase = 0;
        static struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
 
        struct option options[] = {
@@ -686,6 +678,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                        OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
                        N_("print only branches of the object"), 0, parse_opt_object_name
                },
+               OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                OPT_END(),
        };
 
@@ -723,6 +716,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
        if (filter.abbrev == -1)
                filter.abbrev = DEFAULT_ABBREV;
+       filter.ignore_case = icase;
+
        finalize_colopts(&colopts, -1);
        if (filter.verbose) {
                if (explicitly_enable_column(colopts))
@@ -744,6 +739,16 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
                        filter.kind |= FILTER_REFS_DETACHED_HEAD;
                filter.name_patterns = argv;
+               /*
+                * If no sorting parameter is given then we default to sorting
+                * by 'refname'. This would give us an alphabetically sorted
+                * array with the 'HEAD' ref at the beginning followed by
+                * local branches 'refs/heads/...' and finally remote-tacking
+                * branches 'refs/remotes/...'.
+                */
+               if (!sorting)
+                       sorting = ref_default_sorting();
+               sorting->ignore_case = icase;
                print_ref_list(&filter, sorting);
                print_columns(&output, colopts, NULL);
                string_list_clear(&output, 0);
index 30a49d9f424c0a1e04b321b5eb0a5e25462a53af..07631d0c9c59f6ba03f288294797e08cdfe22b7c 100644 (file)
@@ -205,7 +205,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
        if (index_opt && !state.base_dir_len && !to_tempfile) {
                state.refresh_cache = 1;
                state.istate = &the_index;
-               newfd = hold_locked_index(&lock_file, 1);
+               newfd = hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
        }
 
        /* Check out named files first */
index 512492aad9099dd2a7aa85391b5c9a8e321c3bfe..bfe685c198cd38b59ffe66fa6b3d3a7bced60824 100644 (file)
@@ -274,7 +274,7 @@ static int checkout_paths(const struct checkout_opts *opts,
 
        lock_file = xcalloc(1, sizeof(struct lock_file));
 
-       hold_locked_index(lock_file, 1);
+       hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
        if (read_cache_preload(&opts->pathspec) < 0)
                return error(_("index file corrupt"));
 
@@ -467,7 +467,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
        int ret;
        struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
-       hold_locked_index(lock_file, 1);
+       hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
        if (read_cache_preload(NULL) < 0)
                return error(_("index file corrupt"));
 
index 0371010afbad54283ceca9883f2a9fbe6da4686b..d6bc3aaaea0dfdbac2386d54f4ff2d25dbccf7e6 100644 (file)
@@ -287,11 +287,11 @@ static void pretty_print_menus(struct string_list *menu_list)
 static void prompt_help_cmd(int singleton)
 {
        clean_print_color(CLEAN_COLOR_HELP);
-       printf_ln(singleton ?
+       printf(singleton ?
                  _("Prompt help:\n"
                    "1          - select a numbered item\n"
                    "foo        - select item based on unique prefix\n"
-                   "           - (empty) select nothing") :
+                   "           - (empty) select nothing\n") :
                  _("Prompt help:\n"
                    "1          - select a single item\n"
                    "3-5        - select a range of items\n"
@@ -299,7 +299,7 @@ static void prompt_help_cmd(int singleton)
                    "foo        - select item based on unique prefix\n"
                    "-...       - unselect specified items\n"
                    "*          - choose all items\n"
-                   "           - (empty) finish selecting"));
+                   "           - (empty) finish selecting\n"));
        clean_print_color(CLEAN_COLOR_RESET);
 }
 
@@ -508,7 +508,7 @@ static int parse_choice(struct menu_stuff *menu_stuff,
                if (top <= 0 || bottom <= 0 || top > menu_stuff->nr || bottom > top ||
                    (is_single && bottom != top)) {
                        clean_print_color(CLEAN_COLOR_ERROR);
-                       printf_ln(_("Huh (%s)?"), (*ptr)->buf);
+                       printf(_("Huh (%s)?\n"), (*ptr)->buf);
                        clean_print_color(CLEAN_COLOR_RESET);
                        continue;
                }
@@ -774,7 +774,7 @@ static int ask_each_cmd(void)
 static int quit_cmd(void)
 {
        string_list_clear(&del_list, 0);
-       printf_ln(_("Bye."));
+       printf(_("Bye.\n"));
        return MENU_RETURN_NO_LOOP;
 }
 
index 6c76a6ed66fef567ca06e3e864b37fc3bed151d5..5ef81927a629985aa4f0de6acba326f79747e7aa 100644 (file)
@@ -99,7 +99,7 @@ static struct option builtin_clone_options[] = {
        OPT_STRING(0, "shallow-since", &option_since, N_("time"),
                    N_("create a shallow clone since a specific time")),
        OPT_STRING_LIST(0, "shallow-exclude", &option_not, N_("revision"),
-                       N_("deepen history of shallow clone by excluding rev")),
+                       N_("deepen history of shallow clone, excluding rev")),
        OPT_BOOL(0, "single-branch", &option_single_branch,
                    N_("clone only one branch, HEAD or --branch")),
        OPT_BOOL(0, "shallow-submodules", &option_shallow_submodules,
@@ -711,7 +711,7 @@ static int checkout(int submodule_progress)
        setup_work_tree();
 
        lock_file = xcalloc(1, sizeof(struct lock_file));
-       hold_locked_index(lock_file, 1);
+       hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
 
        memset(&opts, 0, sizeof opts);
        opts.update = 1;
index 8976c3d29bf817be789f983697f7052fe5769f39..711f96cc438c0125290a587a0187702121bc461d 100644 (file)
@@ -351,7 +351,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 
        if (interactive) {
                char *old_index_env = NULL;
-               hold_locked_index(&index_lock, 1);
+               hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 
                refresh_cache_or_die(refresh_flags);
 
@@ -396,7 +396,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
         * (B) on failure, rollback the real index.
         */
        if (all || (also && pathspec.nr)) {
-               hold_locked_index(&index_lock, 1);
+               hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
                add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
                refresh_cache_or_die(refresh_flags);
                update_main_cache_tree(WRITE_TREE_SILENT);
@@ -416,7 +416,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
         * We still need to refresh the index here.
         */
        if (!only && !pathspec.nr) {
-               hold_locked_index(&index_lock, 1);
+               hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
                refresh_cache_or_die(refresh_flags);
                if (active_cache_changed
                    || !cache_tree_fully_valid(active_cache_tree))
@@ -468,7 +468,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
        if (read_cache() < 0)
                die(_("cannot read the index"));
 
-       hold_locked_index(&index_lock, 1);
+       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
        add_remove_files(&partial);
        refresh_cache(REFRESH_QUIET);
        update_main_cache_tree(WRITE_TREE_SILENT);
@@ -790,7 +790,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                strbuf_stripspace(&sb, 0);
 
        if (signoff)
-               append_signoff(&sb, ignore_non_trailer(&sb), 0);
+               append_signoff(&sb, ignore_non_trailer(sb.buf, sb.len), 0);
 
        if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
                die_errno(_("could not write commit template"));
@@ -1206,10 +1206,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
 
        if (also + only + all + interactive > 1)
                die(_("Only one of --include/--only/--all/--interactive/--patch can be used."));
-       if (argc == 0 && (also || (only && !amend)))
+       if (argc == 0 && (also || (only && !amend && !allow_empty)))
                die(_("No paths with --include/--only does not make sense."));
-       if (argc == 0 && only && amend)
-               only_include_assumed = _("Clever... amending the last one with dirty index.");
        if (argc > 0 && !also && !only)
                only_include_assumed = _("Explicit paths specified without -i or -o; assuming --only paths...");
        if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
index b6a5597cbf332fc56b5feabfd29d03c98d4d6686..f1570e346434e8695e80ba568c28b1363b2c0cb5 100644 (file)
@@ -122,7 +122,7 @@ static struct option builtin_fetch_options[] = {
        OPT_STRING(0, "shallow-since", &deepen_since, N_("time"),
                   N_("deepen history of shallow repository based on time")),
        OPT_STRING_LIST(0, "shallow-exclude", &deepen_not, N_("revision"),
-                       N_("deepen history of shallow clone by excluding rev")),
+                       N_("deepen history of shallow clone, excluding rev")),
        OPT_INTEGER(0, "deepen", &deepen_relative,
                    N_("deepen history of shallow clone")),
        { OPTION_SET_INT, 0, "unshallow", &unshallow, NULL,
@@ -359,9 +359,6 @@ static struct ref *get_ref_map(struct transport *transport,
 
                for (i = 0; i < fetch_refspec_nr; i++)
                        get_fetch_map(ref_map, &fetch_refspec[i], &oref_tail, 1);
-
-               if (tags == TAGS_SET)
-                       get_fetch_map(remote_refs, tag_refspec, &tail, 0);
        } else if (refmap_array) {
                die("--refmap option is only meaningful with command-line refspec(s).");
        } else {
index 4e9f6c29bf1e0c1cc7b44548f49077c2e4a81ec8..df41fa035004e1cf8a0c7c9ff09081a47b944f38 100644 (file)
@@ -18,7 +18,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
        int i;
        const char *format = "%(objectname) %(objecttype)\t%(refname)";
        struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
-       int maxcount = 0, quote_style = 0;
+       int maxcount = 0, quote_style = 0, icase = 0;
        struct ref_array array;
        struct ref_filter filter;
 
@@ -43,6 +43,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                OPT_MERGED(&filter, N_("print only refs that are merged")),
                OPT_NO_MERGED(&filter, N_("print only refs that are not merged")),
                OPT_CONTAINS(&filter.with_commit, N_("print only refs which contain the commit")),
+               OPT_BOOL(0, "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                OPT_END(),
        };
 
@@ -63,6 +64,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
 
        if (!sorting)
                sorting = ref_default_sorting();
+       sorting->ignore_case = icase;
+       filter.ignore_case = icase;
 
        /* for warn_ambiguous_refs */
        git_config(git_default_config, NULL);
index 8887b6addb5f9085dd9ed46a9e5ad81768c551cb..2c727ef499c0fa7b44c0cf1890cc44427dc8921f 100644 (file)
 #include "quote.h"
 #include "dir.h"
 #include "pathspec.h"
+#include "submodule.h"
+#include "submodule-config.h"
 
 static char const * const grep_usage[] = {
        N_("git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]"),
        NULL
 };
 
+static const char *super_prefix;
+static int recurse_submodules;
+static struct argv_array submodule_options = ARGV_ARRAY_INIT;
+static const char *parent_basename;
+
+static int grep_submodule_launch(struct grep_opt *opt,
+                                const struct grep_source *gs);
+
 #define GREP_NUM_THREADS_DEFAULT 8
 static int num_threads;
 
@@ -174,7 +184,10 @@ static void *run(void *arg)
                        break;
 
                opt->output_priv = w;
-               hit |= grep_source(opt, &w->source);
+               if (w->source.type == GREP_SOURCE_SUBMODULE)
+                       hit |= grep_submodule_launch(opt, &w->source);
+               else
+                       hit |= grep_source(opt, &w->source);
                grep_source_clear_data(&w->source);
                work_done(w);
        }
@@ -300,6 +313,10 @@ static int grep_sha1(struct grep_opt *opt, const unsigned char *sha1,
        if (opt->relative && opt->prefix_length) {
                quote_path_relative(filename + tree_name_len, opt->prefix, &pathbuf);
                strbuf_insert(&pathbuf, 0, filename, tree_name_len);
+       } else if (super_prefix) {
+               strbuf_add(&pathbuf, filename, tree_name_len);
+               strbuf_addstr(&pathbuf, super_prefix);
+               strbuf_addstr(&pathbuf, filename + tree_name_len);
        } else {
                strbuf_addstr(&pathbuf, filename);
        }
@@ -328,10 +345,13 @@ static int grep_file(struct grep_opt *opt, const char *filename)
 {
        struct strbuf buf = STRBUF_INIT;
 
-       if (opt->relative && opt->prefix_length)
+       if (opt->relative && opt->prefix_length) {
                quote_path_relative(filename, opt->prefix, &buf);
-       else
+       } else {
+               if (super_prefix)
+                       strbuf_addstr(&buf, super_prefix);
                strbuf_addstr(&buf, filename);
+       }
 
 #ifndef NO_PTHREADS
        if (num_threads) {
@@ -378,31 +398,310 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
                exit(status);
 }
 
-static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int cached)
+static void compile_submodule_options(const struct grep_opt *opt,
+                                     const struct pathspec *pathspec,
+                                     int cached, int untracked,
+                                     int opt_exclude, int use_index,
+                                     int pattern_type_arg)
+{
+       struct grep_pat *pattern;
+       int i;
+
+       if (recurse_submodules)
+               argv_array_push(&submodule_options, "--recurse-submodules");
+
+       if (cached)
+               argv_array_push(&submodule_options, "--cached");
+       if (!use_index)
+               argv_array_push(&submodule_options, "--no-index");
+       if (untracked)
+               argv_array_push(&submodule_options, "--untracked");
+       if (opt_exclude > 0)
+               argv_array_push(&submodule_options, "--exclude-standard");
+
+       if (opt->invert)
+               argv_array_push(&submodule_options, "-v");
+       if (opt->ignore_case)
+               argv_array_push(&submodule_options, "-i");
+       if (opt->word_regexp)
+               argv_array_push(&submodule_options, "-w");
+       switch (opt->binary) {
+       case GREP_BINARY_NOMATCH:
+               argv_array_push(&submodule_options, "-I");
+               break;
+       case GREP_BINARY_TEXT:
+               argv_array_push(&submodule_options, "-a");
+               break;
+       default:
+               break;
+       }
+       if (opt->allow_textconv)
+               argv_array_push(&submodule_options, "--textconv");
+       if (opt->max_depth != -1)
+               argv_array_pushf(&submodule_options, "--max-depth=%d",
+                                opt->max_depth);
+       if (opt->linenum)
+               argv_array_push(&submodule_options, "-n");
+       if (!opt->pathname)
+               argv_array_push(&submodule_options, "-h");
+       if (!opt->relative)
+               argv_array_push(&submodule_options, "--full-name");
+       if (opt->name_only)
+               argv_array_push(&submodule_options, "-l");
+       if (opt->unmatch_name_only)
+               argv_array_push(&submodule_options, "-L");
+       if (opt->null_following_name)
+               argv_array_push(&submodule_options, "-z");
+       if (opt->count)
+               argv_array_push(&submodule_options, "-c");
+       if (opt->file_break)
+               argv_array_push(&submodule_options, "--break");
+       if (opt->heading)
+               argv_array_push(&submodule_options, "--heading");
+       if (opt->pre_context)
+               argv_array_pushf(&submodule_options, "--before-context=%d",
+                                opt->pre_context);
+       if (opt->post_context)
+               argv_array_pushf(&submodule_options, "--after-context=%d",
+                                opt->post_context);
+       if (opt->funcname)
+               argv_array_push(&submodule_options, "-p");
+       if (opt->funcbody)
+               argv_array_push(&submodule_options, "-W");
+       if (opt->all_match)
+               argv_array_push(&submodule_options, "--all-match");
+       if (opt->debug)
+               argv_array_push(&submodule_options, "--debug");
+       if (opt->status_only)
+               argv_array_push(&submodule_options, "-q");
+
+       switch (pattern_type_arg) {
+       case GREP_PATTERN_TYPE_BRE:
+               argv_array_push(&submodule_options, "-G");
+               break;
+       case GREP_PATTERN_TYPE_ERE:
+               argv_array_push(&submodule_options, "-E");
+               break;
+       case GREP_PATTERN_TYPE_FIXED:
+               argv_array_push(&submodule_options, "-F");
+               break;
+       case GREP_PATTERN_TYPE_PCRE:
+               argv_array_push(&submodule_options, "-P");
+               break;
+       case GREP_PATTERN_TYPE_UNSPECIFIED:
+               break;
+       }
+
+       for (pattern = opt->pattern_list; pattern != NULL;
+            pattern = pattern->next) {
+               switch (pattern->token) {
+               case GREP_PATTERN:
+                       argv_array_pushf(&submodule_options, "-e%s",
+                                        pattern->pattern);
+                       break;
+               case GREP_AND:
+               case GREP_OPEN_PAREN:
+               case GREP_CLOSE_PAREN:
+               case GREP_NOT:
+               case GREP_OR:
+                       argv_array_push(&submodule_options, pattern->pattern);
+                       break;
+               /* BODY and HEAD are not used by git-grep */
+               case GREP_PATTERN_BODY:
+               case GREP_PATTERN_HEAD:
+                       break;
+               }
+       }
+
+       /*
+        * Limit number of threads for child process to use.
+        * This is to prevent potential fork-bomb behavior of git-grep as each
+        * submodule process has its own thread pool.
+        */
+       argv_array_pushf(&submodule_options, "--threads=%d",
+                        (num_threads + 1) / 2);
+
+       /* Add Pathspecs */
+       argv_array_push(&submodule_options, "--");
+       for (i = 0; i < pathspec->nr; i++)
+               argv_array_push(&submodule_options,
+                               pathspec->items[i].original);
+}
+
+/*
+ * Launch child process to grep contents of a submodule
+ */
+static int grep_submodule_launch(struct grep_opt *opt,
+                                const struct grep_source *gs)
+{
+       struct child_process cp = CHILD_PROCESS_INIT;
+       int status, i;
+       const char *end_of_base;
+       const char *name;
+       struct work_item *w = opt->output_priv;
+
+       end_of_base = strchr(gs->name, ':');
+       if (gs->identifier && end_of_base)
+               name = end_of_base + 1;
+       else
+               name = gs->name;
+
+       prepare_submodule_repo_env(&cp.env_array);
+       argv_array_push(&cp.env_array, GIT_DIR_ENVIRONMENT);
+
+       /* Add super prefix */
+       argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
+                        super_prefix ? super_prefix : "",
+                        name);
+       argv_array_push(&cp.args, "grep");
+
+       /*
+        * Add basename of parent project
+        * When performing grep on a tree object the filename is prefixed
+        * with the object's name: 'tree-name:filename'.  In order to
+        * provide uniformity of output we want to pass the name of the
+        * parent project's object name to the submodule so the submodule can
+        * prefix its output with the parent's name and not its own SHA1.
+        */
+       if (gs->identifier && end_of_base)
+               argv_array_pushf(&cp.args, "--parent-basename=%.*s",
+                                (int) (end_of_base - gs->name),
+                                gs->name);
+
+       /* Add options */
+       for (i = 0; i < submodule_options.argc; i++) {
+               /*
+                * If there is a tree identifier for the submodule, add the
+                * rev after adding the submodule options but before the
+                * pathspecs.  To do this we listen for the '--' and insert the
+                * sha1 before pushing the '--' onto the child process argv
+                * array.
+                */
+               if (gs->identifier &&
+                   !strcmp("--", submodule_options.argv[i])) {
+                       argv_array_push(&cp.args, sha1_to_hex(gs->identifier));
+               }
+
+               argv_array_push(&cp.args, submodule_options.argv[i]);
+       }
+
+       cp.git_cmd = 1;
+       cp.dir = gs->path;
+
+       /*
+        * Capture output to output buffer and check the return code from the
+        * child process.  A '0' indicates a hit, a '1' indicates no hit and
+        * anything else is an error.
+        */
+       status = capture_command(&cp, &w->out, 0);
+       if (status && (status != 1)) {
+               /* flush the buffer */
+               write_or_die(1, w->out.buf, w->out.len);
+               die("process for submodule '%s' failed with exit code: %d",
+                   gs->name, status);
+       }
+
+       /* invert the return code to make a hit equal to 1 */
+       return !status;
+}
+
+/*
+ * Prep grep structures for a submodule grep
+ * sha1: the sha1 of the submodule or NULL if using the working tree
+ * filename: name of the submodule including tree name of parent
+ * path: location of the submodule
+ */
+static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
+                         const char *filename, const char *path)
+{
+       if (!is_submodule_initialized(path))
+               return 0;
+       if (!is_submodule_populated(path)) {
+               /*
+                * If searching history, check for the presense of the
+                * submodule's gitdir before skipping the submodule.
+                */
+               if (sha1) {
+                       const struct submodule *sub =
+                                       submodule_from_path(null_sha1, path);
+                       if (sub)
+                               path = git_path("modules/%s", sub->name);
+
+                       if (!(is_directory(path) && is_git_directory(path)))
+                               return 0;
+               } else {
+                       return 0;
+               }
+       }
+
+#ifndef NO_PTHREADS
+       if (num_threads) {
+               add_work(opt, GREP_SOURCE_SUBMODULE, filename, path, sha1);
+               return 0;
+       } else
+#endif
+       {
+               struct work_item w;
+               int hit;
+
+               grep_source_init(&w.source, GREP_SOURCE_SUBMODULE,
+                                filename, path, sha1);
+               strbuf_init(&w.out, 0);
+               opt->output_priv = &w;
+               hit = grep_submodule_launch(opt, &w.source);
+
+               write_or_die(1, w.out.buf, w.out.len);
+
+               grep_source_clear(&w.source);
+               strbuf_release(&w.out);
+               return hit;
+       }
+}
+
+static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
+                     int cached)
 {
        int hit = 0;
        int nr;
+       struct strbuf name = STRBUF_INIT;
+       int name_base_len = 0;
+       if (super_prefix) {
+               name_base_len = strlen(super_prefix);
+               strbuf_addstr(&name, super_prefix);
+       }
+
        read_cache();
 
        for (nr = 0; nr < active_nr; nr++) {
                const struct cache_entry *ce = active_cache[nr];
-               if (!S_ISREG(ce->ce_mode))
-                       continue;
-               if (!ce_path_match(ce, pathspec, NULL))
+               strbuf_setlen(&name, name_base_len);
+               strbuf_addstr(&name, ce->name);
+
+               if (S_ISREG(ce->ce_mode) &&
+                   match_pathspec(pathspec, name.buf, name.len, 0, NULL,
+                                  S_ISDIR(ce->ce_mode) ||
+                                  S_ISGITLINK(ce->ce_mode))) {
+                       /*
+                        * If CE_VALID is on, we assume worktree file and its
+                        * cache entry are identical, even if worktree file has
+                        * been modified, so use cache version instead
+                        */
+                       if (cached || (ce->ce_flags & CE_VALID) ||
+                           ce_skip_worktree(ce)) {
+                               if (ce_stage(ce) || ce_intent_to_add(ce))
+                                       continue;
+                               hit |= grep_sha1(opt, ce->oid.hash, ce->name,
+                                                0, ce->name);
+                       } else {
+                               hit |= grep_file(opt, ce->name);
+                       }
+               } else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
+                          submodule_path_match(pathspec, name.buf, NULL)) {
+                       hit |= grep_submodule(opt, NULL, ce->name, ce->name);
+               } else {
                        continue;
-               /*
-                * If CE_VALID is on, we assume worktree file and its cache entry
-                * are identical, even if worktree file has been modified, so use
-                * cache version instead
-                */
-               if (cached || (ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) {
-                       if (ce_stage(ce) || ce_intent_to_add(ce))
-                               continue;
-                       hit |= grep_sha1(opt, ce->oid.hash, ce->name, 0,
-                                        ce->name);
                }
-               else
-                       hit |= grep_file(opt, ce->name);
+
                if (ce_stage(ce)) {
                        do {
                                nr++;
@@ -413,6 +712,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
                if (hit && opt->status_only)
                        break;
        }
+
+       strbuf_release(&name);
        return hit;
 }
 
@@ -424,12 +725,22 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
        enum interesting match = entry_not_interesting;
        struct name_entry entry;
        int old_baselen = base->len;
+       struct strbuf name = STRBUF_INIT;
+       int name_base_len = 0;
+       if (super_prefix) {
+               strbuf_addstr(&name, super_prefix);
+               name_base_len = name.len;
+       }
 
        while (tree_entry(tree, &entry)) {
                int te_len = tree_entry_len(&entry);
 
                if (match != all_entries_interesting) {
-                       match = tree_entry_interesting(&entry, base, tn_len, pathspec);
+                       strbuf_addstr(&name, base->buf + tn_len);
+                       match = tree_entry_interesting(&entry, &name,
+                                                      0, pathspec);
+                       strbuf_setlen(&name, name_base_len);
+
                        if (match == all_entries_not_interesting)
                                break;
                        if (match == entry_not_interesting)
@@ -441,8 +752,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
                if (S_ISREG(entry.mode)) {
                        hit |= grep_sha1(opt, entry.oid->hash, base->buf, tn_len,
                                         check_attr ? base->buf + tn_len : NULL);
-               }
-               else if (S_ISDIR(entry.mode)) {
+               } else if (S_ISDIR(entry.mode)) {
                        enum object_type type;
                        struct tree_desc sub;
                        void *data;
@@ -458,12 +768,18 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
                        hit |= grep_tree(opt, pathspec, &sub, base, tn_len,
                                         check_attr);
                        free(data);
+               } else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
+                       hit |= grep_submodule(opt, entry.oid->hash, base->buf,
+                                             base->buf + tn_len);
                }
+
                strbuf_setlen(base, old_baselen);
 
                if (hit && opt->status_only)
                        break;
        }
+
+       strbuf_release(&name);
        return hit;
 }
 
@@ -487,6 +803,10 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
                if (!data)
                        die(_("unable to read tree (%s)"), oid_to_hex(&obj->oid));
 
+               /* Use parent's name as base when recursing submodules */
+               if (recurse_submodules && parent_basename)
+                       name = parent_basename;
+
                len = name ? strlen(name) : 0;
                strbuf_init(&base, PATH_MAX + len + 1);
                if (len) {
@@ -513,6 +833,12 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
        for (i = 0; i < nr; i++) {
                struct object *real_obj;
                real_obj = deref_tag(list->objects[i].item, NULL, 0);
+
+               /* load the gitmodules file for this rev */
+               if (recurse_submodules) {
+                       submodule_free();
+                       gitmodules_config_sha1(real_obj->oid.hash);
+               }
                if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path)) {
                        hit = 1;
                        if (opt->status_only)
@@ -651,6 +977,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        N_("search in both tracked and untracked files")),
                OPT_SET_INT(0, "exclude-standard", &opt_exclude,
                            N_("ignore files specified via '.gitignore'"), 1),
+               OPT_BOOL(0, "recurse-submodules", &recurse_submodules,
+                        N_("recursivley search in each submodule")),
+               OPT_STRING(0, "parent-basename", &parent_basename,
+                          N_("basename"),
+                          N_("prepend parent project's basename to output")),
                OPT_GROUP(""),
                OPT_BOOL('v', "invert-match", &opt.invert,
                        N_("show non-matching lines")),
@@ -755,6 +1086,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        init_grep_defaults();
        git_config(grep_cmd_config, NULL);
        grep_init(&opt, prefix);
+       super_prefix = get_super_prefix();
 
        /*
         * If there is no -- then the paths must exist in the working
@@ -872,6 +1204,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        pathspec.max_depth = opt.max_depth;
        pathspec.recursive = 1;
 
+       if (recurse_submodules) {
+               gitmodules_config();
+               compile_submodule_options(&opt, &pathspec, cached, untracked,
+                                         opt_exclude, use_index,
+                                         pattern_type_arg);
+       }
+
        if (show_in_pager && (cached || list.nr))
                die(_("--open-files-in-pager only works on the worktree"));
 
@@ -895,6 +1234,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                }
        }
 
+       if (recurse_submodules && (!use_index || untracked))
+               die(_("option not supported with --recurse-submodules."));
+
        if (!show_in_pager && !opt.status_only)
                setup_pager();
 
index 0a27bab11b6b5a1b162c4dfef34c645c7d5f14ad..f4b87c6c9f901e5834ce9e50db089fb487c6eafc 100644 (file)
@@ -787,13 +787,15 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                        const unsigned char *sha1)
 {
        void *new_data = NULL;
-       int collision_test_needed;
+       int collision_test_needed = 0;
 
        assert(data || obj_entry);
 
-       read_lock();
-       collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
-       read_unlock();
+       if (startup_info->have_repository) {
+               read_lock();
+               collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
+               read_unlock();
+       }
 
        if (collision_test_needed && !data) {
                read_lock();
@@ -1730,6 +1732,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                usage(index_pack_usage);
        if (fix_thin_pack && !from_stdin)
                die(_("--fix-thin cannot be used without --stdin"));
+       if (from_stdin && !startup_info->have_repository)
+               die(_("--stdin requires a git repository"));
        if (!index_name && pack_name)
                index_name = derive_filename(pack_name, ".idx", &index_name_buf);
        if (keep_msg && !keep_name && pack_name)
index 2399b97d902668a08c3c881d544f4d6a88f4e263..76d68fad001083d85800b937798529a1682959c9 100644 (file)
@@ -338,7 +338,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
 {
        int reinit;
        int exist_ok = flags & INIT_DB_EXIST_OK;
-       char *original_git_dir = xstrdup(real_path(git_dir));
+       char *original_git_dir = real_pathdup(git_dir);
 
        if (real_git_dir) {
                struct stat st;
@@ -489,7 +489,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
 
        if (real_git_dir && !is_absolute_path(real_git_dir))
-               real_git_dir = xstrdup(real_path(real_git_dir));
+               real_git_dir = real_pathdup(real_git_dir);
 
        if (argc == 1) {
                int mkdir_tried = 0;
@@ -560,7 +560,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                const char *git_dir_parent = strrchr(git_dir, '/');
                if (git_dir_parent) {
                        char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
-                       git_work_tree_cfg = xstrdup(real_path(rel));
+                       git_work_tree_cfg = real_pathdup(rel);
                        free(rel);
                }
                if (!git_work_tree_cfg)
index b65eeaa87d303b027230bf2479f78c15a02ca08a..a96d4fb501bf1441b52a313313b8c04f3187e4d9 100644 (file)
@@ -46,6 +46,7 @@ static const char * const builtin_merge_usage[] = {
        N_("git merge [<options>] [<commit>...]"),
        N_("git merge [<options>] <msg> HEAD <commit>"),
        N_("git merge --abort"),
+       N_("git merge --continue"),
        NULL
 };
 
@@ -65,6 +66,7 @@ static int option_renormalize;
 static int verbosity;
 static int allow_rerere_auto;
 static int abort_current_merge;
+static int continue_current_merge;
 static int allow_unrelated_histories;
 static int show_progress = -1;
 static int default_to_upstream = 1;
@@ -223,6 +225,8 @@ static struct option builtin_merge_options[] = {
        OPT__VERBOSITY(&verbosity),
        OPT_BOOL(0, "abort", &abort_current_merge,
                N_("abort the current in-progress merge")),
+       OPT_BOOL(0, "continue", &continue_current_merge,
+               N_("continue the current in-progress merge")),
        OPT_BOOL(0, "allow-unrelated-histories", &allow_unrelated_histories,
                 N_("allow merging unrelated histories")),
        OPT_SET_INT(0, "progress", &show_progress, N_("force progress reporting"), 1),
@@ -634,7 +638,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 {
        static struct lock_file lock;
 
-       hold_locked_index(&lock, 1);
+       hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
        refresh_cache(REFRESH_QUIET);
        if (active_cache_changed &&
            write_locked_index(&the_index, &lock, COMMIT_LOCK))
@@ -671,7 +675,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                for (j = common; j; j = j->next)
                        commit_list_insert(j->item, &reversed);
 
-               hold_locked_index(&lock, 1);
+               hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
                clean = merge_recursive(&o, head,
                                remoteheads->item, reversed, &result);
                if (clean < 0)
@@ -781,7 +785,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
        struct commit_list *parents, **pptr = &parents;
        static struct lock_file lock;
 
-       hold_locked_index(&lock, 1);
+       hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
        refresh_cache(REFRESH_QUIET);
        if (active_cache_changed &&
            write_locked_index(&the_index, &lock, COMMIT_LOCK))
@@ -1125,6 +1129,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        const char *best_strategy = NULL, *wt_strategy = NULL;
        struct commit_list *remoteheads, *p;
        void *branch_to_free;
+       int orig_argc = argc;
 
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_merge_usage, builtin_merge_options);
@@ -1158,6 +1163,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                int nargc = 2;
                const char *nargv[] = {"reset", "--merge", NULL};
 
+               if (orig_argc != 2)
+                       usage_msg_opt(_("--abort expects no arguments"),
+                             builtin_merge_usage, builtin_merge_options);
+
                if (!file_exists(git_path_merge_head()))
                        die(_("There is no merge to abort (MERGE_HEAD missing)."));
 
@@ -1166,6 +1175,22 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                goto done;
        }
 
+       if (continue_current_merge) {
+               int nargc = 1;
+               const char *nargv[] = {"commit", NULL};
+
+               if (orig_argc != 2)
+                       usage_msg_opt(_("--continue expects no arguments"),
+                             builtin_merge_usage, builtin_merge_options);
+
+               if (!file_exists(git_path_merge_head()))
+                       die(_("There is no merge in progress (MERGE_HEAD missing)."));
+
+               /* Invoke 'git commit' */
+               ret = cmd_commit(nargc, nargv, prefix);
+               goto done;
+       }
+
        if (read_cache_unmerged())
                die_resolve_conflict("merge");
 
index 2f43877bc9a17c5bef2906a383cc8cdd6f4f5b82..43adf92ba64426a2f312cd6133276a98b20855f1 100644 (file)
@@ -126,7 +126,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
        if (--argc < 1)
                usage_with_options(builtin_mv_usage, builtin_mv_options);
 
-       hold_locked_index(&lock_file, 1);
+       hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
        if (read_cache() < 0)
                die(_("index file corrupt"));
 
index 0fd52bd6b4b985b24d93ab7fb9887f57305b49fd..8841f8b366b4cee57d13a9086071351f849ddbba 100644 (file)
@@ -61,8 +61,6 @@ static int delta_search_threads;
 static int pack_to_stdout;
 static int num_preferred_base;
 static struct progress *progress_state;
-static int pack_compression_level = Z_DEFAULT_COMPRESSION;
-static int pack_compression_seen;
 
 static struct packed_git *reuse_packfile;
 static uint32_t reuse_packfile_objects;
@@ -2368,16 +2366,6 @@ static int git_pack_config(const char *k, const char *v, void *cb)
                depth = git_config_int(k, v);
                return 0;
        }
-       if (!strcmp(k, "pack.compression")) {
-               int level = git_config_int(k, v);
-               if (level == -1)
-                       level = Z_DEFAULT_COMPRESSION;
-               else if (level < 0 || level > Z_BEST_COMPRESSION)
-                       die("bad pack compression level %d", level);
-               pack_compression_level = level;
-               pack_compression_seen = 1;
-               return 0;
-       }
        if (!strcmp(k, "pack.deltacachesize")) {
                max_delta_cache_size = git_config_int(k, v);
                return 0;
@@ -2869,8 +2857,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 
        reset_pack_idx_option(&pack_idx_opts);
        git_config(git_pack_config, NULL);
-       if (!pack_compression_seen && core_compression_seen)
-               pack_compression_level = core_compression_level;
 
        progress = isatty(2);
        argc = parse_options(argc, argv, prefix, pack_objects_options,
index d6e46ee6d0054c152d721e92e354795c6f6002f8..3ecb881b0bcacbf1a453bf9a6cb95ae00cdecb1d 100644 (file)
@@ -857,10 +857,24 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
                if (merge_heads.nr > 1)
                        die(_("Cannot merge multiple branches into empty head."));
                return pull_into_void(*merge_heads.sha1, curr_head);
-       } else if (opt_rebase) {
-               if (merge_heads.nr > 1)
-                       die(_("Cannot rebase onto multiple branches."));
+       }
+       if (opt_rebase && merge_heads.nr > 1)
+               die(_("Cannot rebase onto multiple branches."));
+
+       if (opt_rebase) {
+               struct commit_list *list = NULL;
+               struct commit *merge_head, *head;
+
+               head = lookup_commit_reference(orig_head);
+               commit_list_insert(head, &list);
+               merge_head = lookup_commit_reference(merge_heads.sha1[0]);
+               if (is_descendant_of(merge_head, list)) {
+                       /* we can fast-forward this without invoking rebase */
+                       opt_ff = "--ff-only";
+                       return run_merge();
+               }
                return run_rebase(curr_head, *merge_heads.sha1, rebase_fork_point);
-       } else
+       } else {
                return run_merge();
+       }
 }
index 3bb9d6b7e63b3e3082023c3d333c11757df6fbda..9307ad56a9fb91455eaf06371382b1431d115598 100644 (file)
@@ -194,15 +194,18 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
                        die_push_simple(branch, remote);
        }
 
-       strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
+       strbuf_addf(&refspec, "%s:%s", branch->refname, branch->merge[0]->src);
        add_refspec(refspec.buf);
 }
 
 static void setup_push_current(struct remote *remote, struct branch *branch)
 {
+       struct strbuf refspec = STRBUF_INIT;
+
        if (!branch)
                die(_(message_detached_head_die), remote->name);
-       add_refspec(branch->name);
+       strbuf_addf(&refspec, "%s:%s", branch->refname, branch->refname);
+       add_refspec(refspec.buf);
 }
 
 static int is_workflow_triangular(struct remote *remote)
index 9bd1fd755ef03824442f6c751a9603b95bfe66ee..fa6edb35b21cede4425746d84b41c8bd9e31e1dc 100644 (file)
@@ -150,7 +150,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
        argc = parse_options(argc, argv, unused_prefix, read_tree_options,
                             read_tree_usage, 0);
 
-       hold_locked_index(&lock_file, 1);
+       hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
 
        prefix_set = opts.prefix ? 1 : 0;
        if (1 < opts.merge + opts.reset + prefix_set)
index e6b3879a5b90034937dfb8eee32f8d2981f6bb53..6b97cbdbe9444d72d575c149678e4b609a154842 100644 (file)
@@ -795,8 +795,8 @@ static char *refuse_unconfigured_deny_msg =
           "with what you pushed, and will require 'git reset --hard' to match\n"
           "the work tree to HEAD.\n"
           "\n"
-          "You can set 'receive.denyCurrentBranch' configuration variable to\n"
-          "'ignore' or 'warn' in the remote repository to allow pushing into\n"
+          "You can set the 'receive.denyCurrentBranch' configuration variable\n"
+          "to 'ignore' or 'warn' in the remote repository to allow pushing into\n"
           "its current branch; however, this is not recommended unless you\n"
           "arranged to update its work tree to match what you pushed in some\n"
           "other way.\n"
index c04ac076dc53b99039768dcdcbf2861e285896c2..8ab915bfcb71ae5d5f4bd1bebe7fd3c8725780b2 100644 (file)
@@ -354,7 +354,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 
        if (reset_type != SOFT) {
                struct lock_file *lock = xcalloc(1, sizeof(*lock));
-               hold_locked_index(lock, 1);
+               hold_locked_index(lock, LOCK_DIE_ON_ERROR);
                if (reset_type == MIXED) {
                        int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
                        if (read_from_tree(&pathspec, &oid, intent_to_add))
index cfb0f1510c59674abe68fb67ff45142b5c92ac89..ff13e59e1dbd200b6e7cf7d1c508b620b19e8cc7 100644 (file)
@@ -342,11 +342,16 @@ static int try_parent_shorthands(const char *arg)
        for (parents = commit->parents, parent_number = 1;
             parents;
             parents = parents->next, parent_number++) {
+               char *name = NULL;
+
                if (exclude_parent && parent_number != exclude_parent)
                        continue;
 
+               if (symbolic)
+                       name = xstrfmt("%s^%d", arg, parent_number);
                show_rev(include_parents ? NORMAL : REVERSED,
-                        parents->item->object.oid.hash, arg);
+                        parents->item->object.oid.hash, name);
+               free(name);
        }
 
        *dotdot = '^';
index 3f3e24eb36af03481f4e7b3f4d22d8e4b5904593..452170a3ab45d24e03ab11965448572a411c349f 100644 (file)
@@ -59,27 +59,9 @@ static void print_error_files(struct string_list *files_list,
        }
 }
 
-static void error_removing_concrete_submodules(struct string_list *files, int *errs)
-{
-       print_error_files(files,
-                         Q_("the following submodule (or one of its nested "
-                            "submodules)\n"
-                            "uses a .git directory:",
-                            "the following submodules (or one of their nested "
-                            "submodules)\n"
-                            "use a .git directory:", files->nr),
-                         _("\n(use 'rm -rf' if you really want to remove "
-                           "it including all of its history)"),
-                         errs);
-       string_list_clear(files, 0);
-}
-
-static int check_submodules_use_gitfiles(void)
+static void submodules_absorb_gitdir_if_needed(const char *prefix)
 {
        int i;
-       int errs = 0;
-       struct string_list files = STRING_LIST_INIT_NODUP;
-
        for (i = 0; i < list.nr; i++) {
                const char *name = list.entry[i].name;
                int pos;
@@ -99,12 +81,9 @@ static int check_submodules_use_gitfiles(void)
                        continue;
 
                if (!submodule_uses_gitfile(name))
-                       string_list_append(&files, name);
+                       absorb_git_dir_into_superproject(prefix, name,
+                               ABSORB_GITDIR_RECURSE_SUBMODULES);
        }
-
-       error_removing_concrete_submodules(&files, &errs);
-
-       return errs;
 }
 
 static int check_local_mod(struct object_id *head, int index_only)
@@ -120,7 +99,6 @@ static int check_local_mod(struct object_id *head, int index_only)
        int errs = 0;
        struct string_list files_staged = STRING_LIST_INIT_NODUP;
        struct string_list files_cached = STRING_LIST_INIT_NODUP;
-       struct string_list files_submodule = STRING_LIST_INIT_NODUP;
        struct string_list files_local = STRING_LIST_INIT_NODUP;
 
        no_head = is_null_oid(head);
@@ -187,7 +165,9 @@ static int check_local_mod(struct object_id *head, int index_only)
                 */
                if (ce_match_stat(ce, &st, 0) ||
                    (S_ISGITLINK(ce->ce_mode) &&
-                    !ok_to_remove_submodule(ce->name)))
+                    bad_to_remove_submodule(ce->name,
+                               SUBMODULE_REMOVAL_DIE_ON_ERROR |
+                               SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)))
                        local_changes = 1;
 
                /*
@@ -217,13 +197,8 @@ static int check_local_mod(struct object_id *head, int index_only)
                else if (!index_only) {
                        if (staged_changes)
                                string_list_append(&files_cached, name);
-                       if (local_changes) {
-                               if (S_ISGITLINK(ce->ce_mode) &&
-                                   !submodule_uses_gitfile(name))
-                                       string_list_append(&files_submodule, name);
-                               else
-                                       string_list_append(&files_local, name);
-                       }
+                       if (local_changes)
+                               string_list_append(&files_local, name);
                }
        }
        print_error_files(&files_staged,
@@ -245,8 +220,6 @@ static int check_local_mod(struct object_id *head, int index_only)
                          &errs);
        string_list_clear(&files_cached, 0);
 
-       error_removing_concrete_submodules(&files_submodule, &errs);
-
        print_error_files(&files_local,
                          Q_("the following file has local modifications:",
                             "the following files have local modifications:",
@@ -292,7 +265,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
        if (!index_only)
                setup_work_tree();
 
-       hold_locked_index(&lock_file, 1);
+       hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
 
        if (read_cache() < 0)
                die(_("index file corrupt"));
@@ -340,6 +313,9 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                        exit(0);
        }
 
+       if (!index_only)
+               submodules_absorb_gitdir_if_needed(prefix);
+
        /*
         * If not forced, the file, the index and the HEAD (if exists)
         * must match; but the file can already been removed, since
@@ -356,9 +332,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                        oidclr(&oid);
                if (check_local_mod(&oid, index_only))
                        exit(1);
-       } else if (!index_only) {
-               if (check_submodules_use_gitfiles())
-                       exit(1);
        }
 
        /*
@@ -387,32 +360,20 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
         */
        if (!index_only) {
                int removed = 0, gitmodules_modified = 0;
-               struct strbuf buf = STRBUF_INIT;
                for (i = 0; i < list.nr; i++) {
                        const char *path = list.entry[i].name;
                        if (list.entry[i].is_submodule) {
-                               if (is_empty_dir(path)) {
-                                       if (!rmdir(path)) {
-                                               removed = 1;
-                                               if (!remove_path_from_gitmodules(path))
-                                                       gitmodules_modified = 1;
-                                               continue;
-                                       }
-                               } else {
-                                       strbuf_reset(&buf);
-                                       strbuf_addstr(&buf, path);
-                                       if (!remove_dir_recursively(&buf, 0)) {
-                                               removed = 1;
-                                               if (!remove_path_from_gitmodules(path))
-                                                       gitmodules_modified = 1;
-                                               strbuf_release(&buf);
-                                               continue;
-                                       } else if (!file_exists(path))
-                                               /* Submodule was removed by user */
-                                               if (!remove_path_from_gitmodules(path))
-                                                       gitmodules_modified = 1;
-                                       /* Fallthrough and let remove_path() fail. */
-                               }
+                               struct strbuf buf = STRBUF_INIT;
+
+                               strbuf_addstr(&buf, path);
+                               if (remove_dir_recursively(&buf, 0))
+                                       die(_("could not remove '%s'"), path);
+                               strbuf_release(&buf);
+
+                               removed = 1;
+                               if (!remove_path_from_gitmodules(path))
+                                       gitmodules_modified = 1;
+                               continue;
                        }
                        if (!remove_path(path)) {
                                removed = 1;
@@ -421,7 +382,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                        if (!removed)
                                die_errno("git rm: '%s'", path);
                }
-               strbuf_release(&buf);
                if (gitmodules_modified)
                        stage_updated_gitmodules();
        }
index ba0e1154a9f0b95f60e5bcb6cdb716bf0f6ef366..c9585d475d90c41554465f870e530c16ab93199f 100644 (file)
@@ -117,11 +117,15 @@ static void read_from_stdin(struct shortlog *log)
 {
        struct strbuf author = STRBUF_INIT;
        struct strbuf oneline = STRBUF_INIT;
+       static const char *author_match[2] = { "Author: ", "author " };
+       static const char *committer_match[2] = { "Commit: ", "committer " };
+       const char **match;
 
+       match = log->committer ? committer_match : author_match;
        while (strbuf_getline_lf(&author, stdin) != EOF) {
                const char *v;
-               if (!skip_prefix(author.buf, "Author: ", &v) &&
-                   !skip_prefix(author.buf, "author ", &v))
+               if (!skip_prefix(author.buf, match[0], &v) &&
+                   !skip_prefix(author.buf, match[1], &v))
                        continue;
                while (strbuf_getline_lf(&oneline, stdin) != EOF &&
                       oneline.len)
@@ -140,6 +144,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
        struct strbuf author = STRBUF_INIT;
        struct strbuf oneline = STRBUF_INIT;
        struct pretty_print_context ctx = {0};
+       const char *fmt;
 
        ctx.fmt = CMIT_FMT_USERFORMAT;
        ctx.abbrev = log->abbrev;
@@ -148,7 +153,9 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
        ctx.date_mode.type = DATE_NORMAL;
        ctx.output_encoding = get_log_output_encoding();
 
-       format_commit_message(commit, "%an <%ae>", &author, &ctx);
+       fmt = log->committer ? "%cn <%ce>" : "%an <%ae>";
+
+       format_commit_message(commit, fmt, &author, &ctx);
        if (!log->summary) {
                if (log->user_format)
                        pretty_print_commit(&ctx, commit, &oneline);
@@ -238,6 +245,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
        int nongit = !startup_info->have_repository;
 
        const struct option options[] = {
+               OPT_BOOL('c', "committer", &log.committer,
+                        N_("Group by committer rather than author")),
                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,
index 4beeda5f9f49d6c2e2f552308b50bacf70ebd421..df0d9c166f05b27469fbd6c1ddd208ac763667d7 100644 (file)
@@ -498,9 +498,9 @@ static int add_possible_reference_from_superproject(
 
        /*
         * If the alternate object store is another repository, try the
-        * standard layout with .git/modules/<name>/objects
+        * standard layout with .git/(modules/<name>)+/objects
         */
-       if (ends_with(alt->path, ".git/objects")) {
+       if (ends_with(alt->path, "/objects")) {
                char *sm_alternate;
                struct strbuf sb = STRBUF_INIT;
                struct strbuf err = STRBUF_INIT;
@@ -583,6 +583,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
        struct strbuf rel_path = STRBUF_INIT;
        struct strbuf sb = STRBUF_INIT;
        struct string_list reference = STRING_LIST_INIT_NODUP;
+       char *sm_alternate = NULL, *error_strategy = NULL;
 
        struct option module_clone_options[] = {
                OPT_STRING(0, "prefix", &prefix,
@@ -672,6 +673,20 @@ static int module_clone(int argc, const char **argv, const char *prefix)
                die(_("could not get submodule directory for '%s'"), path);
        git_config_set_in_file(p, "core.worktree",
                               relative_path(path, sm_gitdir, &rel_path));
+
+       /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
+       git_config_get_string("submodule.alternateLocation", &sm_alternate);
+       if (sm_alternate)
+               git_config_set_in_file(p, "submodule.alternateLocation",
+                                          sm_alternate);
+       git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
+       if (error_strategy)
+               git_config_set_in_file(p, "submodule.alternateErrorStrategy",
+                                          error_strategy);
+
+       free(sm_alternate);
+       free(error_strategy);
+
        strbuf_release(&sb);
        strbuf_release(&rel_path);
        free(sm_gitdir);
@@ -1076,21 +1091,62 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,
        return 0;
 }
 
+static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
+{
+       int i;
+       struct pathspec pathspec;
+       struct module_list list = MODULE_LIST_INIT;
+       unsigned flags = ABSORB_GITDIR_RECURSE_SUBMODULES;
+
+       struct option embed_gitdir_options[] = {
+               OPT_STRING(0, "prefix", &prefix,
+                          N_("path"),
+                          N_("path into the working tree")),
+               OPT_BIT(0, "--recursive", &flags, N_("recurse into submodules"),
+                       ABSORB_GITDIR_RECURSE_SUBMODULES),
+               OPT_END()
+       };
+
+       const char *const git_submodule_helper_usage[] = {
+               N_("git submodule--helper embed-git-dir [<path>...]"),
+               NULL
+       };
+
+       argc = parse_options(argc, argv, prefix, embed_gitdir_options,
+                            git_submodule_helper_usage, 0);
+
+       gitmodules_config();
+       git_config(submodule_config, NULL);
+
+       if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
+               return 1;
+
+       for (i = 0; i < list.nr; i++)
+               absorb_git_dir_into_superproject(prefix,
+                               list.entries[i]->name, flags);
+
+       return 0;
+}
+
+#define SUPPORT_SUPER_PREFIX (1<<0)
+
 struct cmd_struct {
        const char *cmd;
        int (*fn)(int, const char **, const char *);
+       unsigned option;
 };
 
 static struct cmd_struct commands[] = {
-       {"list", module_list},
-       {"name", module_name},
-       {"clone", module_clone},
-       {"update-clone", update_clone},
-       {"relative-path", resolve_relative_path},
-       {"resolve-relative-url", resolve_relative_url},
-       {"resolve-relative-url-test", resolve_relative_url_test},
-       {"init", module_init},
-       {"remote-branch", resolve_remote_submodule_branch}
+       {"list", module_list, 0},
+       {"name", module_name, 0},
+       {"clone", module_clone, 0},
+       {"update-clone", update_clone, 0},
+       {"relative-path", resolve_relative_path, 0},
+       {"resolve-relative-url", resolve_relative_url, 0},
+       {"resolve-relative-url-test", resolve_relative_url_test, 0},
+       {"init", module_init, 0},
+       {"remote-branch", resolve_remote_submodule_branch, 0},
+       {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX},
 };
 
 int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
@@ -1100,9 +1156,15 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
                die(_("submodule--helper subcommand must be "
                      "called with a subcommand"));
 
-       for (i = 0; i < ARRAY_SIZE(commands); i++)
-               if (!strcmp(argv[1], commands[i].cmd))
+       for (i = 0; i < ARRAY_SIZE(commands); i++) {
+               if (!strcmp(argv[1], commands[i].cmd)) {
+                       if (get_super_prefix() &&
+                           !(commands[i].option & SUPPORT_SUPER_PREFIX))
+                               die(_("%s doesn't support --super-prefix"),
+                                   commands[i].cmd);
                        return commands[i].fn(argc - 1, argv + 1, prefix);
+               }
+       }
 
        die(_("'%s' is not a valid submodule--helper "
              "subcommand"), argv[1]);
index 50e4ae5678c21f348c3ce0e0d0662c9d5f995847..73df728114e81ac87dd1b84604947d739d948fb6 100644 (file)
@@ -335,6 +335,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        struct ref_filter filter;
        static struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
        const char *format = NULL;
+       int icase = 0;
        struct option options[] = {
                OPT_CMDMODE('l', "list", &cmdmode, N_("list tag names"), 'l'),
                { OPTION_INTEGER, 'n', NULL, &filter.lines, N_("n"),
@@ -370,6 +371,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                        N_("print only tags of the object"), 0, parse_opt_object_name
                },
                OPT_STRING(  0 , "format", &format, N_("format"), N_("format to use for the output")),
+               OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                OPT_END()
        };
 
@@ -401,6 +403,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        }
        if (!sorting)
                sorting = ref_default_sorting();
+       sorting->ignore_case = icase;
+       filter.ignore_case = icase;
        if (cmdmode == 'l') {
                int ret;
                if (column_active(colopts)) {
index f3f07e7f1cb2d952144bf98969b481dc331155bf..d530e89368b42bf1465784b80163b9158a06585a 100644 (file)
@@ -1012,6 +1012,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
        /* We can't free this memory, it becomes part of a linked list parsed atexit() */
        lock_file = xcalloc(1, sizeof(struct lock_file));
 
+       /* we will diagnose later if it turns out that we need to update it */
        newfd = hold_locked_index(lock_file, 0);
        if (newfd < 0)
                lock_error = errno;
index 5c4854d3e4a679f59f4a7db7cb3f37bd0e210622..9a97e37a3fa53e730f0963f8f00bbca9f6d6efc6 100644 (file)
@@ -388,7 +388,7 @@ static void show_worktree_porcelain(struct worktree *wt)
                printf("HEAD %s\n", sha1_to_hex(wt->head_sha1));
                if (wt->is_detached)
                        printf("detached\n");
-               else
+               else if (wt->head_ref)
                        printf("branch %s\n", wt->head_ref);
        }
        printf("\n");
@@ -406,10 +406,12 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
        else {
                strbuf_addf(&sb, "%-*s ", abbrev_len,
                                find_unique_abbrev(wt->head_sha1, DEFAULT_ABBREV));
-               if (!wt->is_detached)
+               if (wt->is_detached)
+                       strbuf_addstr(&sb, "(detached HEAD)");
+               else if (wt->head_ref)
                        strbuf_addf(&sb, "[%s]", shorten_unambiguous_ref(wt->head_ref, 0));
                else
-                       strbuf_addstr(&sb, "(detached HEAD)");
+                       strbuf_addstr(&sb, "(error)");
        }
        printf("%s\n", sb.buf);
 
@@ -445,7 +447,7 @@ static int list(int ac, const char **av, const char *prefix)
        if (ac)
                usage_with_options(worktree_usage, options);
        else {
-               struct worktree **worktrees = get_worktrees();
+               struct worktree **worktrees = get_worktrees(GWT_SORT_LINKED);
                int path_maxlen = 0, abbrev = DEFAULT_ABBREV, i;
 
                if (!porcelain)
@@ -476,7 +478,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
        if (ac != 1)
                usage_with_options(worktree_usage, options);
 
-       worktrees = get_worktrees();
+       worktrees = get_worktrees(0);
        wt = find_worktree(worktrees, prefix, av[0]);
        if (!wt)
                die(_("'%s' is not a working tree"), av[0]);
@@ -509,7 +511,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
        if (ac != 1)
                usage_with_options(worktree_usage, options);
 
-       worktrees = get_worktrees();
+       worktrees = get_worktrees(0);
        wt = find_worktree(worktrees, prefix, av[0]);
        if (!wt)
                die(_("'%s' is not a working tree"), av[0]);
index 4347f5c76aa72873eb5ccb090584428399f3159c..991b4a13e2491093ed9e9942ac116843973f65ff 100644 (file)
@@ -7,8 +7,6 @@
 #include "pack.h"
 #include "strbuf.h"
 
-static int pack_compression_level = Z_DEFAULT_COMPRESSION;
-
 static struct bulk_checkin_state {
        unsigned plugged:1;
 
diff --git a/cache.h b/cache.h
index a50a61a19787de94daa9d66caa9fcccca58081fe..c74df701276e92aaae71dee36da96197b2dc3316 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -670,7 +670,7 @@ extern const char *git_attributes_file;
 extern const char *git_hooks_path;
 extern int zlib_compression_level;
 extern int core_compression_level;
-extern int core_compression_seen;
+extern int pack_compression_level;
 extern size_t packed_git_window_size;
 extern size_t packed_git_limit;
 extern size_t delta_base_cache_limit;
@@ -1064,8 +1064,11 @@ static inline int is_absolute_path(const char *path)
        return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
 }
 int is_directory(const char *);
+char *strbuf_realpath(struct strbuf *resolved, const char *path,
+                     int die_on_error);
 const char *real_path(const char *path);
 const char *real_path_if_valid(const char *path);
+char *real_pathdup(const char *path);
 const char *absolute_path(const char *path);
 const char *remove_leading_path(const char *in, const char *prefix);
 const char *relative_path(const char *in, const char *prefix, struct strbuf *sb);
@@ -1125,7 +1128,8 @@ extern int write_sha1_file(const void *buf, unsigned long len, const char *type,
 extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);
 extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
-extern int git_open(const char *name);
+extern int git_open_cloexec(const char *name, int flags);
+#define git_open(name) git_open_cloexec(name, O_RDONLY)
 extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);
 extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
 extern int parse_sha1_header(const char *hdr, unsigned long *sizep);
@@ -1690,6 +1694,8 @@ extern int git_default_config(const char *, const char *, void *);
 extern int git_config_from_file(config_fn_t fn, const char *, void *);
 extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type,
                                        const char *name, const char *buf, size_t len, void *data);
+extern int git_config_from_blob_sha1(config_fn_t fn, const char *name,
+                                    const unsigned char *sha1, void *data);
 extern void git_config_push_parameter(const char *text);
 extern int git_config_from_parameters(config_fn_t fn, void *data);
 extern void git_config(config_fn_t fn, void *);
index 856fd4aeeff654c45ba0a6149f9db2c22806e0cb..2cf85158b4899b664a3cbae8d0777f5a9e473318 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -1649,7 +1649,7 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
 }
 
 /*
- * Inspect sb and determine the true "end" of the log message, in
+ * Inspect the given string and determine the true "end" of the log message, in
  * order to find where to put a new Signed-off-by: line.  Ignored are
  * trailing comment lines and blank lines, and also the traditional
  * "Conflicts:" block that is not commented out, so that we can use
@@ -1659,37 +1659,37 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
  * Returns the number of bytes from the tail to ignore, to be fed as
  * the second parameter to append_signoff().
  */
-int ignore_non_trailer(struct strbuf *sb)
+int ignore_non_trailer(const char *buf, size_t len)
 {
        int boc = 0;
        int bol = 0;
        int in_old_conflicts_block = 0;
 
-       while (bol < sb->len) {
-               char *next_line;
+       while (bol < len) {
+               const char *next_line = memchr(buf + bol, '\n', len - bol);
 
-               if (!(next_line = memchr(sb->buf + bol, '\n', sb->len - bol)))
-                       next_line = sb->buf + sb->len;
+               if (!next_line)
+                       next_line = buf + len;
                else
                        next_line++;
 
-               if (sb->buf[bol] == comment_line_char || sb->buf[bol] == '\n') {
+               if (buf[bol] == comment_line_char || buf[bol] == '\n') {
                        /* is this the first of the run of comments? */
                        if (!boc)
                                boc = bol;
                        /* otherwise, it is just continuing */
-               } else if (starts_with(sb->buf + bol, "Conflicts:\n")) {
+               } else if (starts_with(buf + bol, "Conflicts:\n")) {
                        in_old_conflicts_block = 1;
                        if (!boc)
                                boc = bol;
-               } else if (in_old_conflicts_block && sb->buf[bol] == '\t') {
+               } else if (in_old_conflicts_block && buf[bol] == '\t') {
                        ; /* a pathname in the conflicts block */
                } else if (boc) {
                        /* the previous was not trailing comment */
                        boc = 0;
                        in_old_conflicts_block = 0;
                }
-               bol = next_line - sb->buf;
+               bol = next_line - buf;
        }
-       return boc ? sb->len - boc : 0;
+       return boc ? len - boc : 0;
 }
index afd14f318c0c4d18f3a03781d3229f2fdc0f64c6..9c12abb91110151e3a982c4d8baf8753d0382441 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -355,7 +355,7 @@ extern const char *find_commit_header(const char *msg, const char *key,
                                      size_t *out_len);
 
 /* Find the end of the log message, the right place for a new trailer. */
-extern int ignore_non_trailer(struct strbuf *sb);
+extern int ignore_non_trailer(const char *buf, size_t len);
 
 typedef void (*each_mergetag_fn)(struct commit *commit, struct commit_extra_header *extra,
                                 void *cb_data);
index 034fff9479d03d2a2e3c7017a4fe4131461f0ec6..33501695550accdb08368aa867b9addb25c90d5f 100644 (file)
@@ -384,6 +384,9 @@ int mingw_raise(int sig);
  * ANSI emulation wrappers
  */
 
+int winansi_isatty(int fd);
+#define isatty winansi_isatty
+
 void winansi_init(void);
 HANDLE winansi_get_osfhandle(int fd);
 
index db4a5b0a37d687218ab085f22b57eb35e28893b8..3c9ed3cfe07c1f3b58f5400af861fb8ae44c3fdb 100644 (file)
@@ -6,6 +6,12 @@
 #include "../git-compat-util.h"
 #include <wingdi.h>
 #include <winreg.h>
+#include "win32.h"
+
+static int fd_is_interactive[3] = { 0, 0, 0 };
+#define FD_CONSOLE 0x1
+#define FD_SWAPPED 0x2
+#define FD_MSYS    0x4
 
 /*
  ANSI codes used by git: m, K
@@ -81,6 +87,7 @@ static void warn_if_raster_font(void)
 static int is_console(int fd)
 {
        CONSOLE_SCREEN_BUFFER_INFO sbi;
+       DWORD mode;
        HANDLE hcon;
 
        static int initialized = 0;
@@ -95,9 +102,15 @@ static int is_console(int fd)
                return 0;
 
        /* check if its a handle to a console output screen buffer */
-       if (!GetConsoleScreenBufferInfo(hcon, &sbi))
+       if (!fd) {
+               if (!GetConsoleMode(hcon, &mode))
+                       return 0;
+       } else if (!GetConsoleScreenBufferInfo(hcon, &sbi))
                return 0;
 
+       if (fd >= 0 && fd <= 2)
+               fd_is_interactive[fd] |= FD_CONSOLE;
+
        /* initialize attributes */
        if (!initialized) {
                console = hcon;
@@ -459,76 +472,50 @@ static HANDLE duplicate_handle(HANDLE hnd)
        return hresult;
 }
 
-
-/*
- * Make MSVCRT's internal file descriptor control structure accessible
- * so that we can tweak OS handles and flags directly (we need MSVCRT
- * to treat our pipe handle as if it were a console).
- *
- * We assume that the ioinfo structure (exposed by MSVCRT.dll via
- * __pioinfo) starts with the OS handle and the flags. The exact size
- * varies between MSVCRT versions, so we try different sizes until
- * toggling the FDEV bit of _pioinfo(1)->osflags is reflected in
- * isatty(1).
- */
-typedef struct {
-       HANDLE osfhnd;
-       char osflags;
-} ioinfo;
-
-extern __declspec(dllimport) ioinfo *__pioinfo[];
-
-static size_t sizeof_ioinfo = 0;
-
-#define IOINFO_L2E 5
-#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
-
-#define FPIPE 0x08
-#define FDEV  0x40
-
-static inline ioinfo* _pioinfo(int fd)
-{
-       return (ioinfo*)((char*)__pioinfo[fd >> IOINFO_L2E] +
-                       (fd & (IOINFO_ARRAY_ELTS - 1)) * sizeof_ioinfo);
-}
-
-static int init_sizeof_ioinfo(void)
-{
-       int istty, wastty;
-       /* don't init twice */
-       if (sizeof_ioinfo)
-               return sizeof_ioinfo >= 256;
-
-       sizeof_ioinfo = sizeof(ioinfo);
-       wastty = isatty(1);
-       while (sizeof_ioinfo < 256) {
-               /* toggle FDEV flag, check isatty, then toggle back */
-               _pioinfo(1)->osflags ^= FDEV;
-               istty = isatty(1);
-               _pioinfo(1)->osflags ^= FDEV;
-               /* return if we found the correct size */
-               if (istty != wastty)
-                       return 0;
-               sizeof_ioinfo += sizeof(void*);
-       }
-       error("Tweaking file descriptors doesn't work with this MSVCRT.dll");
-       return 1;
-}
-
 static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
 {
-       ioinfo *pioinfo;
-       HANDLE old_handle;
-
-       /* init ioinfo size if we haven't done so */
-       if (init_sizeof_ioinfo())
-               return INVALID_HANDLE_VALUE;
-
-       /* get ioinfo pointer and change the handles */
-       pioinfo = _pioinfo(fd);
-       old_handle = pioinfo->osfhnd;
-       pioinfo->osfhnd = new_handle;
-       return old_handle;
+       /*
+        * Create a copy of the original handle associated with fd
+        * because the original will get closed when we dup2().
+        */
+       HANDLE handle = (HANDLE)_get_osfhandle(fd);
+       HANDLE duplicate = duplicate_handle(handle);
+
+       /* Create a temp fd associated with the already open "new_handle". */
+       int new_fd = _open_osfhandle((intptr_t)new_handle, O_BINARY);
+
+       assert((fd == 1) || (fd == 2));
+
+       /*
+        * Use stock dup2() to re-bind fd to the new handle.  Note that
+        * this will implicitly close(1) and close both fd=1 and the
+        * originally associated handle.  It will open a new fd=1 and
+        * call DuplicateHandle() on the handle associated with new_fd.
+        * It is because of this implicit close() that we created the
+        * copy of the original.
+        *
+        * Note that the OS can recycle HANDLE (numbers) just like it
+        * recycles fd (numbers), so we must update the cached value
+        * of "console".  You can use GetFileType() to see that
+        * handle and _get_osfhandle(fd) may have the same number
+        * value, but they refer to different actual files now.
+        *
+        * Note that dup2() when given target := {0,1,2} will also
+        * call SetStdHandle(), so we don't need to worry about that.
+        */
+       dup2(new_fd, fd);
+       if (console == handle)
+               console = duplicate;
+       handle = INVALID_HANDLE_VALUE;
+
+       /* Close the temp fd.  This explicitly closes "new_handle"
+        * (because it has been associated with it).
+        */
+       close(new_fd);
+
+       fd_is_interactive[fd] |= FD_SWAPPED;
+
+       return duplicate;
 }
 
 #ifdef DETECT_MSYS_TTY
@@ -553,23 +540,37 @@ static void detect_msys_tty(int fd)
                        buffer, sizeof(buffer) - 2, &result)))
                return;
        name = nameinfo->Name.Buffer;
-       name[nameinfo->Name.Length] = 0;
-
-       /* check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX') */
-       if (!wcsstr(name, L"msys-") || !wcsstr(name, L"-pty"))
-               return;
-
-       /* init ioinfo size if we haven't done so */
-       if (init_sizeof_ioinfo())
+       name[nameinfo->Name.Length / sizeof(*name)] = 0;
+
+       /*
+        * Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
+        * or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX')
+        */
+       if ((!wcsstr(name, L"msys-") && !wcsstr(name, L"cygwin-")) ||
+                       !wcsstr(name, L"-pty"))
                return;
 
-       /* set FDEV flag, reset FPIPE flag */
-       _pioinfo(fd)->osflags &= ~FPIPE;
-       _pioinfo(fd)->osflags |= FDEV;
+       fd_is_interactive[fd] |= FD_MSYS;
 }
 
 #endif
 
+/*
+ * Wrapper for isatty().  Most calls in the main git code
+ * call isatty(1 or 2) to see if the instance is interactive
+ * and should: be colored, show progress, paginate output.
+ * We lie and give results for what the descriptor WAS at
+ * startup (and ignore any pipe redirection we internally
+ * do).
+ */
+#undef isatty
+int winansi_isatty(int fd)
+{
+       if (fd >= 0 && fd <= 2)
+               return fd_is_interactive[fd] != 0;
+       return isatty(fd);
+}
+
 void winansi_init(void)
 {
        int con1, con2;
@@ -578,6 +579,10 @@ void winansi_init(void)
        /* check if either stdout or stderr is a console output screen buffer */
        con1 = is_console(1);
        con2 = is_console(2);
+
+       /* Also compute console bit for fd 0 even though we don't need the result here. */
+       is_console(0);
+
        if (!con1 && !con2) {
 #ifdef DETECT_MSYS_TTY
                /* check if stdin / stdout / stderr are MSYS2 pty pipes */
@@ -621,12 +626,10 @@ void winansi_init(void)
  */
 HANDLE winansi_get_osfhandle(int fd)
 {
-       HANDLE hnd = (HANDLE) _get_osfhandle(fd);
-       if (isatty(fd) && GetFileType(hnd) == FILE_TYPE_PIPE) {
-               if (fd == 1 && hconsole1)
-                       return hconsole1;
-               else if (fd == 2 && hconsole2)
-                       return hconsole2;
-       }
-       return hnd;
+       if (fd == 1 && (fd_is_interactive[1] & FD_SWAPPED))
+               return hconsole1;
+       if (fd == 2 && (fd_is_interactive[2] & FD_SWAPPED))
+               return hconsole2;
+
+       return (HANDLE)_get_osfhandle(fd);
 }
index 83fdecb1bc9f6f31bc625c79c1d3c12ba5b27f77..b680f79732aa867d39a2e10ac889b5b2abfb1e7f 100644 (file)
--- a/config.c
+++ b/config.c
@@ -66,6 +66,8 @@ static struct key_value_info *current_config_kvi;
  */
 static enum config_scope current_parsing_scope;
 
+static int core_compression_seen;
+static int pack_compression_seen;
 static int zlib_compression_seen;
 
 /*
@@ -834,10 +836,16 @@ static int git_default_core_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "core.abbrev")) {
-               int abbrev = git_config_int(var, value);
-               if (abbrev < minimum_abbrev || abbrev > 40)
-                       return -1;
-               default_abbrev = abbrev;
+               if (!value)
+                       return config_error_nonbool(var);
+               if (!strcasecmp(value, "auto"))
+                       default_abbrev = -1;
+               else {
+                       int abbrev = git_config_int(var, value);
+                       if (abbrev < minimum_abbrev || abbrev > 40)
+                               return error("abbrev length out of range: %d", abbrev);
+                       default_abbrev = abbrev;
+               }
                return 0;
        }
 
@@ -865,6 +873,8 @@ static int git_default_core_config(const char *var, const char *value)
                core_compression_seen = 1;
                if (!zlib_compression_seen)
                        zlib_compression_level = level;
+               if (!pack_compression_seen)
+                       pack_compression_level = level;
                return 0;
        }
 
@@ -1125,6 +1135,18 @@ int git_default_config(const char *var, const char *value, void *dummy)
                pack_size_limit_cfg = git_config_ulong(var, value);
                return 0;
        }
+
+       if (!strcmp(var, "pack.compression")) {
+               int level = git_config_int(var, value);
+               if (level == -1)
+                       level = Z_DEFAULT_COMPRESSION;
+               else if (level < 0 || level > Z_BEST_COMPRESSION)
+                       die(_("bad pack compression level %d"), level);
+               pack_compression_level = level;
+               pack_compression_seen = 1;
+               return 0;
+       }
+
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;
 }
@@ -1214,10 +1236,10 @@ int git_config_from_mem(config_fn_t fn, const enum config_origin_type origin_typ
        return do_config_from(&top, fn, data);
 }
 
-static int git_config_from_blob_sha1(config_fn_t fn,
-                                    const char *name,
-                                    const unsigned char *sha1,
-                                    void *data)
+int git_config_from_blob_sha1(config_fn_t fn,
+                             const char *name,
+                             const unsigned char *sha1,
+                             void *data)
 {
        enum object_type type;
        char *buf;
@@ -2194,7 +2216,12 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
                        goto out_free;
                }
 
-               fstat(in_fd, &st);
+               if (fstat(in_fd, &st) == -1) {
+                       error_errno(_("fstat on %s failed"), config_filename);
+                       ret = CONFIG_INVALID_FILE;
+                       goto out_free;
+               }
+
                contents_sz = xsize_t(st.st_size);
                contents = xmmap_gently(NULL, contents_sz, PROT_READ,
                                        MAP_PRIVATE, in_fd, 0);
@@ -2396,7 +2423,7 @@ int git_config_rename_section_in_file(const char *config_filename,
 
        if (new_name && !section_name_is_ok(new_name)) {
                ret = error("invalid section name: %s", new_name);
-               goto out;
+               goto out_no_rollback;
        }
 
        if (!config_filename)
@@ -2411,10 +2438,13 @@ int git_config_rename_section_in_file(const char *config_filename,
 
        if (!(config_file = fopen(config_filename, "rb"))) {
                /* no config file means nothing to rename, no error */
-               goto unlock_and_out;
+               goto commit_and_out;
        }
 
-       fstat(fileno(config_file), &st);
+       if (fstat(fileno(config_file), &st) == -1) {
+               ret = error_errno(_("fstat on %s failed"), config_filename);
+               goto out;
+       }
 
        if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
                ret = error_errno("chmod on %s failed",
@@ -2470,11 +2500,13 @@ int git_config_rename_section_in_file(const char *config_filename,
                }
        }
        fclose(config_file);
-unlock_and_out:
+commit_and_out:
        if (commit_lock_file(lock) < 0)
                ret = error_errno("could not write config file %s",
                                  config_filename);
 out:
+       rollback_lock_file(lock);
+out_no_rollback:
        free(filename_buf);
        return ret;
 }
index b232908f8c8c2eae84bd6ef8ab2a96ac45bf94a3..447f36ac2e31dd4d11e90f326b114a78fdba8df0 100644 (file)
@@ -17,9 +17,6 @@ endif
 # because maintaining the nesting to match is a pain.  If
 # we had "elif" things would have been much nicer...
 
-ifeq ($(uname_M),x86_64)
-       XDL_FAST_HASH = YesPlease
-endif
 ifeq ($(uname_S),OSF1)
        # Need this for u_short definitions et al
        BASIC_CFLAGS += -D_OSF_SOURCE
index 21016bf8dfe87572fb53a05488ba05bb3c08ed97..6721ff80fb1324ec1cf450f7b69cbf8266880035 100644 (file)
@@ -1552,7 +1552,7 @@ _git_merge ()
        case "$cur" in
        --*)
                __gitcomp "$__git_merge_options
-                       --rerere-autoupdate --no-rerere-autoupdate --abort"
+                       --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
                return
        esac
        __gitcomp_nl "$(__git_refs)"
@@ -1734,10 +1734,10 @@ _git_rebase ()
 {
        local dir="$(__gitdir)"
        if [ -f "$dir"/rebase-merge/interactive ]; then
-               __gitcomp "--continue --skip --abort --edit-todo"
+               __gitcomp "--continue --skip --abort --quit --edit-todo"
                return
        elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
-               __gitcomp "--continue --skip --abort"
+               __gitcomp "--continue --skip --abort --quit"
                return
        fi
        __git_complete_strategy && return
index 39457055a59261c6af9ce72616fa5f74079c672d..a677569ddd95f4ce567570ad68111e37a5ed8508 100755 (executable)
@@ -81,8 +81,12 @@ sub packet_flush {
 packet_flush();
 
 while (1) {
-       my ($command)  = packet_txt_read() =~ /^command=([^=]+)$/;
-       my ($pathname) = packet_txt_read() =~ /^pathname=([^=]+)$/;
+       my ($command)  = packet_txt_read() =~ /^command=(.+)$/;
+       my ($pathname) = packet_txt_read() =~ /^pathname=(.+)$/;
+
+       if ( $pathname eq "" ) {
+               die "bad pathname '$pathname'";
+       }
 
        packet_bin_read();
 
diff --git a/contrib/update-unicode/.gitignore b/contrib/update-unicode/.gitignore
new file mode 100644 (file)
index 0000000..b0ebc6a
--- /dev/null
@@ -0,0 +1,3 @@
+uniset/
+UnicodeData.txt
+EastAsianWidth.txt
diff --git a/contrib/update-unicode/README b/contrib/update-unicode/README
new file mode 100644 (file)
index 0000000..b9e2fc8
--- /dev/null
@@ -0,0 +1,20 @@
+TL;DR: Run update_unicode.sh after the publication of a new Unicode
+standard and commit the resulting unicode_widths.h file.
+
+The long version
+================
+
+The Git source code ships the file unicode_widths.h which contains
+tables of zero and double width Unicode code points, respectively.
+These tables are generated using update_unicode.sh in this directory.
+update_unicode.sh itself uses a third-party tool, uniset, to query two
+Unicode data files for the interesting code points.
+
+On first run, update_unicode.sh clones uniset from Github and builds it.
+This requires a current-ish version of autoconf (2.69 works per December
+2016).
+
+On each run, update_unicode.sh checks whether more recent Unicode data
+files are available from the Unicode consortium, and rebuilds the header
+unicode_widths.h with the new data. The new header can then be
+committed.
diff --git a/contrib/update-unicode/update_unicode.sh b/contrib/update-unicode/update_unicode.sh
new file mode 100755 (executable)
index 0000000..e05db92
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+#See http://www.unicode.org/reports/tr44/
+#
+#Me Enclosing_Mark  an enclosing combining mark
+#Mn Nonspacing_Mark a nonspacing combining mark (zero advance width)
+#Cf Format          a format control character
+#
+cd "$(dirname "$0")"
+UNICODEWIDTH_H=$(git rev-parse --show-toplevel)/unicode_width.h
+
+wget -N http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt \
+       http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt &&
+if ! test -d uniset; then
+       git clone https://github.com/depp/uniset.git &&
+       ( cd uniset && git checkout 4b186196dd )
+fi &&
+(
+       cd uniset &&
+       if ! test -x uniset; then
+               autoreconf -i &&
+               ./configure --enable-warnings=-Werror CFLAGS='-O0 -ggdb'
+       fi &&
+       make
+) &&
+UNICODE_DIR=. && export UNICODE_DIR &&
+cat >$UNICODEWIDTH_H <<-EOF
+static const struct interval zero_width[] = {
+       $(uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD)
+};
+static const struct interval double_width[] = {
+       $(uniset/uniset --32 eaw:F,W)
+};
+EOF
index be91358462a72c9d5a6c02f2b0e44585a76d4783..4e17e45ed265b3f4861d1b7a1e86edaa4df3b1ac 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -279,15 +279,16 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
                if (convert_is_binary(len, &stats))
                        return 0;
                /*
-                * If the file in the index has any CR in it, do not convert.
-                * This is the new safer autocrlf handling.
+                * If the file in the index has any CR in it, do not
+                * convert.  This is the new safer autocrlf handling,
+                * unless we want to renormalize in a merge or
+                * cherry-pick.
                 */
-               if (checksafe == SAFE_CRLF_RENORMALIZE)
-                       checksafe = SAFE_CRLF_FALSE;
-               else if (has_cr_in_index(path))
+               if ((checksafe != SAFE_CRLF_RENORMALIZE) && has_cr_in_index(path))
                        convert_crlf_into_lf = 0;
        }
-       if (checksafe && len) {
+       if ((checksafe == SAFE_CRLF_WARN ||
+           (checksafe == SAFE_CRLF_FAIL)) && len) {
                struct text_stat new_stats;
                memcpy(&new_stats, &stats, sizeof(new_stats));
                /* simulate "git add" */
diff --git a/diff.c b/diff.c
index ec8728362dae5a3bf404f6782f9091d6a1c9a6c2..e2eb6d66a9a633e699398146e37dcbcc0b7ec81f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -28,7 +28,6 @@
 
 static int diff_detect_rename_default;
 static int diff_indent_heuristic; /* experimental */
-static int diff_compaction_heuristic; /* experimental */
 static int diff_rename_limit_default = 400;
 static int diff_suppress_blank_empty;
 static int diff_use_color_default = -1;
@@ -223,16 +222,8 @@ void init_diff_ui_defaults(void)
 
 int git_diff_heuristic_config(const char *var, const char *value, void *cb)
 {
-       if (!strcmp(var, "diff.indentheuristic")) {
+       if (!strcmp(var, "diff.indentheuristic"))
                diff_indent_heuristic = git_config_bool(var, value);
-               if (diff_indent_heuristic)
-                       diff_compaction_heuristic = 0;
-       }
-       if (!strcmp(var, "diff.compactionheuristic")) {
-               diff_compaction_heuristic = git_config_bool(var, value);
-               if (diff_compaction_heuristic)
-                       diff_indent_heuristic = 0;
-       }
        return 0;
 }
 
@@ -3106,7 +3097,8 @@ static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
                        abbrev = FALLBACK_DEFAULT_ABBREV;
                if (abbrev > GIT_SHA1_HEXSZ)
                        die("BUG: oid abbreviation out of range: %d", abbrev);
-               hex[abbrev] = '\0';
+               if (abbrev)
+                       hex[abbrev] = '\0';
                return hex;
        }
 }
@@ -3364,6 +3356,7 @@ void diff_setup(struct diff_options *options)
 
        options->file = stdout;
 
+       options->abbrev = DEFAULT_ABBREV;
        options->line_termination = '\n';
        options->break_opt = -1;
        options->rename_limit = -1;
@@ -3380,8 +3373,6 @@ void diff_setup(struct diff_options *options)
        options->xdl_opts |= diff_algorithm;
        if (diff_indent_heuristic)
                DIFF_XDL_SET(options, INDENT_HEURISTIC);
-       else if (diff_compaction_heuristic)
-               DIFF_XDL_SET(options, COMPACTION_HEURISTIC);
 
        options->orderfile = diff_order_file_cfg;
 
@@ -3876,16 +3867,10 @@ int diff_opt_parse(struct diff_options *options,
                DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);
        else if (!strcmp(arg, "--ignore-blank-lines"))
                DIFF_XDL_SET(options, IGNORE_BLANK_LINES);
-       else if (!strcmp(arg, "--indent-heuristic")) {
+       else if (!strcmp(arg, "--indent-heuristic"))
                DIFF_XDL_SET(options, INDENT_HEURISTIC);
-               DIFF_XDL_CLR(options, COMPACTION_HEURISTIC);
-       } else if (!strcmp(arg, "--no-indent-heuristic"))
-               DIFF_XDL_CLR(options, INDENT_HEURISTIC);
-       else if (!strcmp(arg, "--compaction-heuristic")) {
-               DIFF_XDL_SET(options, COMPACTION_HEURISTIC);
+       else if (!strcmp(arg, "--no-indent-heuristic"))
                DIFF_XDL_CLR(options, INDENT_HEURISTIC);
-       } else if (!strcmp(arg, "--no-compaction-heuristic"))
-               DIFF_XDL_CLR(options, COMPACTION_HEURISTIC);
        else if (!strcmp(arg, "--patience"))
                options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
        else if (!strcmp(arg, "--histogram"))
@@ -4024,6 +4009,8 @@ int diff_opt_parse(struct diff_options *options,
                            offending, optarg);
                return argcount;
        }
+       else if (!strcmp(arg, "--no-abbrev"))
+               options->abbrev = 0;
        else if (!strcmp(arg, "--abbrev"))
                options->abbrev = DEFAULT_ABBREV;
        else if (skip_prefix(arg, "--abbrev=", &arg)) {
diff --git a/dir.c b/dir.c
index bfa8c8a9a51297c3a969c8706467504cb11ce51b..d872cc1570989bf22d8bd5d741d817372e76018f 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -2748,3 +2748,40 @@ void untracked_cache_add_to_index(struct index_state *istate,
 {
        untracked_cache_invalidate_path(istate, path);
 }
+
+/* Update gitfile and core.worktree setting to connect work tree and git dir */
+void connect_work_tree_and_git_dir(const char *work_tree_, const char *git_dir_)
+{
+       struct strbuf file_name = STRBUF_INIT;
+       struct strbuf rel_path = STRBUF_INIT;
+       char *git_dir = xstrdup(real_path(git_dir_));
+       char *work_tree = xstrdup(real_path(work_tree_));
+
+       /* Update gitfile */
+       strbuf_addf(&file_name, "%s/.git", work_tree);
+       write_file(file_name.buf, "gitdir: %s",
+                  relative_path(git_dir, work_tree, &rel_path));
+
+       /* Update core.worktree setting */
+       strbuf_reset(&file_name);
+       strbuf_addf(&file_name, "%s/config", git_dir);
+       git_config_set_in_file(file_name.buf, "core.worktree",
+                              relative_path(work_tree, git_dir, &rel_path));
+
+       strbuf_release(&file_name);
+       strbuf_release(&rel_path);
+       free(work_tree);
+       free(git_dir);
+}
+
+/*
+ * Migrate the git directory of the given path from old_git_dir to new_git_dir.
+ */
+void relocate_gitdir(const char *path, const char *old_git_dir, const char *new_git_dir)
+{
+       if (rename(old_git_dir, new_git_dir) < 0)
+               die_errno(_("could not migrate git directory from '%s' to '%s'"),
+                       old_git_dir, new_git_dir);
+
+       connect_work_tree_and_git_dir(path, new_git_dir);
+}
diff --git a/dir.h b/dir.h
index 97c83bb383a6b1fb5ce58d5e81dead570b73ac43..bf23a470af57775c8f0099597f7a403995bf3a89 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -335,4 +335,8 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
 void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);
 void add_untracked_cache(struct index_state *istate);
 void remove_untracked_cache(struct index_state *istate);
+extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
+extern void relocate_gitdir(const char *path,
+                           const char *old_git_dir,
+                           const char *new_git_dir);
 #endif
index 0935ec696e530e1b610c71eda0a0a7072d1d656f..8a83101d04240b1b5b1471e68c810f822f68269d 100644 (file)
@@ -34,7 +34,7 @@ const char *git_attributes_file;
 const char *git_hooks_path;
 int zlib_compression_level = Z_BEST_SPEED;
 int core_compression_level;
-int core_compression_seen;
+int pack_compression_level = Z_DEFAULT_COMPRESSION;
 int fsync_object_files;
 size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
@@ -259,7 +259,7 @@ void set_git_work_tree(const char *new_work_tree)
                return;
        }
        git_work_tree_initialized = 1;
-       work_tree = xstrdup(real_path(new_work_tree));
+       work_tree = real_pathdup(new_work_tree);
 }
 
 const char *get_git_work_tree(void)
index cb545d7df514b73a5ad9358b614ea9b4751e3c1e..64fe602f0bb62c4848798d1bdb43a7be9ab5f523 100644 (file)
@@ -284,8 +284,6 @@ static unsigned long max_depth = 10;
 static off_t max_packsize;
 static int unpack_limit = 100;
 static int force_update;
-static int pack_compression_level = Z_DEFAULT_COMPRESSION;
-static int pack_compression_seen;
 
 /* Stats and misc. counters */
 static uintmax_t alloc_count;
@@ -2220,13 +2218,17 @@ static uintmax_t do_change_note_fanout(
                char *fullpath, unsigned int fullpath_len,
                unsigned char fanout)
 {
-       struct tree_content *t = root->tree;
+       struct tree_content *t;
        struct tree_entry *e, leaf;
        unsigned int i, tmp_hex_sha1_len, tmp_fullpath_len;
        uintmax_t num_notes = 0;
        unsigned char sha1[20];
        char realpath[60];
 
+       if (!root->tree)
+               load_tree(root);
+       t = root->tree;
+
        for (i = 0; t && i < t->entry_count; i++) {
                e = t->entries[i];
                tmp_hex_sha1_len = hex_sha1_len + e->name->str_len;
@@ -2278,8 +2280,6 @@ static uintmax_t do_change_note_fanout(
                                leaf.tree);
                } else if (S_ISDIR(e->versions[1].mode)) {
                        /* This is a subdir that may contain note entries */
-                       if (!e->tree)
-                               load_tree(e);
                        num_notes += do_change_note_fanout(orig_root, e,
                                hex_sha1, tmp_hex_sha1_len,
                                fullpath, tmp_fullpath_len, fanout);
@@ -3381,15 +3381,6 @@ static void git_pack_config(void)
                if (max_depth > MAX_DEPTH)
                        max_depth = MAX_DEPTH;
        }
-       if (!git_config_get_int("pack.compression", &pack_compression_level)) {
-               if (pack_compression_level == -1)
-                       pack_compression_level = Z_DEFAULT_COMPRESSION;
-               else if (pack_compression_level < 0 ||
-                        pack_compression_level > Z_BEST_COMPRESSION)
-                       git_die_config("pack.compression",
-                                       "bad pack compression level %d", pack_compression_level);
-               pack_compression_seen = 1;
-       }
        if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
                pack_idx_opts.version = indexversion_value;
                if (pack_idx_opts.version > 2)
@@ -3454,8 +3445,6 @@ int cmd_main(int argc, const char **argv)
        setup_git_directory();
        reset_pack_idx_option(&pack_idx_opts);
        git_pack_config();
-       if (!pack_compression_seen && core_compression_seen)
-               pack_compression_level = core_compression_level;
 
        alloc_objects(object_entry_alloc);
        strbuf_init(&command_buf, 0);
index ee3d812695fa232f30682b0e546105ca0eea5d49..cf6fc926ab9325780eca5b6242cc04a656723451 100755 (executable)
@@ -4,6 +4,7 @@
 use strict;
 use warnings;
 use Git;
+use Git::I18N;
 
 binmode(STDOUT, ":raw");
 
@@ -46,7 +47,6 @@
 
 my $diff_algorithm = $repo->config('diff.algorithm');
 my $diff_indent_heuristic = $repo->config_bool('diff.indentheuristic');
-my $diff_compaction_heuristic = $repo->config_bool('diff.compactionheuristic');
 my $diff_filter = $repo->config('interactive.difffilter');
 
 my $use_readkey = 0;
@@ -92,6 +92,7 @@ sub colored {
 }
 
 # command line options
+my $cmd;
 my $patch_mode;
 my $patch_mode_revision;
 
@@ -104,9 +105,6 @@ sub colored {
                DIFF => 'diff-files -p',
                APPLY => sub { apply_patch 'apply --cached', @_; },
                APPLY_CHECK => 'apply --cached',
-               VERB => 'Stage',
-               TARGET => '',
-               PARTICIPLE => 'staging',
                FILTER => 'file-only',
                IS_REVERSE => 0,
        },
@@ -114,9 +112,6 @@ sub colored {
                DIFF => 'diff-index -p HEAD',
                APPLY => sub { apply_patch 'apply --cached', @_; },
                APPLY_CHECK => 'apply --cached',
-               VERB => 'Stash',
-               TARGET => '',
-               PARTICIPLE => 'stashing',
                FILTER => undef,
                IS_REVERSE => 0,
        },
@@ -124,9 +119,6 @@ sub colored {
                DIFF => 'diff-index -p --cached',
                APPLY => sub { apply_patch 'apply -R --cached', @_; },
                APPLY_CHECK => 'apply -R --cached',
-               VERB => 'Unstage',
-               TARGET => '',
-               PARTICIPLE => 'unstaging',
                FILTER => 'index-only',
                IS_REVERSE => 1,
        },
@@ -134,9 +126,6 @@ sub colored {
                DIFF => 'diff-index -R -p --cached',
                APPLY => sub { apply_patch 'apply --cached', @_; },
                APPLY_CHECK => 'apply --cached',
-               VERB => 'Apply',
-               TARGET => ' to index',
-               PARTICIPLE => 'applying',
                FILTER => 'index-only',
                IS_REVERSE => 0,
        },
@@ -144,9 +133,6 @@ sub colored {
                DIFF => 'diff-files -p',
                APPLY => sub { apply_patch 'apply -R', @_; },
                APPLY_CHECK => 'apply -R',
-               VERB => 'Discard',
-               TARGET => ' from worktree',
-               PARTICIPLE => 'discarding',
                FILTER => 'file-only',
                IS_REVERSE => 1,
        },
@@ -154,9 +140,6 @@ sub colored {
                DIFF => 'diff-index -p',
                APPLY => sub { apply_patch_for_checkout_commit '-R', @_ },
                APPLY_CHECK => 'apply -R',
-               VERB => 'Discard',
-               TARGET => ' from index and worktree',
-               PARTICIPLE => 'discarding',
                FILTER => undef,
                IS_REVERSE => 1,
        },
@@ -164,15 +147,13 @@ sub colored {
                DIFF => 'diff-index -R -p',
                APPLY => sub { apply_patch_for_checkout_commit '', @_ },
                APPLY_CHECK => 'apply',
-               VERB => 'Apply',
-               TARGET => ' to index and worktree',
-               PARTICIPLE => 'applying',
                FILTER => undef,
                IS_REVERSE => 0,
        },
 );
 
-my %patch_mode_flavour = %{$patch_modes{stage}};
+$patch_mode = 'stage';
+my %patch_mode_flavour = %{$patch_modes{$patch_mode}};
 
 sub run_cmd_pipe {
        if ($^O eq 'MSWin32') {
@@ -253,8 +234,9 @@ sub list_untracked {
        run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
 }
 
-my $status_fmt = '%12s %12s %s';
-my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');
+# TRANSLATORS: you can adjust this to align "git add -i" status menu
+my $status_fmt = __('%12s %12s %s');
+my $status_head = sprintf($status_fmt, __('staged'), __('unstaged'), __('path'));
 
 {
        my $initial;
@@ -312,7 +294,7 @@ sub list_modified {
                        my ($change, $bin);
                        $file = unquote_path($file);
                        if ($add eq '-' && $del eq '-') {
-                               $change = 'binary';
+                               $change = __('binary');
                                $bin = 1;
                        }
                        else {
@@ -321,7 +303,7 @@ sub list_modified {
                        $data{$file} = {
                                INDEX => $change,
                                BINARY => $bin,
-                               FILE => 'nothing',
+                               FILE => __('nothing'),
                        }
                }
                elsif (($adddel, $file) =
@@ -337,7 +319,7 @@ sub list_modified {
                        $file = unquote_path($file);
                        my ($change, $bin);
                        if ($add eq '-' && $del eq '-') {
-                               $change = 'binary';
+                               $change = __('binary');
                                $bin = 1;
                        }
                        else {
@@ -357,7 +339,7 @@ sub list_modified {
                        $file = unquote_path($2);
                        if (!exists $data{$file}) {
                                $data{$file} = +{
-                                       INDEX => 'unchanged',
+                                       INDEX => __('unchanged'),
                                        BINARY => 0,
                                };
                        }
@@ -372,10 +354,10 @@ sub list_modified {
 
                if ($only) {
                        if ($only eq 'index-only') {
-                               next if ($it->{INDEX} eq 'unchanged');
+                               next if ($it->{INDEX} eq __('unchanged'));
                        }
                        if ($only eq 'file-only') {
-                               next if ($it->{FILE} eq 'nothing');
+                               next if ($it->{FILE} eq __('nothing'));
                        }
                }
                push @return, +{
@@ -613,12 +595,12 @@ sub list_and_choose {
                        else {
                                $bottom = $top = find_unique($choice, @stuff);
                                if (!defined $bottom) {
-                                       error_msg "Huh ($choice)?\n";
+                                       error_msg sprintf(__("Huh (%s)?\n"), $choice);
                                        next TOPLOOP;
                                }
                        }
                        if ($opts->{SINGLETON} && $bottom != $top) {
-                               error_msg "Huh ($choice)?\n";
+                               error_msg sprintf(__("Huh (%s)?\n"), $choice);
                                next TOPLOOP;
                        }
                        for ($i = $bottom-1; $i <= $top-1; $i++) {
@@ -637,7 +619,7 @@ sub list_and_choose {
 }
 
 sub singleton_prompt_help_cmd {
-       print colored $help_color, <<\EOF ;
+       print colored $help_color, __ <<'EOF' ;
 Prompt help:
 1          - select a numbered item
 foo        - select item based on unique prefix
@@ -646,7 +628,7 @@ sub singleton_prompt_help_cmd {
 }
 
 sub prompt_help_cmd {
-       print colored $help_color, <<\EOF ;
+       print colored $help_color, __ <<'EOF' ;
 Prompt help:
 1          - select a single item
 3-5        - select a range of items
@@ -667,12 +649,18 @@ sub status_cmd {
 sub say_n_paths {
        my $did = shift @_;
        my $cnt = scalar @_;
-       print "$did ";
-       if (1 < $cnt) {
-               print "$cnt paths\n";
-       }
-       else {
-               print "one path\n";
+       if ($did eq 'added') {
+               printf(__n("added %d path\n", "added %d paths\n",
+                          $cnt), $cnt);
+       } elsif ($did eq 'updated') {
+               printf(__n("updated %d path\n", "updated %d paths\n",
+                          $cnt), $cnt);
+       } elsif ($did eq 'reverted') {
+               printf(__n("reverted %d path\n", "reverted %d paths\n",
+                          $cnt), $cnt);
+       } else {
+               printf(__n("touched %d path\n", "touched %d paths\n",
+                          $cnt), $cnt);
        }
 }
 
@@ -680,7 +668,7 @@ sub update_cmd {
        my @mods = list_modified('file-only');
        return if (!@mods);
 
-       my @update = list_and_choose({ PROMPT => 'Update',
+       my @update = list_and_choose({ PROMPT => __('Update'),
                                       HEADER => $status_head, },
                                     @mods);
        if (@update) {
@@ -692,7 +680,7 @@ sub update_cmd {
 }
 
 sub revert_cmd {
-       my @update = list_and_choose({ PROMPT => 'Revert',
+       my @update = list_and_choose({ PROMPT => __('Revert'),
                                       HEADER => $status_head, },
                                     list_modified());
        if (@update) {
@@ -715,7 +703,7 @@ sub revert_cmd {
                                    $_->{INDEX_ADDDEL} eq 'create') {
                                        system(qw(git update-index --force-remove --),
                                               $_->{VALUE});
-                                       print "note: $_->{VALUE} is untracked now.\n";
+                                       printf(__("note: %s is untracked now.\n"), $_->{VALUE});
                                }
                        }
                }
@@ -726,13 +714,13 @@ sub revert_cmd {
 }
 
 sub add_untracked_cmd {
-       my @add = list_and_choose({ PROMPT => 'Add untracked' },
+       my @add = list_and_choose({ PROMPT => __('Add untracked') },
                                  list_untracked());
        if (@add) {
                system(qw(git update-index --add --), @add);
                say_n_paths('added', @add);
        } else {
-               print "No untracked files.\n";
+               print __("No untracked files.\n");
        }
        print "\n";
 }
@@ -753,8 +741,6 @@ sub parse_diff {
        }
        if ($diff_indent_heuristic) {
                splice @diff_cmd, 1, 0, "--indent-heuristic";
-       } elsif ($diff_compaction_heuristic) {
-               splice @diff_cmd, 1, 0, "--compaction-heuristic";
        }
        if (defined $patch_mode_revision) {
                push @diff_cmd, get_diff_reference($patch_mode_revision);
@@ -1048,29 +1034,55 @@ sub color_diff {
        } @_;
 }
 
+my %edit_hunk_manually_modes = (
+       stage => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for staging."),
+       stash => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for stashing."),
+       reset_head => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for unstaging."),
+       reset_nothead => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for applying."),
+       checkout_index => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for discarding"),
+       checkout_head => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for discarding."),
+       checkout_nothead => N__(
+"If the patch applies cleanly, the edited hunk will immediately be
+marked for applying."),
+);
+
 sub edit_hunk_manually {
        my ($oldtext) = @_;
 
        my $hunkfile = $repo->repo_path . "/addp-hunk-edit.diff";
        my $fh;
        open $fh, '>', $hunkfile
-               or die "failed to open hunk edit file for writing: " . $!;
-       print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
+               or die sprintf(__("failed to open hunk edit file for writing: %s"), $!);
+       print $fh Git::comment_lines __("Manual hunk edit mode -- see bottom for a quick guide.\n");
        print $fh @$oldtext;
-       my $participle = $patch_mode_flavour{PARTICIPLE};
        my $is_reverse = $patch_mode_flavour{IS_REVERSE};
        my ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');
-       print $fh <<EOF;
-# ---
-# To remove '$remove_minus' lines, make them ' ' lines (context).
-# To remove '$remove_plus' lines, delete them.
-# Lines starting with # will be removed.
-#
-# If the patch applies cleanly, the edited hunk will immediately be
-# marked for $participle. If it does not apply cleanly, you will be given
-# an opportunity to edit again. If all lines of the hunk are removed,
-# then the edit is aborted and the hunk is left unchanged.
+       my $comment_line_char = Git::get_comment_line_char;
+       print $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),
+---
+To remove '%s' lines, make them ' ' lines (context).
+To remove '%s' lines, delete them.
+Lines starting with %s will be removed.
 EOF
+__($edit_hunk_manually_modes{$patch_mode}),
+# TRANSLATORS: 'it' refers to the patch mentioned in the previous messages.
+__ <<EOF2 ;
+If it does not apply cleanly, you will be given an opportunity to
+edit again.  If all lines of the hunk are removed, then the edit is
+aborted and the hunk is left unchanged.
+EOF2
        close $fh;
 
        chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));
@@ -1081,8 +1093,8 @@ sub edit_hunk_manually {
        }
 
        open $fh, '<', $hunkfile
-               or die "failed to open hunk edit file for reading: " . $!;
-       my @newtext = grep { !/^#/ } <$fh>;
+               or die sprintf(__("failed to open hunk edit file for reading: %s"), $!);
+       my @newtext = grep { !/^$comment_line_char/ } <$fh>;
        close $fh;
        unlink $hunkfile;
 
@@ -1166,22 +1178,66 @@ sub edit_hunk_loop {
                }
                else {
                        prompt_yesno(
-                               'Your edited hunk does not apply. Edit again '
-                               . '(saying "no" discards!) [y/n]? '
+                               # TRANSLATORS: do not translate [y/n]
+                               # The program will only accept that input
+                               # at this point.
+                               # Consider translating (saying "no" discards!) as
+                               # (saying "n" for "no" discards!) if the translation
+                               # of the word "no" does not start with n.
+                               __('Your edited hunk does not apply. Edit again '
+                                  . '(saying "no" discards!) [y/n]? ')
                                ) or return undef;
                }
        }
 }
 
+my %help_patch_modes = (
+       stage => N__(
+"y - stage this hunk
+n - do not stage this hunk
+q - quit; do not stage this hunk or any of the remaining ones
+a - stage this hunk and all later hunks in the file
+d - do not stage this hunk or any of the later hunks in the file"),
+       stash => N__(
+"y - stash this hunk
+n - do not stash this hunk
+q - quit; do not stash this hunk or any of the remaining ones
+a - stash this hunk and all later hunks in the file
+d - do not stash this hunk or any of the later hunks in the file"),
+       reset_head => N__(
+"y - unstage this hunk
+n - do not unstage this hunk
+q - quit; do not unstage this hunk or any of the remaining ones
+a - unstage this hunk and all later hunks in the file
+d - do not unstage this hunk or any of the later hunks in the file"),
+       reset_nothead => N__(
+"y - apply this hunk to index
+n - do not apply this hunk to index
+q - quit; do not apply this hunk or any of the remaining ones
+a - apply this hunk and all later hunks in the file
+d - do not apply this hunk or any of the later hunks in the file"),
+       checkout_index => N__(
+"y - discard this hunk from worktree
+n - do not discard this hunk from worktree
+q - quit; do not discard this hunk or any of the remaining ones
+a - discard this hunk and all later hunks in the file
+d - do not discard this hunk or any of the later hunks in the file"),
+       checkout_head => N__(
+"y - discard this hunk from index and worktree
+n - do not discard this hunk from index and worktree
+q - quit; do not discard this hunk or any of the remaining ones
+a - discard this hunk and all later hunks in the file
+d - do not discard this hunk or any of the later hunks in the file"),
+       checkout_nothead => N__(
+"y - apply this hunk to index and worktree
+n - do not apply this hunk to index and worktree
+q - quit; do not apply this hunk or any of the remaining ones
+a - apply this hunk and all later hunks in the file
+d - do not apply this hunk or any of the later hunks in the file"),
+);
+
 sub help_patch_cmd {
-       my $verb = lc $patch_mode_flavour{VERB};
-       my $target = $patch_mode_flavour{TARGET};
-       print colored $help_color, <<EOF ;
-y - $verb this hunk$target
-n - do not $verb this hunk$target
-q - quit; do not $verb this hunk or any of the remaining ones
-a - $verb this hunk and all later hunks in the file
-d - do not $verb this hunk or any of the later hunks in the file
+       print colored $help_color, __($help_patch_modes{$patch_mode}), "\n", __ <<EOF ;
 g - select a hunk to go to
 / - search for a hunk matching the given regex
 j - leave this hunk undecided, see next undecided hunk
@@ -1213,11 +1269,11 @@ sub apply_patch_for_checkout_commit {
                run_git_apply 'apply '.$reverse, @_;
                return 1;
        } elsif (!$applies_index) {
-               print colored $error_color, "The selected hunks do not apply to the index!\n";
-               if (prompt_yesno "Apply them to the worktree anyway? ") {
+               print colored $error_color, __("The selected hunks do not apply to the index!\n");
+               if (prompt_yesno __("Apply them to the worktree anyway? ")) {
                        return run_git_apply 'apply '.$reverse, @_;
                } else {
-                       print colored $error_color, "Nothing was applied.\n";
+                       print colored $error_color, __("Nothing was applied.\n");
                        return 0;
                }
        } else {
@@ -1228,7 +1284,7 @@ sub apply_patch_for_checkout_commit {
 
 sub patch_update_cmd {
        my @all_mods = list_modified($patch_mode_flavour{FILTER});
-       error_msg "ignoring unmerged: $_->{VALUE}\n"
+       error_msg sprintf(__("ignoring unmerged: %s\n"), $_->{VALUE})
                for grep { $_->{UNMERGED} } @all_mods;
        @all_mods = grep { !$_->{UNMERGED} } @all_mods;
 
@@ -1237,9 +1293,9 @@ sub patch_update_cmd {
 
        if (!@mods) {
                if (@all_mods) {
-                       print STDERR "Only binary files changed.\n";
+                       print STDERR __("Only binary files changed.\n");
                } else {
-                       print STDERR "No changes.\n";
+                       print STDERR __("No changes.\n");
                }
                return 0;
        }
@@ -1247,7 +1303,7 @@ sub patch_update_cmd {
                @them = @mods;
        }
        else {
-               @them = list_and_choose({ PROMPT => 'Patch update',
+               @them = list_and_choose({ PROMPT => __('Patch update'),
                                          HEADER => $status_head, },
                                        @mods);
        }
@@ -1297,6 +1353,44 @@ sub display_hunks {
        return $i;
 }
 
+my %patch_update_prompt_modes = (
+       stage => {
+               mode => N__("Stage mode change [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Stage deletion [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Stage this hunk [y,n,q,a,d,/%s,?]? "),
+       },
+       stash => {
+               mode => N__("Stash mode change [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Stash deletion [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Stash this hunk [y,n,q,a,d,/%s,?]? "),
+       },
+       reset_head => {
+               mode => N__("Unstage mode change [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Unstage deletion [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Unstage this hunk [y,n,q,a,d,/%s,?]? "),
+       },
+       reset_nothead => {
+               mode => N__("Apply mode change to index [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Apply deletion to index [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Apply this hunk to index [y,n,q,a,d,/%s,?]? "),
+       },
+       checkout_index => {
+               mode => N__("Discard mode change from worktree [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Discard deletion from worktree [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Discard this hunk from worktree [y,n,q,a,d,/%s,?]? "),
+       },
+       checkout_head => {
+               mode => N__("Discard mode change from index and worktree [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Discard deletion from index and worktree [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Discard this hunk from index and worktree [y,n,q,a,d,/%s,?]? "),
+       },
+       checkout_nothead => {
+               mode => N__("Apply mode change to index and worktree [y,n,q,a,d,/%s,?]? "),
+               deletion => N__("Apply deletion to index and worktree [y,n,q,a,d,/%s,?]? "),
+               hunk => N__("Apply this hunk to index and worktree [y,n,q,a,d,/%s,?]? "),
+       },
+);
+
 sub patch_update_file {
        my $quit = 0;
        my ($ix, $num);
@@ -1369,12 +1463,9 @@ sub patch_update_file {
                for (@{$hunk[$ix]{DISPLAY}}) {
                        print;
                }
-               print colored $prompt_color, $patch_mode_flavour{VERB},
-                 ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :
-                  $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :
-                  ' this hunk'),
-                 $patch_mode_flavour{TARGET},
-                 " [y,n,q,a,d,/$other,?]? ";
+               print colored $prompt_color,
+                       sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
+
                my $line = prompt_single_character;
                last unless defined $line;
                if ($line) {
@@ -1397,12 +1488,12 @@ sub patch_update_file {
                                my $response = $1;
                                my $no = $ix > 10 ? $ix - 10 : 0;
                                while ($response eq '') {
-                                       my $extra = "";
                                        $no = display_hunks(\@hunk, $no);
                                        if ($no < $num) {
-                                               $extra = " (<ret> to see more)";
+                                               print __("go to which hunk (<ret> to see more)? ");
+                                       } else {
+                                               print __("go to which hunk? ");
                                        }
-                                       print "go to which hunk$extra? ";
                                        $response = <STDIN>;
                                        if (!defined $response) {
                                                $response = '';
@@ -1410,11 +1501,13 @@ sub patch_update_file {
                                        chomp $response;
                                }
                                if ($response !~ /^\s*\d+\s*$/) {
-                                       error_msg "Invalid number: '$response'\n";
+                                       error_msg sprintf(__("Invalid number: '%s'\n"),
+                                                            $response);
                                } elsif (0 < $response && $response <= $num) {
                                        $ix = $response - 1;
                                } else {
-                                       error_msg "Sorry, only $num hunks available.\n";
+                                       error_msg sprintf(__n("Sorry, only %d hunk available.\n",
+                                                             "Sorry, only %d hunks available.\n", $num), $num);
                                }
                                next;
                        }
@@ -1439,7 +1532,7 @@ sub patch_update_file {
                        elsif ($line =~ m|^/(.*)|) {
                                my $regex = $1;
                                if ($1 eq "") {
-                                       print colored $prompt_color, "search for regex? ";
+                                       print colored $prompt_color, __("search for regex? ");
                                        $regex = <STDIN>;
                                        if (defined $regex) {
                                                chomp $regex;
@@ -1452,7 +1545,7 @@ sub patch_update_file {
                                if ($@) {
                                        my ($err,$exp) = ($@, $1);
                                        $err =~ s/ at .*git-add--interactive line \d+, <STDIN> line \d+.*$//;
-                                       error_msg "Malformed search regexp $exp: $err\n";
+                                       error_msg sprintf(__("Malformed search regexp %s: %s\n"), $exp, $err);
                                        next;
                                }
                                my $iy = $ix;
@@ -1462,7 +1555,7 @@ sub patch_update_file {
                                        $iy++;
                                        $iy = 0 if ($iy >= $num);
                                        if ($ix == $iy) {
-                                               error_msg "No hunk matches the given pattern\n";
+                                               error_msg __("No hunk matches the given pattern\n");
                                                last;
                                        }
                                }
@@ -1474,7 +1567,7 @@ sub patch_update_file {
                                        $ix--;
                                }
                                else {
-                                       error_msg "No previous hunk\n";
+                                       error_msg __("No previous hunk\n");
                                }
                                next;
                        }
@@ -1483,7 +1576,7 @@ sub patch_update_file {
                                        $ix++;
                                }
                                else {
-                                       error_msg "No next hunk\n";
+                                       error_msg __("No next hunk\n");
                                }
                                next;
                        }
@@ -1496,21 +1589,23 @@ sub patch_update_file {
                                        }
                                }
                                else {
-                                       error_msg "No previous hunk\n";
+                                       error_msg __("No previous hunk\n");
                                }
                                next;
                        }
                        elsif ($line =~ /^j/) {
                                if ($other !~ /j/) {
-                                       error_msg "No next hunk\n";
+                                       error_msg __("No next hunk\n");
                                        next;
                                }
                        }
                        elsif ($other =~ /s/ && $line =~ /^s/) {
                                my @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});
                                if (1 < @split) {
-                                       print colored $header_color, "Split into ",
-                                       scalar(@split), " hunks.\n";
+                                       print colored $header_color, sprintf(
+                                               __n("Split into %d hunk.\n",
+                                                   "Split into %d hunks.\n",
+                                                   scalar(@split)), scalar(@split));
                                }
                                splice (@hunk, $ix, 1, @split);
                                $num = scalar @hunk;
@@ -1560,23 +1655,25 @@ sub diff_cmd {
        my @mods = list_modified('index-only');
        @mods = grep { !($_->{BINARY}) } @mods;
        return if (!@mods);
-       my (@them) = list_and_choose({ PROMPT => 'Review diff',
+       my (@them) = list_and_choose({ PROMPT => __('Review diff'),
                                     IMMEDIATE => 1,
                                     HEADER => $status_head, },
                                   @mods);
        return if (!@them);
-       my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
+       my $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';
        system(qw(git diff -p --cached), $reference, '--',
                map { $_->{VALUE} } @them);
 }
 
 sub quit_cmd {
-       print "Bye.\n";
+       print __("Bye.\n");
        exit(0);
 }
 
 sub help_cmd {
-       print colored $help_color, <<\EOF ;
+# TRANSLATORS: please do not translate the command names
+# 'status', 'update', 'revert', etc.
+       print colored $help_color, __ <<'EOF' ;
 status        - show paths with changes
 update        - add working tree state to the staged set of changes
 revert        - revert staged set of changes back to the HEAD version
@@ -1594,39 +1691,40 @@ sub process_args {
                        if ($1 eq 'reset') {
                                $patch_mode = 'reset_head';
                                $patch_mode_revision = 'HEAD';
-                               $arg = shift @ARGV or die "missing --";
+                               $arg = shift @ARGV or die __("missing --");
                                if ($arg ne '--') {
                                        $patch_mode_revision = $arg;
                                        $patch_mode = ($arg eq 'HEAD' ?
                                                       'reset_head' : 'reset_nothead');
-                                       $arg = shift @ARGV or die "missing --";
+                                       $arg = shift @ARGV or die __("missing --");
                                }
                        } elsif ($1 eq 'checkout') {
-                               $arg = shift @ARGV or die "missing --";
+                               $arg = shift @ARGV or die __("missing --");
                                if ($arg eq '--') {
                                        $patch_mode = 'checkout_index';
                                } else {
                                        $patch_mode_revision = $arg;
                                        $patch_mode = ($arg eq 'HEAD' ?
                                                       'checkout_head' : 'checkout_nothead');
-                                       $arg = shift @ARGV or die "missing --";
+                                       $arg = shift @ARGV or die __("missing --");
                                }
                        } elsif ($1 eq 'stage' or $1 eq 'stash') {
                                $patch_mode = $1;
-                               $arg = shift @ARGV or die "missing --";
+                               $arg = shift @ARGV or die __("missing --");
                        } else {
-                               die "unknown --patch mode: $1";
+                               die sprintf(__("unknown --patch mode: %s"), $1);
                        }
                } else {
                        $patch_mode = 'stage';
-                       $arg = shift @ARGV or die "missing --";
+                       $arg = shift @ARGV or die __("missing --");
                }
-               die "invalid argument $arg, expecting --"
-                   unless $arg eq "--";
+               die sprintf(__("invalid argument %s, expecting --"),
+                              $arg) unless $arg eq "--";
                %patch_mode_flavour = %{$patch_modes{$patch_mode}};
+               $cmd = 1;
        }
        elsif ($arg ne "--") {
-               die "invalid argument $arg, expecting --";
+               die sprintf(__("invalid argument %s, expecting --"), $arg);
        }
 }
 
@@ -1641,10 +1739,10 @@ sub main_loop {
                   [ 'help', \&help_cmd, ],
        );
        while (1) {
-               my ($it) = list_and_choose({ PROMPT => 'What now',
+               my ($it) = list_and_choose({ PROMPT => __('What now'),
                                             SINGLETON => 1,
                                             LIST_FLAT => 4,
-                                            HEADER => '*** Commands ***',
+                                            HEADER => __('*** Commands ***'),
                                             ON_EOF => \&quit_cmd,
                                             IMMEDIATE => 1 }, @cmd);
                if ($it) {
@@ -1660,7 +1758,7 @@ sub main_loop {
 
 process_args();
 refresh();
-if ($patch_mode) {
+if ($cmd) {
        patch_update_cmd();
 }
 else {
index a5790d03a075884ffe93dbff782b28ec87263051..df59bdfe97786b5d9f48777cfad80545ff6bbdc2 100755 (executable)
@@ -22,6 +22,7 @@
 use File::Temp qw(tempdir);
 use Getopt::Long qw(:config pass_through);
 use Git;
+use Git::I18N;
 
 sub usage
 {
@@ -59,14 +60,14 @@ sub exit_cleanup
 
 sub use_wt_file
 {
-       my ($workdir, $file, $sha1) = @_;
+       my ($file, $sha1) = @_;
        my $null_sha1 = '0' x 40;
 
-       if (-l "$workdir/$file" || ! -e _) {
+       if (-l $file || ! -e _) {
                return (0, $null_sha1);
        }
 
-       my $wt_sha1 = Git::command_oneline('hash-object', "$workdir/$file");
+       my $wt_sha1 = Git::command_oneline('hash-object', $file);
        my $use = ($sha1 eq $null_sha1) || ($sha1 eq $wt_sha1);
        return ($use, $wt_sha1);
 }
@@ -100,11 +101,17 @@ sub changed_files
 
 sub setup_dir_diff
 {
-       my ($workdir, $symlinks) = @_;
+       my ($worktree, $symlinks) = @_;
        my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV);
        my $diffrtn = Git::command_oneline(@gitargs);
        exit(0) unless defined($diffrtn);
 
+       # Go to the root of the worktree now that we've captured the list of
+       # changed files.  The paths returned by diff --raw are relative to the
+       # top-level of the repository, but we defer changing directories so
+       # that @ARGV can perform pathspec limiting in the current directory.
+       chdir($worktree);
+
        # Build index info for left and right sides of the diff
        my $submodule_mode = '160000';
        my $symlink_mode = '120000';
@@ -115,14 +122,14 @@ sub setup_dir_diff
        my $wtindex = '';
        my %submodule;
        my %symlink;
-       my @working_tree = ();
+       my @files = ();
        my %working_tree_dups = ();
        my @rawdiff = split('\0', $diffrtn);
 
        my $i = 0;
        while ($i < $#rawdiff) {
                if ($rawdiff[$i] =~ /^::/) {
-                       warn << 'EOF';
+                       warn __ <<'EOF';
 Combined diff formats ('-c' and '--cc') are not supported in
 directory diff mode ('-d' and '--dir-diff').
 EOF
@@ -167,14 +174,14 @@ sub setup_dir_diff
                }
 
                if ($rmode ne $null_mode) {
-                       # Avoid duplicate working_tree entries
+                       # Avoid duplicate entries
                        if ($working_tree_dups{$dst_path}++) {
                                next;
                        }
                        my ($use, $wt_sha1) =
-                               use_wt_file($workdir, $dst_path, $rsha1);
+                               use_wt_file($dst_path, $rsha1);
                        if ($use) {
-                               push @working_tree, $dst_path;
+                               push @files, $dst_path;
                                $wtindex .= "$rmode $wt_sha1\t$dst_path\0";
                        } else {
                                $rindex .= "$rmode $rsha1\t$dst_path\0";
@@ -182,6 +189,10 @@ sub setup_dir_diff
                }
        }
 
+       # Go to the root of the worktree so that the left index files
+       # are properly setup -- the index is toplevel-relative.
+       chdir($worktree);
+
        # Setup temp directories
        my $tmpdir = tempdir('git-difftool.XXXXX', CLEANUP => 0, TMPDIR => 1);
        my $ldir = "$tmpdir/left";
@@ -220,23 +231,21 @@ sub setup_dir_diff
        delete($ENV{GIT_INDEX_FILE});
 
        # Changes in the working tree need special treatment since they are
-       # not part of the index. Remove any trailing slash from $workdir
-       # before starting to avoid double slashes in symlink targets.
-       $workdir =~ s|/$||;
-       for my $file (@working_tree) {
+       # not part of the index.
+       for my $file (@files) {
                my $dir = dirname($file);
                unless (-d "$rdir/$dir") {
                        mkpath("$rdir/$dir") or
                        exit_cleanup($tmpdir, 1);
                }
                if ($symlinks) {
-                       symlink("$workdir/$file", "$rdir/$file") or
+                       symlink("$worktree/$file", "$rdir/$file") or
                        exit_cleanup($tmpdir, 1);
                } else {
-                       copy("$workdir/$file", "$rdir/$file") or
+                       copy($file, "$rdir/$file") or
                        exit_cleanup($tmpdir, 1);
 
-                       my $mode = stat("$workdir/$file")->mode;
+                       my $mode = stat($file)->mode;
                        chmod($mode, "$rdir/$file") or
                        exit_cleanup($tmpdir, 1);
                }
@@ -274,7 +283,7 @@ sub setup_dir_diff
                exit_cleanup($tmpdir, 1) if not $ok;
        }
 
-       return ($ldir, $rdir, $tmpdir, @working_tree);
+       return ($ldir, $rdir, $tmpdir, @files);
 }
 
 sub write_to_file
@@ -338,7 +347,7 @@ sub main
                if (length($opts{difftool_cmd}) > 0) {
                        $ENV{GIT_DIFF_TOOL} = $opts{difftool_cmd};
                } else {
-                       print "No <tool> given for --tool=<tool>\n";
+                       print __("No <tool> given for --tool=<tool>\n");
                        usage(1);
                }
        }
@@ -346,7 +355,7 @@ sub main
                if (length($opts{extcmd}) > 0) {
                        $ENV{GIT_DIFFTOOL_EXTCMD} = $opts{extcmd};
                } else {
-                       print "No <cmd> given for --extcmd=<cmd>\n";
+                       print __("No <cmd> given for --extcmd=<cmd>\n");
                        usage(1);
                }
        }
@@ -384,8 +393,9 @@ sub dir_diff
        my $error = 0;
        my $repo = Git->repository();
        my $repo_path = $repo->repo_path();
-       my $workdir = $repo->wc_path();
-       my ($a, $b, $tmpdir, @worktree) = setup_dir_diff($workdir, $symlinks);
+       my $worktree = $repo->wc_path();
+       $worktree =~ s|/$||; # Avoid double slashes in symlink targets
+       my ($a, $b, $tmpdir, @files) = setup_dir_diff($worktree, $symlinks);
 
        if (defined($extcmd)) {
                $rc = system($extcmd, $a, $b);
@@ -406,37 +416,38 @@ sub dir_diff
        my %tmp_modified;
        my $indices_loaded = 0;
 
-       for my $file (@worktree) {
+       for my $file (@files) {
                next if $symlinks && -l "$b/$file";
                next if ! -f "$b/$file";
 
                if (!$indices_loaded) {
                        %wt_modified = changed_files(
-                               $repo_path, "$tmpdir/wtindex", $workdir);
+                               $repo_path, "$tmpdir/wtindex", $worktree);
                        %tmp_modified = changed_files(
                                $repo_path, "$tmpdir/wtindex", $b);
                        $indices_loaded = 1;
                }
 
                if (exists $wt_modified{$file} and exists $tmp_modified{$file}) {
-                       my $errmsg = "warning: Both files modified: ";
-                       $errmsg .= "'$workdir/$file' and '$b/$file'.\n";
-                       $errmsg .= "warning: Working tree file has been left.\n";
-                       $errmsg .= "warning:\n";
-                       warn $errmsg;
+                       warn sprintf(__(
+                               "warning: Both files modified:\n" .
+                               "'%s/%s' and '%s/%s'.\n" .
+                               "warning: Working tree file has been left.\n" .
+                               "warning:\n"), $worktree, $file, $b, $file);
                        $error = 1;
                } elsif (exists $tmp_modified{$file}) {
                        my $mode = stat("$b/$file")->mode;
-                       copy("$b/$file", "$workdir/$file") or
+                       copy("$b/$file", $file) or
                        exit_cleanup($tmpdir, 1);
 
-                       chmod($mode, "$workdir/$file") or
+                       chmod($mode, $file) or
                        exit_cleanup($tmpdir, 1);
                }
        }
        if ($error) {
-               warn "warning: Temporary files exist in '$tmpdir'.\n";
-               warn "warning: You may want to cleanup or recover these.\n";
+               warn sprintf(__(
+                       "warning: Temporary files exist in '%s'.\n" .
+                       "warning: You may want to cleanup or recover these.\n"), $tmpdir);
                exit(1);
        } else {
                exit_cleanup($tmpdir, $rc);
index 9abd00be212b3e55883c0f9fa0487c7b31a6039f..9a8b97a2aba9aa9fabb095558c03cb8f27df3d50 100644 (file)
@@ -125,16 +125,7 @@ setup_user_tool () {
        }
 
        merge_cmd () {
-               trust_exit_code=$(git config --bool \
-                       "mergetool.$1.trustExitCode" || echo false)
-               if test "$trust_exit_code" = "false"
-               then
-                       touch "$BACKUP"
-                       ( eval $merge_tool_cmd )
-                       check_unchanged
-               else
-                       ( eval $merge_tool_cmd )
-               fi
+               ( eval $merge_tool_cmd )
        }
 }
 
@@ -162,6 +153,28 @@ setup_tool () {
                echo "$1"
        }
 
+       # Most tools' exit codes cannot be trusted, so By default we ignore
+       # their exit code and check the merged file's modification time in
+       # check_unchanged() to determine whether or not the merge was
+       # successful.  The return value from run_merge_cmd, by default, is
+       # determined by check_unchanged().
+       #
+       # When a tool's exit code can be trusted then the return value from
+       # run_merge_cmd is simply the tool's exit code, and check_unchanged()
+       # is not called.
+       #
+       # The return value of exit_code_trustable() tells us whether or not we
+       # can trust the tool's exit code.
+       #
+       # User-defined and built-in tools default to false.
+       # Built-in tools advertise that their exit code is trustable by
+       # redefining exit_code_trustable() to true.
+
+       exit_code_trustable () {
+               false
+       }
+
+
        if ! test -f "$MERGE_TOOLS_DIR/$tool"
        then
                setup_user_tool
@@ -197,6 +210,19 @@ get_merge_tool_cmd () {
        fi
 }
 
+trust_exit_code () {
+       if git config --bool "mergetool.$1.trustExitCode"
+       then
+               :; # OK
+       elif exit_code_trustable
+       then
+               echo true
+       else
+               echo false
+       fi
+}
+
+
 # Entry point for running tools
 run_merge_tool () {
        # If GIT_PREFIX is empty then we cannot use it in tools
@@ -225,7 +251,15 @@ run_diff_cmd () {
 
 # Run a either a configured or built-in merge tool
 run_merge_cmd () {
-       merge_cmd "$1"
+       mergetool_trust_exit_code=$(trust_exit_code "$1")
+       if test "$mergetool_trust_exit_code" = "true"
+       then
+               merge_cmd "$1"
+       else
+               touch "$BACKUP"
+               merge_cmd "$1"
+               check_unchanged
+       fi
 }
 
 list_merge_tool_candidates () {
index 2d39d10122caa2e5a5c6814200639912d87f1f68..7bda915bd0c9af438d7303abaabf53fc15f9a5dd 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -25,6 +25,7 @@
 import zipfile
 import zlib
 import ctypes
+import errno
 
 try:
     from subprocess import CalledProcessError
@@ -92,6 +93,16 @@ def p4_build_cmd(cmd):
         real_cmd += cmd
     return real_cmd
 
+def git_dir(path):
+    """ Return TRUE if the given path is a git directory (/path/to/dir/.git).
+        This won't automatically add ".git" to a directory.
+    """
+    d = read_pipe(["git", "--git-dir", path, "rev-parse", "--git-dir"], True).strip()
+    if not d or len(d) == 0:
+        return None
+    else:
+        return d
+
 def chdir(path, is_client_path=False):
     """Do chdir to the given path, and set the PWD environment
        variable for use by P4.  It does not look at getcwd() output.
@@ -269,6 +280,10 @@ def p4_revert(f):
 def p4_reopen(type, f):
     p4_system(["reopen", "-t", type, wildcard_encode(f)])
 
+def p4_reopen_in_change(changelist, files):
+    cmd = ["reopen", "-c", str(changelist)] + files
+    p4_system(cmd)
+
 def p4_move(src, dest):
     p4_system(["move", "-k", wildcard_encode(src), wildcard_encode(dest)])
 
@@ -570,10 +585,7 @@ def currentGitBranch():
         return read_pipe(["git", "name-rev", "HEAD"]).split(" ")[1].strip()
 
 def isValidGitDir(path):
-    if (os.path.exists(path + "/HEAD")
-        and os.path.exists(path + "/refs") and os.path.exists(path + "/objects")):
-        return True;
-    return False
+    return git_dir(path) != None
 
 def parseRevision(ref):
     return read_pipe("git rev-parse %s" % ref).strip()
@@ -829,7 +841,7 @@ def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
                 die("cannot use --changes-block-size with non-numeric revisions")
             block_size = None
 
-    changes = []
+    changes = set()
 
     # Retrieve changes a block at a time, to prevent running
     # into a MaxResults/MaxScanRows error from the server.
@@ -848,7 +860,7 @@ def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
 
         # Insert changes in chronological order
         for line in reversed(p4_read_pipe_lines(cmd)):
-            changes.append(int(line.split(" ")[1]))
+            changes.add(int(line.split(" ")[1]))
 
         if not block_size:
             break
@@ -1012,18 +1024,20 @@ def processContent(self, git_mode, relPath, contents):
            steps."""
         if self.exceedsLargeFileThreshold(relPath, contents) or self.hasLargeFileExtension(relPath):
             contentTempFile = self.generateTempFile(contents)
-            (git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
-
-            # Move temp file to final location in large file system
-            largeFileDir = os.path.dirname(localLargeFile)
-            if not os.path.isdir(largeFileDir):
-                os.makedirs(largeFileDir)
-            shutil.move(contentTempFile, localLargeFile)
-            self.addLargeFile(relPath)
-            if gitConfigBool('git-p4.largeFilePush'):
-                self.pushFile(localLargeFile)
-            if verbose:
-                sys.stderr.write("%s moved to large file system (%s)\n" % (relPath, localLargeFile))
+            (pointer_git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
+            if pointer_git_mode:
+                git_mode = pointer_git_mode
+            if localLargeFile:
+                # Move temp file to final location in large file system
+                largeFileDir = os.path.dirname(localLargeFile)
+                if not os.path.isdir(largeFileDir):
+                    os.makedirs(largeFileDir)
+                shutil.move(contentTempFile, localLargeFile)
+                self.addLargeFile(relPath)
+                if gitConfigBool('git-p4.largeFilePush'):
+                    self.pushFile(localLargeFile)
+                if verbose:
+                    sys.stderr.write("%s moved to large file system (%s)\n" % (relPath, localLargeFile))
         return (git_mode, contents)
 
 class MockLFS(LargeFileSystem):
@@ -1063,6 +1077,9 @@ def generatePointer(self, contentFile):
            the actual content. Return also the new location of the actual
            content.
            """
+        if os.path.getsize(contentFile) == 0:
+            return (None, '', None)
+
         pointerProcess = subprocess.Popen(
             ['git', 'lfs', 'pointer', '--file=' + contentFile],
             stdout=subprocess.PIPE
@@ -1105,10 +1122,10 @@ def generateGitAttributes(self):
                 '# Git LFS (see https://git-lfs.github.com/)\n',
                 '#\n',
             ] +
-            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
+            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
                 for f in sorted(gitConfigList('git-p4.largeFileExtensions'))
             ] +
-            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
+            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
                 for f in sorted(self.largeFiles) if not self.hasLargeFileExtension(f)
             ]
         )
@@ -1296,6 +1313,12 @@ def __init__(self):
                 optparse.make_option("--conflict", dest="conflict_behavior",
                                      choices=self.conflict_behavior_choices),
                 optparse.make_option("--branch", dest="branch"),
+                optparse.make_option("--shelve", dest="shelve", action="store_true",
+                                     help="Shelve instead of submit. Shelved files are reverted, "
+                                     "restoring the workspace to the state before the shelve"),
+                optparse.make_option("--update-shelve", dest="update_shelve", action="store", type="int",
+                                     metavar="CHANGELIST",
+                                     help="update an existing shelved changelist, implies --shelve")
         ]
         self.description = "Submit changes from git to the perforce depot."
         self.usage += " [name of git branch to submit into perforce depot]"
@@ -1303,6 +1326,8 @@ def __init__(self):
         self.detectRenames = False
         self.preserveUser = gitConfigBool("git-p4.preserveUser")
         self.dry_run = False
+        self.shelve = False
+        self.update_shelve = None
         self.prepare_p4_only = False
         self.conflict_behavior = None
         self.isWindows = (platform.system() == "Windows")
@@ -1471,7 +1496,7 @@ def canChangeChangelists(self):
                     return 1
         return 0
 
-    def prepareSubmitTemplate(self):
+    def prepareSubmitTemplate(self, changelist=None):
         """Run "p4 change -o" to grab a change specification template.
            This does not use "p4 -G", as it is nice to keep the submission
            template in original order, since a human might edit it.
@@ -1483,7 +1508,11 @@ def prepareSubmitTemplate(self):
 
         template = ""
         inFilesSection = False
-        for line in p4_read_pipe_lines(['change', '-o']):
+        args = ['change', '-o']
+        if changelist:
+            args.append(str(changelist))
+
+        for line in p4_read_pipe_lines(args):
             if line.endswith("\r\n"):
                 line = line[:-2] + "\n"
             if inFilesSection:
@@ -1545,7 +1574,7 @@ def edit_template(self, template_file):
             if response == 'n':
                 return False
 
-    def get_diff_description(self, editedFiles, filesToAdd):
+    def get_diff_description(self, editedFiles, filesToAdd, symlinks):
         # diff
         if os.environ.has_key("P4DIFF"):
             del(os.environ["P4DIFF"])
@@ -1560,10 +1589,17 @@ def get_diff_description(self, editedFiles, filesToAdd):
             newdiff += "==== new file ====\n"
             newdiff += "--- /dev/null\n"
             newdiff += "+++ %s\n" % newFile
-            f = open(newFile, "r")
-            for line in f.readlines():
-                newdiff += "+" + line
-            f.close()
+
+            is_link = os.path.islink(newFile)
+            expect_link = newFile in symlinks
+
+            if is_link and expect_link:
+                newdiff += "+%s\n" % os.readlink(newFile)
+            else:
+                f = open(newFile, "r")
+                for line in f.readlines():
+                    newdiff += "+" + line
+                f.close()
 
         return (diff + newdiff).replace('\r\n', '\n')
 
@@ -1581,12 +1617,16 @@ def applyCommit(self, id):
         filesToDelete = set()
         editedFiles = set()
         pureRenameCopy = set()
+        symlinks = set()
         filesToChangeExecBit = {}
+        all_files = list()
 
         for line in diff:
             diff = parseDiffTreeEntry(line)
             modifier = diff['status']
             path = diff['src']
+            all_files.append(path)
+
             if modifier == "M":
                 p4_edit(path)
                 if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
@@ -1597,6 +1637,11 @@ def applyCommit(self, id):
                 filesToChangeExecBit[path] = diff['dst_mode']
                 if path in filesToDelete:
                     filesToDelete.remove(path)
+
+                dst_mode = int(diff['dst_mode'], 8)
+                if dst_mode == 0120000:
+                    symlinks.add(path)
+
             elif modifier == "D":
                 filesToDelete.add(path)
                 if path in filesToAdd:
@@ -1712,6 +1757,10 @@ def applyCommit(self, id):
             mode = filesToChangeExecBit[f]
             setP4ExecBit(f, mode)
 
+        if self.update_shelve:
+            print("all_files = %s" % str(all_files))
+            p4_reopen_in_change(self.update_shelve, all_files)
+
         #
         # Build p4 change description, starting with the contents
         # of the git commit message.
@@ -1720,7 +1769,7 @@ def applyCommit(self, id):
         logMessage = logMessage.strip()
         (logMessage, jobs) = self.separate_jobs_from_description(logMessage)
 
-        template = self.prepareSubmitTemplate()
+        template = self.prepareSubmitTemplate(self.update_shelve)
         submitTemplate = self.prepareLogMessage(template, logMessage, jobs)
 
         if self.preserveUser:
@@ -1734,7 +1783,7 @@ def applyCommit(self, id):
         separatorLine = "######## everything below this line is just the diff #######\n"
         if not self.prepare_p4_only:
             submitTemplate += separatorLine
-            submitTemplate += self.get_diff_description(editedFiles, filesToAdd)
+            submitTemplate += self.get_diff_description(editedFiles, filesToAdd, symlinks)
 
         (handle, fileName) = tempfile.mkstemp()
         tmpFile = os.fdopen(handle, "w+b")
@@ -1792,7 +1841,17 @@ def applyCommit(self, id):
                 if self.isWindows:
                     message = message.replace("\r\n", "\n")
                 submitTemplate = message[:message.index(separatorLine)]
-                p4_write_pipe(['submit', '-i'], submitTemplate)
+
+                if self.update_shelve:
+                    p4_write_pipe(['shelve', '-r', '-i'], submitTemplate)
+                elif self.shelve:
+                    p4_write_pipe(['shelve', '-i'], submitTemplate)
+                else:
+                    p4_write_pipe(['submit', '-i'], submitTemplate)
+                    # The rename/copy happened by applying a patch that created a
+                    # new file.  This leaves it writable, which confuses p4.
+                    for f in pureRenameCopy:
+                        p4_sync(f, "-f")
 
                 if self.preserveUser:
                     if p4User:
@@ -1802,23 +1861,20 @@ def applyCommit(self, id):
                         changelist = self.lastP4Changelist()
                         self.modifyChangelistUser(changelist, p4User)
 
-                # The rename/copy happened by applying a patch that created a
-                # new file.  This leaves it writable, which confuses p4.
-                for f in pureRenameCopy:
-                    p4_sync(f, "-f")
                 submitted = True
 
         finally:
             # skip this patch
-            if not submitted:
-                print "Submission cancelled, undoing p4 changes."
-                for f in editedFiles:
+            if not submitted or self.shelve:
+                if self.shelve:
+                    print ("Reverting shelved files.")
+                else:
+                    print ("Submission cancelled, undoing p4 changes.")
+                for f in editedFiles | filesToDelete:
                     p4_revert(f)
                 for f in filesToAdd:
                     p4_revert(f)
                     os.remove(f)
-                for f in filesToDelete:
-                    p4_revert(f)
 
         os.remove(fileName)
         return submitted
@@ -1914,6 +1970,9 @@ def run(self, args):
         if len(self.origin) == 0:
             self.origin = upstream
 
+        if self.update_shelve:
+            self.shelve = True
+
         if self.preserveUser:
             if not self.canChangeChangelists():
                 die("Cannot preserve user names without p4 super-user or admin permissions")
@@ -2074,13 +2133,13 @@ def run(self, args):
                         break
 
         chdir(self.oldWorkingDirectory)
-
+        shelved_applied = "shelved" if self.shelve else "applied"
         if self.dry_run:
             pass
         elif self.prepare_p4_only:
             pass
         elif len(commits) == len(applied):
-            print "All commits applied!"
+            print ("All commits {0}!".format(shelved_applied))
 
             sync = P4Sync()
             if self.branch:
@@ -2092,9 +2151,9 @@ def run(self, args):
 
         else:
             if len(applied) == 0:
-                print "No commits applied."
+                print ("No commits {0}.".format(shelved_applied))
             else:
-                print "Applied only the commits marked with '*':"
+                print ("{0} only the commits marked with '*':".format(shelved_applied.capitalize()))
                 for c in commits:
                     if c in applied:
                         star = "*"
@@ -3689,6 +3748,7 @@ def main():
         if cmd.gitdir == None:
             cmd.gitdir = os.path.abspath(".git")
             if not isValidGitDir(cmd.gitdir):
+                # "rev-parse --git-dir" without arguments will try $PWD/.git
                 cmd.gitdir = read_pipe("git rev-parse --git-dir").strip()
                 if os.path.exists(cmd.gitdir):
                     cdup = read_pipe("git rev-parse --show-cdup").strip()
@@ -3701,6 +3761,7 @@ def main():
             else:
                 die("fatal: cannot locate git repository at %s" % cmd.gitdir)
 
+        # so git commands invoked from the P4 workspace will succeed
         os.environ["GIT_DIR"] = cmd.gitdir
 
     if not cmd.run(args):
index 41fd374c725de1f42965b829c2bed5c48c92e19c..b0a6f2b7bae0d4ccd5fcf00ae4dac6c29e50bd71 100644 (file)
@@ -437,7 +437,8 @@ update_squash_messages () {
                        }' <"$squash_msg".bak
                } >"$squash_msg"
        else
-               commit_message HEAD > "$fixup_msg" || die "$(gettext "Cannot write \$fixup_msg")"
+               commit_message HEAD >"$fixup_msg" ||
+               die "$(eval_gettext "Cannot write \$fixup_msg")"
                count=2
                {
                        printf '%s\n' "$comment_char $(gettext "This is a combination of 2 commits.")"
index 04f6e44bc8c779d7f4c60c19066820533279324a..48d7c5ded40e1801a36a897849e0f32b314e5981 100755 (executable)
@@ -43,6 +43,7 @@ continue!          continue
 abort!             abort and check out the original branch
 skip!              skip current patch and continue
 edit-todo!         edit the todo list during an interactive rebase
+quit!              abort but keep HEAD where it is
 "
 . git-sh-setup
 set_reflog_action rebase
@@ -241,7 +242,7 @@ do
        --verify)
                ok_to_skip_pre_rebase=
                ;;
-       --continue|--skip|--abort|--edit-todo)
+       --continue|--skip|--abort|--quit|--edit-todo)
                test $total_argc -eq 2 || usage
                action=${1##--}
                ;;
@@ -399,6 +400,9 @@ abort)
        finish_rebase
        exit
        ;;
+quit)
+       exec rm -rf "$state_dir"
+       ;;
 edit-todo)
        run_specific_rebase
        ;;
index da81be40cb7f9af1a960be2c22f8e75c9d16822e..068d60b3e698f03f433db33d9e5f085ea57ce0a3 100755 (executable)
@@ -28,6 +28,7 @@
 use File::Spec::Functions qw(catfile);
 use Error qw(:try);
 use Git;
+use Git::I18N;
 
 Getopt::Long::Configure qw/ pass_through /;
 
@@ -117,20 +118,20 @@ sub format_2822_time {
        my $localmin = $localtm[1] + $localtm[2] * 60;
        my $gmtmin = $gmttm[1] + $gmttm[2] * 60;
        if ($localtm[0] != $gmttm[0]) {
-               die "local zone differs from GMT by a non-minute interval\n";
+               die __("local zone differs from GMT by a non-minute interval\n");
        }
        if ((($gmttm[6] + 1) % 7) == $localtm[6]) {
                $localmin += 1440;
        } elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {
                $localmin -= 1440;
        } elsif ($gmttm[6] != $localtm[6]) {
-               die "local time offset greater than or equal to 24 hours\n";
+               die __("local time offset greater than or equal to 24 hours\n");
        }
        my $offset = $localmin - $gmtmin;
        my $offhour = $offset / 60;
        my $offmin = abs($offset % 60);
        if (abs($offhour) >= 24) {
-               die ("local time offset greater than or equal to 24 hours\n");
+               die __("local time offset greater than or equal to 24 hours\n");
        }
 
        return sprintf("%s, %2d %s %d %02d:%02d:%02d %s%02d%02d",
@@ -198,13 +199,13 @@ sub do_edit {
                map {
                        system('sh', '-c', $editor.' "$@"', $editor, $_);
                        if (($? & 127) || ($? >> 8)) {
-                               die("the editor exited uncleanly, aborting everything");
+                               die(__("the editor exited uncleanly, aborting everything"));
                        }
                } @_;
        } else {
                system('sh', '-c', $editor.' "$@"', $editor, @_);
                if (($? & 127) || ($? >> 8)) {
-                       die("the editor exited uncleanly, aborting everything");
+                       die(__("the editor exited uncleanly, aborting everything"));
                }
        }
 }
@@ -278,10 +279,13 @@ sub signal_handler {
        # tmp files from --compose
        if (defined $compose_filename) {
                if (-e $compose_filename) {
-                       print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
+                       printf __("'%s' contains an intermediate version ".
+                                 "of the email you were composing.\n"),
+                                 $compose_filename;
                }
                if (-e ($compose_filename . ".final")) {
-                       print "'$compose_filename.final' contains the composed email.\n"
+                       printf __("'%s.final' contains the composed email.\n"),
+                                 $compose_filename;
                }
        }
 
@@ -298,7 +302,7 @@ sub signal_handler {
 my $rc = GetOptions("h" => \$help,
                     "dump-aliases" => \$dump_aliases);
 usage() unless $rc;
-die "--dump-aliases incompatible with other options\n"
+die __("--dump-aliases incompatible with other options\n")
     if !$help and $dump_aliases and @ARGV;
 $rc = GetOptions(
                    "sender|from=s" => \$sender,
@@ -361,7 +365,7 @@ sub signal_handler {
     usage();
 }
 
-die "Cannot run git format-patch from outside a repository\n"
+die __("Cannot run git format-patch from outside a repository\n")
        if $format_patch and not $repo;
 
 # Now, let's fill any that aren't set in with defaults:
@@ -430,7 +434,7 @@ sub read_config {
 my(%suppress_cc);
 if (@suppress_cc) {
        foreach my $entry (@suppress_cc) {
-               die "Unknown --suppress-cc field: '$entry'\n"
+               die sprintf(__("Unknown --suppress-cc field: '%s'\n"), $entry)
                        unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;
                $suppress_cc{$entry} = 1;
        }
@@ -459,7 +463,7 @@ sub read_config {
 if ($confirm_unconfigured) {
        $confirm = scalar %suppress_cc ? 'compose' : 'auto';
 };
-die "Unknown --confirm setting: '$confirm'\n"
+die sprintf(__("Unknown --confirm setting: '%s'\n"), $confirm)
        unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
 
 # Debugging, print out the suppressions.
@@ -491,16 +495,16 @@ sub split_addrs {
 sub parse_sendmail_alias {
        local $_ = shift;
        if (/"/) {
-               print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
+               printf STDERR __("warning: sendmail alias with quotes is not supported: %s\n"), $_;
        } elsif (/:include:/) {
-               print STDERR "warning: `:include:` not supported: $_\n";
+               printf STDERR __("warning: `:include:` not supported: %s\n"), $_;
        } elsif (/[\/|]/) {
-               print STDERR "warning: `/file` or `|pipe` redirection not supported: $_\n";
+               printf STDERR __("warning: `/file` or `|pipe` redirection not supported: %s\n"), $_;
        } elsif (/^(\S+?)\s*:\s*(.+)$/) {
                my ($alias, $addr) = ($1, $2);
                $aliases{$alias} = [ split_addrs($addr) ];
        } else {
-               print STDERR "warning: sendmail line is not recognized: $_\n";
+               printf STDERR __("warning: sendmail line is not recognized: %s\n"), $_;
        }
 }
 
@@ -581,11 +585,11 @@ sub is_format_patch_arg {
                if (defined($format_patch)) {
                        return $format_patch;
                }
-               die(<<EOF);
-File '$f' exists but it could also be the range of commits
+               die sprintf(__ <<EOF, $f, $f);
+File '%s' exists but it could also be the range of commits
 to produce patches for.  Please disambiguate by...
 
-    * Saying "./$f" if you mean a file; or
+    * Saying "./%s" if you mean a file; or
     * Giving --format-patch option if you mean a range.
 EOF
        } catch Git::Error::Command with {
@@ -603,7 +607,7 @@ sub is_format_patch_arg {
                @ARGV = ();
        } elsif (-d $f and !is_format_patch_arg($f)) {
                opendir my $dh, $f
-                       or die "Failed to opendir $f: $!";
+                       or die sprintf(__("Failed to opendir %s: %s"), $f, $!);
 
                push @files, grep { -f $_ } map { catfile($f, $_) }
                                sort readdir $dh;
@@ -616,7 +620,7 @@ sub is_format_patch_arg {
 }
 
 if (@rev_list_opts) {
-       die "Cannot run git format-patch from outside a repository\n"
+       die __("Cannot run git format-patch from outside a repository\n")
                unless $repo;
        push @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);
 }
@@ -627,7 +631,8 @@ sub is_format_patch_arg {
        foreach my $f (@files) {
                unless (-p $f) {
                        my $error = validate_patch($f);
-                       $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+                       $error and die sprintf(__("fatal: %s: %s\nwarning: no patches were sent\n"),
+                                                 $f, $error);
                }
        }
 }
@@ -637,7 +642,7 @@ sub is_format_patch_arg {
                print $_,"\n" for (@files);
        }
 } else {
-       print STDERR "\nNo patch files specified!\n\n";
+       print STDERR __("\nNo patch files specified!\n\n");
        usage();
 }
 
@@ -650,7 +655,7 @@ sub get_patch_subject {
                return "GIT: $1\n";
        }
        close $fh;
-       die "No subject line in $fn ?";
+       die sprintf(__("No subject line in %s?"), $fn);
 }
 
 if ($compose) {
@@ -660,25 +665,27 @@ sub get_patch_subject {
                tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
                tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
        open my $c, ">", $compose_filename
-               or die "Failed to open for writing $compose_filename: $!";
+               or die sprintf(__("Failed to open for writing %s: %s"), $compose_filename, $!);
 
 
        my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
        my $tpl_subject = $initial_subject || '';
        my $tpl_reply_to = $initial_reply_to || '';
 
-       print $c <<EOT;
+       print $c <<EOT1, Git::prefix_lines("GIT: ", __ <<EOT2), <<EOT3;
 From $tpl_sender # This line is ignored.
-GIT: Lines beginning in "GIT:" will be removed.
-GIT: Consider including an overall diffstat or table of contents
-GIT: for the patch you are writing.
-GIT:
-GIT: Clear the body content if you don't wish to send a summary.
+EOT1
+Lines beginning in "GIT:" will be removed.
+Consider including an overall diffstat or table of contents
+for the patch you are writing.
+
+Clear the body content if you don't wish to send a summary.
+EOT2
 From: $tpl_sender
 Subject: $tpl_subject
 In-Reply-To: $tpl_reply_to
 
-EOT
+EOT3
        for my $f (@files) {
                print $c get_patch_subject($f);
        }
@@ -691,10 +698,10 @@ sub get_patch_subject {
        }
 
        open my $c2, ">", $compose_filename . ".final"
-               or die "Failed to open $compose_filename.final : " . $!;
+               or die sprintf(__("Failed to open %s.final: %s"), $compose_filename, $!);
 
        open $c, "<", $compose_filename
-               or die "Failed to open $compose_filename : " . $!;
+               or die sprintf(__("Failed to open %s: %s"), $compose_filename, $!);
 
        my $need_8bit_cte = file_has_nonascii($compose_filename);
        my $in_body = 0;
@@ -729,7 +736,7 @@ sub get_patch_subject {
                        $sender = $1;
                        next;
                } elsif (/^(?:To|Cc|Bcc):/i) {
-                       print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
+                       print __("To/Cc/Bcc fields are not interpreted yet, they have been ignored\n");
                        next;
                }
                print $c2 $_;
@@ -738,7 +745,7 @@ sub get_patch_subject {
        close $c2;
 
        if ($summary_empty) {
-               print "Summary email is empty, skipping it\n";
+               print __("Summary email is empty, skipping it\n");
                $compose = -1;
        }
 } elsif ($annotate) {
@@ -768,7 +775,9 @@ sub ask {
                        return $resp;
                }
                if ($confirm_only) {
-                       my $yesno = $term->readline("Are you sure you want to use <$resp> [y/N]? ");
+                       my $yesno = $term->readline(
+                               # TRANSLATORS: please keep [y/N] as is.
+                               sprintf(__("Are you sure you want to use <%s> [y/N]? "), $resp));
                        if (defined $yesno && $yesno =~ /y/i) {
                                return $resp;
                        }
@@ -797,12 +806,12 @@ sub file_declares_8bit_cte {
 }
 
 if (!defined $auto_8bit_encoding && scalar %broken_encoding) {
-       print "The following files are 8bit, but do not declare " .
-               "a Content-Transfer-Encoding.\n";
+       print __("The following files are 8bit, but do not declare " .
+                "a Content-Transfer-Encoding.\n");
        foreach my $f (sort keys %broken_encoding) {
                print "    $f\n";
        }
-       $auto_8bit_encoding = ask("Which 8bit encoding should I declare [UTF-8]? ",
+       $auto_8bit_encoding = ask(__("Which 8bit encoding should I declare [UTF-8]? "),
                                  valid_re => qr/.{4}/, confirm_only => 1,
                                  default => "UTF-8");
 }
@@ -810,9 +819,9 @@ sub file_declares_8bit_cte {
 if (!$force) {
        for my $f (@files) {
                if (get_patch_subject($f) =~ /\Q*** SUBJECT HERE ***\E/) {
-                       die "Refusing to send because the patch\n\t$f\n"
+                       die sprintf(__("Refusing to send because the patch\n\t%s\n"
                                . "has the template subject '*** SUBJECT HERE ***'. "
-                               . "Pass --force if you really want to send.\n";
+                               . "Pass --force if you really want to send.\n"), $f);
                }
        }
 }
@@ -829,7 +838,7 @@ sub file_declares_8bit_cte {
 # But it's a no-op to run sanitize_address on an already sanitized address.
 $sender = sanitize_address($sender);
 
-my $to_whom = "To whom should the emails be sent (if anyone)?";
+my $to_whom = __("To whom should the emails be sent (if anyone)?");
 my $prompting = 0;
 if (!@initial_to && !defined $to_cmd) {
        my $to = ask("$to_whom ",
@@ -847,7 +856,7 @@ sub expand_aliases {
 sub expand_one_alias {
        my $alias = shift;
        if ($EXPANDED_ALIASES{$alias}) {
-               die "fatal: alias '$alias' expands to itself\n";
+               die sprintf(__("fatal: alias '%s' expands to itself\n"), $alias);
        }
        local $EXPANDED_ALIASES{$alias} = 1;
        return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;
@@ -859,7 +868,7 @@ sub expand_one_alias {
 
 if ($thread && !defined $initial_reply_to && $prompting) {
        $initial_reply_to = ask(
-               "Message-ID to be used as In-Reply-To for the first email (if any)? ",
+               __("Message-ID to be used as In-Reply-To for the first email (if any)? "),
                default => "",
                valid_re => qr/\@.*\./, confirm_only => 1);
 }
@@ -909,7 +918,7 @@ sub extract_valid_address {
 sub extract_valid_address_or_die {
        my $address = shift;
        $address = extract_valid_address($address);
-       die "error: unable to extract a valid address from: $address\n"
+       die sprintf(__("error: unable to extract a valid address from: %s\n"), $address)
                if !$address;
        return $address;
 }
@@ -917,8 +926,11 @@ sub extract_valid_address_or_die {
 sub validate_address {
        my $address = shift;
        while (!extract_valid_address($address)) {
-               print STDERR "error: unable to extract a valid address from: $address\n";
-               $_ = ask("What to do with this address? ([q]uit|[d]rop|[e]dit): ",
+               printf STDERR __("error: unable to extract a valid address from: %s\n"), $address;
+               # TRANSLATORS: Make sure to include [q] [d] [e] in your
+               # translation. The program will only accept English input
+               # at this point.
+               $_ = ask(__("What to do with this address? ([q]uit|[d]rop|[e]dit): "),
                        valid_re => qr/^(?:quit|q|drop|d|edit|e)/i,
                        default => 'q');
                if (/^d/i) {
@@ -1219,7 +1231,7 @@ sub ssl_verify_params {
                return (SSL_verify_mode => SSL_VERIFY_PEER(),
                        SSL_ca_file => $smtp_ssl_cert_path);
        } else {
-               die "CA path \"$smtp_ssl_cert_path\" does not exist";
+               die sprintf(__("CA path \"%s\" does not exist"), $smtp_ssl_cert_path);
        }
 }
 
@@ -1293,20 +1305,26 @@ sub send_message {
                if ($needs_confirm eq "inform") {
                        $confirm_unconfigured = 0; # squelch this message for the rest of this run
                        $ask_default = "y"; # assume yes on EOF since user hasn't explicitly asked for confirmation
-                       print "    The Cc list above has been expanded by additional\n";
-                       print "    addresses found in the patch commit message. By default\n";
-                       print "    send-email prompts before sending whenever this occurs.\n";
-                       print "    This behavior is controlled by the sendemail.confirm\n";
-                       print "    configuration setting.\n";
-                       print "\n";
-                       print "    For additional information, run 'git send-email --help'.\n";
-                       print "    To retain the current behavior, but squelch this message,\n";
-                       print "    run 'git config --global sendemail.confirm auto'.\n\n";
+                       print __ <<EOF ;
+    The Cc list above has been expanded by additional
+    addresses found in the patch commit message. By default
+    send-email prompts before sending whenever this occurs.
+    This behavior is controlled by the sendemail.confirm
+    configuration setting.
+
+    For additional information, run 'git send-email --help'.
+    To retain the current behavior, but squelch this message,
+    run 'git config --global sendemail.confirm auto'.
+
+EOF
                }
-               $_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
+               # TRANSLATORS: Make sure to include [y] [n] [q] [a] in your
+               # translation. The program will only accept English input
+               # at this point.
+               $_ = ask(__("Send this email? ([y]es|[n]o|[q]uit|[a]ll): "),
                         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
                         default => $ask_default);
-               die "Send this email reply required" unless defined $_;
+               die __("Send this email reply required") unless defined $_;
                if (/^n/i) {
                        return 0;
                } elsif (/^q/i) {
@@ -1332,7 +1350,7 @@ sub send_message {
        } else {
 
                if (!defined $smtp_server) {
-                       die "The required SMTP server is not properly defined."
+                       die __("The required SMTP server is not properly defined.")
                }
 
                if ($smtp_encryption eq 'ssl') {
@@ -1376,14 +1394,14 @@ sub send_message {
                                        # supported commands
                                        $smtp->hello($smtp_domain);
                                } else {
-                                       die "Server does not support STARTTLS! ".$smtp->message;
+                                       die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message);
                                }
                        }
                }
 
                if (!$smtp) {
-                       die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
-                           "VALUES: server=$smtp_server ",
+                       die __("Unable to initialize SMTP properly. Check config and use --smtp-debug."),
+                           " VALUES: server=$smtp_server ",
                            "encryption=$smtp_encryption ",
                            "hello=$smtp_domain",
                            defined $smtp_server_port ? " port=$smtp_server_port" : "";
@@ -1400,12 +1418,12 @@ sub send_message {
                        $smtp->datasend("$line") or die $smtp->message;
                }
                $smtp->dataend() or die $smtp->message;
-               $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
+               $smtp->code =~ /250|200/ or die sprintf(__("Failed to send %s\n"), $subject).$smtp->message;
        }
        if ($quiet) {
-               printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
+               printf($dry_run ? __("Dry-Sent %s\n") : __("Sent %s\n"), $subject);
        } else {
-               print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
+               print($dry_run ? __("Dry-OK. Log says:\n") : __("OK. Log says:\n"));
                if (!file_name_is_absolute($smtp_server)) {
                        print "Server: $smtp_server\n";
                        print "MAIL FROM:<$raw_from>\n";
@@ -1417,10 +1435,10 @@ sub send_message {
                }
                print $header, "\n";
                if ($smtp) {
-                       print "Result: ", $smtp->code, ' ',
+                       print __("Result: "), $smtp->code, ' ',
                                ($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
                } else {
-                       print "Result: OK\n";
+                       print __("Result: OK\n");
                }
        }
 
@@ -1433,7 +1451,7 @@ sub send_message {
 $message_num = 0;
 
 foreach my $t (@files) {
-       open my $fh, "<", $t or die "can't open file $t";
+       open my $fh, "<", $t or die sprintf(__("can't open file %s"), $t);
 
        my $author = undef;
        my $sauthor = undef;
@@ -1480,13 +1498,13 @@ sub send_message {
                                $sauthor = sanitize_address($author);
                                next if $suppress_cc{'author'};
                                next if $suppress_cc{'self'} and $sauthor eq $sender;
-                               printf("(mbox) Adding cc: %s from line '%s'\n",
+                               printf(__("(mbox) Adding cc: %s from line '%s'\n"),
                                        $1, $_) unless $quiet;
                                push @cc, $1;
                        }
                        elsif (/^To:\s+(.*)$/i) {
                                foreach my $addr (parse_address_line($1)) {
-                                       printf("(mbox) Adding to: %s from line '%s'\n",
+                                       printf(__("(mbox) Adding to: %s from line '%s'\n"),
                                                $addr, $_) unless $quiet;
                                        push @to, $addr;
                                }
@@ -1500,7 +1518,7 @@ sub send_message {
                                        } else {
                                                next if ($suppress_cc{'cc'});
                                        }
-                                       printf("(mbox) Adding cc: %s from line '%s'\n",
+                                       printf(__("(mbox) Adding cc: %s from line '%s'\n"),
                                                $addr, $_) unless $quiet;
                                        push @cc, $addr;
                                }
@@ -1534,7 +1552,7 @@ sub send_message {
                        # So let's support that, too.
                        $input_format = 'lots';
                        if (@cc == 0 && !$suppress_cc{'cc'}) {
-                               printf("(non-mbox) Adding cc: %s from line '%s'\n",
+                               printf(__("(non-mbox) Adding cc: %s from line '%s'\n"),
                                        $_, $_) unless $quiet;
                                push @cc, $_;
                        } elsif (!defined $subject) {
@@ -1557,7 +1575,7 @@ sub send_message {
                                next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
                        }
                        push @cc, $c;
-                       printf("(body) Adding cc: %s from line '%s'\n",
+                       printf(__("(body) Adding cc: %s from line '%s'\n"),
                                $c, $_) unless $quiet;
                }
        }
@@ -1655,18 +1673,18 @@ sub recipients_cmd {
 
        my @addresses = ();
        open my $fh, "-|", "$cmd \Q$file\E"
-           or die "($prefix) Could not execute '$cmd'";
+           or die sprintf(__("(%s) Could not execute '%s'"), $prefix, $cmd);
        while (my $address = <$fh>) {
                $address =~ s/^\s*//g;
                $address =~ s/\s*$//g;
                $address = sanitize_address($address);
                next if ($address eq $sender and $suppress_cc{'self'});
                push @addresses, $address;
-               printf("($prefix) Adding %s: %s from: '%s'\n",
-                      $what, $address, $cmd) unless $quiet;
+               printf(__("(%s) Adding %s: %s from: '%s'\n"),
+                      $prefix, $what, $address, $cmd) unless $quiet;
                }
        close $fh
-           or die "($prefix) failed to close pipe to '$cmd'";
+           or die sprintf(__("(%s) failed to close pipe to '%s'"), $prefix, $cmd);
        return @addresses;
 }
 
@@ -1693,7 +1711,7 @@ sub apply_transfer_encoding {
        $message = MIME::Base64::decode($message)
                if ($from eq 'base64');
 
-       die "cannot send message as 7bit"
+       die __("cannot send message as 7bit")
                if ($to eq '7bit' and $message =~ /[^[:ascii:]]/);
        return $message
                if ($to eq '7bit' or $to eq '8bit');
@@ -1701,7 +1719,7 @@ sub apply_transfer_encoding {
                if ($to eq 'quoted-printable');
        return MIME::Base64::encode($message, "\n")
                if ($to eq 'base64');
-       die "invalid transfer encoding";
+       die __("invalid transfer encoding");
 }
 
 sub unique_email_list {
@@ -1720,10 +1738,10 @@ sub unique_email_list {
 sub validate_patch {
        my $fn = shift;
        open(my $fh, '<', $fn)
-               or die "unable to open $fn: $!\n";
+               or die sprintf(__("unable to open %s: %s\n"), $fn, $!);
        while (my $line = <$fh>) {
                if (length($line) > 998) {
-                       return "$.: patch contains a line longer than 998 characters";
+                       return sprintf(__("%s: patch contains a line longer than 998 characters"), $.);
                }
        }
        return;
@@ -1739,10 +1757,11 @@ sub handle_backup {
            (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";
+                       printf(__("Skipping %s with backup suffix '%s'.\n"), $file, $known_suffix);
                        $skip = 1;
                } else {
-                       my $answer = ask("Do you really want to send $file? (y|N): ",
+                       # TRANSLATORS: please keep "[y|N]" as is.
+                       my $answer = ask(sprintf(__("Do you really want to send %s? [y|N]: "), $file),
                                         valid_re => qr/^(?:y|n)/i,
                                         default => 'n');
                        $skip = ($answer ne 'y');
@@ -1770,7 +1789,7 @@ sub handle_backup_files {
 sub file_has_nonascii {
        my $fn = shift;
        open(my $fh, '<', $fn)
-               or die "unable to open $fn: $!\n";
+               or die sprintf(__("unable to open %s: %s\n"), $fn, $!);
        while (my $line = <$fh>) {
                return 1 if $line =~ /[^[:ascii:]]/;
        }
@@ -1780,7 +1799,7 @@ sub file_has_nonascii {
 sub body_or_subject_has_nonascii {
        my $fn = shift;
        open(my $fh, '<', $fn)
-               or die "unable to open $fn: $!\n";
+               or die sprintf(__("unable to open %s: %s\n"), $fn, $!);
        while (my $line = <$fh>) {
                last if $line =~ /^$/;
                return 1 if $line =~ /^Subject.*[^[:ascii:]]/;
index 240c7ebcd1449935d359e12b8bae817179f567bf..378928518b2c42ee3adb69b52d3b0eb63fca8ac3 100644 (file)
@@ -196,14 +196,14 @@ require_work_tree_exists () {
        if test "z$(git rev-parse --is-bare-repository)" != zfalse
        then
                program_name=$0
-               die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
+               die "$(eval_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 || {
                program_name=$0
-               die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
+               die "$(eval_gettext "fatal: \$program_name cannot be used without a working tree.")"
        }
 }
 
index 4546abaaef3dab9e0c4dc719f111682f1cb1dd57..10c284d1aa2273a3dfe5cc39f1d6738830d02462 100755 (executable)
@@ -115,7 +115,7 @@ create_stash () {
                        git read-tree --index-output="$TMPindex" -m $i_tree &&
                        GIT_INDEX_FILE="$TMPindex" &&
                        export GIT_INDEX_FILE &&
-                       git diff --name-only -z HEAD -- >"$TMP-stagenames" &&
+                       git diff-index --name-only -z HEAD -- >"$TMP-stagenames" &&
                        git update-index -z --add --remove --stdin <"$TMP-stagenames" &&
                        git write-tree &&
                        rm -f "$TMPindex"
index a024a135d6663c8a8d5ceb926e3f42df1f577411..554bd1c4943a5f2dd9aa9615dadc962bf6405d7a 100755 (executable)
@@ -21,14 +21,10 @@ require_work_tree
 wt_prefix=$(git rev-parse --show-prefix)
 cd_to_toplevel
 
-# Restrict ourselves to a vanilla subset of protocols; the URLs
-# we get are under control of a remote repository, and we do not
-# want them kicking off arbitrary git-remote-* programs.
-#
-# If the user has already specified a set of allowed protocols,
-# we assume they know what they're doing and use that instead.
-: ${GIT_ALLOW_PROTOCOL=file:git:http:https:ssh}
-export GIT_ALLOW_PROTOCOL
+# Tell the rest of git that any URLs we get don't come
+# directly from the user, so it can apply policy as appropriate.
+GIT_PROTOCOL_FROM_USER=0
+export GIT_PROTOCOL_FROM_USER
 
 command=
 branch=
@@ -1131,6 +1127,11 @@ cmd_sync()
        done
 }
 
+cmd_absorbgitdirs()
+{
+       git submodule--helper absorb-git-dirs --prefix "$wt_prefix" "$@"
+}
+
 # This loop parses the command line arguments to find the
 # subcommand name to dispatch.  Parsing of the subcommand specific
 # options are primarily done by the subcommand implementations.
@@ -1140,7 +1141,7 @@ cmd_sync()
 while test $# != 0 && test -z "$command"
 do
        case "$1" in
-       add | foreach | init | deinit | update | status | summary | sync)
+       add | foreach | init | deinit | update | status | summary | sync | absorbgitdirs)
                command=$1
                ;;
        -q|--quiet)
diff --git a/git.c b/git.c
index dce529fcbfd6e5d8526b0e88b43f6c568876ce9d..e4714aadb3e6f38baec6afaee493c15590875684 100644 (file)
--- a/git.c
+++ b/git.c
@@ -434,7 +434,7 @@ static struct cmd_struct commands[] = {
        { "fsck-objects", cmd_fsck, RUN_SETUP },
        { "gc", cmd_gc, RUN_SETUP },
        { "get-tar-commit-id", cmd_get_tar_commit_id },
-       { "grep", cmd_grep, RUN_SETUP_GENTLY },
+       { "grep", cmd_grep, RUN_SETUP_GENTLY | SUPPORT_SUPER_PREFIX },
        { "hash-object", cmd_hash_object },
        { "help", cmd_help },
        { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
@@ -493,7 +493,7 @@ static struct cmd_struct commands[] = {
        { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
        { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
        { "stripspace", cmd_stripspace },
-       { "submodule--helper", cmd_submodule__helper, RUN_SETUP },
+       { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX},
        { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
        { "tag", cmd_tag, RUN_SETUP },
        { "unpack-file", cmd_unpack_file, RUN_SETUP },
index 5acdc900abdfb3ccc1ad7616fecb098ce6f060e2..5bdd52a6ebfa722fe077ec6a3160f9bbd8ff6a2b 100644 (file)
@@ -50,6 +50,7 @@ endif
 all:: gitk-wish $(ALL_MSGFILES)
 
 install:: all
+       $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
        $(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'
        $(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
index 805a1c703040d4b08fc0d6992c92e2a044c5ddc5..a14d7a16b2dd1162fa8572d776f4adee8a0ce91f 100755 (executable)
@@ -2,7 +2,7 @@
 # Tcl ignores the next line -*- tcl -*- \
 exec wish "$0" -- "$@"
 
-# Copyright © 2005-2014 Paul Mackerras.  All rights reserved.
+# Copyright © 2005-2016 Paul Mackerras.  All rights reserved.
 # This program is free software; it may be used, copied, modified
 # and distributed under the terms of the GNU General Public Licence,
 # either version 2, or (at your option) any later version.
@@ -588,7 +588,7 @@ proc updatecommits {} {
 proc reloadcommits {} {
     global curview viewcomplete selectedline currentid thickerline
     global showneartags treediffs commitinterest cached_commitrow
-    global targetid
+    global targetid commitinfo
 
     set selid {}
     if {$selectedline ne {}} {
@@ -609,6 +609,7 @@ proc reloadcommits {} {
        getallcommits
     }
     clear_display
+    unset -nocomplain commitinfo
     unset -nocomplain commitinterest
     unset -nocomplain cached_commitrow
     unset -nocomplain targetid
@@ -1315,7 +1316,7 @@ proc commitonrow {row} {
 
 proc closevarcs {v} {
     global varctok varccommits varcid parents children
-    global cmitlisted commitidx vtokmod
+    global cmitlisted commitidx vtokmod curview numcommits
 
     set missing_parents 0
     set scripts {}
@@ -1340,6 +1341,9 @@ proc closevarcs {v} {
            }
            lappend varccommits($v,$b) $p
            incr commitidx($v)
+           if {$v == $curview} {
+               set numcommits $commitidx($v)
+           }
            set scripts [check_interest $p $scripts]
        }
     }
@@ -2265,7 +2269,7 @@ proc makewindow {} {
        set h [expr {[font metrics uifont -linespace] + 2}]
        set progresscanv .tf.bar.progress
        canvas $progresscanv -relief sunken -height $h -borderwidth 2
-       set progressitem [$progresscanv create rect -1 0 0 $h -fill lime]
+       set progressitem [$progresscanv create rect -1 0 0 $h -fill "#00ff00"]
        set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
        set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
     }
@@ -2403,7 +2407,7 @@ proc makewindow {} {
 
     set ctext .bleft.bottom.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
-       -state disabled -font textfont \
+       -state disabled -undo 0 -font textfont \
        -yscrollcommand scrolltext -wrap none \
        -xscrollcommand ".bleft.bottom.sbhorizontal set"
     if {$have_tk85} {
@@ -2664,6 +2668,7 @@ proc makewindow {} {
     set headctxmenu .headctxmenu
     makemenu $headctxmenu {
        {mc "Check out this branch" command cobranch}
+       {mc "Rename this branch" command mvbranch}
        {mc "Remove this branch" command rmbranch}
        {mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}}
     }
@@ -3033,7 +3038,7 @@ proc about {} {
     message $w.m -text [mc "
 Gitk - a commit viewer for git
 
-Copyright \u00a9 2005-2014 Paul Mackerras
+Copyright \u00a9 2005-2016 Paul Mackerras
 
 Use and redistribute under the terms of the GNU General Public License"] \
            -justify center -aspect 400 -border 2 -bg $bgcolor -relief groove
@@ -3397,7 +3402,7 @@ set rectmask {
        0x00, 0x00, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f,
        0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0x00, 0x00};
 }
-image create bitmap reficon-H -background black -foreground lime \
+image create bitmap reficon-H -background black -foreground "#00ff00" \
     -data $rectdata -maskdata $rectmask
 image create bitmap reficon-o -background black -foreground "#ddddff" \
     -data $rectdata -maskdata $rectmask
@@ -8069,7 +8074,11 @@ proc getblobdiffline {bdf ids} {
     $ctext conf -state normal
     while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {
        if {$ids != $diffids || $bdf != $blobdifffd($ids)} {
+           # Older diff read. Abort it.
            catch {close $bdf}
+           if {$ids != $diffids} {
+               array unset blobdifffd $ids
+           }
            return 0
        }
        parseblobdiffline $ids $line
@@ -8078,6 +8087,7 @@ proc getblobdiffline {bdf ids} {
     blobdiffmaybeseehere [eof $bdf]
     if {[eof $bdf]} {
        catch {close $bdf}
+       array unset blobdifffd $ids
        return 0
     }
     return [expr {$nr >= 1000? 2: 1}]
@@ -9452,26 +9462,63 @@ proc wrcomcan {} {
 }
 
 proc mkbranch {} {
-    global rowmenuid mkbrtop NS
+    global NS rowmenuid
+
+    set top .branchdialog
+
+    set val(name) ""
+    set val(id) $rowmenuid
+    set val(command) [list mkbrgo $top]
+
+    set ui(title) [mc "Create branch"]
+    set ui(accept) [mc "Create"]
+
+    branchdia $top val ui
+}
+
+proc mvbranch {} {
+    global NS
+    global headmenuid headmenuhead
+
+    set top .branchdialog
+
+    set val(name) $headmenuhead
+    set val(id) $headmenuid
+    set val(command) [list mvbrgo $top $headmenuhead]
+
+    set ui(title) [mc "Rename branch %s" $headmenuhead]
+    set ui(accept) [mc "Rename"]
+
+    branchdia $top val ui
+}
+
+proc branchdia {top valvar uivar} {
+    global NS commitinfo
+    upvar $valvar val $uivar ui
 
-    set top .makebranch
     catch {destroy $top}
     ttk_toplevel $top
     make_transient $top .
-    ${NS}::label $top.title -text [mc "Create new branch"]
+    ${NS}::label $top.title -text $ui(title)
     grid $top.title - -pady 10
     ${NS}::label $top.id -text [mc "ID:"]
     ${NS}::entry $top.sha1 -width 40
-    $top.sha1 insert 0 $rowmenuid
+    $top.sha1 insert 0 $val(id)
     $top.sha1 conf -state readonly
     grid $top.id $top.sha1 -sticky w
+    ${NS}::entry $top.head -width 60
+    $top.head insert 0 [lindex $commitinfo($val(id)) 0]
+    $top.head conf -state readonly
+    grid x $top.head -sticky ew
+    grid columnconfigure $top 1 -weight 1
     ${NS}::label $top.nlab -text [mc "Name:"]
     ${NS}::entry $top.name -width 40
+    $top.name insert 0 $val(name)
     grid $top.nlab $top.name -sticky w
     ${NS}::frame $top.buts
-    ${NS}::button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
+    ${NS}::button $top.buts.go -text $ui(accept) -command $val(command)
     ${NS}::button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
-    bind $top <Key-Return> [list mkbrgo $top]
+    bind $top <Key-Return> $val(command)
     bind $top <Key-Escape> "catch {destroy $top}"
     grid $top.buts.go $top.buts.can
     grid columnconfigure $top.buts 0 -weight 1 -uniform a
@@ -9526,6 +9573,46 @@ proc mkbrgo {top} {
     }
 }
 
+proc mvbrgo {top prevname} {
+    global headids idheads mainhead mainheadid
+
+    set name [$top.name get]
+    set id [$top.sha1 get]
+    set cmdargs {}
+    if {$name eq $prevname} {
+       catch {destroy $top}
+       return
+    }
+    if {$name eq {}} {
+       error_popup [mc "Please specify a new name for the branch"] $top
+       return
+    }
+    catch {destroy $top}
+    lappend cmdargs -m $prevname $name
+    nowbusy renamebranch
+    update
+    if {[catch {
+       eval exec git branch $cmdargs
+    } err]} {
+       notbusy renamebranch
+       error_popup $err
+    } else {
+       notbusy renamebranch
+       removehead $id $prevname
+       removedhead $id $prevname
+       set headids($name) $id
+       lappend idheads($id) $name
+       addedhead $id $name
+       if {$prevname eq $mainhead} {
+           set mainhead $name
+           set mainheadid $id
+       }
+       redrawtags $id
+       dispneartags 0
+       run refill_reflist
+    }
+}
+
 proc exec_citool {tool_args {baseid {}}} {
     global commitinfo env
 
@@ -9751,20 +9838,25 @@ proc readresetstat {fd} {
 
 # context menu for a head
 proc headmenu {x y id head} {
-    global headmenuid headmenuhead headctxmenu mainhead
+    global headmenuid headmenuhead headctxmenu mainhead headids
 
     stopfinding
     set headmenuid $id
     set headmenuhead $head
-    set state normal
+    array set state {0 normal 1 normal 2 normal}
     if {[string match "remotes/*" $head]} {
-       set state disabled
+       set localhead [string range $head [expr [string last / $head] + 1] end]
+       if {[info exists headids($localhead)]} {
+           set state(0) disabled
+       }
+       array set state {1 disabled 2 disabled}
     }
     if {$head eq $mainhead} {
-       set state disabled
+       array set state {0 disabled 2 disabled}
+    }
+    foreach i {0 1 2} {
+       $headctxmenu entryconfigure $i -state $state($i)
     }
-    $headctxmenu entryconfigure 0 -state $state
-    $headctxmenu entryconfigure 1 -state $state
     tk_popup $headctxmenu $x $y
 }
 
@@ -9773,11 +9865,27 @@ proc cobranch {} {
     global showlocalchanges
 
     # check the tree is clean first??
+    set newhead $headmenuhead
+    set command [list | git checkout]
+    if {[string match "remotes/*" $newhead]} {
+       set remote $newhead
+       set newhead [string range $newhead [expr [string last / $newhead] + 1] end]
+       # The following check is redundant - the menu option should
+       # be disabled to begin with...
+       if {[info exists headids($newhead)]} {
+           error_popup [mc "A local branch named %s exists already" $newhead]
+           return
+       }
+       lappend command -b $newhead --track $remote
+    } else {
+       lappend command $newhead
+    }
+    lappend command 2>@1
     nowbusy checkout [mc "Checking out"]
     update
     dohidelocalchanges
     if {[catch {
-       set fd [open [list | git checkout $headmenuhead 2>@1] r]
+       set fd [open $command r]
     } err]} {
        notbusy checkout
        error_popup $err
@@ -9785,12 +9893,12 @@ proc cobranch {} {
            dodiffindex
        }
     } else {
-       filerun $fd [list readcheckoutstat $fd $headmenuhead $headmenuid]
+       filerun $fd [list readcheckoutstat $fd $newhead $headmenuid]
     }
 }
 
 proc readcheckoutstat {fd newhead newheadid} {
-    global mainhead mainheadid headids showlocalchanges progresscoords
+    global mainhead mainheadid headids idheads showlocalchanges progresscoords
     global viewmainheadid curview
 
     if {[gets $fd line] >= 0} {
@@ -9805,8 +9913,14 @@ proc readcheckoutstat {fd newhead newheadid} {
     notbusy checkout
     if {[catch {close $fd} err]} {
        error_popup $err
+       return
     }
     set oldmainid $mainheadid
+    if {! [info exists headids($newhead)]} {
+       set headids($newhead) $newheadid
+       lappend idheads($newheadid) $newhead
+       addedhead $newheadid $newhead
+    }
     set mainhead $newhead
     set mainheadid $newheadid
     set viewmainheadid($curview) $newheadid
@@ -12188,7 +12302,7 @@ if {[tk windowingsystem] eq "aqua"} {
     set extdifftool "meld"
 }
 
-set colors {lime red blue magenta darkgrey brown orange}
+set colors {"#00ff00" red blue magenta darkgrey brown orange}
 if {[tk windowingsystem] eq "win32"} {
     set uicolor SystemButtonFace
     set uifgcolor SystemButtonText
@@ -12206,12 +12320,12 @@ if {[tk windowingsystem] eq "win32"} {
 }
 set diffcolors {red "#00a000" blue}
 set diffcontext 3
-set mergecolors {red blue lime purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
+set mergecolors {red blue "#00ff00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
 set ignorespace 0
 set worddiff ""
 set markbgcolor "#e0e0ff"
 
-set headbgcolor lime
+set headbgcolor "#00ff00"
 set headfgcolor black
 set headoutlinecolor black
 set remotebgcolor #ffddaa
@@ -12226,7 +12340,7 @@ set linehoverfgcolor black
 set linehoveroutlinecolor black
 set mainheadcirclecolor yellow
 set workingfilescirclecolor red
-set indexcirclecolor lime
+set indexcirclecolor "#00ff00"
 set circlecolors {white blue gray blue blue}
 set linkfgcolor blue
 set circleoutlinecolor $fgcolor
index 99aa77aa63bd24af12a2ccee120b2a1db7307781..407d5550b1aba947549ad509a641134c34f28d46 100644 (file)
@@ -371,14 +371,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk — визуализация на подаванията в Git\n"
 "\n"
-"Авторски права: © 2005-2014 Paul Mackerras\n"
+"Авторски права: © 2005-2016 Paul Mackerras\n"
 "\n"
 "Използвайте и разпространявайте при условията на ОПЛ на ГНУ"
 
index 5ad066f7ce84c4be7801a467498ee3de3abccbf9..87dfc18b4406b202221b7e09894f0372988e728d 100644 (file)
@@ -1,5 +1,5 @@
 # Translation of gitk
-# Copyright (C) 2005-2014 Paul Mackerras
+# Copyright (C) 2005-2016 Paul Mackerras
 # This file is distributed under the same license as the gitk package.
 # Alex Henrie <alexhenrie24@gmail.com>, 2015.
 #
@@ -365,14 +365,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - visualitzador de comissions per al git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Useu-lo i redistribuïu-lo sota els termes de la Llicència Pública General GNU"
 
index bde749ed8ac7391746e06a00742c44905f7e686e..5db38248289baa42f1732a6f72566652d5819289 100644 (file)
@@ -363,14 +363,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - eine Visualisierung der Git-Historie\n"
 "\n"
-"Copyright \\u00a9 2005-2014 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2016 Paul Mackerras\n"
 "\n"
 "Benutzung und Weiterverbreitung gemäß den Bedingungen der GNU General Public "
 "License"
index ddcb0a5f68dc27127d72f2a42f6d77d2bbf7c23f..fef3bbafeead3e6f25300efa219ad1304596cf78 100644 (file)
@@ -370,14 +370,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - un visualizador de revisiones para git\n"
 "\n"
-"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2016 Paul Mackerras\n"
 "\n"
 "Uso y redistribución permitidos según los términos de la Licencia Pública "
 "General de GNU (GNU GPL)"
index c44f994fa5807036043e2ebe197e832c9d2e3e1f..e4fac932e5b0f6267076943c8244196e31bbd678 100644 (file)
@@ -372,14 +372,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - visualisateur de commit pour git\n"
 "\n"
-"Copyright \\u00a9 2005-2014 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2016 Paul Mackerras\n"
 "\n"
 "Utilisation et redistribution soumises aux termes de la GNU General Public License"
 
index 66fd75ba5b1634f13f067e4aab3cc1d921ca804b..79ec5a565674b0bc3fcec50588bb845afbde07a3 100644 (file)
@@ -366,14 +366,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - commit nézegető a githez\n"
 "\n"
-"Szerzői jog \\u00a9 2005-2010 Paul Mackerras\n"
+"Szerzői jog \\u00a9 2005-2016 Paul Mackerras\n"
 "\n"
 "Használd és terjeszd a GNU General Public License feltételei mellett"
 
index b5f002db7d52d3106d3a52dbb03047ad67233b62..b58d23eb2b9253808282e31d44125e98098584e0 100644 (file)
@@ -367,14 +367,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - un visualizzatore di revisioni per git\n"
 "\n"
-"Copyright \\u00a9 2005-2010 Paul Mackerras\n"
+"Copyright \\u00a9 2005-2016 Paul Mackerras\n"
 "\n"
 "Utilizzo e redistribuzione permessi sotto i termini della GNU General Public "
 "License"
index f143753db0b27cf0dfd1ef28ba89372c921feb7b..ca3c29b457bd375ff5f42bdc321d809f4cd301dc 100644 (file)
@@ -2,16 +2,17 @@
 # Copyright (C) 2005-2015 Paul Mackerras
 # This file is distributed under the same license as the gitk package.
 #
-# YOKOTA Hiroshi <yokota@netlab.cs.tsukuba.ac.jp>, 2015.
 # Mizar <mizar.jp@gmail.com>, 2009.
 # Junio C Hamano <gitster@pobox.com>, 2009.
+# YOKOTA Hiroshi <yokota@netlab.cs.tsukuba.ac.jp>, 2015.
+# Satoshi Yasushima <s.yasushima@gmail.com>, 2016.
 msgid ""
 msgstr ""
 "Project-Id-Version: gitk\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2015-05-17 14:32+1000\n"
 "PO-Revision-Date: 2015-11-12 13:00+0900\n"
-"Last-Translator: YOKOTA Hiroshi <yokota@netlab.cs.tsukuba.ac.jp>\n"
+"Last-Translator: Satoshi Yasushima <s.yasushima@gmail.com>\n"
 "Language-Team: Japanese\n"
 "Language: ja\n"
 "MIME-Version: 1.0\n"
@@ -314,11 +315,11 @@ msgstr "マークを付けたコミットと比較する"
 
 #: gitk:2630 gitk:2641
 msgid "Diff this -> marked commit"
-msgstr "これと選択したコミットのdiffを見る"
+msgstr "これとマークを付けたコミットのdiffを見る"
 
 #: gitk:2631 gitk:2642
 msgid "Diff marked commit -> this"
-msgstr "選択したコミットとこれのdiffを見る"
+msgstr "マークを付けたコミットとこれのdiffを見る"
 
 #: gitk:2632
 msgid "Revert this commit"
@@ -373,14 +374,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - gitコミットビューア\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "使用および再配布は GNU General Public License に従ってください"
 
index 3f78f1b7482614098e295f3f1ffb6c0925ae6383..1feb34854b32ccd03c0eaf15adbd488d3573aef4 100644 (file)
@@ -368,14 +368,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - um visualizador de revisões para o git \n"
 "\n"
-"Copyright ©9 2005-2010 Paul Mackerras\n"
+"Copyright ©9 2005-2016 Paul Mackerras\n"
 "\n"
 "Uso e distribuição segundo os termos da Licença Pública Geral GNU"
 
diff --git a/gitk-git/po/pt_pt.po b/gitk-git/po/pt_pt.po
new file mode 100644 (file)
index 0000000..f680ea8
--- /dev/null
@@ -0,0 +1,1376 @@
+# Portuguese translations for gitk package.
+# Copyright (C) 2016 Paul Mackerras
+# This file is distributed under the same license as the gitk package.
+# Vasco Almeida <vascomalmeida@sapo.pt>, 2016.
+msgid ""
+msgstr ""
+"Project-Id-Version: gitk\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-04-15 16:52+0000\n"
+"PO-Revision-Date: 2016-05-06 15:35+0000\n"
+"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
+"Language-Team: Portuguese\n"
+"Language: pt\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Virtaal 0.7.1\n"
+
+#: gitk:140
+msgid "Couldn't get list of unmerged files:"
+msgstr "Não foi possível obter lista de ficheiros não integrados:"
+
+#: gitk:212 gitk:2399
+msgid "Color words"
+msgstr "Colorir palavras"
+
+#: gitk:217 gitk:2399 gitk:8239 gitk:8272
+msgid "Markup words"
+msgstr "Marcar palavras"
+
+#: gitk:324
+msgid "Error parsing revisions:"
+msgstr "Erro ao analisar revisões:"
+
+#: gitk:380
+msgid "Error executing --argscmd command:"
+msgstr "Erro ao executar o comando de --argscmd:"
+
+#: gitk:393
+msgid "No files selected: --merge specified but no files are unmerged."
+msgstr ""
+"Nenhum ficheiro selecionado: --merge especificado mas não há ficheiros por "
+"integrar."
+
+#: gitk:396
+msgid ""
+"No files selected: --merge specified but no unmerged files are within file "
+"limit."
+msgstr ""
+"Nenhum ficheiro selecionado: --merge especificado mas não há ficheiros por "
+"integrar ao nível de ficheiro."
+
+#: gitk:418 gitk:566
+msgid "Error executing git log:"
+msgstr "Erro ao executar git log:"
+
+#: gitk:436 gitk:582
+msgid "Reading"
+msgstr "A ler"
+
+#: gitk:496 gitk:4544
+msgid "Reading commits..."
+msgstr "A ler commits..."
+
+#: gitk:499 gitk:1637 gitk:4547
+msgid "No commits selected"
+msgstr "Nenhum commit selecionado"
+
+#: gitk:1445 gitk:4064 gitk:12469
+msgid "Command line"
+msgstr "Linha de comandos"
+
+#: gitk:1511
+msgid "Can't parse git log output:"
+msgstr "Não é possível analisar a saída de git log:"
+
+#: gitk:1740
+msgid "No commit information available"
+msgstr "Não há informação disponível sobre o commit"
+
+#: gitk:1903 gitk:1932 gitk:4334 gitk:9702 gitk:11274 gitk:11554
+msgid "OK"
+msgstr "OK"
+
+#: gitk:1934 gitk:4336 gitk:9215 gitk:9294 gitk:9424 gitk:9473 gitk:9704
+#: gitk:11275 gitk:11555
+msgid "Cancel"
+msgstr "Cancelar"
+
+#: gitk:2083
+msgid "&Update"
+msgstr "At&ualizar"
+
+#: gitk:2084
+msgid "&Reload"
+msgstr "&Recarregar"
+
+#: gitk:2085
+msgid "Reread re&ferences"
+msgstr "Reler re&ferências"
+
+#: gitk:2086
+msgid "&List references"
+msgstr "&Listar referências"
+
+#: gitk:2088
+msgid "Start git &gui"
+msgstr "Iniciar git &gui"
+
+#: gitk:2090
+msgid "&Quit"
+msgstr "&Sair"
+
+#: gitk:2082
+msgid "&File"
+msgstr "&Ficheiro"
+
+#: gitk:2094
+msgid "&Preferences"
+msgstr "&Preferências"
+
+#: gitk:2093
+msgid "&Edit"
+msgstr "&Editar"
+
+#: gitk:2098
+msgid "&New view..."
+msgstr "&Nova vista..."
+
+#: gitk:2099
+msgid "&Edit view..."
+msgstr "&Editar vista..."
+
+#: gitk:2100
+msgid "&Delete view"
+msgstr "Elimina&r vista"
+
+#: gitk:2102
+msgid "&All files"
+msgstr "&Todos os ficheiros"
+
+#: gitk:2097
+msgid "&View"
+msgstr "&Ver"
+
+#: gitk:2107 gitk:2117
+msgid "&About gitk"
+msgstr "&Sobre gitk"
+
+#: gitk:2108 gitk:2122
+msgid "&Key bindings"
+msgstr "&Atalhos"
+
+#: gitk:2106 gitk:2121
+msgid "&Help"
+msgstr "&Ajuda"
+
+#: gitk:2199 gitk:8671
+msgid "SHA1 ID:"
+msgstr "ID SHA1:"
+
+#: gitk:2243
+msgid "Row"
+msgstr "Linha"
+
+#: gitk:2281
+msgid "Find"
+msgstr "Procurar"
+
+#: gitk:2309
+msgid "commit"
+msgstr "commit"
+
+#: gitk:2313 gitk:2315 gitk:4706 gitk:4729 gitk:4753 gitk:6774 gitk:6846
+#: gitk:6931
+msgid "containing:"
+msgstr "contendo:"
+
+#: gitk:2316 gitk:3545 gitk:3550 gitk:4782
+msgid "touching paths:"
+msgstr "altera os caminhos:"
+
+#: gitk:2317 gitk:4796
+msgid "adding/removing string:"
+msgstr "adiciona/remove a cadeia:"
+
+#: gitk:2318 gitk:4798
+msgid "changing lines matching:"
+msgstr "altera linhas com:"
+
+#: gitk:2327 gitk:2329 gitk:4785
+msgid "Exact"
+msgstr "Exato"
+
+#: gitk:2329 gitk:4873 gitk:6742
+msgid "IgnCase"
+msgstr "IgnMaiúsculas"
+
+#: gitk:2329 gitk:4755 gitk:4871 gitk:6738
+msgid "Regexp"
+msgstr "Expr. regular"
+
+#: gitk:2331 gitk:2332 gitk:4893 gitk:4923 gitk:4930 gitk:6867 gitk:6935
+msgid "All fields"
+msgstr "Todos os campos"
+
+#: gitk:2332 gitk:4890 gitk:4923 gitk:6805
+msgid "Headline"
+msgstr "Cabeçalho"
+
+#: gitk:2333 gitk:4890 gitk:6805 gitk:6935 gitk:7408
+msgid "Comments"
+msgstr "Comentários"
+
+#: gitk:2333 gitk:4890 gitk:4895 gitk:4930 gitk:6805 gitk:7343 gitk:8849
+#: gitk:8864
+msgid "Author"
+msgstr "Autor"
+
+#: gitk:2333 gitk:4890 gitk:6805 gitk:7345
+msgid "Committer"
+msgstr "Committer"
+
+#: gitk:2367
+msgid "Search"
+msgstr "Pesquisar"
+
+#: gitk:2375
+msgid "Diff"
+msgstr "Diff"
+
+#: gitk:2377
+msgid "Old version"
+msgstr "Versão antiga"
+
+#: gitk:2379
+msgid "New version"
+msgstr "Versão nova"
+
+#: gitk:2382
+msgid "Lines of context"
+msgstr "Linhas de contexto"
+
+#: gitk:2392
+msgid "Ignore space change"
+msgstr "Ignorar espaços"
+
+#: gitk:2396 gitk:2398 gitk:7978 gitk:8225
+msgid "Line diff"
+msgstr "Diff de linha"
+
+#: gitk:2463
+msgid "Patch"
+msgstr "Patch"
+
+#: gitk:2465
+msgid "Tree"
+msgstr "Árvore"
+
+#: gitk:2635 gitk:2656
+msgid "Diff this -> selected"
+msgstr "Diff este -> seleção"
+
+#: gitk:2636 gitk:2657
+msgid "Diff selected -> this"
+msgstr "Diff seleção -> este"
+
+#: gitk:2637 gitk:2658
+msgid "Make patch"
+msgstr "Gerar patch"
+
+#: gitk:2638 gitk:9273
+msgid "Create tag"
+msgstr "Criar tag"
+
+#: gitk:2639
+msgid "Copy commit summary"
+msgstr "Copiar sumário do commit"
+
+#: gitk:2640 gitk:9404
+msgid "Write commit to file"
+msgstr "Escrever commit num ficheiro"
+
+#: gitk:2641 gitk:9461
+msgid "Create new branch"
+msgstr "Criar novo ramo"
+
+#: gitk:2642
+msgid "Cherry-pick this commit"
+msgstr "Efetuar cherry-pick deste commit"
+
+#: gitk:2643
+msgid "Reset HEAD branch to here"
+msgstr "Repor ramo HEAD para aqui"
+
+#: gitk:2644
+msgid "Mark this commit"
+msgstr "Marcar este commit"
+
+#: gitk:2645
+msgid "Return to mark"
+msgstr "Voltar à marca"
+
+#: gitk:2646
+msgid "Find descendant of this and mark"
+msgstr "Encontrar descendeste deste e da marca"
+
+#: gitk:2647
+msgid "Compare with marked commit"
+msgstr "Comparar com o commit marcado"
+
+#: gitk:2648 gitk:2659
+msgid "Diff this -> marked commit"
+msgstr "Diff este -> commit marcado"
+
+#: gitk:2649 gitk:2660
+msgid "Diff marked commit -> this"
+msgstr "Diff commit marcado -> este"
+
+#: gitk:2650
+msgid "Revert this commit"
+msgstr "Reverter este commit"
+
+#: gitk:2666
+msgid "Check out this branch"
+msgstr "Extrair este ramo"
+
+#: gitk:2667
+msgid "Remove this branch"
+msgstr "Remover este ramo"
+
+#: gitk:2668
+msgid "Copy branch name"
+msgstr "Copiar nome do ramo"
+
+#: gitk:2675
+msgid "Highlight this too"
+msgstr "Realçar este também"
+
+#: gitk:2676
+msgid "Highlight this only"
+msgstr "Realçar apenas este"
+
+#: gitk:2677
+msgid "External diff"
+msgstr "Diff externo"
+
+#: gitk:2678
+msgid "Blame parent commit"
+msgstr "Culpar commit pai"
+
+#: gitk:2679
+msgid "Copy path"
+msgstr "Copiar caminho"
+
+#: gitk:2686
+msgid "Show origin of this line"
+msgstr "Mostrar origem deste ficheiro"
+
+#: gitk:2687
+msgid "Run git gui blame on this line"
+msgstr "Executar git gui blame sobre esta linha"
+
+#: gitk:3031
+msgid "About gitk"
+msgstr "Sobre gitk"
+
+#: gitk:3033
+msgid ""
+"\n"
+"Gitk - a commit viewer for git\n"
+"\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
+"\n"
+"Use and redistribute under the terms of the GNU General Public License"
+msgstr ""
+"\n"
+"Gitk - um visualizador de commits do git\n"
+"\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
+"\n"
+"Use e redistribua sob os termos da GNU General Public License"
+
+#: gitk:3041 gitk:3108 gitk:9890
+msgid "Close"
+msgstr "Fechar"
+
+#: gitk:3062
+msgid "Gitk key bindings"
+msgstr "Atalhos do gitk"
+
+#: gitk:3065
+msgid "Gitk key bindings:"
+msgstr "Atalhos do gitk:"
+
+#: gitk:3067
+#, tcl-format
+msgid "<%s-Q>\t\tQuit"
+msgstr "<%s-Q>\t\tSair"
+
+#: gitk:3068
+#, tcl-format
+msgid "<%s-W>\t\tClose window"
+msgstr "<%s-W>\t\tFechar janela"
+
+#: gitk:3069
+msgid "<Home>\t\tMove to first commit"
+msgstr "<Home>\t\tMover para o primeiro commit"
+
+#: gitk:3070
+msgid "<End>\t\tMove to last commit"
+msgstr "<End>\t\tMover para o último commit"
+
+#: gitk:3071
+msgid "<Up>, p, k\tMove up one commit"
+msgstr "<Cima>, p, k\tMover para o commit acima"
+
+#: gitk:3072
+msgid "<Down>, n, j\tMove down one commit"
+msgstr "<Baixo>, n, j\tMover para o commit abaixo"
+
+#: gitk:3073
+msgid "<Left>, z, h\tGo back in history list"
+msgstr "<Esquerda>, z, h\tRecuar no histórico"
+
+#: gitk:3074
+msgid "<Right>, x, l\tGo forward in history list"
+msgstr "<Direita>, x, l\tAvançar no histórico"
+
+#: gitk:3075
+#, tcl-format
+msgid "<%s-n>\tGo to n-th parent of current commit in history list"
+msgstr "<%s-n>\tIr para o n-ésimo pai do commit atual no histórico"
+
+#: gitk:3076
+msgid "<PageUp>\tMove up one page in commit list"
+msgstr "<PageUp>\tMover a lista de commits uma página para cima"
+
+#: gitk:3077
+msgid "<PageDown>\tMove down one page in commit list"
+msgstr "<PageDown>\tMover a lista de commits uma página para baixo"
+
+#: gitk:3078
+#, tcl-format
+msgid "<%s-Home>\tScroll to top of commit list"
+msgstr "<%s-Home>\tDeslocar para o topo da lista"
+
+#: gitk:3079
+#, tcl-format
+msgid "<%s-End>\tScroll to bottom of commit list"
+msgstr "<%s-End>\tDeslocar para o fim da lista"
+
+#: gitk:3080
+#, tcl-format
+msgid "<%s-Up>\tScroll commit list up one line"
+msgstr "<%s-Cima>\tDeslocar a lista de commits uma linha para cima"
+
+#: gitk:3081
+#, tcl-format
+msgid "<%s-Down>\tScroll commit list down one line"
+msgstr "<%s-Baixo>\tDeslocar a lista de commits uma linha para baixo"
+
+#: gitk:3082
+#, tcl-format
+msgid "<%s-PageUp>\tScroll commit list up one page"
+msgstr "<%s-PageUp>\tDeslocar a lista de commits uma página para cima"
+
+#: gitk:3083
+#, tcl-format
+msgid "<%s-PageDown>\tScroll commit list down one page"
+msgstr "<%s-PageDown>\tDeslocar a lista de commits uma página para baixo"
+
+#: gitk:3084
+msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
+msgstr "<Shift-Cima>\tProcurar para trás (para cima, commits posteriores)"
+
+#: gitk:3085
+msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
+msgstr "<Shift-Baixo>\tProcurar para a frente (para baixo, commits anteriores)"
+
+#: gitk:3086
+msgid "<Delete>, b\tScroll diff view up one page"
+msgstr "<Delete>, b\tDeslocar vista diff uma página para cima"
+
+#: gitk:3087
+msgid "<Backspace>\tScroll diff view up one page"
+msgstr "<Retrocesso>\tDeslocar vista diff uma página para cima"
+
+#: gitk:3088
+msgid "<Space>\t\tScroll diff view down one page"
+msgstr "<Espaço>\tDeslocar vista diff uma página para baixo"
+
+#: gitk:3089
+msgid "u\t\tScroll diff view up 18 lines"
+msgstr "u\t\tDeslocar vista diff 18 linhas para cima"
+
+#: gitk:3090
+msgid "d\t\tScroll diff view down 18 lines"
+msgstr "d\t\tDeslocar vista diff 18 linhas para baixo"
+
+#: gitk:3091
+#, tcl-format
+msgid "<%s-F>\t\tFind"
+msgstr "<%s-F>\t\tProcurar"
+
+#: gitk:3092
+#, tcl-format
+msgid "<%s-G>\t\tMove to next find hit"
+msgstr "<%s-G>\t\tMover para a ocorrência seguinte"
+
+#: gitk:3093
+msgid "<Return>\tMove to next find hit"
+msgstr "<Return>\tMover para a ocorrência seguinte"
+
+#: gitk:3094
+msgid "g\t\tGo to commit"
+msgstr "g\t\tIr para o commit"
+
+#: gitk:3095
+msgid "/\t\tFocus the search box"
+msgstr "/\t\tFocar a caixa de pesquisa"
+
+#: gitk:3096
+msgid "?\t\tMove to previous find hit"
+msgstr "?\t\tMover para a ocorrência anterior"
+
+#: gitk:3097
+msgid "f\t\tScroll diff view to next file"
+msgstr "f\t\tDeslocar vista diff para o ficheiro seguinte"
+
+#: gitk:3098
+#, tcl-format
+msgid "<%s-S>\t\tSearch for next hit in diff view"
+msgstr "<%s-S>\t\tProcurar pela ocorrência seguinte na vista diff"
+
+#: gitk:3099
+#, tcl-format
+msgid "<%s-R>\t\tSearch for previous hit in diff view"
+msgstr "<%s-R>\t\tProcurar pela ocorrência anterior na vista diff"
+
+#: gitk:3100
+#, tcl-format
+msgid "<%s-KP+>\tIncrease font size"
+msgstr "<%s-KP+>\tAumentar o tamanho da letra"
+
+#: gitk:3101
+#, tcl-format
+msgid "<%s-plus>\tIncrease font size"
+msgstr "<%s-mais>\tAumentar o tamanho da letra"
+
+#: gitk:3102
+#, tcl-format
+msgid "<%s-KP->\tDecrease font size"
+msgstr "<%s-KP->\tDiminuir o tamanho da letra"
+
+#: gitk:3103
+#, tcl-format
+msgid "<%s-minus>\tDecrease font size"
+msgstr "<%s-menos>\tDiminuir o tamanho da letra"
+
+#: gitk:3104
+msgid "<F5>\t\tUpdate"
+msgstr "<F5>\t\tAtualizar"
+
+#: gitk:3569 gitk:3578
+#, tcl-format
+msgid "Error creating temporary directory %s:"
+msgstr "Erro ao criar ficheiro temporário %s:"
+
+#: gitk:3591
+#, tcl-format
+msgid "Error getting \"%s\" from %s:"
+msgstr "Erro ao obter \"%s\" de %s:"
+
+#: gitk:3654
+msgid "command failed:"
+msgstr "o comando falhou:"
+
+#: gitk:3803
+msgid "No such commit"
+msgstr "Commit inexistente"
+
+#: gitk:3817
+msgid "git gui blame: command failed:"
+msgstr "git gui blame: o comando falhou:"
+
+#: gitk:3848
+#, tcl-format
+msgid "Couldn't read merge head: %s"
+msgstr "Não foi possível ler a cabeça de integração: %s"
+
+#: gitk:3856
+#, tcl-format
+msgid "Error reading index: %s"
+msgstr "Erro ao ler o índice: %s"
+
+#: gitk:3881
+#, tcl-format
+msgid "Couldn't start git blame: %s"
+msgstr "Não foi possível iniciar git blame: %s"
+
+#: gitk:3884 gitk:6773
+msgid "Searching"
+msgstr "A procurar"
+
+#: gitk:3916
+#, tcl-format
+msgid "Error running git blame: %s"
+msgstr "Erro ao executar git blame: %s"
+
+#: gitk:3944
+#, tcl-format
+msgid "That line comes from commit %s,  which is not in this view"
+msgstr "Essa linha provém do commit %s, que não está nesta vista"
+
+#: gitk:3958
+msgid "External diff viewer failed:"
+msgstr "Visualizador diff externo falhou:"
+
+#: gitk:4062
+msgid "All files"
+msgstr "Todos os ficheiros"
+
+#: gitk:4086
+msgid "View"
+msgstr "Vista"
+
+#: gitk:4089
+msgid "Gitk view definition"
+msgstr "Definição de vistas do gitk"
+
+#: gitk:4093
+msgid "Remember this view"
+msgstr "Recordar esta vista"
+
+#: gitk:4094
+msgid "References (space separated list):"
+msgstr "Referências (lista separada por espaço):"
+
+#: gitk:4095
+msgid "Branches & tags:"
+msgstr "Ramos e tags:"
+
+#: gitk:4096
+msgid "All refs"
+msgstr "Todas as referências"
+
+#: gitk:4097
+msgid "All (local) branches"
+msgstr "Todos os ramos (locais)"
+
+#: gitk:4098
+msgid "All tags"
+msgstr "Todas as tags"
+
+#: gitk:4099
+msgid "All remote-tracking branches"
+msgstr "Todos os ramos remotos de monitorização"
+
+#: gitk:4100
+msgid "Commit Info (regular expressions):"
+msgstr "Informação Sobre o Commit (expressões regulares):"
+
+#: gitk:4101
+msgid "Author:"
+msgstr "Autor:"
+
+#: gitk:4102
+msgid "Committer:"
+msgstr "Committer:"
+
+#: gitk:4103
+msgid "Commit Message:"
+msgstr "Mensagem de Commit:"
+
+#: gitk:4104
+msgid "Matches all Commit Info criteria"
+msgstr "Corresponde a todos os critérios da Informação Sobre o Commit"
+
+#: gitk:4105
+msgid "Matches no Commit Info criteria"
+msgstr "Não corresponde a nenhum critério da Informação Sobre o Commit"
+
+#: gitk:4106
+msgid "Changes to Files:"
+msgstr "Alterações nos Ficheiros:"
+
+#: gitk:4107
+msgid "Fixed String"
+msgstr "Cadeia Fixa"
+
+#: gitk:4108
+msgid "Regular Expression"
+msgstr "Expressão Regular"
+
+#: gitk:4109
+msgid "Search string:"
+msgstr "Procurar pela cadeia:"
+
+#: gitk:4110
+msgid ""
+"Commit Dates (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 "
+"15:27:38\"):"
+msgstr ""
+"Datas de Commit (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 "
+"15:27:38\"):"
+
+#: gitk:4111
+msgid "Since:"
+msgstr "Desde:"
+
+#: gitk:4112
+msgid "Until:"
+msgstr "Até:"
+
+#: gitk:4113
+msgid "Limit and/or skip a number of revisions (positive integer):"
+msgstr "Limitar e/ou ignorar um número de revisões (inteiro positivo):"
+
+#: gitk:4114
+msgid "Number to show:"
+msgstr "Número a mostrar:"
+
+#: gitk:4115
+msgid "Number to skip:"
+msgstr "Número a ignorar:"
+
+#: gitk:4116
+msgid "Miscellaneous options:"
+msgstr "Opções diversas:"
+
+#: gitk:4117
+msgid "Strictly sort by date"
+msgstr "Ordenar estritamente pela data"
+
+#: gitk:4118
+msgid "Mark branch sides"
+msgstr "Marcar lado dos ramos"
+
+#: gitk:4119
+msgid "Limit to first parent"
+msgstr "Restringir ao primeiro pai"
+
+#: gitk:4120
+msgid "Simple history"
+msgstr "Histórico simples"
+
+#: gitk:4121
+msgid "Additional arguments to git log:"
+msgstr "Argumentos adicionais ao git log:"
+
+#: gitk:4122
+msgid "Enter files and directories to include, one per line:"
+msgstr "Introduza ficheiros e diretórios para incluir, um por linha:"
+
+#: gitk:4123
+msgid "Command to generate more commits to include:"
+msgstr "Comando para gerar mais commits para incluir:"
+
+#: gitk:4247
+msgid "Gitk: edit view"
+msgstr "Gitk: editar vista"
+
+#: gitk:4255
+msgid "-- criteria for selecting revisions"
+msgstr "-- critério para selecionar revisões"
+
+#: gitk:4260
+msgid "View Name"
+msgstr "Nome da Vista"
+
+#: gitk:4335
+msgid "Apply (F5)"
+msgstr "Aplicar (F5)"
+
+#: gitk:4373
+msgid "Error in commit selection arguments:"
+msgstr "Erro nos argumentos de seleção de commits:"
+
+#: gitk:4428 gitk:4481 gitk:4943 gitk:4957 gitk:6227 gitk:12410 gitk:12411
+msgid "None"
+msgstr "Nenhum"
+
+#: gitk:5040 gitk:5045
+msgid "Descendant"
+msgstr "Descendente"
+
+#: gitk:5041
+msgid "Not descendant"
+msgstr "Não descendente"
+
+#: gitk:5048 gitk:5053
+msgid "Ancestor"
+msgstr "Antecessor"
+
+#: gitk:5049
+msgid "Not ancestor"
+msgstr "Não antecessor"
+
+#: gitk:5343
+msgid "Local changes checked in to index but not committed"
+msgstr "Alterações locais preparadas no índice mas não submetidas"
+
+#: gitk:5379
+msgid "Local uncommitted changes, not checked in to index"
+msgstr "Alterações locais não submetidas, não preparadas no índice"
+
+#: gitk:7153
+msgid "and many more"
+msgstr "e muitos mais"
+
+#: gitk:7156
+msgid "many"
+msgstr "muitos"
+
+#: gitk:7347
+msgid "Tags:"
+msgstr "Tags:"
+
+#: gitk:7364 gitk:7370 gitk:8844
+msgid "Parent"
+msgstr "Pai"
+
+#: gitk:7375
+msgid "Child"
+msgstr "Filho"
+
+#: gitk:7384
+msgid "Branch"
+msgstr "Ramo"
+
+#: gitk:7387
+msgid "Follows"
+msgstr "Sucede"
+
+#: gitk:7390
+msgid "Precedes"
+msgstr "Precede"
+
+#: gitk:7985
+#, tcl-format
+msgid "Error getting diffs: %s"
+msgstr "Erro ao obter diferenças: %s"
+
+#: gitk:8669
+msgid "Goto:"
+msgstr "Ir para:"
+
+#: gitk:8690
+#, tcl-format
+msgid "Short SHA1 id %s is ambiguous"
+msgstr "O id SHA1 abreviado %s é ambíguo"
+
+#: gitk:8697
+#, tcl-format
+msgid "Revision %s is not known"
+msgstr "A revisão %s não é conhecida"
+
+#: gitk:8707
+#, tcl-format
+msgid "SHA1 id %s is not known"
+msgstr "O id SHA1 %s não é conhecido"
+
+#: gitk:8709
+#, tcl-format
+msgid "Revision %s is not in the current view"
+msgstr "A revisão %s não se encontra na vista atual"
+
+#: gitk:8851 gitk:8866
+msgid "Date"
+msgstr "Data"
+
+#: gitk:8854
+msgid "Children"
+msgstr "Filhos"
+
+#: gitk:8917
+#, tcl-format
+msgid "Reset %s branch to here"
+msgstr "Repor o ramo %s para aqui"
+
+#: gitk:8919
+msgid "Detached head: can't reset"
+msgstr "Cabeça destacada: não é possível repor"
+
+#: gitk:9024 gitk:9030
+msgid "Skipping merge commit "
+msgstr "A ignorar commit de integração "
+
+#: gitk:9039 gitk:9044
+msgid "Error getting patch ID for "
+msgstr "Erro ao obter ID de patch de "
+
+#: gitk:9040 gitk:9045
+msgid " - stopping\n"
+msgstr " - a interromper\n"
+
+#: gitk:9050 gitk:9053 gitk:9061 gitk:9075 gitk:9084
+msgid "Commit "
+msgstr "Commit "
+
+#: gitk:9054
+msgid ""
+" is the same patch as\n"
+"       "
+msgstr ""
+" é o mesmo patch que\n"
+"       "
+
+#: gitk:9062
+msgid ""
+" differs from\n"
+"       "
+msgstr ""
+" difere de\n"
+"       "
+
+#: gitk:9064
+msgid ""
+"Diff of commits:\n"
+"\n"
+msgstr ""
+"Diferença dos commits:\n"
+"\n"
+
+#: gitk:9076 gitk:9085
+#, tcl-format
+msgid " has %s children - stopping\n"
+msgstr " tem %s filhos - a interromper\n"
+
+#: gitk:9104
+#, tcl-format
+msgid "Error writing commit to file: %s"
+msgstr "Erro ao escrever commit no ficheiro: %s"
+
+#: gitk:9110
+#, tcl-format
+msgid "Error diffing commits: %s"
+msgstr "Erro ao calcular as diferenças dos commits: %s"
+
+#: gitk:9156
+msgid "Top"
+msgstr "Topo"
+
+#: gitk:9157
+msgid "From"
+msgstr "De"
+
+#: gitk:9162
+msgid "To"
+msgstr "Para"
+
+#: gitk:9186
+msgid "Generate patch"
+msgstr "Gerar patch"
+
+#: gitk:9188
+msgid "From:"
+msgstr "De:"
+
+#: gitk:9197
+msgid "To:"
+msgstr "Para:"
+
+#: gitk:9206
+msgid "Reverse"
+msgstr "Reverter"
+
+#: gitk:9208 gitk:9418
+msgid "Output file:"
+msgstr "Ficheiro de saída:"
+
+#: gitk:9214
+msgid "Generate"
+msgstr "Gerar"
+
+#: gitk:9252
+msgid "Error creating patch:"
+msgstr "Erro ao criar patch:"
+
+#: gitk:9275 gitk:9406 gitk:9463
+msgid "ID:"
+msgstr "ID:"
+
+#: gitk:9284
+msgid "Tag name:"
+msgstr "Nome da tag:"
+
+#: gitk:9287
+msgid "Tag message is optional"
+msgstr "A mensagem da tag é opcional"
+
+#: gitk:9289
+msgid "Tag message:"
+msgstr "Mensagem da tag:"
+
+#: gitk:9293 gitk:9472
+msgid "Create"
+msgstr "Criar"
+
+#: gitk:9311
+msgid "No tag name specified"
+msgstr "Nenhum nome de tag especificado"
+
+#: gitk:9315
+#, tcl-format
+msgid "Tag \"%s\" already exists"
+msgstr "A tag \"%s\" já existe"
+
+#: gitk:9325
+msgid "Error creating tag:"
+msgstr "Erro ao criar tag:"
+
+#: gitk:9415
+msgid "Command:"
+msgstr "Comando:"
+
+#: gitk:9423
+msgid "Write"
+msgstr "Escrever"
+
+#: gitk:9441
+msgid "Error writing commit:"
+msgstr "Erro ao escrever commit:"
+
+#: gitk:9468
+msgid "Name:"
+msgstr "Nome:"
+
+#: gitk:9491
+msgid "Please specify a name for the new branch"
+msgstr "Especifique um nome para o novo ramo"
+
+#: gitk:9496
+#, tcl-format
+msgid "Branch '%s' already exists. Overwrite?"
+msgstr "O ramo '%s' já existe. Substituí-lo?"
+
+#: gitk:9563
+#, tcl-format
+msgid "Commit %s is already included in branch %s -- really re-apply it?"
+msgstr "O commit %s já está incluído no ramo %s -- reaplicá-lo mesmo assim?"
+
+#: gitk:9568
+msgid "Cherry-picking"
+msgstr "A efetuar cherry-pick"
+
+#: gitk:9577
+#, tcl-format
+msgid ""
+"Cherry-pick failed because of local changes to file '%s'.\n"
+"Please commit, reset or stash your changes and try again."
+msgstr ""
+"Falha ao efetuar cherry-pick devido a alterações locais no ficheiro '%s'.\n"
+"Submeta, empilhe ou reponha as alterações e tente de novo."
+
+#: gitk:9583
+msgid ""
+"Cherry-pick failed because of merge conflict.\n"
+"Do you wish to run git citool to resolve it?"
+msgstr ""
+"Falha ao efetuar cherry-pick devido a conflito de integração.\n"
+"Deseja executar git citool para resolvê-lo?"
+
+#: gitk:9599 gitk:9657
+msgid "No changes committed"
+msgstr "Não foi submetida nenhum alteração"
+
+#: gitk:9626
+#, tcl-format
+msgid "Commit %s is not included in branch %s -- really revert it?"
+msgstr "O commit %s não está incluído no ramo %s -- revertê-lo mesmo assim?"
+
+#: gitk:9631
+msgid "Reverting"
+msgstr "A reverter"
+
+#: gitk:9639
+#, tcl-format
+msgid ""
+"Revert failed because of local changes to the following files:%s Please "
+"commit, reset or stash  your changes and try again."
+msgstr ""
+"Falha ao reverter devido a alterações locais nos seguintes ficheiros:%s "
+"Submeta, empilhe ou reponha as alterações e tente de novo."
+
+#: gitk:9643
+msgid ""
+"Revert failed because of merge conflict.\n"
+" Do you wish to run git citool to resolve it?"
+msgstr ""
+"Falha ao reverter devido a conflito de integração.\n"
+"Deseja executar git citool para resolvê-lo?"
+
+#: gitk:9686
+msgid "Confirm reset"
+msgstr "Confirmar reposição"
+
+#: gitk:9688
+#, tcl-format
+msgid "Reset branch %s to %s?"
+msgstr "Repor o ramo %s para %s?"
+
+#: gitk:9690
+msgid "Reset type:"
+msgstr "Tipo de reposição:"
+
+#: gitk:9693
+msgid "Soft: Leave working tree and index untouched"
+msgstr "Suave: Deixar a árvore de trabalho e o índice intactos"
+
+#: gitk:9696
+msgid "Mixed: Leave working tree untouched, reset index"
+msgstr "Misto: Deixar a árvore de trabalho intacta, repor índice"
+
+#: gitk:9699
+msgid ""
+"Hard: Reset working tree and index\n"
+"(discard ALL local changes)"
+msgstr ""
+"Forte: Repor árvore de trabalho e índice\n"
+"(descartar TODAS as alterações locais)"
+
+#: gitk:9716
+msgid "Resetting"
+msgstr "A repor"
+
+#: gitk:9776
+msgid "Checking out"
+msgstr "A extrair"
+
+#: gitk:9829
+msgid "Cannot delete the currently checked-out branch"
+msgstr "Não é possível eliminar o ramo atual extraído"
+
+#: gitk:9835
+#, tcl-format
+msgid ""
+"The commits on branch %s aren't on any other branch.\n"
+"Really delete branch %s?"
+msgstr ""
+"Os commits no ramo %s não estão presentes em mais nenhum ramo.\n"
+"Eliminar o ramo %s mesmo assim?"
+
+#: gitk:9866
+#, tcl-format
+msgid "Tags and heads: %s"
+msgstr "Tags e cabeças: %s"
+
+#: gitk:9883
+msgid "Filter"
+msgstr "Filtrar"
+
+#: gitk:10179
+msgid ""
+"Error reading commit topology information; branch and preceding/following "
+"tag information will be incomplete."
+msgstr ""
+"Erro ao ler informação de topologia do commit; a informação do ramo e da tag "
+"precedente/seguinte ficará incompleta."
+
+#: gitk:11156
+msgid "Tag"
+msgstr "Tag"
+
+#: gitk:11160
+msgid "Id"
+msgstr "Id"
+
+#: gitk:11243
+msgid "Gitk font chooser"
+msgstr "Escolha de tipo de letra do gitk"
+
+#: gitk:11260
+msgid "B"
+msgstr "B"
+
+#: gitk:11263
+msgid "I"
+msgstr "I"
+
+#: gitk:11381
+msgid "Commit list display options"
+msgstr "Opções de visualização da lista de commits"
+
+#: gitk:11384
+msgid "Maximum graph width (lines)"
+msgstr "Largura máxima do gráfico (linhas)"
+
+#: gitk:11388
+#, no-tcl-format
+msgid "Maximum graph width (% of pane)"
+msgstr "Largura máxima do gráfico (% do painel)"
+
+#: gitk:11391
+msgid "Show local changes"
+msgstr "Mostrar alterações locais"
+
+#: gitk:11394
+msgid "Auto-select SHA1 (length)"
+msgstr "Selecionar automaticamente SHA1 (largura)"
+
+#: gitk:11398
+msgid "Hide remote refs"
+msgstr "Ocultar referências remotas"
+
+#: gitk:11402
+msgid "Diff display options"
+msgstr "Opções de visualização de diferenças"
+
+#: gitk:11404
+msgid "Tab spacing"
+msgstr "Espaçamento da tabulação"
+
+#: gitk:11407
+msgid "Display nearby tags/heads"
+msgstr "Mostrar tags/cabeças próximas"
+
+#: gitk:11410
+msgid "Maximum # tags/heads to show"
+msgstr "Nº máximo de tags/cabeças a mostrar"
+
+#: gitk:11413
+msgid "Limit diffs to listed paths"
+msgstr "Limitar diferenças aos caminhos listados"
+
+#: gitk:11416
+msgid "Support per-file encodings"
+msgstr "Suportar codificação por cada ficheiro"
+
+#: gitk:11422 gitk:11569
+msgid "External diff tool"
+msgstr "Ferramenta diff externa"
+
+#: gitk:11423
+msgid "Choose..."
+msgstr "Escolher..."
+
+#: gitk:11428
+msgid "General options"
+msgstr "Opções gerais"
+
+#: gitk:11431
+msgid "Use themed widgets"
+msgstr "Usar widgets com estilo"
+
+#: gitk:11433
+msgid "(change requires restart)"
+msgstr "(alteração exige reiniciar)"
+
+#: gitk:11435
+msgid "(currently unavailable)"
+msgstr "(não disponível de momento)"
+
+#: gitk:11446
+msgid "Colors: press to choose"
+msgstr "Cores: pressione para escolher"
+
+#: gitk:11449
+msgid "Interface"
+msgstr "Interface"
+
+#: gitk:11450
+msgid "interface"
+msgstr "interface"
+
+#: gitk:11453
+msgid "Background"
+msgstr "Fundo"
+
+#: gitk:11454 gitk:11484
+msgid "background"
+msgstr "fundo"
+
+#: gitk:11457
+msgid "Foreground"
+msgstr "Primeiro plano"
+
+#: gitk:11458
+msgid "foreground"
+msgstr "primeiro plano"
+
+#: gitk:11461
+msgid "Diff: old lines"
+msgstr "Diff: linhas antigas"
+
+#: gitk:11462
+msgid "diff old lines"
+msgstr "diff linhas antigas"
+
+#: gitk:11466
+msgid "Diff: new lines"
+msgstr "Diff: linhas novas"
+
+#: gitk:11467
+msgid "diff new lines"
+msgstr "diff linhas novas"
+
+#: gitk:11471
+msgid "Diff: hunk header"
+msgstr "Diff: cabeçalho do excerto"
+
+#: gitk:11473
+msgid "diff hunk header"
+msgstr "diff cabeçalho do excerto"
+
+#: gitk:11477
+msgid "Marked line bg"
+msgstr "Fundo da linha marcada"
+
+#: gitk:11479
+msgid "marked line background"
+msgstr "fundo da linha marcada"
+
+#: gitk:11483
+msgid "Select bg"
+msgstr "Selecionar fundo"
+
+#: gitk:11492
+msgid "Fonts: press to choose"
+msgstr "Tipo de letra: pressione para escolher"
+
+#: gitk:11494
+msgid "Main font"
+msgstr "Tipo de letra principal"
+
+#: gitk:11495
+msgid "Diff display font"
+msgstr "Tipo de letra ao mostrar diferenças"
+
+#: gitk:11496
+msgid "User interface font"
+msgstr "Tipo de letra da interface de utilizador"
+
+#: gitk:11518
+msgid "Gitk preferences"
+msgstr "Preferências do gitk"
+
+#: gitk:11527
+msgid "General"
+msgstr "Geral"
+
+#: gitk:11528
+msgid "Colors"
+msgstr "Cores"
+
+#: gitk:11529
+msgid "Fonts"
+msgstr "Tipos de letra"
+
+#: gitk:11579
+#, tcl-format
+msgid "Gitk: choose color for %s"
+msgstr "Gitk: escolher cor de %s"
+
+#: gitk:12092
+msgid ""
+"Sorry, gitk cannot run with this version of Tcl/Tk.\n"
+" Gitk requires at least Tcl/Tk 8.4."
+msgstr ""
+"Não é possível executar o gitk com esta versão do Tcl/Tk.\n"
+"O gitk requer pelo menos Tcl/Tk 8.4."
+
+#: gitk:12302
+msgid "Cannot find a git repository here."
+msgstr "Não foi encontrado nenhum repositório git aqui."
+
+#: gitk:12349
+#, tcl-format
+msgid "Ambiguous argument '%s': both revision and filename"
+msgstr "Argumento '%s' ambíguo: pode ser uma revisão ou um ficheiro"
+
+#: gitk:12361
+msgid "Bad arguments to gitk:"
+msgstr "Argumentos do gitk incorretos:"
index 17ed026aa7da7c636457c302b2c28f7b866ae45a..9b08c263eadea7226a70d92d072f7a581da2bd20 100644 (file)
@@ -3,15 +3,15 @@
 # Translators:
 # 0xAX <kuleshovmail@gmail.com>, 2014
 # Alex Riesen <raa.lkml@gmail.com>, 2015
-# Dimitriy Ryazantcev <DJm00n@mail.ru>, 2015
+# Dimitriy Ryazantcev <DJm00n@mail.ru>, 2015-2016
 # Dmitry Potapov <dpotapov@gmail.com>, 2009
 # Skip <bsvskip@rambler.ru>, 2011
 msgid ""
 msgstr ""
 "Project-Id-Version: Git Russian Localization Project\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-05-17 14:32+1000\n"
-"PO-Revision-Date: 2015-10-12 10:14+0000\n"
+"POT-Creation-Date: 2016-12-15 00:18+0200\n"
+"PO-Revision-Date: 2016-12-14 22:23+0000\n"
 "Last-Translator: Dimitriy Ryazantcev <DJm00n@mail.ru>\n"
 "Language-Team: Russian (http://www.transifex.com/djm00n/git-po-ru/language/ru/)\n"
 "MIME-Version: 1.0\n"
@@ -24,11 +24,11 @@ msgstr ""
 msgid "Couldn't get list of unmerged files:"
 msgstr "Невозможно получить список файлов незавершённой операции слияния:"
 
-#: gitk:212 gitk:2381
+#: gitk:212 gitk:2403
 msgid "Color words"
 msgstr "Цветные слова"
 
-#: gitk:217 gitk:2381 gitk:8220 gitk:8253
+#: gitk:217 gitk:2403 gitk:8249 gitk:8282
 msgid "Markup words"
 msgstr "Помеченые слова"
 
@@ -58,1272 +58,1314 @@ msgstr "Ошибка запуска git log:"
 msgid "Reading"
 msgstr "Чтение"
 
-#: gitk:496 gitk:4525
+#: gitk:496 gitk:4549
 msgid "Reading commits..."
 msgstr "Чтение коммитов..."
 
-#: gitk:499 gitk:1637 gitk:4528
+#: gitk:499 gitk:1641 gitk:4552
 msgid "No commits selected"
 msgstr "Ничего не выбрано"
 
-#: gitk:1445 gitk:4045 gitk:12432
+#: gitk:1449 gitk:4069 gitk:12583
 msgid "Command line"
 msgstr "Командная строка"
 
-#: gitk:1511
+#: gitk:1515
 msgid "Can't parse git log output:"
 msgstr "Ошибка обработки вывода команды git log:"
 
-#: gitk:1740
+#: gitk:1744
 msgid "No commit information available"
 msgstr "Нет информации о коммите"
 
-#: gitk:1903 gitk:1932 gitk:4315 gitk:9669 gitk:11241 gitk:11521
+#: gitk:1907 gitk:1936 gitk:4339 gitk:9789 gitk:11388 gitk:11668
 msgid "OK"
 msgstr "Ok"
 
-#: gitk:1934 gitk:4317 gitk:9196 gitk:9275 gitk:9391 gitk:9440 gitk:9671
-#: gitk:11242 gitk:11522
+#: gitk:1938 gitk:4341 gitk:9225 gitk:9304 gitk:9434 gitk:9520 gitk:9791
+#: gitk:11389 gitk:11669
 msgid "Cancel"
 msgstr "Отмена"
 
-#: gitk:2069
+#: gitk:2087
 msgid "&Update"
 msgstr "Обновить"
 
-#: gitk:2070
+#: gitk:2088
 msgid "&Reload"
 msgstr "Перечитать"
 
-#: gitk:2071
+#: gitk:2089
 msgid "Reread re&ferences"
 msgstr "Обновить список ссылок"
 
-#: gitk:2072
+#: gitk:2090
 msgid "&List references"
 msgstr "Список ссылок"
 
-#: gitk:2074
+#: gitk:2092
 msgid "Start git &gui"
 msgstr "Запустить git gui"
 
-#: gitk:2076
+#: gitk:2094
 msgid "&Quit"
 msgstr "Завершить"
 
-#: gitk:2068
+#: gitk:2086
 msgid "&File"
 msgstr "Файл"
 
-#: gitk:2080
+#: gitk:2098
 msgid "&Preferences"
 msgstr "Настройки"
 
-#: gitk:2079
+#: gitk:2097
 msgid "&Edit"
 msgstr "Редактировать"
 
-#: gitk:2084
+#: gitk:2102
 msgid "&New view..."
 msgstr "Новое представление..."
 
-#: gitk:2085
+#: gitk:2103
 msgid "&Edit view..."
 msgstr "Редактировать представление..."
 
-#: gitk:2086
+#: gitk:2104
 msgid "&Delete view"
 msgstr "Удалить представление"
 
-#: gitk:2088 gitk:4043
+#: gitk:2106
 msgid "&All files"
 msgstr "Все файлы"
 
-#: gitk:2083 gitk:4067
+#: gitk:2101
 msgid "&View"
 msgstr "Представление"
 
-#: gitk:2093 gitk:2103 gitk:3012
+#: gitk:2111 gitk:2121
 msgid "&About gitk"
 msgstr "О gitk"
 
-#: gitk:2094 gitk:2108
+#: gitk:2112 gitk:2126
 msgid "&Key bindings"
 msgstr "Назначения клавиатуры"
 
-#: gitk:2092 gitk:2107
+#: gitk:2110 gitk:2125
 msgid "&Help"
 msgstr "Подсказка"
 
-#: gitk:2185 gitk:8652
+#: gitk:2203 gitk:8681
 msgid "SHA1 ID:"
 msgstr "SHA1 ID:"
 
-#: gitk:2229
+#: gitk:2247
 msgid "Row"
 msgstr "Строка"
 
-#: gitk:2267
+#: gitk:2285
 msgid "Find"
 msgstr "Поиск"
 
-#: gitk:2295
+#: gitk:2313
 msgid "commit"
 msgstr "коммит"
 
-#: gitk:2299 gitk:2301 gitk:4687 gitk:4710 gitk:4734 gitk:6755 gitk:6827
-#: gitk:6912
+#: gitk:2317 gitk:2319 gitk:4711 gitk:4734 gitk:4758 gitk:6779 gitk:6851
+#: gitk:6936
 msgid "containing:"
 msgstr "содержащее:"
 
-#: gitk:2302 gitk:3526 gitk:3531 gitk:4763
+#: gitk:2320 gitk:3550 gitk:3555 gitk:4787
 msgid "touching paths:"
 msgstr "касательно файлов:"
 
-#: gitk:2303 gitk:4777
+#: gitk:2321 gitk:4801
 msgid "adding/removing string:"
 msgstr "добавив/удалив строку:"
 
-#: gitk:2304 gitk:4779
+#: gitk:2322 gitk:4803
 msgid "changing lines matching:"
 msgstr "изменяя совпадающие строки:"
 
-#: gitk:2313 gitk:2315 gitk:4766
+#: gitk:2331 gitk:2333 gitk:4790
 msgid "Exact"
 msgstr "Точно"
 
-#: gitk:2315 gitk:4854 gitk:6723
+#: gitk:2333 gitk:4878 gitk:6747
 msgid "IgnCase"
 msgstr "Игнорировать большие/маленькие"
 
-#: gitk:2315 gitk:4736 gitk:4852 gitk:6719
+#: gitk:2333 gitk:4760 gitk:4876 gitk:6743
 msgid "Regexp"
 msgstr "Регулярные выражения"
 
-#: gitk:2317 gitk:2318 gitk:4874 gitk:4904 gitk:4911 gitk:6848 gitk:6916
+#: gitk:2335 gitk:2336 gitk:4898 gitk:4928 gitk:4935 gitk:6872 gitk:6940
 msgid "All fields"
 msgstr "Во всех полях"
 
-#: gitk:2318 gitk:4871 gitk:4904 gitk:6786
+#: gitk:2336 gitk:4895 gitk:4928 gitk:6810
 msgid "Headline"
 msgstr "Заголовок"
 
-#: gitk:2319 gitk:4871 gitk:6786 gitk:6916 gitk:7389
+#: gitk:2337 gitk:4895 gitk:6810 gitk:6940 gitk:7413
 msgid "Comments"
 msgstr "Комментарии"
 
-#: gitk:2319 gitk:4871 gitk:4876 gitk:4911 gitk:6786 gitk:7324 gitk:8830
-#: gitk:8845
+#: gitk:2337 gitk:4895 gitk:4900 gitk:4935 gitk:6810 gitk:7348 gitk:8859
+#: gitk:8874
 msgid "Author"
 msgstr "Автор"
 
-#: gitk:2319 gitk:4871 gitk:6786 gitk:7326
+#: gitk:2337 gitk:4895 gitk:6810 gitk:7350
 msgid "Committer"
 msgstr "Коммитер"
 
-#: gitk:2350
+#: gitk:2371
 msgid "Search"
 msgstr "Найти"
 
-#: gitk:2358
+#: gitk:2379
 msgid "Diff"
 msgstr "Сравнить"
 
-#: gitk:2360
+#: gitk:2381
 msgid "Old version"
 msgstr "Старая версия"
 
-#: gitk:2362
+#: gitk:2383
 msgid "New version"
 msgstr "Новая версия"
 
-#: gitk:2364
+#: gitk:2386
 msgid "Lines of context"
 msgstr "Строк контекста"
 
-#: gitk:2374
+#: gitk:2396
 msgid "Ignore space change"
 msgstr "Игнорировать пробелы"
 
-#: gitk:2378 gitk:2380 gitk:7959 gitk:8206
+#: gitk:2400 gitk:2402 gitk:7983 gitk:8235
 msgid "Line diff"
 msgstr "Изменения строк"
 
-#: gitk:2445
+#: gitk:2467
 msgid "Patch"
 msgstr "Патч"
 
-#: gitk:2447
+#: gitk:2469
 msgid "Tree"
 msgstr "Файлы"
 
-#: gitk:2617 gitk:2637
+#: gitk:2639 gitk:2660
 msgid "Diff this -> selected"
 msgstr "Сравнить этот коммит с выделенным"
 
-#: gitk:2618 gitk:2638
+#: gitk:2640 gitk:2661
 msgid "Diff selected -> this"
 msgstr "Сравнить выделенный с этим коммитом"
 
-#: gitk:2619 gitk:2639
+#: gitk:2641 gitk:2662
 msgid "Make patch"
 msgstr "Создать патч"
 
-#: gitk:2620 gitk:9254
+#: gitk:2642 gitk:9283
 msgid "Create tag"
 msgstr "Создать метку"
 
-#: gitk:2621 gitk:9371
+#: gitk:2643
+msgid "Copy commit summary"
+msgstr "Копировать информацию о коммите"
+
+#: gitk:2644 gitk:9414
 msgid "Write commit to file"
 msgstr "Сохранить коммит в файл"
 
-#: gitk:2622 gitk:9428
+#: gitk:2645
 msgid "Create new branch"
 msgstr "Создать ветку"
 
-#: gitk:2623
+#: gitk:2646
 msgid "Cherry-pick this commit"
-msgstr "Ð\9eÑ\82боÑ\80 Ð»Ñ\83Ñ\87Ñ\88его Ð´Ð»Ñ\8f Ñ\8dÑ\82ого ÐºÐ¾Ð¼Ð¼Ð¸Ñ\82а"
+msgstr "Ð\9aопиÑ\80оваÑ\82Ñ\8c Ñ\8dÑ\82оÑ\82 ÐºÐ¾Ð¼Ð¼Ð¸Ñ\82 Ð² Ñ\82екÑ\83Ñ\89Ñ\83Ñ\8e Ð²ÐµÑ\82кÑ\83"
 
-#: gitk:2624
+#: gitk:2647
 msgid "Reset HEAD branch to here"
 msgstr "Установить HEAD на этот коммит"
 
-#: gitk:2625
+#: gitk:2648
 msgid "Mark this commit"
 msgstr "Пометить этот коммит"
 
-#: gitk:2626
+#: gitk:2649
 msgid "Return to mark"
 msgstr "Вернуться на пометку"
 
-#: gitk:2627
+#: gitk:2650
 msgid "Find descendant of this and mark"
 msgstr "Найти и пометить потомка этого коммита"
 
-#: gitk:2628
+#: gitk:2651
 msgid "Compare with marked commit"
 msgstr "Сравнить с помеченным коммитом"
 
-#: gitk:2629 gitk:2640
+#: gitk:2652 gitk:2663
 msgid "Diff this -> marked commit"
 msgstr "Сравнить выделенное с помеченным коммитом"
 
-#: gitk:2630 gitk:2641
+#: gitk:2653 gitk:2664
 msgid "Diff marked commit -> this"
 msgstr "Сравнить помеченный с этим коммитом"
 
-#: gitk:2631
+#: gitk:2654
 msgid "Revert this commit"
-msgstr "Ð\92озвÑ\80аÑ\82 этого коммита"
+msgstr "Ð\9eбÑ\80аÑ\82иÑ\82Ñ\8c Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ\8f этого коммита"
 
-#: gitk:2647
+#: gitk:2670
 msgid "Check out this branch"
 msgstr "Перейти на эту ветку"
 
-#: gitk:2648
+#: gitk:2671
+msgid "Rename this branch"
+msgstr "Переименовать эту ветку"
+
+#: gitk:2672
 msgid "Remove this branch"
 msgstr "Удалить эту ветку"
 
-#: gitk:2649
+#: gitk:2673
 msgid "Copy branch name"
 msgstr "Копировать имя ветки"
 
-#: gitk:2656
+#: gitk:2680
 msgid "Highlight this too"
 msgstr "Подсветить этот тоже"
 
-#: gitk:2657
+#: gitk:2681
 msgid "Highlight this only"
 msgstr "Подсветить только этот"
 
-#: gitk:2658
+#: gitk:2682
 msgid "External diff"
 msgstr "Программа сравнения"
 
-#: gitk:2659
+#: gitk:2683
 msgid "Blame parent commit"
 msgstr "Авторы изменений родительского коммита"
 
-#: gitk:2660
+#: gitk:2684
 msgid "Copy path"
 msgstr "Копировать путь"
 
-#: gitk:2667
+#: gitk:2691
 msgid "Show origin of this line"
 msgstr "Показать источник этой строки"
 
-#: gitk:2668
+#: gitk:2692
 msgid "Run git gui blame on this line"
 msgstr "Запустить git gui blame для этой строки"
 
-#: gitk:3014
+#: gitk:3036
+msgid "About gitk"
+msgstr "О gitk"
+
+#: gitk:3038
 msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright  2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
-msgstr "\nGitk - программа просмотра истории репозиториев git\n\n©  2005-2014 Paul Mackerras\n\nИспользование и распространение согласно условиям GNU General Public License"
+msgstr "\nGitk — программа просмотра истории репозиториев git\n\n© 2005-2016 Paul Mackerras\n\nИспользование и распространение согласно условиям GNU General Public License"
 
-#: gitk:3022 gitk:3089 gitk:9857
+#: gitk:3046 gitk:3113 gitk:10004
 msgid "Close"
 msgstr "Закрыть"
 
-#: gitk:3043
+#: gitk:3067
 msgid "Gitk key bindings"
 msgstr "Назначения клавиатуры в Gitk"
 
-#: gitk:3046
+#: gitk:3070
 msgid "Gitk key bindings:"
 msgstr "Назначения клавиатуры в Gitk:"
 
-#: gitk:3048
+#: gitk:3072
 #, tcl-format
 msgid "<%s-Q>\t\tQuit"
 msgstr "<%s-Q>\t\tЗавершить"
 
-#: gitk:3049
+#: gitk:3073
 #, tcl-format
 msgid "<%s-W>\t\tClose window"
 msgstr "<%s-W>\t\tЗакрыть окно"
 
-#: gitk:3050
+#: gitk:3074
 msgid "<Home>\t\tMove to first commit"
 msgstr "<Home>\t\tПерейти к первому коммиту"
 
-#: gitk:3051
+#: gitk:3075
 msgid "<End>\t\tMove to last commit"
 msgstr "<End>\t\tПерейти к последнему коммиту"
 
-#: gitk:3052
+#: gitk:3076
 msgid "<Up>, p, k\tMove up one commit"
 msgstr "<Up>, p, k\tПерейти на один коммит вверх"
 
-#: gitk:3053
+#: gitk:3077
 msgid "<Down>, n, j\tMove down one commit"
 msgstr "<Down>, n, j\tПерейти на один коммит вниз"
 
-#: gitk:3054
+#: gitk:3078
 msgid "<Left>, z, h\tGo back in history list"
 msgstr "<Left>, z, h\tПоказать ранее посещённое состояние"
 
-#: gitk:3055
+#: gitk:3079
 msgid "<Right>, x, l\tGo forward in history list"
 msgstr "<Right>, x, l\tПоказать следующий посещённый коммит"
 
-#: gitk:3056
+#: gitk:3080
 #, tcl-format
 msgid "<%s-n>\tGo to n-th parent of current commit in history list"
 msgstr "<%s-n>\tПерейти на n родителя от текущего коммита"
 
-#: gitk:3057
+#: gitk:3081
 msgid "<PageUp>\tMove up one page in commit list"
 msgstr "<PageUp>\tПерейти на страницу выше в списке коммитов"
 
-#: gitk:3058
+#: gitk:3082
 msgid "<PageDown>\tMove down one page in commit list"
 msgstr "<PageDown>\tПерейти на страницу ниже в списке коммитов"
 
-#: gitk:3059
+#: gitk:3083
 #, tcl-format
 msgid "<%s-Home>\tScroll to top of commit list"
 msgstr "<%s-Home>\tПерейти на начало списка коммитов"
 
-#: gitk:3060
+#: gitk:3084
 #, tcl-format
 msgid "<%s-End>\tScroll to bottom of commit list"
 msgstr "<%s-End>\tПерейти на конец списка коммитов"
 
-#: gitk:3061
+#: gitk:3085
 #, tcl-format
 msgid "<%s-Up>\tScroll commit list up one line"
 msgstr "<%s-Up>\tПровернуть список коммитов вверх"
 
-#: gitk:3062
+#: gitk:3086
 #, tcl-format
 msgid "<%s-Down>\tScroll commit list down one line"
 msgstr "<%s-Down>\tПровернуть список коммитов вниз"
 
-#: gitk:3063
+#: gitk:3087
 #, tcl-format
 msgid "<%s-PageUp>\tScroll commit list up one page"
 msgstr "<%s-PageUp>\tПровернуть список коммитов на страницу вверх"
 
-#: gitk:3064
+#: gitk:3088
 #, tcl-format
 msgid "<%s-PageDown>\tScroll commit list down one page"
 msgstr "<%s-PageDown>\tПровернуть список коммитов на страницу вниз"
 
-#: gitk:3065
+#: gitk:3089
 msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
 msgstr "<Shift-Up>\tПоиск в обратном порядке (вверх, среди новых коммитов)"
 
-#: gitk:3066
+#: gitk:3090
 msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
 msgstr "<Shift-Down>\tПоиск (вниз, среди старых коммитов)"
 
-#: gitk:3067
+#: gitk:3091
 msgid "<Delete>, b\tScroll diff view up one page"
 msgstr "<Delete>, b\tПрокрутить список изменений на страницу выше"
 
-#: gitk:3068
+#: gitk:3092
 msgid "<Backspace>\tScroll diff view up one page"
 msgstr "<Backspace>\tПрокрутить список изменений на страницу выше"
 
-#: gitk:3069
+#: gitk:3093
 msgid "<Space>\t\tScroll diff view down one page"
 msgstr "<Leertaste>\t\tПрокрутить список изменений на страницу ниже"
 
-#: gitk:3070
+#: gitk:3094
 msgid "u\t\tScroll diff view up 18 lines"
 msgstr "u\t\tПрокрутить список изменений на 18 строк вверх"
 
-#: gitk:3071
+#: gitk:3095
 msgid "d\t\tScroll diff view down 18 lines"
 msgstr "d\t\tПрокрутить список изменений на 18 строк вниз"
 
-#: gitk:3072
+#: gitk:3096
 #, tcl-format
 msgid "<%s-F>\t\tFind"
 msgstr "<%s-F>\t\tПоиск"
 
-#: gitk:3073
+#: gitk:3097
 #, tcl-format
 msgid "<%s-G>\t\tMove to next find hit"
 msgstr "<%s-G>\t\tПерейти к следующему найденному коммиту"
 
-#: gitk:3074
+#: gitk:3098
 msgid "<Return>\tMove to next find hit"
 msgstr "<Return>\tПерейти к следующему найденному коммиту"
 
-#: gitk:3075
+#: gitk:3099
 msgid "g\t\tGo to commit"
 msgstr "g\t\tПерейти на коммит"
 
-#: gitk:3076
+#: gitk:3100
 msgid "/\t\tFocus the search box"
 msgstr "/\t\tПерейти к полю поиска"
 
-#: gitk:3077
+#: gitk:3101
 msgid "?\t\tMove to previous find hit"
 msgstr "?\t\tПерейти к предыдущему найденному коммиту"
 
-#: gitk:3078
+#: gitk:3102
 msgid "f\t\tScroll diff view to next file"
 msgstr "f\t\tПрокрутить список изменений к следующему файлу"
 
-#: gitk:3079
+#: gitk:3103
 #, tcl-format
 msgid "<%s-S>\t\tSearch for next hit in diff view"
 msgstr "<%s-S>\t\tПродолжить поиск в списке изменений"
 
-#: gitk:3080
+#: gitk:3104
 #, tcl-format
 msgid "<%s-R>\t\tSearch for previous hit in diff view"
 msgstr "<%s-R>\t\tПерейти к предыдущему найденному тексту в списке изменений"
 
-#: gitk:3081
+#: gitk:3105
 #, tcl-format
 msgid "<%s-KP+>\tIncrease font size"
 msgstr "<%s-KP+>\tУвеличить размер шрифта"
 
-#: gitk:3082
+#: gitk:3106
 #, tcl-format
 msgid "<%s-plus>\tIncrease font size"
 msgstr "<%s-plus>\tУвеличить размер шрифта"
 
-#: gitk:3083
+#: gitk:3107
 #, tcl-format
 msgid "<%s-KP->\tDecrease font size"
 msgstr "<%s-KP->\tУменьшить размер шрифта"
 
-#: gitk:3084
+#: gitk:3108
 #, tcl-format
 msgid "<%s-minus>\tDecrease font size"
 msgstr "<%s-minus>\tУменьшить размер шрифта"
 
-#: gitk:3085
+#: gitk:3109
 msgid "<F5>\t\tUpdate"
 msgstr "<F5>\t\tОбновить"
 
-#: gitk:3550 gitk:3559
+#: gitk:3574 gitk:3583
 #, tcl-format
 msgid "Error creating temporary directory %s:"
 msgstr "Ошибка создания временного каталога %s:"
 
-#: gitk:3572
+#: gitk:3596
 #, tcl-format
 msgid "Error getting \"%s\" from %s:"
 msgstr "Ошибка получения «%s» из %s:"
 
-#: gitk:3635
+#: gitk:3659
 msgid "command failed:"
 msgstr "ошибка выполнения команды:"
 
-#: gitk:3784
+#: gitk:3808
 msgid "No such commit"
 msgstr "Коммит не найден"
 
-#: gitk:3798
+#: gitk:3822
 msgid "git gui blame: command failed:"
 msgstr "git gui blame: ошибка выполнения команды:"
 
-#: gitk:3829
+#: gitk:3853
 #, tcl-format
 msgid "Couldn't read merge head: %s"
 msgstr "Ошибка чтения MERGE_HEAD: %s"
 
-#: gitk:3837
+#: gitk:3861
 #, tcl-format
 msgid "Error reading index: %s"
 msgstr "Ошибка чтения индекса: %s"
 
-#: gitk:3862
+#: gitk:3886
 #, tcl-format
 msgid "Couldn't start git blame: %s"
 msgstr "Ошибка запуска git blame: %s"
 
-#: gitk:3865 gitk:6754
+#: gitk:3889 gitk:6778
 msgid "Searching"
 msgstr "Поиск"
 
-#: gitk:3897
+#: gitk:3921
 #, tcl-format
 msgid "Error running git blame: %s"
 msgstr "Ошибка выполнения git blame: %s"
 
-#: gitk:3925
+#: gitk:3949
 #, tcl-format
 msgid "That line comes from commit %s,  which is not in this view"
 msgstr "Эта строка принадлежит коммиту %s, который не показан в этом представлении"
 
-#: gitk:3939
+#: gitk:3963
 msgid "External diff viewer failed:"
 msgstr "Ошибка выполнения программы сравнения:"
 
-#: gitk:4070
+#: gitk:4067
+msgid "All files"
+msgstr "Все файлы"
+
+#: gitk:4091
+msgid "View"
+msgstr "Представление"
+
+#: gitk:4094
 msgid "Gitk view definition"
 msgstr "Gitk определение представлений"
 
-#: gitk:4074
+#: gitk:4098
 msgid "Remember this view"
 msgstr "Запомнить представление"
 
-#: gitk:4075
+#: gitk:4099
 msgid "References (space separated list):"
 msgstr "Ссылки (разделённые пробелом):"
 
-#: gitk:4076
+#: gitk:4100
 msgid "Branches & tags:"
 msgstr "Ветки и метки"
 
-#: gitk:4077
+#: gitk:4101
 msgid "All refs"
 msgstr "Все ссылки"
 
-#: gitk:4078
+#: gitk:4102
 msgid "All (local) branches"
 msgstr "Все (локальные) ветки"
 
-#: gitk:4079
+#: gitk:4103
 msgid "All tags"
 msgstr "Все метки"
 
-#: gitk:4080
+#: gitk:4104
 msgid "All remote-tracking branches"
 msgstr "Все внешние отслеживаемые ветки"
 
-#: gitk:4081
+#: gitk:4105
 msgid "Commit Info (regular expressions):"
 msgstr "Информация о коммите (регулярные выражения):"
 
-#: gitk:4082
+#: gitk:4106
 msgid "Author:"
 msgstr "Автор:"
 
-#: gitk:4083
+#: gitk:4107
 msgid "Committer:"
 msgstr "Коммитер:"
 
-#: gitk:4084
+#: gitk:4108
 msgid "Commit Message:"
 msgstr "Сообщение коммита:"
 
-#: gitk:4085
+#: gitk:4109
 msgid "Matches all Commit Info criteria"
 msgstr "Совпадает со всеми условиями информации о коммите"
 
-#: gitk:4086
+#: gitk:4110
 msgid "Matches no Commit Info criteria"
 msgstr "Не совпадает с условиями информации о коммите"
 
-#: gitk:4087
+#: gitk:4111
 msgid "Changes to Files:"
 msgstr "Изменения файлов:"
 
-#: gitk:4088
+#: gitk:4112
 msgid "Fixed String"
 msgstr "Обычная строка"
 
-#: gitk:4089
+#: gitk:4113
 msgid "Regular Expression"
 msgstr "Регулярное выражение:"
 
-#: gitk:4090
+#: gitk:4114
 msgid "Search string:"
 msgstr "Строка для поиска:"
 
-#: gitk:4091
+#: gitk:4115
 msgid ""
 "Commit Dates (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 "
 "15:27:38\"):"
 msgstr "Даты коммита («2 недели назад», «2009-03-17 15:27:38», «17 марта 2009 15:27:38»):"
 
-#: gitk:4092
+#: gitk:4116
 msgid "Since:"
 msgstr "С даты:"
 
-#: gitk:4093
+#: gitk:4117
 msgid "Until:"
 msgstr "По дату:"
 
-#: gitk:4094
+#: gitk:4118
 msgid "Limit and/or skip a number of revisions (positive integer):"
 msgstr "Ограничить и/или пропустить количество редакций (положительное число):"
 
-#: gitk:4095
+#: gitk:4119
 msgid "Number to show:"
 msgstr "Показать количество:"
 
-#: gitk:4096
+#: gitk:4120
 msgid "Number to skip:"
 msgstr "Пропустить количество:"
 
-#: gitk:4097
+#: gitk:4121
 msgid "Miscellaneous options:"
 msgstr "Различные опции:"
 
-#: gitk:4098
+#: gitk:4122
 msgid "Strictly sort by date"
 msgstr "Строгая сортировка по дате"
 
-#: gitk:4099
+#: gitk:4123
 msgid "Mark branch sides"
 msgstr "Отметить стороны веток"
 
-#: gitk:4100
+#: gitk:4124
 msgid "Limit to first parent"
 msgstr "Ограничить первым предком"
 
-#: gitk:4101
+#: gitk:4125
 msgid "Simple history"
 msgstr "Упрощенная история"
 
-#: gitk:4102
+#: gitk:4126
 msgid "Additional arguments to git log:"
 msgstr "Дополнительные аргументы для git log:"
 
-#: gitk:4103
+#: gitk:4127
 msgid "Enter files and directories to include, one per line:"
 msgstr "Файлы и каталоги для ограничения истории, по одному на строку:"
 
-#: gitk:4104
+#: gitk:4128
 msgid "Command to generate more commits to include:"
 msgstr "Дополнительная команда для списка коммитов:"
 
-#: gitk:4228
+#: gitk:4252
 msgid "Gitk: edit view"
 msgstr "Gitk: изменить представление"
 
-#: gitk:4236
+#: gitk:4260
 msgid "-- criteria for selecting revisions"
 msgstr "— критерий поиска редакций"
 
-#: gitk:4241
+#: gitk:4265
 msgid "View Name"
 msgstr "Имя представления"
 
-#: gitk:4316
+#: gitk:4340
 msgid "Apply (F5)"
 msgstr "Применить (F5)"
 
-#: gitk:4354
+#: gitk:4378
 msgid "Error in commit selection arguments:"
 msgstr "Ошибка в параметрах выбора коммитов:"
 
-#: gitk:4409 gitk:4462 gitk:4924 gitk:4938 gitk:6208 gitk:12373 gitk:12374
+#: gitk:4433 gitk:4486 gitk:4948 gitk:4962 gitk:6232 gitk:12524 gitk:12525
 msgid "None"
 msgstr "Ни одного"
 
-#: gitk:5021 gitk:5026
+#: gitk:5045 gitk:5050
 msgid "Descendant"
 msgstr "Порождённое"
 
-#: gitk:5022
+#: gitk:5046
 msgid "Not descendant"
 msgstr "Не порождённое"
 
-#: gitk:5029 gitk:5034
+#: gitk:5053 gitk:5058
 msgid "Ancestor"
 msgstr "Предок"
 
-#: gitk:5030
+#: gitk:5054
 msgid "Not ancestor"
 msgstr "Не предок"
 
-#: gitk:5324
+#: gitk:5348
 msgid "Local changes checked in to index but not committed"
 msgstr "Проиндексированные изменения"
 
-#: gitk:5360
+#: gitk:5384
 msgid "Local uncommitted changes, not checked in to index"
 msgstr "Непроиндексированные изменения"
 
-#: gitk:7134
+#: gitk:7158
 msgid "and many more"
 msgstr "и многое другое"
 
-#: gitk:7137
+#: gitk:7161
 msgid "many"
 msgstr "много"
 
-#: gitk:7328
+#: gitk:7352
 msgid "Tags:"
 msgstr "Метки:"
 
-#: gitk:7345 gitk:7351 gitk:8825
+#: gitk:7369 gitk:7375 gitk:8854
 msgid "Parent"
 msgstr "Предок"
 
-#: gitk:7356
+#: gitk:7380
 msgid "Child"
 msgstr "Потомок"
 
-#: gitk:7365
+#: gitk:7389
 msgid "Branch"
 msgstr "Ветка"
 
-#: gitk:7368
+#: gitk:7392
 msgid "Follows"
 msgstr "Следует за"
 
-#: gitk:7371
+#: gitk:7395
 msgid "Precedes"
 msgstr "Предшествует"
 
-#: gitk:7966
+#: gitk:7990
 #, tcl-format
 msgid "Error getting diffs: %s"
 msgstr "Ошибка получения изменений: %s"
 
-#: gitk:8650
+#: gitk:8679
 msgid "Goto:"
 msgstr "Перейти к:"
 
-#: gitk:8671
+#: gitk:8700
 #, tcl-format
 msgid "Short SHA1 id %s is ambiguous"
 msgstr "Сокращённый SHA1 идентификатор %s неоднозначен"
 
-#: gitk:8678
+#: gitk:8707
 #, tcl-format
 msgid "Revision %s is not known"
 msgstr "Редакция %s не найдена"
 
-#: gitk:8688
+#: gitk:8717
 #, tcl-format
 msgid "SHA1 id %s is not known"
 msgstr "SHA1 идентификатор %s не найден"
 
-#: gitk:8690
+#: gitk:8719
 #, tcl-format
 msgid "Revision %s is not in the current view"
 msgstr "Редакция %s не найдена в текущем представлении"
 
-#: gitk:8832 gitk:8847
+#: gitk:8861 gitk:8876
 msgid "Date"
 msgstr "Дата"
 
-#: gitk:8835
+#: gitk:8864
 msgid "Children"
 msgstr "Потомки"
 
-#: gitk:8898
+#: gitk:8927
 #, tcl-format
 msgid "Reset %s branch to here"
 msgstr "Сбросить ветку %s на этот коммит"
 
-#: gitk:8900
+#: gitk:8929
 msgid "Detached head: can't reset"
 msgstr "Коммит не принадлежит ни одной ветке, сбросить невозможно"
 
-#: gitk:9005 gitk:9011
+#: gitk:9034 gitk:9040
 msgid "Skipping merge commit "
 msgstr "Пропускаю коммит-слияние"
 
-#: gitk:9020 gitk:9025
+#: gitk:9049 gitk:9054
 msgid "Error getting patch ID for "
 msgstr "Не удалось получить идентификатор патча для "
 
-#: gitk:9021 gitk:9026
+#: gitk:9050 gitk:9055
 msgid " - stopping\n"
 msgstr " — останов\n"
 
-#: gitk:9031 gitk:9034 gitk:9042 gitk:9056 gitk:9065
+#: gitk:9060 gitk:9063 gitk:9071 gitk:9085 gitk:9094
 msgid "Commit "
 msgstr "Коммит"
 
-#: gitk:9035
+#: gitk:9064
 msgid ""
 " is the same patch as\n"
 "       "
 msgstr " такой же патч, как и\n       "
 
-#: gitk:9043
+#: gitk:9072
 msgid ""
 " differs from\n"
 "       "
 msgstr " отличается от\n       "
 
-#: gitk:9045
+#: gitk:9074
 msgid ""
 "Diff of commits:\n"
 "\n"
 msgstr "Различия коммитов:\n\n"
 
-#: gitk:9057 gitk:9066
+#: gitk:9086 gitk:9095
 #, tcl-format
 msgid " has %s children - stopping\n"
 msgstr " является %s потомком — останов\n"
 
-#: gitk:9085
+#: gitk:9114
 #, tcl-format
 msgid "Error writing commit to file: %s"
 msgstr "Произошла ошибка при записи коммита в файл: %s"
 
-#: gitk:9091
+#: gitk:9120
 #, tcl-format
 msgid "Error diffing commits: %s"
 msgstr "Произошла ошибка при выводе различий коммитов: %s"
 
-#: gitk:9137
+#: gitk:9166
 msgid "Top"
 msgstr "Верх"
 
-#: gitk:9138
+#: gitk:9167
 msgid "From"
 msgstr "От"
 
-#: gitk:9143
+#: gitk:9172
 msgid "To"
 msgstr "До"
 
-#: gitk:9167
+#: gitk:9196
 msgid "Generate patch"
 msgstr "Создать патч"
 
-#: gitk:9169
+#: gitk:9198
 msgid "From:"
 msgstr "От:"
 
-#: gitk:9178
+#: gitk:9207
 msgid "To:"
 msgstr "До:"
 
-#: gitk:9187
+#: gitk:9216
 msgid "Reverse"
 msgstr "В обратном порядке"
 
-#: gitk:9189 gitk:9385
+#: gitk:9218 gitk:9428
 msgid "Output file:"
 msgstr "Файл для сохранения:"
 
-#: gitk:9195
+#: gitk:9224
 msgid "Generate"
 msgstr "Создать"
 
-#: gitk:9233
+#: gitk:9262
 msgid "Error creating patch:"
 msgstr "Ошибка создания патча:"
 
-#: gitk:9256 gitk:9373 gitk:9430
+#: gitk:9285 gitk:9416 gitk:9504
 msgid "ID:"
 msgstr "ID:"
 
-#: gitk:9265
+#: gitk:9294
 msgid "Tag name:"
 msgstr "Имя метки:"
 
-#: gitk:9268
+#: gitk:9297
 msgid "Tag message is optional"
 msgstr "Описание метки указывать не обязательно"
 
-#: gitk:9270
+#: gitk:9299
 msgid "Tag message:"
 msgstr "Описание метки:"
 
-#: gitk:9274 gitk:9439
+#: gitk:9303 gitk:9474
 msgid "Create"
 msgstr "Создать"
 
-#: gitk:9292
+#: gitk:9321
 msgid "No tag name specified"
 msgstr "Не задано имя метки"
 
-#: gitk:9296
+#: gitk:9325
 #, tcl-format
 msgid "Tag \"%s\" already exists"
 msgstr "Метка «%s» уже существует"
 
-#: gitk:9306
+#: gitk:9335
 msgid "Error creating tag:"
 msgstr "Ошибка создания метки:"
 
-#: gitk:9382
+#: gitk:9425
 msgid "Command:"
 msgstr "Команда:"
 
-#: gitk:9390
+#: gitk:9433
 msgid "Write"
 msgstr "Запись"
 
-#: gitk:9408
+#: gitk:9451
 msgid "Error writing commit:"
 msgstr "Произошла ошибка при записи коммита:"
 
-#: gitk:9435
+#: gitk:9473
+msgid "Create branch"
+msgstr "Создать ветку"
+
+#: gitk:9489
+#, tcl-format
+msgid "Rename branch %s"
+msgstr "Переименовать ветку %s"
+
+#: gitk:9490
+msgid "Rename"
+msgstr "Переименовать"
+
+#: gitk:9514
 msgid "Name:"
 msgstr "Имя:"
 
-#: gitk:9458
+#: gitk:9538
 msgid "Please specify a name for the new branch"
 msgstr "Укажите имя для новой ветки"
 
-#: gitk:9463
+#: gitk:9543
 #, tcl-format
 msgid "Branch '%s' already exists. Overwrite?"
 msgstr "Ветка «%s» уже существует. Переписать?"
 
-#: gitk:9530
+#: gitk:9587
+msgid "Please specify a new name for the branch"
+msgstr "Укажите имя для новой ветки"
+
+#: gitk:9650
 #, tcl-format
 msgid "Commit %s is already included in branch %s -- really re-apply it?"
 msgstr "Коммит %s уже включён в ветку %s. Продолжить операцию?"
 
-#: gitk:9535
+#: gitk:9655
 msgid "Cherry-picking"
-msgstr "Ð\9aопиÑ\80ование Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ð¹"
+msgstr "Ð\9aопиÑ\80ование ÐºÐ¾Ð¼Ð¼Ð¸Ñ\82а"
 
-#: gitk:9544
+#: gitk:9664
 #, tcl-format
 msgid ""
 "Cherry-pick failed because of local changes to file '%s'.\n"
 "Please commit, reset or stash your changes and try again."
-msgstr "Ð\9eÑ\82боÑ\80 Ð»Ñ\83Ñ\87Ñ\88его Ð½ÐµÐ²Ð¾Ð·Ð¼Ð¾Ð¶ÐµÐ½ Ð¸Ð·-за Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ð¹ Ð² Ñ\84айле Â«%s».\nÐ\97акомитьте, сбросьте или спрячьте изменения и повторите операцию."
+msgstr "Ð\9aопиÑ\80ование ÐºÐ¾Ð¼Ð¼Ð¸Ñ\82а Ð½ÐµÐ²Ð¾Ð·Ð¼Ð¾Ð¶Ð½Ð¾ Ð¸Ð·-за Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ð¹ Ð² Ñ\84айле Â«%s».\nÐ\97акоммитьте, сбросьте или спрячьте изменения и повторите операцию."
 
-#: gitk:9550
+#: gitk:9670
 msgid ""
 "Cherry-pick failed because of merge conflict.\n"
 "Do you wish to run git citool to resolve it?"
 msgstr "Копирование изменений невозможно из-за незавершённой операции слияния.\nЗапустить git citool для завершения этой операции?"
 
-#: gitk:9566 gitk:9624
+#: gitk:9686 gitk:9744
 msgid "No changes committed"
 msgstr "Изменения не закоммичены"
 
-#: gitk:9593
+#: gitk:9713
 #, tcl-format
 msgid "Commit %s is not included in branch %s -- really revert it?"
 msgstr "Коммит %s не включён в ветку %s. Продолжить операцию?"
 
-#: gitk:9598
+#: gitk:9718
 msgid "Reverting"
-msgstr "Ð\92озвÑ\80аÑ\82 изменений"
+msgstr "Ð\9eбÑ\80аÑ\89ение изменений"
 
-#: gitk:9606
+#: gitk:9726
 #, tcl-format
 msgid ""
 "Revert failed because of local changes to the following files:%s Please "
 "commit, reset or stash  your changes and try again."
-msgstr "Возврат изменений коммита не удался из-за локальных изменений в указанных файлах: %s\nЗакомитьте, сбросьте или спрячьте изменения и повторите операцию."
+msgstr "Ð\92озвÑ\80аÑ\82 Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ð¹ ÐºÐ¾Ð¼Ð¼Ð¸Ñ\82а Ð½Ðµ Ñ\83далÑ\81Ñ\8f Ð¸Ð·-за Ð»Ð¾ÐºÐ°Ð»Ñ\8cнÑ\8bÑ\85 Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ð¹ Ð² Ñ\83казаннÑ\8bÑ\85 Ñ\84айлаÑ\85: %s\nÐ\97акоммиÑ\82Ñ\8cÑ\82е, Ñ\81бÑ\80оÑ\81Ñ\8cÑ\82е Ð¸Ð»Ð¸ Ñ\81пÑ\80Ñ\8fÑ\87Ñ\8cÑ\82е Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ\8f Ð¸ Ð¿Ð¾Ð²Ñ\82оÑ\80иÑ\82е Ð¾Ð¿ÐµÑ\80аÑ\86иÑ\8e."
 
-#: gitk:9610
+#: gitk:9730
 msgid ""
 "Revert failed because of merge conflict.\n"
 " Do you wish to run git citool to resolve it?"
 msgstr "Возврат изменений невозможен из-за незавершённой операции слияния.\nЗапустить git citool для завершения этой операции?"
 
-#: gitk:9653
+#: gitk:9773
 msgid "Confirm reset"
 msgstr "Подтвердите операцию перехода"
 
-#: gitk:9655
+#: gitk:9775
 #, tcl-format
 msgid "Reset branch %s to %s?"
 msgstr "Сбросить ветку %s на коммит %s?"
 
-#: gitk:9657
+#: gitk:9777
 msgid "Reset type:"
 msgstr "Тип операции перехода:"
 
-#: gitk:9660
+#: gitk:9780
 msgid "Soft: Leave working tree and index untouched"
 msgstr "Лёгкий: оставить рабочий каталог и индекс неизменными"
 
-#: gitk:9663
+#: gitk:9783
 msgid "Mixed: Leave working tree untouched, reset index"
 msgstr "Смешанный: оставить рабочий каталог неизменным, установить индекс"
 
-#: gitk:9666
+#: gitk:9786
 msgid ""
 "Hard: Reset working tree and index\n"
 "(discard ALL local changes)"
 msgstr "Жесткий: переписать индекс и рабочий каталог\n(все изменения в рабочем каталоге будут потеряны)"
 
-#: gitk:9683
+#: gitk:9803
 msgid "Resetting"
 msgstr "Сброс"
 
-#: gitk:9743
+#: gitk:9876
+#, tcl-format
+msgid "A local branch named %s exists already"
+msgstr "Локальная ветка с именем %s уже существует"
+
+#: gitk:9884
 msgid "Checking out"
 msgstr "Переход"
 
-#: gitk:9796
+#: gitk:9943
 msgid "Cannot delete the currently checked-out branch"
 msgstr "Активная ветка не может быть удалена"
 
-#: gitk:9802
+#: gitk:9949
 #, tcl-format
 msgid ""
 "The commits on branch %s aren't on any other branch.\n"
 "Really delete branch %s?"
 msgstr "Коммиты из ветки %s не принадлежат больше никакой другой ветке.\nДействительно удалить ветку %s?"
 
-#: gitk:9833
+#: gitk:9980
 #, tcl-format
 msgid "Tags and heads: %s"
 msgstr "Метки и ветки: %s"
 
-#: gitk:9850
+#: gitk:9997
 msgid "Filter"
 msgstr "Фильтровать"
 
-#: gitk:10146
+#: gitk:10293
 msgid ""
 "Error reading commit topology information; branch and preceding/following "
 "tag information will be incomplete."
 msgstr "Ошибка чтения истории проекта; информация о ветках и коммитах вокруг меток (до/после) может быть неполной."
 
-#: gitk:11123
+#: gitk:11270
 msgid "Tag"
 msgstr "Метка"
 
-#: gitk:11127
+#: gitk:11274
 msgid "Id"
 msgstr "Id"
 
-#: gitk:11210
+#: gitk:11357
 msgid "Gitk font chooser"
 msgstr "Шрифт Gitk"
 
-#: gitk:11227
+#: gitk:11374
 msgid "B"
 msgstr "Ж"
 
-#: gitk:11230
+#: gitk:11377
 msgid "I"
 msgstr "К"
 
-#: gitk:11348
+#: gitk:11495
 msgid "Commit list display options"
 msgstr "Параметры показа списка коммитов"
 
-#: gitk:11351
+#: gitk:11498
 msgid "Maximum graph width (lines)"
 msgstr "Макс. ширина графа (строк)"
 
-#: gitk:11355
+#: gitk:11502
 #, no-tcl-format
 msgid "Maximum graph width (% of pane)"
 msgstr "Макс. ширина графа (% ширины панели)"
 
-#: gitk:11358
+#: gitk:11505
 msgid "Show local changes"
 msgstr "Показывать изменения в рабочем каталоге"
 
-#: gitk:11361
+#: gitk:11508
 msgid "Auto-select SHA1 (length)"
 msgstr "Автоматически выделить SHA1 (длинна)"
 
-#: gitk:11365
+#: gitk:11512
 msgid "Hide remote refs"
 msgstr "Скрыть внешние ссылки"
 
-#: gitk:11369
+#: gitk:11516
 msgid "Diff display options"
 msgstr "Параметры показа изменений"
 
-#: gitk:11371
+#: gitk:11518
 msgid "Tab spacing"
 msgstr "Ширина табуляции"
 
-#: gitk:11374
+#: gitk:11521
 msgid "Display nearby tags/heads"
 msgstr "Показывать близкие метки/ветки"
 
-#: gitk:11377
+#: gitk:11524
 msgid "Maximum # tags/heads to show"
 msgstr "Показывать максимальное количество меток/веток"
 
-#: gitk:11380
+#: gitk:11527
 msgid "Limit diffs to listed paths"
 msgstr "Ограничить показ изменений выбранными файлами"
 
-#: gitk:11383
+#: gitk:11530
 msgid "Support per-file encodings"
 msgstr "Поддержка кодировок в отдельных файлах"
 
-#: gitk:11389 gitk:11536
+#: gitk:11536 gitk:11683
 msgid "External diff tool"
 msgstr "Программа для показа изменений"
 
-#: gitk:11390
+#: gitk:11537
 msgid "Choose..."
 msgstr "Выберите..."
 
-#: gitk:11395
+#: gitk:11542
 msgid "General options"
 msgstr "Общие опции"
 
-#: gitk:11398
+#: gitk:11545
 msgid "Use themed widgets"
 msgstr "Использовать стили виджетов"
 
-#: gitk:11400
+#: gitk:11547
 msgid "(change requires restart)"
 msgstr "(изменение потребует перезапуск)"
 
-#: gitk:11402
+#: gitk:11549
 msgid "(currently unavailable)"
 msgstr "(недоступно в данный момент)"
 
-#: gitk:11413
+#: gitk:11560
 msgid "Colors: press to choose"
 msgstr "Цвета: нажмите для выбора"
 
-#: gitk:11416
+#: gitk:11563
 msgid "Interface"
 msgstr "Интерфейс"
 
-#: gitk:11417
+#: gitk:11564
 msgid "interface"
 msgstr "интерфейс"
 
-#: gitk:11420
+#: gitk:11567
 msgid "Background"
 msgstr "Фон"
 
-#: gitk:11421 gitk:11451
+#: gitk:11568 gitk:11598
 msgid "background"
 msgstr "фон"
 
-#: gitk:11424
+#: gitk:11571
 msgid "Foreground"
 msgstr "Передний план"
 
-#: gitk:11425
+#: gitk:11572
 msgid "foreground"
 msgstr "передний план"
 
-#: gitk:11428
+#: gitk:11575
 msgid "Diff: old lines"
 msgstr "Изменения: старый текст"
 
-#: gitk:11429
+#: gitk:11576
 msgid "diff old lines"
 msgstr "старый текст изменения"
 
-#: gitk:11433
+#: gitk:11580
 msgid "Diff: new lines"
 msgstr "Изменения: новый текст"
 
-#: gitk:11434
+#: gitk:11581
 msgid "diff new lines"
 msgstr "новый текст изменения"
 
-#: gitk:11438
+#: gitk:11585
 msgid "Diff: hunk header"
 msgstr "Изменения: заголовок блока"
 
-#: gitk:11440
+#: gitk:11587
 msgid "diff hunk header"
 msgstr "заголовок блока изменений"
 
-#: gitk:11444
+#: gitk:11591
 msgid "Marked line bg"
 msgstr "Фон выбранной строки"
 
-#: gitk:11446
+#: gitk:11593
 msgid "marked line background"
 msgstr "фон выбранной строки"
 
-#: gitk:11450
+#: gitk:11597
 msgid "Select bg"
 msgstr "Выберите фон"
 
-#: gitk:11459
+#: gitk:11606
 msgid "Fonts: press to choose"
 msgstr "Шрифт: нажмите для выбора"
 
-#: gitk:11461
+#: gitk:11608
 msgid "Main font"
 msgstr "Основной шрифт"
 
-#: gitk:11462
+#: gitk:11609
 msgid "Diff display font"
 msgstr "Шрифт показа изменений"
 
-#: gitk:11463
+#: gitk:11610
 msgid "User interface font"
 msgstr "Шрифт интерфейса"
 
-#: gitk:11485
+#: gitk:11632
 msgid "Gitk preferences"
 msgstr "Настройки Gitk"
 
-#: gitk:11494
+#: gitk:11641
 msgid "General"
 msgstr "Общие"
 
-#: gitk:11495
+#: gitk:11642
 msgid "Colors"
 msgstr "Цвета"
 
-#: gitk:11496
+#: gitk:11643
 msgid "Fonts"
 msgstr "Шрифты"
 
-#: gitk:11546
+#: gitk:11693
 #, tcl-format
 msgid "Gitk: choose color for %s"
 msgstr "Gitk: выберите цвет для %s"
 
-#: gitk:12059
+#: gitk:12206
 msgid ""
 "Sorry, gitk cannot run with this version of Tcl/Tk.\n"
 " Gitk requires at least Tcl/Tk 8.4."
 msgstr "К сожалению gitk не может работать с этой версий Tcl/Tk.\nТребуется как минимум Tcl/Tk 8.4."
 
-#: gitk:12269
+#: gitk:12416
 msgid "Cannot find a git repository here."
 msgstr "Git-репозитарий не найден в текущем каталоге."
 
-#: gitk:12316
+#: gitk:12463
 #, tcl-format
 msgid "Ambiguous argument '%s': both revision and filename"
 msgstr "Неоднозначный аргумент «%s»: существует как редакция и как имя файла"
 
-#: gitk:12328
+#: gitk:12475
 msgid "Bad arguments to gitk:"
 msgstr "Неправильные аргументы для gitk:"
index d9d4e87a44a5cddafe957f276248ceec3c3ebc40..2a06fe5bbcf826c4a3312b0cff1e1ff53cf69490 100644 (file)
@@ -374,14 +374,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - en incheckningsvisare för git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Använd och vidareförmedla enligt villkoren i GNU General Public License"
 
@@ -1385,21 +1385,6 @@ msgstr "Felaktiga argument till gitk:"
 #~ msgid "mc"
 #~ msgstr "mc"
 
-#~ msgid ""
-#~ "\n"
-#~ "Gitk - a commit viewer for git\n"
-#~ "\n"
-#~ "Copyright © 2005-2015 Paul Mackerras\n"
-#~ "\n"
-#~ "Use and redistribute under the terms of the GNU General Public License"
-#~ msgstr ""
-#~ "\n"
-#~ "Gitk - en incheckningsvisare för git\n"
-#~ "\n"
-#~ "Copyright © 2005-2015 Paul Mackerras\n"
-#~ "\n"
-#~ "Använd och vidareförmedla enligt villkoren i GNU General Public License"
-
 #~ msgid "next"
 #~ msgstr "nästa"
 
index 8966812368a626e8da9f42012b69f233b4181642..59674986604891d9901e87c163e61dd39db14184 100644 (file)
@@ -363,14 +363,14 @@ msgid ""
 "\n"
 "Gitk - a commit viewer for git\n"
 "\n"
-"Copyright © 2005-2014 Paul Mackerras\n"
+"Copyright © 2005-2016 Paul Mackerras\n"
 "\n"
 "Use and redistribute under the terms of the GNU General Public License"
 msgstr ""
 "\n"
 "Gitk - ứng dụng để xem các lần chuyển giao dành cho git\n"
 "\n"
-"Bản quyền © 2005-2014 Paul Mackerras\n"
+"Bản quyền © 2005-2016 Paul Mackerras\n"
 "\n"
 "Dùng và phân phối lại phần mềm này theo các điều khoản của Giấy Phép Công GNU"
 
diff --git a/grep.c b/grep.c
index 1194d35b5d06d7960d4464884952e755914e2519..0dbdc1d007893042dc1005478f3023eed4ecfc12 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1735,12 +1735,23 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
        case GREP_SOURCE_FILE:
                gs->identifier = xstrdup(identifier);
                break;
+       case GREP_SOURCE_SUBMODULE:
+               if (!identifier) {
+                       gs->identifier = NULL;
+                       break;
+               }
+               /*
+                * FALL THROUGH
+                * If the identifier is non-NULL (in the submodule case) it
+                * will be a SHA1 that needs to be copied.
+                */
        case GREP_SOURCE_SHA1:
                gs->identifier = xmalloc(20);
                hashcpy(gs->identifier, identifier);
                break;
        case GREP_SOURCE_BUF:
                gs->identifier = NULL;
+               break;
        }
 }
 
@@ -1760,6 +1771,7 @@ void grep_source_clear_data(struct grep_source *gs)
        switch (gs->type) {
        case GREP_SOURCE_FILE:
        case GREP_SOURCE_SHA1:
+       case GREP_SOURCE_SUBMODULE:
                free(gs->buf);
                gs->buf = NULL;
                gs->size = 0;
@@ -1831,8 +1843,10 @@ static int grep_source_load(struct grep_source *gs)
                return grep_source_load_sha1(gs);
        case GREP_SOURCE_BUF:
                return gs->buf ? 0 : -1;
+       case GREP_SOURCE_SUBMODULE:
+               break;
        }
-       die("BUG: invalid grep_source type");
+       die("BUG: invalid grep_source type to load");
 }
 
 void grep_source_load_driver(struct grep_source *gs)
diff --git a/grep.h b/grep.h
index 5856a23e4620773cbda2e2944f93946c2701f923..267534ca24df532505854e1af31c53ed01bab24e 100644 (file)
--- a/grep.h
+++ b/grep.h
@@ -161,6 +161,7 @@ struct grep_source {
                GREP_SOURCE_SHA1,
                GREP_SOURCE_FILE,
                GREP_SOURCE_BUF,
+               GREP_SOURCE_SUBMODULE,
        } type;
        void *identifier;
 
index 0b2425531a8120fb29f37ee473a1e6e974959605..b34b6ace7cd80a482eae16e2063aa9d8960e8729 100644 (file)
@@ -3,6 +3,7 @@
 #include "walker.h"
 #include "http.h"
 #include "list.h"
+#include "transport.h"
 
 struct alt_base {
        char *base;
@@ -160,6 +161,32 @@ static void prefetch(struct walker *walker, unsigned char *sha1)
 #endif
 }
 
+static int is_alternate_allowed(const char *url)
+{
+       const char *protocols[] = {
+               "http", "https", "ftp", "ftps"
+       };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(protocols); i++) {
+               const char *end;
+               if (skip_prefix(url, protocols[i], &end) &&
+                   starts_with(end, "://"))
+                       break;
+       }
+
+       if (i >= ARRAY_SIZE(protocols)) {
+               warning("ignoring alternate with unknown protocol: %s", url);
+               return 0;
+       }
+       if (!is_transport_allowed(protocols[i], 0)) {
+               warning("ignoring alternate with restricted protocol: %s", url);
+               return 0;
+       }
+
+       return 1;
+}
+
 static void process_alternates_response(void *callback_data)
 {
        struct alternates_request *alt_req =
@@ -274,18 +301,20 @@ static void process_alternates_response(void *callback_data)
                                struct strbuf target = STRBUF_INIT;
                                strbuf_add(&target, base, serverlen);
                                strbuf_add(&target, data + i, posn - i - 7);
-                               if (walker->get_verbosely)
-                                       fprintf(stderr, "Also look at %s\n",
+
+                               if (is_alternate_allowed(target.buf)) {
+                                       warning("adding alternate object store: %s",
                                                target.buf);
-                               newalt = xmalloc(sizeof(*newalt));
-                               newalt->next = NULL;
-                               newalt->base = strbuf_detach(&target, NULL);
-                               newalt->got_indices = 0;
-                               newalt->packs = NULL;
-
-                               while (tail->next != NULL)
-                                       tail = tail->next;
-                               tail->next = newalt;
+                                       newalt = xmalloc(sizeof(*newalt));
+                                       newalt->next = NULL;
+                                       newalt->base = strbuf_detach(&target, NULL);
+                                       newalt->got_indices = 0;
+                                       newalt->packs = NULL;
+
+                                       while (tail->next != NULL)
+                                               tail = tail->next;
+                                       tail->next = newalt;
+                               }
                        }
                }
                i = posn + 1;
@@ -302,6 +331,9 @@ static void fetch_alternates(struct walker *walker, const char *base)
        struct alternates_request alt_req;
        struct walker_data *cdata = walker->data;
 
+       if (http_follow_config != HTTP_FOLLOW_ALWAYS)
+               return;
+
        /*
         * If another request has already started fetching alternates,
         * wait for them to arrive and return to processing this request's
@@ -480,10 +512,13 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)
         * we turned off CURLOPT_FAILONERROR to avoid losing a
         * persistent connection and got CURLE_OK.
         */
-       if (req->http_code == 404 && req->curl_result == CURLE_OK &&
+       if (req->http_code >= 300 && req->curl_result == CURLE_OK &&
                        (starts_with(req->url, "http://") ||
-                        starts_with(req->url, "https://")))
+                        starts_with(req->url, "https://"))) {
                req->curl_result = CURLE_HTTP_RETURNED_ERROR;
+               xsnprintf(req->errorstr, sizeof(req->errorstr),
+                         "HTTP request failed");
+       }
 
        if (obj_req->state == ABORTED) {
                ret = error("Request for %s aborted", hex);
diff --git a/http.c b/http.c
index 4c4a812fcc39509e32fbcae3db21871b97a1a5eb..90a1c0f1131c4a5fcbc50d6cc81c1be9cef3cd71 100644 (file)
--- a/http.c
+++ b/http.c
@@ -111,6 +111,8 @@ static int http_proactive_auth;
 static const char *user_agent;
 static int curl_empty_auth;
 
+enum http_follow_config http_follow_config = HTTP_FOLLOW_INITIAL;
+
 #if LIBCURL_VERSION_NUM >= 0x071700
 /* Use CURLOPT_KEYPASSWD as is */
 #elif LIBCURL_VERSION_NUM >= 0x070903
@@ -366,6 +368,16 @@ static int http_options(const char *var, const char *value, void *cb)
                return 0;
        }
 
+       if (!strcmp("http.followredirects", var)) {
+               if (value && !strcmp(value, "initial"))
+                       http_follow_config = HTTP_FOLLOW_INITIAL;
+               else if (git_config_bool(var, value))
+                       http_follow_config = HTTP_FOLLOW_ALWAYS;
+               else
+                       http_follow_config = HTTP_FOLLOW_NONE;
+               return 0;
+       }
+
        /* Fall back on the default ones */
        return git_default_config(var, value, cb);
 }
@@ -624,11 +636,25 @@ void setup_curl_trace(CURL *handle)
        curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
 }
 
+static long get_curl_allowed_protocols(int from_user)
+{
+       long allowed_protocols = 0;
+
+       if (is_transport_allowed("http", from_user))
+               allowed_protocols |= CURLPROTO_HTTP;
+       if (is_transport_allowed("https", from_user))
+               allowed_protocols |= CURLPROTO_HTTPS;
+       if (is_transport_allowed("ftp", from_user))
+               allowed_protocols |= CURLPROTO_FTP;
+       if (is_transport_allowed("ftps", from_user))
+               allowed_protocols |= CURLPROTO_FTPS;
+
+       return allowed_protocols;
+}
 
 static CURL *get_curl_handle(void)
 {
        CURL *result = curl_easy_init();
-       long allowed_protocols = 0;
 
        if (!result)
                die("curl_easy_init failed");
@@ -717,7 +743,6 @@ static CURL *get_curl_handle(void)
                                 curl_low_speed_time);
        }
 
-       curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
        curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
 #if LIBCURL_VERSION_NUM >= 0x071301
        curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
@@ -725,19 +750,13 @@ static CURL *get_curl_handle(void)
        curl_easy_setopt(result, CURLOPT_POST301, 1);
 #endif
 #if LIBCURL_VERSION_NUM >= 0x071304
-       if (is_transport_allowed("http"))
-               allowed_protocols |= CURLPROTO_HTTP;
-       if (is_transport_allowed("https"))
-               allowed_protocols |= CURLPROTO_HTTPS;
-       if (is_transport_allowed("ftp"))
-               allowed_protocols |= CURLPROTO_FTP;
-       if (is_transport_allowed("ftps"))
-               allowed_protocols |= CURLPROTO_FTPS;
-       curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS, allowed_protocols);
+       curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
+                        get_curl_allowed_protocols(0));
+       curl_easy_setopt(result, CURLOPT_PROTOCOLS,
+                        get_curl_allowed_protocols(-1));
 #else
-       if (transport_restrict_protocols())
-               warning("protocol restrictions not applied to curl redirects because\n"
-                       "your curl version is too old (>= 7.19.4)");
+       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, 1L);
@@ -1044,6 +1063,16 @@ struct active_request_slot *get_active_slot(void)
        curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
        curl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);
 
+       /*
+        * Default following to off unless "ALWAYS" is configured; this gives
+        * callers a sane starting point, and they can tweak for individual
+        * HTTP_FOLLOW_* cases themselves.
+        */
+       if (http_follow_config == HTTP_FOLLOW_ALWAYS)
+               curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
+       else
+               curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);
+
 #if LIBCURL_VERSION_NUM >= 0x070a08
        curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
 #endif
@@ -1286,9 +1315,12 @@ static int handle_curl_result(struct slot_results *results)
         * If we see a failing http code with CURLE_OK, we have turned off
         * FAILONERROR (to keep the server's custom error response), and should
         * translate the code into failure here.
+        *
+        * Likewise, if we see a redirect (30x code), that means we turned off
+        * redirect-following, and we should treat the result as an error.
         */
        if (results->curl_result == CURLE_OK &&
-           results->http_code >= 400) {
+           results->http_code >= 300) {
                results->curl_result = CURLE_HTTP_RETURNED_ERROR;
                /*
                 * Normally curl will already have put the "reason phrase"
@@ -1607,6 +1639,9 @@ static int http_request(const char *url,
                strbuf_addstr(&buf, " no-cache");
        if (options && options->keep_error)
                curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
+       if (options && options->initial_request &&
+           http_follow_config == HTTP_FOLLOW_INITIAL)
+               curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
 
        headers = curl_slist_append(headers, buf.buf);
 
@@ -1655,16 +1690,16 @@ static int http_request(const char *url,
  *
  * Note that this assumes a sane redirect scheme. It's entirely possible
  * in the example above to end up at a URL that does not even end in
- * "info/refs".  In such a case we simply punt, as there is not much we can
- * do (and such a scheme is unlikely to represent a real git repository,
- * which means we are likely about to abort anyway).
+ * "info/refs".  In such a case we die. There's not much we can do, such a
+ * scheme is unlikely to represent a real git repository, and failing to
+ * rewrite the base opens options for malicious redirects to do funny things.
  */
 static int update_url_from_redirect(struct strbuf *base,
                                    const char *asked,
                                    const struct strbuf *got)
 {
        const char *tail;
-       size_t tail_len;
+       size_t new_len;
 
        if (!strcmp(asked, got->buf))
                return 0;
@@ -1673,14 +1708,16 @@ static int update_url_from_redirect(struct strbuf *base,
                die("BUG: update_url_from_redirect: %s is not a superset of %s",
                    asked, base->buf);
 
-       tail_len = strlen(tail);
-
-       if (got->len < tail_len ||
-           strcmp(tail, got->buf + got->len - tail_len))
-               return 0; /* insane redirect scheme */
+       new_len = got->len;
+       if (!strip_suffix_mem(got->buf, &new_len, tail))
+               die(_("unable to update url base from redirection:\n"
+                     "  asked for: %s\n"
+                     "   redirect: %s"),
+                   asked, got->buf);
 
        strbuf_reset(base);
-       strbuf_add(base, got->buf, got->len - tail_len);
+       strbuf_add(base, got->buf, new_len);
+
        return 1;
 }
 
@@ -2028,7 +2065,7 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
                if (c != CURLE_OK)
                        die("BUG: curl_easy_getinfo for HTTP code failed: %s",
                                curl_easy_strerror(c));
-               if (slot->http_code >= 400)
+               if (slot->http_code >= 300)
                        return size;
        }
 
diff --git a/http.h b/http.h
index 5ab9d9c329378f4f254c9d912dd7f05105ea6695..02bccb7b0caf9f2b1be0b98cb16c6fc84b95cc74 100644 (file)
--- a/http.h
+++ b/http.h
@@ -116,6 +116,13 @@ extern struct credential http_auth;
 
 extern char curl_errorstr[CURL_ERROR_SIZE];
 
+enum http_follow_config {
+       HTTP_FOLLOW_NONE,
+       HTTP_FOLLOW_ALWAYS,
+       HTTP_FOLLOW_INITIAL
+};
+extern enum http_follow_config http_follow_config;
+
 static inline int missing__target(int code, int result)
 {
        return  /* file:// URL -- do we ever use one??? */
@@ -139,7 +146,8 @@ extern char *get_remote_object_url(const char *url, const char *hex,
 /* Options for http_get_*() */
 struct http_get_options {
        unsigned no_cache:1,
-                keep_error:1;
+                keep_error:1,
+                initial_request:1;
 
        /* If non-NULL, returns the content-type of the response. */
        struct strbuf *content_type;
index 9268cdf325f3881104d6d12ef31639536b15dcb2..aa69210d8b3a9063517d2d84153dc3ba738bef30 100644 (file)
@@ -174,8 +174,16 @@ int hold_lock_file_for_update_timeout(struct lock_file *lk, const char *path,
                                      int flags, long timeout_ms)
 {
        int fd = lock_file_timeout(lk, path, flags, timeout_ms);
-       if (fd < 0 && (flags & LOCK_DIE_ON_ERROR))
-               unable_to_lock_die(path, errno);
+       if (fd < 0) {
+               if (flags & LOCK_DIE_ON_ERROR)
+                       unable_to_lock_die(path, errno);
+               if (flags & LOCK_REPORT_ON_ERROR) {
+                       struct strbuf buf = STRBUF_INIT;
+                       unable_to_lock_message(path, errno, &buf);
+                       error("%s", buf.buf);
+                       strbuf_release(&buf);
+               }
+       }
        return fd;
 }
 
index d26ad27b2b2df207872cb20ce9cc0299ee0aff8e..7b715f9e7754882061dde0220d13fdc7d0d6c252 100644 (file)
@@ -129,10 +129,16 @@ struct lock_file {
 /*
  * If a lock is already taken for the file, `die()` with an error
  * message. If this flag is not specified, trying to lock a file that
- * is already locked returns -1 to the caller.
+ * is already locked silently returns -1 to the caller, or ...
  */
 #define LOCK_DIE_ON_ERROR 1
 
+/*
+ * ... this flag can be passed instead to return -1 and give the usual
+ * error message upon an error.
+ */
+#define LOCK_REPORT_ON_ERROR 4
+
 /*
  * Usually symbolic links in the destination path are resolved. This
  * means that (1) the lockfile is created by adding ".lock" to the
index 2fb3877ee44e9cdc83c43fa23971f02a94b5a49f..a489d9d0fbcc37a1198247a8daae4b3104ebe284 100644 (file)
@@ -710,7 +710,8 @@ static void flush_inbody_header_accum(struct mailinfo *mi)
 {
        if (!mi->inbody_header_accum.len)
                return;
-       assert(check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0));
+       if (!check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0))
+               die("BUG: inbody_header_accum, if not empty, must always contain a valid in-body header");
        strbuf_reset(&mi->inbody_header_accum);
 }
 
index 9041c2f149c01134ce02119354455894533e713c..d3272094430ccd3914c8214df73ba8e11363cfa7 100644 (file)
@@ -235,6 +235,8 @@ static int add_cacheinfo(struct merge_options *o,
                struct cache_entry *nce;
 
                nce = refresh_cache_entry(ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
+               if (!nce)
+                       return err(o, _("addinfo_cache failed for path '%s'"), path);
                if (nce != ce)
                        ret = add_cache_entry(nce, options);
        }
@@ -388,12 +390,10 @@ static struct string_list *get_unmerged(void)
        return unmerged;
 }
 
-static int string_list_df_name_compare(const void *a, const void *b)
+static int string_list_df_name_compare(const char *one, const char *two)
 {
-       const struct string_list_item *one = a;
-       const struct string_list_item *two = b;
-       int onelen = strlen(one->string);
-       int twolen = strlen(two->string);
+       int onelen = strlen(one);
+       int twolen = strlen(two);
        /*
         * Here we only care that entries for D/F conflicts are
         * adjacent, in particular with the file of the D/F conflict
@@ -406,8 +406,8 @@ static int string_list_df_name_compare(const void *a, const void *b)
         * since in other cases any changes in their order due to
         * sorting cause no problems for us.
         */
-       int cmp = df_name_compare(one->string, onelen, S_IFDIR,
-                                 two->string, twolen, S_IFDIR);
+       int cmp = df_name_compare(one, onelen, S_IFDIR,
+                                 two, twolen, S_IFDIR);
        /*
         * Now that 'foo' and 'foo/bar' compare equal, we have to make sure
         * that 'foo' comes before 'foo/bar'.
@@ -451,8 +451,8 @@ static void record_df_conflict_files(struct merge_options *o,
                string_list_append(&df_sorted_entries, next->string)->util =
                                   next->util;
        }
-       qsort(df_sorted_entries.items, entries->nr, sizeof(*entries->items),
-             string_list_df_name_compare);
+       df_sorted_entries.cmp = string_list_df_name_compare;
+       string_list_sort(&df_sorted_entries);
 
        string_list_clear(&o->df_conflict_file_set, 1);
        for (i = 0; i < df_sorted_entries.nr; i++) {
@@ -664,7 +664,13 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
        return strbuf_detach(&newpath, NULL);
 }
 
-static int dir_in_way(const char *path, int check_working_copy)
+/**
+ * Check whether a directory in the index is in the way of an incoming
+ * file.  Return 1 if so.  If check_working_copy is non-zero, also
+ * check the working directory.  If empty_ok is non-zero, also return
+ * 0 in the case where the working-tree dir exists but is empty.
+ */
+static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
 {
        int pos;
        struct strbuf dirpath = STRBUF_INIT;
@@ -684,7 +690,8 @@ static int dir_in_way(const char *path, int check_working_copy)
        }
 
        strbuf_release(&dirpath);
-       return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode);
+       return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode) &&
+               !(empty_ok && is_empty_dir(path));
 }
 
 static int was_tracked(const char *path)
@@ -1062,7 +1069,7 @@ static int handle_change_delete(struct merge_options *o,
 {
        char *renamed = NULL;
        int ret = 0;
-       if (dir_in_way(path, !o->call_depth)) {
+       if (dir_in_way(path, !o->call_depth, 0)) {
                renamed = unique_path(o, path, a_oid ? o->branch1 : o->branch2);
        }
 
@@ -1195,7 +1202,7 @@ static int handle_file(struct merge_options *o,
                remove_file(o, 0, rename->path, 0);
                dst_name = unique_path(o, rename->path, cur_branch);
        } else {
-               if (dir_in_way(rename->path, !o->call_depth)) {
+               if (dir_in_way(rename->path, !o->call_depth, 0)) {
                        dst_name = unique_path(o, rename->path, cur_branch);
                        output(o, 1, _("%s is a directory in %s adding as %s instead"),
                               rename->path, other_branch, dst_name);
@@ -1704,7 +1711,8 @@ static int merge_content(struct merge_options *o,
                         o->branch2 == rename_conflict_info->branch1) ?
                        pair1->two->path : pair1->one->path;
 
-               if (dir_in_way(path, !o->call_depth))
+               if (dir_in_way(path, !o->call_depth,
+                              S_ISGITLINK(pair1->two->mode)))
                        df_conflict_remains = 1;
        }
        if (merge_file_special_markers(o, &one, &a, &b,
@@ -1862,7 +1870,8 @@ static int process_entry(struct merge_options *o,
                        oid = b_oid;
                        conf = _("directory/file");
                }
-               if (dir_in_way(path, !o->call_depth)) {
+               if (dir_in_way(path, !o->call_depth,
+                              S_ISGITLINK(a_mode))) {
                        char *new_path = unique_path(o, path, add_branch);
                        clean_merge = 0;
                        output(o, 1, _("CONFLICT (%s): There is a directory with name %s in %s. "
@@ -2124,7 +2133,7 @@ int merge_recursive_generic(struct merge_options *o,
                }
        }
 
-       hold_locked_index(lock, 1);
+       hold_locked_index(lock, LOCK_DIE_ON_ERROR);
        clean = merge_recursive(o, head_commit, next_commit, ca,
                        result);
        if (clean < 0)
diff --git a/merge.c b/merge.c
index 23866c91655638d9e1a7213478772b78aa9d7c69..04ee5fc911c8d8134decb5c1a400576ae5681bf6 100644 (file)
--- a/merge.c
+++ b/merge.c
@@ -57,7 +57,7 @@ int checkout_fast_forward(const unsigned char *head,
 
        refresh_cache(REFRESH_QUIET);
 
-       if (hold_locked_index(lock_file, 0) < 0)
+       if (hold_locked_index(lock_file, LOCK_REPORT_ON_ERROR) < 0)
                return -1;
 
        memset(&trees, 0, sizeof(trees));
index 64f97c5e9755d54ace864cb53bf0e7844f530f49..e2407b65b70d1e622979cdb2fe0e425ba6403ee1 100644 (file)
@@ -3,7 +3,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" -wait -merge -3 -a1 \
@@ -12,7 +11,6 @@ merge_cmd () {
                "$merge_tool_path" -wait -2 \
                        "$LOCAL" "$REMOTE" "$MERGED" >/dev/null 2>&1
        fi
-       check_unchanged
 }
 
 translate_merge_tool_path() {
index b6319d206e2333e42469486604d4635e846e5faa..3a69e60faa9c95dcf388cd295d040e9b88e0defd 100644 (file)
@@ -3,7 +3,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" \
@@ -12,7 +11,6 @@ merge_cmd () {
                "$merge_tool_path" "$LOCAL" "$REMOTE" \
                        -mergeoutput="$MERGED"
        fi
-       check_unchanged
 }
 
 translate_merge_tool_path() {
index 3f0486bc807133f50abcaab27c991d4a806ec63c..9f60e8da6527cf28dcc5ad4a3e5f7f0ca9442cb4 100644 (file)
@@ -3,7 +3,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" -MF="$LOCAL" -TF="$REMOTE" -BF="$BASE" \
@@ -12,7 +11,6 @@ merge_cmd () {
                "$merge_tool_path" -MF="$LOCAL" -TF="$REMOTE" \
                        -RF="$MERGED"
        fi
-       check_unchanged
 }
 
 translate_merge_tool_path() {
index b3c71b6236e343dd3b268a2288af853804b3acf6..ee6f374bceb8e14af5b424e64fbe9787006091e8 100644 (file)
@@ -16,6 +16,10 @@ merge_cmd () {
        fi >/dev/null 2>&1
 }
 
-translate_merge_tool_path() {
+translate_merge_tool_path () {
        echo DeltaWalker
 }
+
+exit_code_trustable () {
+       true
+}
index f138cb4e731018b40426337eb8062f40512df088..9b6355b98a71da2627b68c6543cea4f2515b8d54 100644 (file)
@@ -12,3 +12,7 @@ merge_cmd () {
                        --result="$MERGED" "$LOCAL" "$REMOTE"
        fi
 }
+
+exit_code_trustable () {
+       true
+}
index 02e0843f47e09a7cc6cdd2a9c70e36773ecc96af..5a3ae8b5695d3141ff0310a706495ea52037b464 100644 (file)
@@ -3,7 +3,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" \
@@ -13,5 +12,4 @@ merge_cmd () {
                "$merge_tool_path" \
                        "$LOCAL" "$MERGED" "$REMOTE" | cat
        fi
-       check_unchanged
 }
index 13c2e439def45fe6cf58ae4345355894463ba34f..6c5101c4f729d49c544436e9262ca75e4ce6cddd 100644 (file)
@@ -3,7 +3,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \
@@ -12,5 +11,4 @@ merge_cmd () {
                "$merge_tool_path" "$LOCAL" "$REMOTE" \
                        --default --mode=merge2 --to="$MERGED"
        fi
-       check_unchanged
 }
index 7b895fdb1f9955eb470a2614e0634bfcd26d90c9..d1ce513ff5d3b3db14dd1270d2181099e1134c2c 100644 (file)
@@ -20,3 +20,7 @@ merge_cmd () {
 translate_merge_tool_path() {
        echo emacs
 }
+
+exit_code_trustable () {
+       true
+}
index 7b524d4088ff198d70c5e40a378011f2e515770e..e72b06fc4d8ff76e06a0b972ae28df73efd4180d 100644 (file)
@@ -3,14 +3,12 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" -merge "$LOCAL" "$BASE" "$REMOTE" -o:"$MERGED" -nh
        else
                "$merge_tool_path" -merge "$LOCAL" "$REMOTE" -o:"$MERGED" -nh
        fi
-       check_unchanged
 }
 
 translate_merge_tool_path() {
index 793d1293b16c9b28a9ec5c70ec7fa0875ab0da54..0264ed5b20b29fec0fc5586408f88b0e8755d212 100644 (file)
@@ -21,3 +21,7 @@ merge_cmd () {
                >/dev/null 2>&1
        fi
 }
+
+exit_code_trustable () {
+       true
+}
index 433686c12a088195bbf21b2e409c21df199ba988..e8c0bfa678547258ff0f330ae756f3621e6aadc7 100644 (file)
@@ -5,3 +5,7 @@ can_merge () {
 diff_cmd () {
        "$merge_tool_path" "$LOCAL" "$REMOTE"
 }
+
+exit_code_trustable () {
+       true
+}
index 83ebdfb4c328ac79af38bfe935f0dbfa7fb6f53b..bc178e88827a1a0558e9fbee1a6f18f6ede83df1 100644 (file)
@@ -7,7 +7,7 @@ merge_cmd () {
        then
                check_meld_for_output_version
        fi
-       touch "$BACKUP"
+
        if test "$meld_has_output_option" = true
        then
                "$merge_tool_path" --output "$MERGED" \
@@ -15,7 +15,6 @@ merge_cmd () {
        else
                "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
        fi
-       check_unchanged
 }
 
 # Check whether we should use 'meld --output <file>'
index 0942b2a733592d3f0a5a39b4fc1defd635eb7b04..b608dd6de30aaab9b30729145029761330f9fb55 100644 (file)
@@ -3,7 +3,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" "$LOCAL" "$REMOTE" \
@@ -12,5 +11,4 @@ merge_cmd () {
                "$merge_tool_path" "$LOCAL" "$REMOTE" \
                        -merge "$MERGED" | cat
        fi
-       check_unchanged
 }
index 5a608abf9c77f436ab1472592e3d5777ef83805d..7a5b291dd28ad5b60ca0492480b800aaa9cc929e 100644 (file)
@@ -20,14 +20,12 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if ! $base_present
        then
                cp -- "$LOCAL" "$BASE"
                create_virtual_base "$BASE" "$REMOTE"
        fi
        "$merge_tool_path" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
-       check_unchanged
 }
 
 create_empty_file () {
index 618c438e8765a485ffcc70a105fb0cf46010540c..eee5cb57e3ccf7f1ad7ad150c37a8b6d7ab6d436 100644 (file)
@@ -10,3 +10,7 @@ merge_cmd () {
                "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
        fi
 }
+
+exit_code_trustable () {
+       true
+}
index 3b89f1c82dc944fcbec889d24e8e7032fda612fc..d7ab666a59a2c8690861146bb6ae4874ed48e0de 100644 (file)
@@ -5,7 +5,6 @@ can_diff () {
 merge_cmd () {
        if $base_present
        then
-               touch "$BACKUP"
                basename="$(basename "$merge_tool_path" .exe)"
                if test "$basename" = "tortoisegitmerge"
                then
@@ -17,7 +16,6 @@ merge_cmd () {
                                -base:"$BASE" -mine:"$LOCAL" \
                                -theirs:"$REMOTE" -merged:"$MERGED"
                fi
-               check_unchanged
        else
                echo "$merge_tool_path cannot be used without a base" 1>&2
                return 1
index 74ea6d54793f62188cd88e93f1adfe74c5957dda..10d86f3e19304125cecf06ddad928b9ffe2d0c08 100644 (file)
@@ -4,7 +4,6 @@ diff_cmd () {
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        case "$1" in
        gvimdiff|vimdiff)
                if $base_present
@@ -31,7 +30,6 @@ merge_cmd () {
                fi
                ;;
        esac
-       check_unchanged
 }
 
 translate_merge_tool_path() {
@@ -44,3 +42,7 @@ translate_merge_tool_path() {
                ;;
        esac
 }
+
+exit_code_trustable () {
+       true
+}
index f3819d316a2c05d9fe1f850d6ac20b04d9df0417..74d03259fdf157c9ee07eec7b2c40727f5ce49dc 100644 (file)
@@ -6,10 +6,8 @@ diff_cmd () {
 merge_cmd () {
        # mergetool.winmerge.trustExitCode is implicitly false.
        # touch $BACKUP so that we can check_unchanged.
-       touch "$BACKUP"
        "$merge_tool_path" -u -e -dl Local -dr Remote \
                "$LOCAL" "$REMOTE" "$MERGED"
-       check_unchanged
 }
 
 translate_merge_tool_path() {
index 05b443394ba166a82a22abfcf27865b4627405e2..ce5b8e9f296233470d18feae929772235e4f12f2 100644 (file)
@@ -1,25 +1,23 @@
 diff_cmd () {
        "$merge_tool_path" \
                -R 'Accel.Search: "Ctrl+F"' \
-               -R 'Accel.SearchForward: "Ctrl-G"' \
+               -R 'Accel.SearchForward: "Ctrl+G"' \
                "$LOCAL" "$REMOTE"
 }
 
 merge_cmd () {
-       touch "$BACKUP"
        if $base_present
        then
                "$merge_tool_path" -X --show-merged-pane \
-                       -R 'Accel.SaveAsMerged: "Ctrl-S"' \
+                       -R 'Accel.SaveAsMerged: "Ctrl+S"' \
                        -R 'Accel.Search: "Ctrl+F"' \
-                       -R 'Accel.SearchForward: "Ctrl-G"' \
+                       -R 'Accel.SearchForward: "Ctrl+G"' \
                        --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
        else
                "$merge_tool_path" -X $extra \
-                       -R 'Accel.SaveAsMerged: "Ctrl-S"' \
+                       -R 'Accel.SaveAsMerged: "Ctrl+S"' \
                        -R 'Accel.Search: "Ctrl+F"' \
-                       -R 'Accel.SearchForward: "Ctrl-G"' \
+                       -R 'Accel.SearchForward: "Ctrl+G"' \
                        --merged-file "$MERGED" "$LOCAL" "$REMOTE"
        fi
-       check_unchanged
 }
index 312a85dbdef5723ef805917f5a556b75a55a7041..4fbe924a5de27d04b271a11a2ae040e817483951 100644 (file)
@@ -661,7 +661,7 @@ void NORETURN usage_msg_opt(const char *msg,
                   const char * const *usagestr,
                   const struct option *options)
 {
-       fprintf(stderr, "%s\n\n", msg);
+       fprintf(stderr, "fatal: %s\n\n", msg);
        usage_with_options(usagestr, options);
 }
 
diff --git a/path.c b/path.c
index 52d889c88ea8483b7a78937804bb1b789d2daa1e..efcedafba6f2c0cae218f2d32425c13272df8dea 100644 (file)
--- a/path.c
+++ b/path.c
@@ -991,7 +991,7 @@ const char *remove_leading_path(const char *in, const char *prefix)
  *
  * Performs the following normalizations on src, storing the result in dst:
  * - Ensures that components are separated by '/' (Windows only)
- * - Squashes sequences of '/'.
+ * - Squashes sequences of '/' except "//server/share" on Windows
  * - Removes "." components.
  * - Removes ".." components, and the components the precede them.
  * Returns failure (non-zero) if a ".." component appears as first path
@@ -1014,17 +1014,22 @@ const char *remove_leading_path(const char *in, const char *prefix)
 int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
 {
        char *dst0;
-       int i;
+       const char *end;
 
-       for (i = has_dos_drive_prefix(src); i > 0; i--)
-               *dst++ = *src++;
+       /*
+        * Copy initial part of absolute path: "/", "C:/", "//server/share/".
+        */
+       end = src + offset_1st_component(src);
+       while (src < end) {
+               char c = *src++;
+               if (is_dir_sep(c))
+                       c = '/';
+               *dst++ = c;
+       }
        dst0 = dst;
 
-       if (is_dir_sep(*src)) {
-               *dst++ = '/';
-               while (is_dir_sep(*src))
-                       src++;
-       }
+       while (is_dir_sep(*src))
+               src++;
 
        for (;;) {
                char c = *src;
index b2732822af0f34c6f7731df8a1a017d19f3e0508..bfce1f795dfa5fea05f4f96637a1ae2333038735 100644 (file)
@@ -1438,6 +1438,44 @@ sub END {
 
 } # %TEMP_* Lexical Context
 
+=item prefix_lines ( PREFIX, STRING [, STRING... ])
+
+Prefixes lines in C<STRING> with C<PREFIX>.
+
+=cut
+
+sub prefix_lines {
+       my $prefix = shift;
+       my $string = join("\n", @_);
+       $string =~ s/^/$prefix/mg;
+       return $string;
+}
+
+=item get_comment_line_char ( )
+
+Gets the core.commentchar configuration value.
+The value falls-back to '#' if core.commentchar is set to 'auto'.
+
+=cut
+
+sub get_comment_line_char {
+       my $comment_line_char = config("core.commentchar") || '#';
+       $comment_line_char = '#' if ($comment_line_char eq 'auto');
+       $comment_line_char = '#' if (length($comment_line_char) != 1);
+       return $comment_line_char;
+}
+
+=item comment_lines ( STRING [, STRING... ])
+
+Comments lines following core.commentchar configuration.
+
+=cut
+
+sub comment_lines {
+       my $comment_line_char = get_comment_line_char;
+       return prefix_lines("$comment_line_char ", @_);
+}
+
 =back
 
 =head1 ERROR HANDLING
index f889fd6da91d2d9b6a7469442a02e5478f094f8d..c41425c8d07a4b9a223ef3fb71e24ff526cb9fc9 100644 (file)
@@ -13,7 +13,7 @@ BEGIN
        }
 }
 
-our @EXPORT = qw(__);
+our @EXPORT = qw(__ __n N__);
 our @EXPORT_OK = @EXPORT;
 
 sub __bootstrap_locale_messages {
@@ -44,6 +44,7 @@ BEGIN
        eval {
                __bootstrap_locale_messages();
                *__ = \&Locale::Messages::gettext;
+               *__n = \&Locale::Messages::ngettext;
                1;
        } or do {
                # Tell test.pl that we couldn't load the gettext library.
@@ -51,7 +52,10 @@ BEGIN
 
                # Just a fall-through no-op
                *__ = sub ($) { $_[0] };
+               *__n = sub ($$$) { $_[2] == 1 ? $_[0] : $_[1] };
        };
+
+       sub N__($) { return shift; }
 }
 
 1;
@@ -70,6 +74,9 @@ =head1 SYNOPSIS
 
        printf __("The following error occurred: %s\n"), $error;
 
+       printf __n("commited %d file\n", "commited %d files\n", $files), $files;
+
+
 =head1 DESCRIPTION
 
 Git's internal Perl interface to gettext via L<Locale::Messages>. If
@@ -87,6 +94,16 @@ =head2 __($)
 L<Locale::Messages>'s gettext function if all goes well, otherwise our
 passthrough fallback function.
 
+=head2 __n($$$)
+
+L<Locale::Messages>'s ngettext function or passthrough fallback function.
+
+=head2 N__($)
+
+No-operation that only returns its argument. Use this if you want xgettext to
+extract the text to the pot template but do not want to trigger retrival of the
+translation at run time.
+
 =head1 AUTHOR
 
 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avarab@gmail.com>
index e7646968011234c09e1565577357a7678c015762..56ad9870bcfdfae68bd0fb5b57aa73e208bcb0fd 100644 (file)
@@ -606,7 +606,7 @@ sub minimize_url {
                        my $latest = $ra->get_latest_revnum;
                        $ra->get_log("", $latest, 0, 1, 0, 1, sub {});
                };
-       } while ($@ && ($c = shift @components));
+       } while ($@ && defined($c = shift @components));
 
        return canonicalize_url($url);
 }
index 37b2c3b1f9954d79bf799a3af979e8c337698b79..5e683830d9d66a6a1b50a26ab8c3a8338b33198b 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -10,6 +10,7 @@
 #include "color.h"
 #include "reflog-walk.h"
 #include "gpg-interface.h"
+#include "trailer.h"
 
 static char *user_format;
 static struct cmt_fmt_map {
@@ -889,6 +890,16 @@ const char *format_subject(struct strbuf *sb, const char *msg,
        return msg;
 }
 
+static void format_trailers(struct strbuf *sb, const char *msg)
+{
+       struct trailer_info info;
+
+       trailer_info_get(&info, msg);
+       strbuf_add(sb, info.trailer_start,
+                  info.trailer_end - info.trailer_start);
+       trailer_info_release(&info);
+}
+
 static void parse_commit_message(struct format_commit_context *c)
 {
        const char *msg = c->message + c->message_off;
@@ -1292,6 +1303,12 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                strbuf_addstr(sb, msg + c->body_off);
                return 1;
        }
+
+       if (starts_with(placeholder, "(trailers)")) {
+               format_trailers(sb, msg + c->subject_off);
+               return strlen("(trailers)");
+       }
+
        return 0;       /* unknown placeholder */
 }
 
index db5d910642663e73e4e4fc8d91e0caba4445bdb1..2eca639cce3a084286418d56f2b48a4303c18dd7 100644 (file)
@@ -156,14 +156,7 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
 static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
 {
        int match = -1;
-       static int cloexec = O_CLOEXEC;
-       int fd = open(ce->name, O_RDONLY | cloexec);
-
-       if ((cloexec & O_CLOEXEC) && fd < 0 && errno == EINVAL) {
-               /* Try again w/o O_CLOEXEC: the kernel might not support it */
-               cloexec &= ~O_CLOEXEC;
-               fd = open(ce->name, O_RDONLY | cloexec);
-       }
+       int fd = git_open_cloexec(ce->name, O_RDONLY);
 
        if (fd >= 0) {
                unsigned char sha1[20];
@@ -1425,12 +1418,9 @@ static int read_index_extension(struct index_state *istate,
        return 0;
 }
 
-int hold_locked_index(struct lock_file *lk, int die_on_error)
+int hold_locked_index(struct lock_file *lk, int lock_flags)
 {
-       return hold_lock_file_for_update(lk, get_index_file(),
-                                        die_on_error
-                                        ? LOCK_DIE_ON_ERROR
-                                        : 0);
+       return hold_lock_file_for_update(lk, get_index_file(), lock_flags);
 }
 
 int read_index(struct index_state *istate)
index f5f7a70c6d9b8ef36ecfe282167714640cace6b1..1a978405e6b97d1f57d75b867ddeae30f091ef19 100644 (file)
@@ -13,6 +13,7 @@
 #include "utf8.h"
 #include "git-compat-util.h"
 #include "version.h"
+#include "trailer.h"
 
 typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
 
@@ -40,7 +41,7 @@ static struct used_atom {
                enum { RR_NORMAL, RR_SHORTEN, RR_TRACK, RR_TRACKSHORT }
                        remote_ref;
                struct {
-                       enum { C_BARE, C_BODY, C_BODY_DEP, C_LINES, C_SIG, C_SUB } option;
+                       enum { C_BARE, C_BODY, C_BODY_DEP, C_LINES, C_SIG, C_SUB, C_TRAILERS } option;
                        unsigned int nlines;
                } contents;
                enum { O_FULL, O_SHORT } objectname;
@@ -85,6 +86,13 @@ static void subject_atom_parser(struct used_atom *atom, const char *arg)
        atom->u.contents.option = C_SUB;
 }
 
+static void trailers_atom_parser(struct used_atom *atom, const char *arg)
+{
+       if (arg)
+               die(_("%%(trailers) does not take arguments"));
+       atom->u.contents.option = C_TRAILERS;
+}
+
 static void contents_atom_parser(struct used_atom *atom, const char *arg)
 {
        if (!arg)
@@ -95,6 +103,8 @@ static void contents_atom_parser(struct used_atom *atom, const char *arg)
                atom->u.contents.option = C_SIG;
        else if (!strcmp(arg, "subject"))
                atom->u.contents.option = C_SUB;
+       else if (!strcmp(arg, "trailers"))
+               atom->u.contents.option = C_TRAILERS;
        else if (skip_prefix(arg, "lines=", &arg)) {
                atom->u.contents.option = C_LINES;
                if (strtoul_ui(arg, 10, &atom->u.contents.nlines))
@@ -194,6 +204,7 @@ static struct {
        { "creatordate", FIELD_TIME },
        { "subject", FIELD_STR, subject_atom_parser },
        { "body", FIELD_STR, body_atom_parser },
+       { "trailers", FIELD_STR, trailers_atom_parser },
        { "contents", FIELD_STR, contents_atom_parser },
        { "upstream", FIELD_STR, remote_ref_atom_parser },
        { "push", FIELD_STR, remote_ref_atom_parser },
@@ -785,6 +796,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj
                        name++;
                if (strcmp(name, "subject") &&
                    strcmp(name, "body") &&
+                   strcmp(name, "trailers") &&
                    !starts_with(name, "contents"))
                        continue;
                if (!subpos)
@@ -808,6 +820,14 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj
                        /*  Size is the length of the message after removing the signature */
                        append_lines(&s, subpos, contents_end - subpos, atom->u.contents.nlines);
                        v->s = strbuf_detach(&s, NULL);
+               } else if (atom->u.contents.option == C_TRAILERS) {
+                       struct trailer_info info;
+
+                       /* Search for trailer info */
+                       trailer_info_get(&info, subpos);
+                       v->s = xmemdupz(info.trailer_start,
+                                       info.trailer_end - info.trailer_start);
+                       trailer_info_release(&info);
                } else if (atom->u.contents.option == C_BARE)
                        v->s = xstrdup(subpos);
        }
@@ -1231,8 +1251,14 @@ static int commit_contains(struct ref_filter *filter, struct commit *commit)
  * matches a pattern "refs/heads/mas") or a wildcard (e.g. the same ref
  * matches "refs/heads/mas*", too).
  */
-static int match_pattern(const char **patterns, const char *refname)
+static int match_pattern(const struct ref_filter *filter, const char *refname)
 {
+       const char **patterns = filter->name_patterns;
+       unsigned flags = 0;
+
+       if (filter->ignore_case)
+               flags |= WM_CASEFOLD;
+
        /*
         * When no '--format' option is given we need to skip the prefix
         * for matching refs of tags and branches.
@@ -1243,7 +1269,7 @@ static int match_pattern(const char **patterns, const char *refname)
               skip_prefix(refname, "refs/", &refname));
 
        for (; *patterns; patterns++) {
-               if (!wildmatch(*patterns, refname, 0, NULL))
+               if (!wildmatch(*patterns, refname, flags, NULL))
                        return 1;
        }
        return 0;
@@ -1255,9 +1281,15 @@ static int match_pattern(const char **patterns, const char *refname)
  * matches a pattern "refs/heads/" but not "refs/heads/m") or a
  * wildcard (e.g. the same ref matches "refs/heads/m*", too).
  */
-static int match_name_as_path(const char **pattern, const char *refname)
+static int match_name_as_path(const struct ref_filter *filter, const char *refname)
 {
+       const char **pattern = filter->name_patterns;
        int namelen = strlen(refname);
+       unsigned flags = WM_PATHNAME;
+
+       if (filter->ignore_case)
+               flags |= WM_CASEFOLD;
+
        for (; *pattern; pattern++) {
                const char *p = *pattern;
                int plen = strlen(p);
@@ -1280,8 +1312,8 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
        if (!*filter->name_patterns)
                return 1; /* No pattern always matches */
        if (filter->match_as_path)
-               return match_name_as_path(filter->name_patterns, refname);
-       return match_pattern(filter->name_patterns, refname);
+               return match_name_as_path(filter, refname);
+       return match_pattern(filter, refname);
 }
 
 /*
@@ -1536,18 +1568,20 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
        struct atom_value *va, *vb;
        int cmp;
        cmp_type cmp_type = used_atom[s->atom].type;
+       int (*cmp_fn)(const char *, const char *);
 
        get_ref_atom_value(a, s->atom, &va);
        get_ref_atom_value(b, s->atom, &vb);
+       cmp_fn = s->ignore_case ? strcasecmp : strcmp;
        if (s->version)
                cmp = versioncmp(va->s, vb->s);
        else if (cmp_type == FIELD_STR)
-               cmp = strcmp(va->s, vb->s);
+               cmp = cmp_fn(va->s, vb->s);
        else {
                if (va->ul < vb->ul)
                        cmp = -1;
                else if (va->ul == vb->ul)
-                       cmp = strcmp(a->refname, b->refname);
+                       cmp = cmp_fn(a->refname, b->refname);
                else
                        cmp = 1;
        }
index 14d435e2ccf0204312d1f72555f1c2c36fabd215..fc55fa3574620bfdc76b2997afc56909528e2275 100644 (file)
@@ -29,6 +29,7 @@ struct ref_sorting {
        struct ref_sorting *next;
        int atom; /* index into used_atom array (internal) */
        unsigned reverse : 1,
+               ignore_case : 1,
                version : 1;
 };
 
@@ -62,6 +63,7 @@ struct ref_filter {
 
        unsigned int with_commit_tag_algo : 1,
                match_as_path : 1,
+               ignore_case : 1,
                detached : 1;
        unsigned int kind,
                lines;
index f14c41f4c0d6d6c9bbfd18d6417d16f0e6068c1d..34a97e7328d440d48badd53bb0d3167a58558ee9 100644 (file)
@@ -274,7 +274,7 @@ static struct discovery *discover_refs(const char *service, int for_push)
        struct strbuf effective_url = STRBUF_INIT;
        struct discovery *last = last_discovery;
        int http_ret, maybe_smart = 0;
-       struct http_get_options options;
+       struct http_get_options http_options;
 
        if (last && !strcmp(service, last->service))
                return last;
@@ -291,15 +291,16 @@ static struct discovery *discover_refs(const char *service, int for_push)
                strbuf_addf(&refs_url, "service=%s", service);
        }
 
-       memset(&options, 0, sizeof(options));
-       options.content_type = &type;
-       options.charset = &charset;
-       options.effective_url = &effective_url;
-       options.base_url = &url;
-       options.no_cache = 1;
-       options.keep_error = 1;
+       memset(&http_options, 0, sizeof(http_options));
+       http_options.content_type = &type;
+       http_options.charset = &charset;
+       http_options.effective_url = &effective_url;
+       http_options.base_url = &url;
+       http_options.initial_request = 1;
+       http_options.no_cache = 1;
+       http_options.keep_error = 1;
 
-       http_ret = http_get_strbuf(refs_url.buf, &buffer, &options);
+       http_ret = http_get_strbuf(refs_url.buf, &buffer, &http_options);
        switch (http_ret) {
        case HTTP_OK:
                break;
@@ -314,6 +315,9 @@ static struct discovery *discover_refs(const char *service, int for_push)
                die("unable to access '%s': %s", url.buf, curl_errorstr);
        }
 
+       if (options.verbosity && !starts_with(refs_url.buf, url.buf))
+               warning(_("redirecting to %s"), url.buf);
+
        last= xcalloc(1, sizeof(*last_discovery));
        last->service = service;
        last->buf_alloc = strbuf_detach(&buffer, &last->len);
@@ -400,6 +404,7 @@ struct rpc_state {
        size_t pos;
        int in;
        int out;
+       int any_written;
        struct strbuf result;
        unsigned gzip_request : 1;
        unsigned initial_buffer : 1;
@@ -456,6 +461,8 @@ static size_t rpc_in(char *ptr, size_t eltsize,
 {
        size_t size = eltsize * nmemb;
        struct rpc_state *rpc = buffer_;
+       if (size)
+               rpc->any_written = 1;
        write_or_die(rpc->in, ptr, size);
        return size;
 }
@@ -659,6 +666,8 @@ static int post_rpc(struct rpc_state *rpc)
        curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
        curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
 
+
+       rpc->any_written = 0;
        err = run_slot(slot, NULL);
        if (err == HTTP_REAUTH && !large_request) {
                credential_fill(&http_auth);
@@ -667,6 +676,9 @@ static int post_rpc(struct rpc_state *rpc)
        if (err != HTTP_OK)
                err = -1;
 
+       if (!rpc->any_written)
+               err = -1;
+
        curl_slist_free_all(headers);
        free(gzip_body);
        return err;
index 5d083ca572df0c8a2cb90c0b12c14e15b4134d48..3bd55caf3b0961888bcca06d3c54577cb25f5223 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -708,7 +708,7 @@ static void update_paths(struct string_list *update)
 {
        int i;
 
-       hold_locked_index(&index_lock, 1);
+       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 
        for (i = 0; i < update->nr; i++) {
                struct string_list_item *item = &update->items[i];
index 30b10ba143959bf2618872427f730a9f0e30d369..9adb7bbf1d4815d9e4f67b66e90c9ec327b2fb72 100644 (file)
@@ -16,6 +16,7 @@
 #include "refs.h"
 #include "argv-array.h"
 #include "quote.h"
+#include "trailer.h"
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
@@ -27,6 +28,7 @@ GIT_PATH_FUNC(git_path_seq_dir, "sequencer")
 static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo")
 static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
 static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
+static GIT_PATH_FUNC(git_path_abort_safety_file, "sequencer/abort-safety")
 
 /*
  * A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
@@ -56,30 +58,6 @@ static const char *get_todo_path(const struct replay_opts *opts)
        return git_path_todo_file();
 }
 
-static int is_rfc2822_line(const char *buf, int len)
-{
-       int i;
-
-       for (i = 0; i < len; i++) {
-               int ch = buf[i];
-               if (ch == ':')
-                       return 1;
-               if (!isalnum(ch) && ch != '-')
-                       break;
-       }
-
-       return 0;
-}
-
-static int is_cherry_picked_from_line(const char *buf, int len)
-{
-       /*
-        * We only care that it looks roughly like (cherry picked from ...)
-        */
-       return len > strlen(cherry_picked_prefix) + 1 &&
-               starts_with(buf, cherry_picked_prefix) && buf[len - 1] == ')';
-}
-
 /*
  * Returns 0 for non-conforming footer
  * Returns 1 for conforming footer
@@ -89,49 +67,25 @@ static int is_cherry_picked_from_line(const char *buf, int len)
 static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
        int ignore_footer)
 {
-       char prev;
-       int i, k;
-       int len = sb->len - ignore_footer;
-       const char *buf = sb->buf;
-       int found_sob = 0;
-
-       /* footer must end with newline */
-       if (!len || buf[len - 1] != '\n')
-               return 0;
+       struct trailer_info info;
+       int i;
+       int found_sob = 0, found_sob_last = 0;
 
-       prev = '\0';
-       for (i = len - 1; i > 0; i--) {
-               char ch = buf[i];
-               if (prev == '\n' && ch == '\n') /* paragraph break */
-                       break;
-               prev = ch;
-       }
+       trailer_info_get(&info, sb->buf);
 
-       /* require at least one blank line */
-       if (prev != '\n' || buf[i] != '\n')
+       if (info.trailer_start == info.trailer_end)
                return 0;
 
-       /* advance to start of last paragraph */
-       while (i < len - 1 && buf[i] == '\n')
-               i++;
-
-       for (; i < len; i = k) {
-               int found_rfc2822;
-
-               for (k = i; k < len && buf[k] != '\n'; k++)
-                       ; /* do nothing */
-               k++;
+       for (i = 0; i < info.trailer_nr; i++)
+               if (sob && !strncmp(info.trailers[i], sob->buf, sob->len)) {
+                       found_sob = 1;
+                       if (i == info.trailer_nr - 1)
+                               found_sob_last = 1;
+               }
 
-               found_rfc2822 = is_rfc2822_line(buf + i, k - i - 1);
-               if (found_rfc2822 && sob &&
-                   !strncmp(buf + i, sob->buf, sob->len))
-                       found_sob = k;
+       trailer_info_release(&info);
 
-               if (!(found_rfc2822 ||
-                     is_cherry_picked_from_line(buf + i, k - i - 1)))
-                       return 0;
-       }
-       if (found_sob == i)
+       if (found_sob_last)
                return 3;
        if (found_sob)
                return 2;
@@ -310,6 +264,20 @@ static int error_dirty_index(struct replay_opts *opts)
        return -1;
 }
 
+static void update_abort_safety_file(void)
+{
+       struct object_id head;
+
+       /* Do nothing on a single-pick */
+       if (!file_exists(git_path_seq_dir()))
+               return;
+
+       if (!get_oid("HEAD", &head))
+               write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head));
+       else
+               write_file(git_path_abort_safety_file(), "%s", "");
+}
+
 static int fast_forward_to(const unsigned char *to, const unsigned char *from,
                        int unborn, struct replay_opts *opts)
 {
@@ -339,6 +307,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
        strbuf_release(&sb);
        strbuf_release(&err);
        ref_transaction_free(transaction);
+       update_abort_safety_file();
        return 0;
 }
 
@@ -370,7 +339,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
        char **xopt;
        static struct lock_file index_lock;
 
-       hold_locked_index(&index_lock, 1);
+       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 
        read_cache();
 
@@ -813,6 +782,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 
 leave:
        free_message(commit, &msg);
+       update_abort_safety_file();
 
        return res;
 }
@@ -1132,9 +1102,34 @@ static int save_head(const char *head)
        return 0;
 }
 
+static int rollback_is_safe(void)
+{
+       struct strbuf sb = STRBUF_INIT;
+       struct object_id expected_head, actual_head;
+
+       if (strbuf_read_file(&sb, git_path_abort_safety_file(), 0) >= 0) {
+               strbuf_trim(&sb);
+               if (get_oid_hex(sb.buf, &expected_head)) {
+                       strbuf_release(&sb);
+                       die(_("could not parse %s"), git_path_abort_safety_file());
+               }
+               strbuf_release(&sb);
+       }
+       else if (errno == ENOENT)
+               oidclr(&expected_head);
+       else
+               die_errno(_("could not read '%s'"), git_path_abort_safety_file());
+
+       if (get_oid("HEAD", &actual_head))
+               oidclr(&actual_head);
+
+       return !oidcmp(&actual_head, &expected_head);
+}
+
 static int reset_for_rollback(const unsigned char *sha1)
 {
        const char *argv[4];    /* reset --merge <arg> + NULL */
+
        argv[0] = "reset";
        argv[1] = "--merge";
        argv[2] = sha1_to_hex(sha1);
@@ -1189,6 +1184,12 @@ int sequencer_rollback(struct replay_opts *opts)
                error(_("cannot abort from a branch yet to be born"));
                goto fail;
        }
+
+       if (!rollback_is_safe()) {
+               /* Do not error, just do not rollback */
+               warning(_("You seem to have moved HEAD. "
+                         "Not rewinding, check your HEAD!"));
+       } else
        if (reset_for_rollback(sha1))
                goto fail;
        strbuf_release(&buf);
@@ -1393,6 +1394,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
                return -1;
        if (save_opts(opts))
                return -1;
+       update_abort_safety_file();
        res = pick_commits(&todo_list, opts);
        todo_list_release(&todo_list);
        return res;
diff --git a/setup.c b/setup.c
index fe572b82c355390e6101aea15d2d53ec5b3b1e15..1b534a750810f3773ba9c21a5ec221f54857349b 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -256,8 +256,10 @@ int get_common_dir_noenv(struct strbuf *sb, const char *gitdir)
                strbuf_addbuf(&path, &data);
                strbuf_addstr(sb, real_path(path.buf));
                ret = 1;
-       } else
+       } else {
                strbuf_addstr(sb, gitdir);
+       }
+
        strbuf_release(&data);
        strbuf_release(&path);
        return ret;
@@ -692,7 +694,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
        /* --work-tree is set without --git-dir; use discovered one */
        if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
                if (offset != cwd->len && !is_absolute_path(gitdir))
-                       gitdir = xstrdup(real_path(gitdir));
+                       gitdir = real_pathdup(gitdir);
                if (chdir(cwd->buf))
                        die_errno("Could not come back to cwd");
                return setup_explicit_git_dir(gitdir, cwd, nongit_ok);
@@ -800,11 +802,12 @@ static int canonicalize_ceiling_entry(struct string_list_item *item,
                /* Keep entry but do not canonicalize it */
                return 1;
        } else {
-               const char *real_path = real_path_if_valid(ceil);
-               if (!real_path)
+               char *real_path = real_pathdup(ceil);
+               if (!real_path) {
                        return 0;
+               }
                free(item->string);
-               item->string = xstrdup(real_path);
+               item->string = real_path;
                return 1;
        }
 }
index 9c86d1924a23e4c81369f34ec8e1058c2dd15c1f..b5e827ac9e716db9fad69960058f1bf2fa50c9d3 100644 (file)
 #include "mru.h"
 #include "list.h"
 #include "mergesort.h"
-
-#ifndef O_NOATIME
-#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
-#define O_NOATIME 01000000
-#else
-#define O_NOATIME 0
-#endif
-#endif
+#include "quote.h"
 
 #define SZ_FMT PRIuMAX
 static inline uintmax_t sz_fmt(size_t s) { return s; }
@@ -291,7 +284,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base,
        struct strbuf pathbuf = STRBUF_INIT;
 
        if (!is_absolute_path(entry) && relative_base) {
-               strbuf_addstr(&pathbuf, real_path(relative_base));
+               strbuf_realpath(&pathbuf, relative_base, 1);
                strbuf_addch(&pathbuf, '/');
        }
        strbuf_addstr(&pathbuf, entry);
@@ -329,13 +322,40 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base,
        return 0;
 }
 
+static const char *parse_alt_odb_entry(const char *string,
+                                      int sep,
+                                      struct strbuf *out)
+{
+       const char *end;
+
+       strbuf_reset(out);
+
+       if (*string == '#') {
+               /* comment; consume up to next separator */
+               end = strchrnul(string, sep);
+       } else if (*string == '"' && !unquote_c_style(out, string, &end)) {
+               /*
+                * quoted path; unquote_c_style has copied the
+                * data for us and set "end". Broken quoting (e.g.,
+                * an entry that doesn't end with a quote) falls
+                * back to the unquoted case below.
+                */
+       } else {
+               /* normal, unquoted path */
+               end = strchrnul(string, sep);
+               strbuf_add(out, string, end - string);
+       }
+
+       if (*end)
+               end++;
+       return end;
+}
+
 static void link_alt_odb_entries(const char *alt, int len, int sep,
                                 const char *relative_base, int depth)
 {
-       struct string_list entries = STRING_LIST_INIT_NODUP;
-       char *alt_copy;
-       int i;
        struct strbuf objdirbuf = STRBUF_INIT;
+       struct strbuf entry = STRBUF_INIT;
 
        if (depth > 5) {
                error("%s: ignoring alternate object stores, nesting too deep.",
@@ -348,16 +368,13 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
                die("unable to normalize object directory: %s",
                    objdirbuf.buf);
 
-       alt_copy = xmemdupz(alt, len);
-       string_list_split_in_place(&entries, alt_copy, sep, -1);
-       for (i = 0; i < entries.nr; i++) {
-               const char *entry = entries.items[i].string;
-               if (entry[0] == '\0' || entry[0] == '#')
+       while (*alt) {
+               alt = parse_alt_odb_entry(alt, sep, &entry);
+               if (!entry.len)
                        continue;
-               link_alt_odb_entry(entry, relative_base, depth, objdirbuf.buf);
+               link_alt_odb_entry(entry.buf, relative_base, depth, objdirbuf.buf);
        }
-       string_list_clear(&entries, 0);
-       free(alt_copy);
+       strbuf_release(&entry);
        strbuf_release(&objdirbuf);
 }
 
@@ -1586,31 +1603,31 @@ int check_sha1_signature(const unsigned char *sha1, void *map,
        return hashcmp(sha1, real_sha1) ? -1 : 0;
 }
 
-int git_open(const char *name)
+int git_open_cloexec(const char *name, int flags)
 {
-       static int sha1_file_open_flag = O_NOATIME | O_CLOEXEC;
-
-       for (;;) {
-               int fd;
-
-               errno = 0;
-               fd = open(name, O_RDONLY | sha1_file_open_flag);
-               if (fd >= 0)
-                       return fd;
+       int fd;
+       static int o_cloexec = O_CLOEXEC;
 
+       fd = open(name, flags | o_cloexec);
+       if ((o_cloexec & O_CLOEXEC) && fd < 0 && errno == EINVAL) {
                /* Try again w/o O_CLOEXEC: the kernel might not support it */
-               if ((sha1_file_open_flag & O_CLOEXEC) && errno == EINVAL) {
-                       sha1_file_open_flag &= ~O_CLOEXEC;
-                       continue;
-               }
+               o_cloexec &= ~O_CLOEXEC;
+               fd = open(name, flags | o_cloexec);
+       }
 
-               /* Might the failure be due to O_NOATIME? */
-               if (errno != ENOENT && (sha1_file_open_flag & O_NOATIME)) {
-                       sha1_file_open_flag &= ~O_NOATIME;
-                       continue;
+#if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC)
+       {
+               static int fd_cloexec = FD_CLOEXEC;
+
+               if (!o_cloexec && 0 <= fd && fd_cloexec) {
+                       /* Opened w/o O_CLOEXEC?  try with fcntl(2) to add it */
+                       int flags = fcntl(fd, F_GETFL);
+                       if (fcntl(fd, F_SETFL, flags | fd_cloexec))
+                               fd_cloexec = 0;
                }
-               return -1;
        }
+#endif
+       return fd;
 }
 
 static int stat_sha1_file(const unsigned char *sha1, struct stat *st)
index 4d0b005d39c1c1ab2379911666d4df75d66b824c..11f7dde9d910093dce6a767150bb4823bff80200 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -431,12 +431,14 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
 
 define_commit_slab(ref_bitmap, uint32_t *);
 
+#define POOL_SIZE (512 * 1024)
+
 struct paint_info {
        struct ref_bitmap ref_bitmap;
        unsigned nr_bits;
-       char **slab;
+       char **pools;
        char *free, *end;
-       unsigned slab_count;
+       unsigned pool_count;
 };
 
 static uint32_t *paint_alloc(struct paint_info *info)
@@ -444,12 +446,15 @@ static uint32_t *paint_alloc(struct paint_info *info)
        unsigned nr = (info->nr_bits + 31) / 32;
        unsigned size = nr * sizeof(uint32_t);
        void *p;
-       if (!info->slab_count || info->free + size > info->end) {
-               info->slab_count++;
-               REALLOC_ARRAY(info->slab, info->slab_count);
-               info->free = xmalloc(COMMIT_SLAB_SIZE);
-               info->slab[info->slab_count - 1] = info->free;
-               info->end = info->free + COMMIT_SLAB_SIZE;
+       if (!info->pool_count || size > info->end - info->free) {
+               if (size > POOL_SIZE)
+                       die("BUG: pool size too small for %d in paint_alloc()",
+                           size);
+               info->pool_count++;
+               REALLOC_ARRAY(info->pools, info->pool_count);
+               info->free = xmalloc(POOL_SIZE);
+               info->pools[info->pool_count - 1] = info->free;
+               info->end = info->free + POOL_SIZE;
        }
        p = info->free;
        info->free += size;
@@ -462,7 +467,7 @@ static uint32_t *paint_alloc(struct paint_info *info)
  * all walked commits.
  */
 static void paint_down(struct paint_info *info, const unsigned char *sha1,
-                      int id)
+                      unsigned int id)
 {
        unsigned int i, nr;
        struct commit_list *head = NULL;
@@ -474,7 +479,7 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
        if (!c)
                return;
        memset(bitmap, 0, bitmap_size);
-       bitmap[id / 32] |= (1 << (id % 32));
+       bitmap[id / 32] |= (1U << (id % 32));
        commit_list_insert(c, &head);
        while (head) {
                struct commit_list *p;
@@ -507,12 +512,8 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
                            oid_to_hex(&c->object.oid));
 
                for (p = c->parents; p; p = p->next) {
-                       uint32_t **p_refs = ref_bitmap_at(&info->ref_bitmap,
-                                                         p->item);
                        if (p->item->object.flags & SEEN)
                                continue;
-                       if (*p_refs == NULL || *p_refs == *refs)
-                               *p_refs = *refs;
                        commit_list_insert(p->item, &head);
                }
        }
@@ -624,9 +625,9 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
                post_assign_shallow(info, &pi.ref_bitmap, ref_status);
 
        clear_ref_bitmap(&pi.ref_bitmap);
-       for (i = 0; i < pi.slab_count; i++)
-               free(pi.slab[i]);
-       free(pi.slab);
+       for (i = 0; i < pi.pool_count; i++)
+               free(pi.pools[i]);
+       free(pi.pools);
        free(shallow);
 }
 
@@ -648,11 +649,11 @@ static int add_ref(const char *refname, const struct object_id *oid,
 
 static void update_refstatus(int *ref_status, int nr, uint32_t *bitmap)
 {
-       int i;
+       unsigned int i;
        if (!ref_status)
                return;
        for (i = 0; i < nr; i++)
-               if (bitmap[i / 32] & (1 << (i % 32)))
+               if (bitmap[i / 32] & (1U << (i % 32)))
                        ref_status[i]++;
 }
 
index 5a326c68602610d856ac543b8bd034542d83f64b..5d64cfe929684807fcfa004ec3edf10d720189c9 100644 (file)
@@ -13,6 +13,7 @@ struct shortlog {
        int in2;
        int user_format;
        int abbrev;
+       int committer;
 
        char *common_repo_prefix;
        int email;
index 098085be69b97687b0febfe9e29c6dc0c64569a1..4bf50f398a5bd705531e32f9329c0e3b7e630506 100644 (file)
@@ -263,12 +263,12 @@ int parse_push_recurse_submodules_arg(const char *opt, const char *arg)
        return parse_push_recurse(opt, arg, 1);
 }
 
-static void warn_multiple_config(const unsigned char *commit_sha1,
+static void warn_multiple_config(const unsigned char *treeish_name,
                                 const char *name, const char *option)
 {
        const char *commit_string = "WORKTREE";
-       if (commit_sha1)
-               commit_string = sha1_to_hex(commit_sha1);
+       if (treeish_name)
+               commit_string = sha1_to_hex(treeish_name);
        warning("%s:.gitmodules, multiple configurations found for "
                        "'submodule.%s.%s'. Skipping second one!",
                        commit_string, name, option);
@@ -276,7 +276,7 @@ static void warn_multiple_config(const unsigned char *commit_sha1,
 
 struct parse_config_parameter {
        struct submodule_cache *cache;
-       const unsigned char *commit_sha1;
+       const unsigned char *treeish_name;
        const unsigned char *gitmodules_sha1;
        int overwrite;
 };
@@ -300,7 +300,7 @@ static int parse_config(const char *var, const char *value, void *data)
                if (!value)
                        ret = config_error_nonbool(var);
                else if (!me->overwrite && submodule->path)
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                        "path");
                else {
                        if (submodule->path)
@@ -314,7 +314,7 @@ static int parse_config(const char *var, const char *value, void *data)
                int die_on_error = is_null_sha1(me->gitmodules_sha1);
                if (!me->overwrite &&
                    submodule->fetch_recurse != RECURSE_SUBMODULES_NONE)
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                        "fetchrecursesubmodules");
                else
                        submodule->fetch_recurse = parse_fetch_recurse(
@@ -324,7 +324,7 @@ static int parse_config(const char *var, const char *value, void *data)
                if (!value)
                        ret = config_error_nonbool(var);
                else if (!me->overwrite && submodule->ignore)
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                        "ignore");
                else if (strcmp(value, "untracked") &&
                         strcmp(value, "dirty") &&
@@ -340,7 +340,7 @@ static int parse_config(const char *var, const char *value, void *data)
                if (!value) {
                        ret = config_error_nonbool(var);
                } else if (!me->overwrite && submodule->url) {
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                        "url");
                } else {
                        free((void *) submodule->url);
@@ -351,21 +351,21 @@ static int parse_config(const char *var, const char *value, void *data)
                        ret = config_error_nonbool(var);
                else if (!me->overwrite &&
                         submodule->update_strategy.type != SM_UPDATE_UNSPECIFIED)
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                             "update");
                else if (parse_submodule_update_strategy(value,
                         &submodule->update_strategy) < 0)
                                die(_("invalid value for %s"), var);
        } else if (!strcmp(item.buf, "shallow")) {
                if (!me->overwrite && submodule->recommend_shallow != -1)
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                             "shallow");
                else
                        submodule->recommend_shallow =
                                git_config_bool(var, value);
        } else if (!strcmp(item.buf, "branch")) {
                if (!me->overwrite && submodule->branch)
-                       warn_multiple_config(me->commit_sha1, submodule->name,
+                       warn_multiple_config(me->treeish_name, submodule->name,
                                             "branch");
                else {
                        free((void *)submodule->branch);
@@ -379,18 +379,18 @@ static int parse_config(const char *var, const char *value, void *data)
        return ret;
 }
 
-static int gitmodule_sha1_from_commit(const unsigned char *commit_sha1,
+int gitmodule_sha1_from_commit(const unsigned char *treeish_name,
                                      unsigned char *gitmodules_sha1,
                                      struct strbuf *rev)
 {
        int ret = 0;
 
-       if (is_null_sha1(commit_sha1)) {
+       if (is_null_sha1(treeish_name)) {
                hashclr(gitmodules_sha1);
                return 1;
        }
 
-       strbuf_addf(rev, "%s:.gitmodules", sha1_to_hex(commit_sha1));
+       strbuf_addf(rev, "%s:.gitmodules", sha1_to_hex(treeish_name));
        if (get_sha1(rev->buf, gitmodules_sha1) >= 0)
                ret = 1;
 
@@ -402,7 +402,7 @@ static int gitmodule_sha1_from_commit(const unsigned char *commit_sha1,
  * revisions.
  */
 static const struct submodule *config_from(struct submodule_cache *cache,
-               const unsigned char *commit_sha1, const char *key,
+               const unsigned char *treeish_name, const char *key,
                enum lookup_type lookup_type)
 {
        struct strbuf rev = STRBUF_INIT;
@@ -418,7 +418,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
         * return the first submodule. Can be used to check whether
         * there are any submodules parsed.
         */
-       if (!commit_sha1 || !key) {
+       if (!treeish_name || !key) {
                struct hashmap_iter iter;
                struct submodule_entry *entry;
 
@@ -428,7 +428,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
                return entry->config;
        }
 
-       if (!gitmodule_sha1_from_commit(commit_sha1, sha1, &rev))
+       if (!gitmodule_sha1_from_commit(treeish_name, sha1, &rev))
                goto out;
 
        switch (lookup_type) {
@@ -448,7 +448,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
 
        /* fill the submodule config into the cache */
        parameter.cache = cache;
-       parameter.commit_sha1 = commit_sha1;
+       parameter.treeish_name = treeish_name;
        parameter.gitmodules_sha1 = sha1;
        parameter.overwrite = 0;
        git_config_from_mem(parse_config, CONFIG_ORIGIN_SUBMODULE_BLOB, rev.buf,
@@ -471,18 +471,6 @@ static const struct submodule *config_from(struct submodule_cache *cache,
        return submodule;
 }
 
-static const struct submodule *config_from_path(struct submodule_cache *cache,
-               const unsigned char *commit_sha1, const char *path)
-{
-       return config_from(cache, commit_sha1, path, lookup_path);
-}
-
-static const struct submodule *config_from_name(struct submodule_cache *cache,
-               const unsigned char *commit_sha1, const char *name)
-{
-       return config_from(cache, commit_sha1, name, lookup_name);
-}
-
 static void ensure_cache_init(void)
 {
        if (is_cache_init)
@@ -496,7 +484,7 @@ int parse_submodule_config_option(const char *var, const char *value)
 {
        struct parse_config_parameter parameter;
        parameter.cache = &the_submodule_cache;
-       parameter.commit_sha1 = NULL;
+       parameter.treeish_name = NULL;
        parameter.gitmodules_sha1 = null_sha1;
        parameter.overwrite = 1;
 
@@ -504,18 +492,18 @@ int parse_submodule_config_option(const char *var, const char *value)
        return parse_config(var, value, &parameter);
 }
 
-const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
+const struct submodule *submodule_from_name(const unsigned char *treeish_name,
                const char *name)
 {
        ensure_cache_init();
-       return config_from_name(&the_submodule_cache, commit_sha1, name);
+       return config_from(&the_submodule_cache, treeish_name, name, lookup_name);
 }
 
-const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
+const struct submodule *submodule_from_path(const unsigned char *treeish_name,
                const char *path)
 {
        ensure_cache_init();
-       return config_from_path(&the_submodule_cache, commit_sha1, path);
+       return config_from(&the_submodule_cache, treeish_name, path, lookup_path);
 }
 
 void submodule_free(void)
index d05c542d2cdace181ea72055c0f71db6b1afda42..70f19363fd8bf5b7f42e974dacdc3ed2cd58a96a 100644 (file)
@@ -25,10 +25,13 @@ struct submodule {
 int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
 int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
 int parse_submodule_config_option(const char *var, const char *value);
-const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
+const struct submodule *submodule_from_name(const unsigned char *commit_or_tree,
                const char *name);
-const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
+const struct submodule *submodule_from_path(const unsigned char *commit_or_tree,
                const char *path);
+extern int gitmodule_sha1_from_commit(const unsigned char *commit_sha1,
+                                     unsigned char *gitmodules_sha1,
+                                     struct strbuf *rev);
 void submodule_free(void);
 
 #endif /* SUBMODULE_CONFIG_H */
index 6f7d883de950af8ba6427537d09e021a4bed36bd..11ff11ed893879601cf0643fb345afe80942734f 100644 (file)
@@ -14,6 +14,7 @@
 #include "blob.h"
 #include "thread-utils.h"
 #include "quote.h"
+#include "worktree.h"
 
 static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
 static int parallel_jobs = 1;
@@ -198,6 +199,56 @@ void gitmodules_config(void)
        }
 }
 
+void gitmodules_config_sha1(const unsigned char *commit_sha1)
+{
+       struct strbuf rev = STRBUF_INIT;
+       unsigned char sha1[20];
+
+       if (gitmodule_sha1_from_commit(commit_sha1, sha1, &rev)) {
+               git_config_from_blob_sha1(submodule_config, rev.buf,
+                                         sha1, NULL);
+       }
+       strbuf_release(&rev);
+}
+
+/*
+ * Determine if a submodule has been initialized at a given 'path'
+ */
+int is_submodule_initialized(const char *path)
+{
+       int ret = 0;
+       const struct submodule *module = NULL;
+
+       module = submodule_from_path(null_sha1, path);
+
+       if (module) {
+               char *key = xstrfmt("submodule.%s.url", module->name);
+               char *value = NULL;
+
+               ret = !git_config_get_string(key, &value);
+
+               free(value);
+               free(key);
+       }
+
+       return ret;
+}
+
+/*
+ * Determine if a submodule has been populated at a given 'path'
+ */
+int is_submodule_populated(const char *path)
+{
+       int ret = 0;
+       char *gitdir = xstrfmt("%s/.git", path);
+
+       if (resolve_gitdir(gitdir))
+               ret = 1;
+
+       free(gitdir);
+       return ret;
+}
+
 int parse_submodule_update_strategy(const char *value,
                struct submodule_update_strategy *dst)
 {
@@ -500,27 +551,67 @@ static int has_remote(const char *refname, const struct object_id *oid,
        return 1;
 }
 
-static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
+static int append_sha1_to_argv(const unsigned char sha1[20], void *data)
+{
+       struct argv_array *argv = data;
+       argv_array_push(argv, sha1_to_hex(sha1));
+       return 0;
+}
+
+static int check_has_commit(const unsigned char sha1[20], void *data)
 {
-       if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
+       int *has_commit = data;
+
+       if (!lookup_commit_reference(sha1))
+               *has_commit = 0;
+
+       return 0;
+}
+
+static int submodule_has_commits(const char *path, struct sha1_array *commits)
+{
+       int has_commit = 1;
+
+       if (add_submodule_odb(path))
+               return 0;
+
+       sha1_array_for_each_unique(commits, check_has_commit, &has_commit);
+       return has_commit;
+}
+
+static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
+{
+       if (!submodule_has_commits(path, commits))
+               /*
+                * NOTE: We do consider it safe to return "no" here. The
+                * correct answer would be "We do not know" instead of
+                * "No push needed", but it is quite hard to change
+                * the submodule pointer without having the submodule
+                * around. If a user did however change the submodules
+                * without having the submodule around, this indicates
+                * an expert who knows what they are doing or a
+                * maintainer integrating work from other people. In
+                * both cases it should be safe to skip this check.
+                */
                return 0;
 
        if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
                struct child_process cp = CHILD_PROCESS_INIT;
-               const char *argv[] = {"rev-list", NULL, "--not", "--remotes", "-n", "1" , NULL};
                struct strbuf buf = STRBUF_INIT;
                int needs_pushing = 0;
 
-               argv[1] = sha1_to_hex(sha1);
-               cp.argv = argv;
+               argv_array_push(&cp.args, "rev-list");
+               sha1_array_for_each_unique(commits, append_sha1_to_argv, &cp.args);
+               argv_array_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
+
                prepare_submodule_repo_env(&cp.env_array);
                cp.git_cmd = 1;
                cp.no_stdin = 1;
                cp.out = -1;
                cp.dir = path;
                if (start_command(&cp))
-                       die("Could not run 'git rev-list %s --not --remotes -n 1' command in submodule %s",
-                               sha1_to_hex(sha1), path);
+                       die("Could not run 'git rev-list <commits> --not --remotes -n 1' command in submodule %s",
+                                       path);
                if (strbuf_read(&buf, cp.out, 41))
                        needs_pushing = 1;
                finish_command(&cp);
@@ -532,19 +623,34 @@ static int submodule_needs_pushing(const char *path, const unsigned char sha1[20
        return 0;
 }
 
+static struct sha1_array *submodule_commits(struct string_list *submodules,
+                                           const char *path)
+{
+       struct string_list_item *item;
+
+       item = string_list_insert(submodules, path);
+       if (item->util)
+               return (struct sha1_array *) item->util;
+
+       /* NEEDSWORK: should we have sha1_array_init()? */
+       item->util = xcalloc(1, sizeof(struct sha1_array));
+       return (struct sha1_array *) item->util;
+}
+
 static void collect_submodules_from_diff(struct diff_queue_struct *q,
                                         struct diff_options *options,
                                         void *data)
 {
        int i;
-       struct string_list *needs_pushing = data;
+       struct string_list *submodules = data;
 
        for (i = 0; i < q->nr; i++) {
                struct diff_filepair *p = q->queue[i];
+               struct sha1_array *commits;
                if (!S_ISGITLINK(p->two->mode))
                        continue;
-               if (submodule_needs_pushing(p->two->path, p->two->oid.hash))
-                       string_list_insert(needs_pushing, p->two->path);
+               commits = submodule_commits(submodules, p->two->path);
+               sha1_array_append(commits, p->two->oid.hash);
        }
 }
 
@@ -560,46 +666,63 @@ static void find_unpushed_submodule_commits(struct commit *commit,
        diff_tree_combined_merge(commit, 1, &rev);
 }
 
-int find_unpushed_submodules(unsigned char new_sha1[20],
+static void free_submodules_sha1s(struct string_list *submodules)
+{
+       struct string_list_item *item;
+       for_each_string_list_item(item, submodules)
+               sha1_array_clear((struct sha1_array *) item->util);
+       string_list_clear(submodules, 1);
+}
+
+int find_unpushed_submodules(struct sha1_array *commits,
                const char *remotes_name, struct string_list *needs_pushing)
 {
        struct rev_info rev;
        struct commit *commit;
-       const char *argv[] = {NULL, NULL, "--not", "NULL", NULL};
-       int argc = ARRAY_SIZE(argv) - 1;
-       char *sha1_copy;
-
-       struct strbuf remotes_arg = STRBUF_INIT;
+       struct string_list submodules = STRING_LIST_INIT_DUP;
+       struct string_list_item *submodule;
+       struct argv_array argv = ARGV_ARRAY_INIT;
 
-       strbuf_addf(&remotes_arg, "--remotes=%s", remotes_name);
        init_revisions(&rev, NULL);
-       sha1_copy = xstrdup(sha1_to_hex(new_sha1));
-       argv[1] = sha1_copy;
-       argv[3] = remotes_arg.buf;
-       setup_revisions(argc, argv, &rev, NULL);
+
+       /* argv.argv[0] will be ignored by setup_revisions */
+       argv_array_push(&argv, "find_unpushed_submodules");
+       sha1_array_for_each_unique(commits, append_sha1_to_argv, &argv);
+       argv_array_push(&argv, "--not");
+       argv_array_pushf(&argv, "--remotes=%s", remotes_name);
+
+       setup_revisions(argv.argc, argv.argv, &rev, NULL);
        if (prepare_revision_walk(&rev))
                die("revision walk setup failed");
 
        while ((commit = get_revision(&rev)) != NULL)
-               find_unpushed_submodule_commits(commit, needs_pushing);
+               find_unpushed_submodule_commits(commit, &submodules);
 
        reset_revision_walk();
-       free(sha1_copy);
-       strbuf_release(&remotes_arg);
+       argv_array_clear(&argv);
+
+       for_each_string_list_item(submodule, &submodules) {
+               struct sha1_array *commits = (struct sha1_array *) submodule->util;
+
+               if (submodule_needs_pushing(submodule->string, commits))
+                       string_list_insert(needs_pushing, submodule->string);
+       }
+       free_submodules_sha1s(&submodules);
 
        return needs_pushing->nr;
 }
 
-static int push_submodule(const char *path)
+static int push_submodule(const char *path, int dry_run)
 {
        if (add_submodule_odb(path))
                return 1;
 
        if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
                struct child_process cp = CHILD_PROCESS_INIT;
-               const char *argv[] = {"push", NULL};
+               argv_array_push(&cp.args, "push");
+               if (dry_run)
+                       argv_array_push(&cp.args, "--dry-run");
 
-               cp.argv = argv;
                prepare_submodule_repo_env(&cp.env_array);
                cp.git_cmd = 1;
                cp.no_stdin = 1;
@@ -612,18 +735,20 @@ static int push_submodule(const char *path)
        return 1;
 }
 
-int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name)
+int push_unpushed_submodules(struct sha1_array *commits,
+                            const char *remotes_name,
+                            int dry_run)
 {
        int i, ret = 1;
        struct string_list needs_pushing = STRING_LIST_INIT_DUP;
 
-       if (!find_unpushed_submodules(new_sha1, remotes_name, &needs_pushing))
+       if (!find_unpushed_submodules(commits, remotes_name, &needs_pushing))
                return 1;
 
        for (i = 0; i < needs_pushing.nr; i++) {
                const char *path = needs_pushing.items[i].string;
                fprintf(stderr, "Pushing submodule '%s'\n", path);
-               if (!push_submodule(path)) {
+               if (!push_submodule(path, dry_run)) {
                        fprintf(stderr, "Unable to push submodule '%s'\n", path);
                        ret = 0;
                }
@@ -1018,45 +1143,64 @@ int submodule_uses_gitfile(const char *path)
        return 1;
 }
 
-int ok_to_remove_submodule(const char *path)
+/*
+ * Check if it is a bad idea to remove a submodule, i.e. if we'd lose data
+ * when doing so.
+ *
+ * Return 1 if we'd lose data, return 0 if the removal is fine,
+ * and negative values for errors.
+ */
+int bad_to_remove_submodule(const char *path, unsigned flags)
 {
        ssize_t len;
        struct child_process cp = CHILD_PROCESS_INIT;
-       const char *argv[] = {
-               "status",
-               "--porcelain",
-               "-u",
-               "--ignore-submodules=none",
-               NULL,
-       };
        struct strbuf buf = STRBUF_INIT;
-       int ok_to_remove = 1;
+       int ret = 0;
 
        if (!file_exists(path) || is_empty_dir(path))
-               return 1;
+               return 0;
 
        if (!submodule_uses_gitfile(path))
-               return 0;
+               return 1;
+
+       argv_array_pushl(&cp.args, "status", "--porcelain",
+                                  "--ignore-submodules=none", NULL);
+
+       if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
+               argv_array_push(&cp.args, "-uno");
+       else
+               argv_array_push(&cp.args, "-uall");
+
+       if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
+               argv_array_push(&cp.args, "--ignored");
 
-       cp.argv = argv;
        prepare_submodule_repo_env(&cp.env_array);
        cp.git_cmd = 1;
        cp.no_stdin = 1;
        cp.out = -1;
        cp.dir = path;
-       if (start_command(&cp))
-               die("Could not run 'git status --porcelain -uall --ignore-submodules=none' in submodule %s", path);
+       if (start_command(&cp)) {
+               if (flags & SUBMODULE_REMOVAL_DIE_ON_ERROR)
+                       die(_("could not start 'git status in submodule '%s'"),
+                               path);
+               ret = -1;
+               goto out;
+       }
 
        len = strbuf_read(&buf, cp.out, 1024);
        if (len > 2)
-               ok_to_remove = 0;
+               ret = 1;
        close(cp.out);
 
-       if (finish_command(&cp))
-               die("'git status --porcelain -uall --ignore-submodules=none' failed in submodule %s", path);
-
+       if (finish_command(&cp)) {
+               if (flags & SUBMODULE_REMOVAL_DIE_ON_ERROR)
+                       die(_("could not run 'git status in submodule '%s'"),
+                               path);
+               ret = -1;
+       }
+out:
        strbuf_release(&buf);
-       return ok_to_remove;
+       return ret;
 }
 
 static int find_first_merges(struct object_array *result, const char *path,
@@ -1222,30 +1366,6 @@ int merge_submodule(unsigned char result[20], const char *path,
        return 0;
 }
 
-/* Update gitfile and core.worktree setting to connect work tree and git dir */
-void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
-{
-       struct strbuf file_name = STRBUF_INIT;
-       struct strbuf rel_path = STRBUF_INIT;
-       const char *real_work_tree = xstrdup(real_path(work_tree));
-
-       /* Update gitfile */
-       strbuf_addf(&file_name, "%s/.git", work_tree);
-       write_file(file_name.buf, "gitdir: %s",
-                  relative_path(git_dir, real_work_tree, &rel_path));
-
-       /* Update core.worktree setting */
-       strbuf_reset(&file_name);
-       strbuf_addf(&file_name, "%s/config", git_dir);
-       git_config_set_in_file(file_name.buf, "core.worktree",
-                              relative_path(real_work_tree, git_dir,
-                                            &rel_path));
-
-       strbuf_release(&file_name);
-       strbuf_release(&rel_path);
-       free((void *)real_work_tree);
-}
-
 int parallel_submodules(void)
 {
        return parallel_jobs;
@@ -1261,3 +1381,105 @@ void prepare_submodule_repo_env(struct argv_array *out)
        }
        argv_array_push(out, "GIT_DIR=.git");
 }
+
+/*
+ * Embeds a single submodules git directory into the superprojects git dir,
+ * non recursively.
+ */
+static void relocate_single_git_dir_into_superproject(const char *prefix,
+                                                     const char *path)
+{
+       char *old_git_dir = NULL, *real_old_git_dir = NULL, *real_new_git_dir = NULL;
+       const char *new_git_dir;
+       const struct submodule *sub;
+
+       if (submodule_uses_worktrees(path))
+               die(_("relocate_gitdir for submodule '%s' with "
+                     "more than one worktree not supported"), path);
+
+       old_git_dir = xstrfmt("%s/.git", path);
+       if (read_gitfile(old_git_dir))
+               /* If it is an actual gitfile, it doesn't need migration. */
+               return;
+
+       real_old_git_dir = real_pathdup(old_git_dir);
+
+       sub = submodule_from_path(null_sha1, path);
+       if (!sub)
+               die(_("could not lookup name for submodule '%s'"), path);
+
+       new_git_dir = git_path("modules/%s", sub->name);
+       if (safe_create_leading_directories_const(new_git_dir) < 0)
+               die(_("could not create directory '%s'"), new_git_dir);
+       real_new_git_dir = real_pathdup(new_git_dir);
+
+       if (!prefix)
+               prefix = get_super_prefix();
+
+       fprintf(stderr, _("Migrating git directory of '%s%s' from\n'%s' to\n'%s'\n"),
+               prefix ? prefix : "", path,
+               real_old_git_dir, real_new_git_dir);
+
+       relocate_gitdir(path, real_old_git_dir, real_new_git_dir);
+
+       free(old_git_dir);
+       free(real_old_git_dir);
+       free(real_new_git_dir);
+}
+
+/*
+ * Migrate the git directory of the submodule given by path from
+ * having its git directory within the working tree to the git dir nested
+ * in its superprojects git dir under modules/.
+ */
+void absorb_git_dir_into_superproject(const char *prefix,
+                                     const char *path,
+                                     unsigned flags)
+{
+       const char *sub_git_dir, *v;
+       char *real_sub_git_dir = NULL, *real_common_git_dir = NULL;
+       struct strbuf gitdir = STRBUF_INIT;
+
+       strbuf_addf(&gitdir, "%s/.git", path);
+       sub_git_dir = resolve_gitdir(gitdir.buf);
+
+       /* Not populated? */
+       if (!sub_git_dir)
+               goto out;
+
+       /* Is it already absorbed into the superprojects git dir? */
+       real_sub_git_dir = real_pathdup(sub_git_dir);
+       real_common_git_dir = real_pathdup(get_git_common_dir());
+       if (!skip_prefix(real_sub_git_dir, real_common_git_dir, &v))
+               relocate_single_git_dir_into_superproject(prefix, path);
+
+       if (flags & ABSORB_GITDIR_RECURSE_SUBMODULES) {
+               struct child_process cp = CHILD_PROCESS_INIT;
+               struct strbuf sb = STRBUF_INIT;
+
+               if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
+                       die("BUG: we don't know how to pass the flags down?");
+
+               if (get_super_prefix())
+                       strbuf_addstr(&sb, get_super_prefix());
+               strbuf_addstr(&sb, path);
+               strbuf_addch(&sb, '/');
+
+               cp.dir = path;
+               cp.git_cmd = 1;
+               cp.no_stdin = 1;
+               argv_array_pushl(&cp.args, "--super-prefix", sb.buf,
+                                          "submodule--helper",
+                                          "absorb-git-dirs", NULL);
+               prepare_submodule_repo_env(&cp.env_array);
+               if (run_command(&cp))
+                       die(_("could not recurse into submodule '%s'"), path);
+
+               strbuf_release(&sb);
+       }
+
+out:
+       strbuf_release(&gitdir);
+       free(real_sub_git_dir);
+       free(real_common_git_dir);
+}
index d9e197a948fdab44b7a5df4161a5df9c3a2938ff..b7fe4d20279dfe165338dc412595fe1ccf6ad73c 100644 (file)
@@ -3,6 +3,7 @@
 
 struct diff_options;
 struct argv_array;
+struct sha1_array;
 
 enum {
        RECURSE_SUBMODULES_CHECK = -4,
@@ -29,50 +30,66 @@ struct submodule_update_strategy {
 };
 #define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
 
-int is_staging_gitmodules_ok(void);
-int update_path_in_gitmodules(const char *oldpath, const char *newpath);
-int remove_path_from_gitmodules(const char *path);
-void stage_updated_gitmodules(void);
-void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
+extern int is_staging_gitmodules_ok(void);
+extern int update_path_in_gitmodules(const char *oldpath, const char *newpath);
+extern int remove_path_from_gitmodules(const char *path);
+extern void stage_updated_gitmodules(void);
+extern void set_diffopt_flags_from_submodule_config(struct diff_options *,
                const char *path);
-int submodule_config(const char *var, const char *value, void *cb);
-void gitmodules_config(void);
-int parse_submodule_update_strategy(const char *value,
+extern int submodule_config(const char *var, const char *value, void *cb);
+extern void gitmodules_config(void);
+extern void gitmodules_config_sha1(const unsigned char *commit_sha1);
+extern int is_submodule_initialized(const char *path);
+extern int is_submodule_populated(const char *path);
+extern int parse_submodule_update_strategy(const char *value,
                struct submodule_update_strategy *dst);
-const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
-void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
-void show_submodule_summary(FILE *f, const char *path,
+extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
+extern void handle_ignore_submodules_arg(struct diff_options *, const char *);
+extern void show_submodule_summary(FILE *f, const char *path,
                const char *line_prefix,
                struct object_id *one, struct object_id *two,
                unsigned dirty_submodule, const char *meta,
                const char *del, const char *add, const char *reset);
-void show_submodule_inline_diff(FILE *f, const char *path,
+extern void show_submodule_inline_diff(FILE *f, const char *path,
                const char *line_prefix,
                struct object_id *one, struct object_id *two,
                unsigned dirty_submodule, const char *meta,
                const char *del, const char *add, const char *reset,
                const struct diff_options *opt);
-void set_config_fetch_recurse_submodules(int value);
-void check_for_new_submodule_commits(unsigned char new_sha1[20]);
-int fetch_populated_submodules(const struct argv_array *options,
+extern void set_config_fetch_recurse_submodules(int value);
+extern void check_for_new_submodule_commits(unsigned char new_sha1[20]);
+extern int fetch_populated_submodules(const struct argv_array *options,
                               const char *prefix, int command_line_option,
                               int quiet, int max_parallel_jobs);
-unsigned is_submodule_modified(const char *path, int ignore_untracked);
-int submodule_uses_gitfile(const char *path);
-int ok_to_remove_submodule(const char *path);
-int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
-                   const unsigned char a[20], const unsigned char b[20], int search);
-int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name,
-               struct string_list *needs_pushing);
-int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
-void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
-int parallel_submodules(void);
+extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
+extern int submodule_uses_gitfile(const char *path);
+
+#define SUBMODULE_REMOVAL_DIE_ON_ERROR (1<<0)
+#define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<1)
+#define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)
+extern int bad_to_remove_submodule(const char *path, unsigned flags);
+extern int merge_submodule(unsigned char result[20], const char *path,
+                          const unsigned char base[20],
+                          const unsigned char a[20],
+                          const unsigned char b[20], int search);
+extern int find_unpushed_submodules(struct sha1_array *commits,
+                                   const char *remotes_name,
+                                   struct string_list *needs_pushing);
+extern int push_unpushed_submodules(struct sha1_array *commits,
+                                   const char *remotes_name,
+                                   int dry_run);
+extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
+extern int parallel_submodules(void);
 
 /*
  * Prepare the "env_array" parameter of a "struct child_process" for executing
  * a submodule by clearing any repo-specific envirionment variables, but
  * retaining any config in the environment.
  */
-void prepare_submodule_repo_env(struct argv_array *out);
+extern void prepare_submodule_repo_env(struct argv_array *out);
 
+#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
+extern void absorb_git_dir_into_superproject(const char *prefix,
+                                            const char *path,
+                                            unsigned flags);
 #endif
index 27fe0405b887671ff0ca4cea1b258aa850e66c8c..d2a63bea4346fb76d38ba43508ee6e60599e41a9 100644 (file)
@@ -8,7 +8,7 @@ static struct lock_file index_lock;
 int cmd_main(int ac, const char **av)
 {
        setup_git_directory();
-       hold_locked_index(&index_lock, 1);
+       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
        if (read_cache() < 0)
                die("unable to read index file");
        active_cache_tree = NULL;
index c3e631394f4a47f32e62e266431607861929f328..69174c6e3110d5e214c048aceccf07232b813ce7 100644 (file)
@@ -123,6 +123,7 @@ ScriptAlias /error/ error.sh/
 </Files>
 
 RewriteEngine on
+RewriteRule ^/dumb-redir/(.*)$ /dumb/$1 [R=301]
 RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301]
 RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302]
 RewriteRule ^/smart-redir-auth/(.*)$ /auth/smart/$1 [R=301]
@@ -132,6 +133,19 @@ RewriteRule ^/ftp-redir/(.*)$ ftp://localhost:1000/$1 [R=302]
 RewriteRule ^/loop-redir/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-(.*) /$1 [R=302]
 RewriteRule ^/loop-redir/(.*)$ /loop-redir/x-$1 [R=302]
 
+# The first rule issues a client-side redirect to something
+# that _doesn't_ look like a git repo. The second rule is a
+# server-side rewrite, so that it turns out the odd-looking
+# thing _is_ a git repo. The "[PT]" tells Apache to match
+# the usual ScriptAlias rules for /smart.
+RewriteRule ^/insane-redir/(.*)$ /intern-redir/$1/foo [R=301]
+RewriteRule ^/intern-redir/(.*)/foo$ /smart/$1 [PT]
+
+# Serve info/refs internally without redirecting, but
+# issue a redirect for any object requests.
+RewriteRule ^/redir-objects/(.*/info/refs)$ /dumb/$1 [PT]
+RewriteRule ^/redir-objects/(.*/objects/.*)$ /dumb/$1 [R=301]
+
 # Apache 2.2 does not understand <RequireAll>, so we use RewriteCond.
 # And as RewriteCond does not allow testing for non-matches, we match
 # the desired case first (one has abra, two has cadabra), and let it
index b0917d93e64a93faef4a87fed300761f7461420a..02f49cb4097153f84d5e397b1801128e229c7909 100644 (file)
@@ -1,15 +1,12 @@
 # Test routines for checking protocol disabling.
 
-# test cloning a particular protocol
-#   $1 - description of the protocol
-#   $2 - machine-readable name of the protocol
-#   $3 - the URL to try cloning
-test_proto () {
+# Test clone/fetch/push with GIT_ALLOW_PROTOCOL whitelist
+test_whitelist () {
        desc=$1
        proto=$2
        url=$3
 
-       test_expect_success "clone $1 (enabled)" '
+       test_expect_success "clone $desc (enabled)" '
                rm -rf tmp.git &&
                (
                        GIT_ALLOW_PROTOCOL=$proto &&
@@ -18,7 +15,7 @@ test_proto () {
                )
        '
 
-       test_expect_success "fetch $1 (enabled)" '
+       test_expect_success "fetch $desc (enabled)" '
                (
                        cd tmp.git &&
                        GIT_ALLOW_PROTOCOL=$proto &&
@@ -27,7 +24,7 @@ test_proto () {
                )
        '
 
-       test_expect_success "push $1 (enabled)" '
+       test_expect_success "push $desc (enabled)" '
                (
                        cd tmp.git &&
                        GIT_ALLOW_PROTOCOL=$proto &&
@@ -36,7 +33,7 @@ test_proto () {
                )
        '
 
-       test_expect_success "push $1 (disabled)" '
+       test_expect_success "push $desc (disabled)" '
                (
                        cd tmp.git &&
                        GIT_ALLOW_PROTOCOL=none &&
@@ -45,7 +42,7 @@ test_proto () {
                )
        '
 
-       test_expect_success "fetch $1 (disabled)" '
+       test_expect_success "fetch $desc (disabled)" '
                (
                        cd tmp.git &&
                        GIT_ALLOW_PROTOCOL=none &&
@@ -54,7 +51,7 @@ test_proto () {
                )
        '
 
-       test_expect_success "clone $1 (disabled)" '
+       test_expect_success "clone $desc (disabled)" '
                rm -rf tmp.git &&
                (
                        GIT_ALLOW_PROTOCOL=none &&
@@ -62,6 +59,129 @@ test_proto () {
                        test_must_fail git clone --bare "$url" tmp.git
                )
        '
+
+       test_expect_success "clone $desc (env var has precedence)" '
+               rm -rf tmp.git &&
+               (
+                       GIT_ALLOW_PROTOCOL=none &&
+                       export GIT_ALLOW_PROTOCOL &&
+                       test_must_fail git -c protocol.allow=always clone --bare "$url" tmp.git &&
+                       test_must_fail git -c protocol.$proto.allow=always clone --bare "$url" tmp.git
+               )
+       '
+}
+
+test_config () {
+       desc=$1
+       proto=$2
+       url=$3
+
+       # Test clone/fetch/push with protocol.<type>.allow config
+       test_expect_success "clone $desc (enabled with config)" '
+               rm -rf tmp.git &&
+               git -c protocol.$proto.allow=always clone --bare "$url" tmp.git
+       '
+
+       test_expect_success "fetch $desc (enabled)" '
+               git -C tmp.git -c protocol.$proto.allow=always fetch
+       '
+
+       test_expect_success "push $desc (enabled)" '
+               git -C tmp.git -c protocol.$proto.allow=always  push origin HEAD:pushed
+       '
+
+       test_expect_success "push $desc (disabled)" '
+               test_must_fail git -C tmp.git -c protocol.$proto.allow=never push origin HEAD:pushed
+       '
+
+       test_expect_success "fetch $desc (disabled)" '
+               test_must_fail git -C tmp.git -c protocol.$proto.allow=never fetch
+       '
+
+       test_expect_success "clone $desc (disabled)" '
+               rm -rf tmp.git &&
+               test_must_fail git -c protocol.$proto.allow=never clone --bare "$url" tmp.git
+       '
+
+       # Test clone/fetch/push with protocol.user.allow and its env var
+       test_expect_success "clone $desc (enabled)" '
+               rm -rf tmp.git &&
+               git -c protocol.$proto.allow=user clone --bare "$url" tmp.git
+       '
+
+       test_expect_success "fetch $desc (enabled)" '
+               git -C tmp.git -c protocol.$proto.allow=user fetch
+       '
+
+       test_expect_success "push $desc (enabled)" '
+               git -C tmp.git -c protocol.$proto.allow=user push origin HEAD:pushed
+       '
+
+       test_expect_success "push $desc (disabled)" '
+               (
+                       cd tmp.git &&
+                       GIT_PROTOCOL_FROM_USER=0 &&
+                       export GIT_PROTOCOL_FROM_USER &&
+                       test_must_fail git -c protocol.$proto.allow=user push origin HEAD:pushed
+               )
+       '
+
+       test_expect_success "fetch $desc (disabled)" '
+               (
+                       cd tmp.git &&
+                       GIT_PROTOCOL_FROM_USER=0 &&
+                       export GIT_PROTOCOL_FROM_USER &&
+                       test_must_fail git -c protocol.$proto.allow=user fetch
+               )
+       '
+
+       test_expect_success "clone $desc (disabled)" '
+               rm -rf tmp.git &&
+               (
+                       GIT_PROTOCOL_FROM_USER=0 &&
+                       export GIT_PROTOCOL_FROM_USER &&
+                       test_must_fail git -c protocol.$proto.allow=user clone --bare "$url" tmp.git
+               )
+       '
+
+       # Test clone/fetch/push with protocol.allow user defined default
+       test_expect_success "clone $desc (enabled)" '
+               rm -rf tmp.git &&
+               git config --global protocol.allow always &&
+               git clone --bare "$url" tmp.git
+       '
+
+       test_expect_success "fetch $desc (enabled)" '
+               git -C tmp.git fetch
+       '
+
+       test_expect_success "push $desc (enabled)" '
+               git -C tmp.git push origin HEAD:pushed
+       '
+
+       test_expect_success "push $desc (disabled)" '
+               git config --global protocol.allow never &&
+               test_must_fail git -C tmp.git push origin HEAD:pushed
+       '
+
+       test_expect_success "fetch $desc (disabled)" '
+               test_must_fail git -C tmp.git fetch
+       '
+
+       test_expect_success "clone $desc (disabled)" '
+               rm -rf tmp.git &&
+               test_must_fail git clone --bare "$url" tmp.git
+       '
+}
+
+# test cloning a particular protocol
+#   $1 - description of the protocol
+#   $2 - machine-readable name of the protocol
+#   $3 - the URL to try cloning
+test_proto () {
+       test_whitelist "$@"
+
+       test_config "$@"
 }
 
 # set up an ssh wrapper that will access $host/$repo in the
index 4ea534e9fa70ea302d4a88a8bc922c100f896873..161f5604464d2f963e60af54eedea3f91be041fa 100755 (executable)
@@ -93,7 +93,7 @@ test_expect_success setup '
        git checkout -- test test.t test.i &&
 
        echo "content-test2" >test2.o &&
-       echo "content-test3 - filename with special characters" >"test3 '\''sq'\'',\$x.o"
+       echo "content-test3 - filename with special characters" >"test3 '\''sq'\'',\$x=.o"
 '
 
 script='s/^\$Id: \([0-9a-f]*\) \$/\1/p'
@@ -350,21 +350,20 @@ test_expect_success PERL 'required process filter should filter data' '
                cd repo &&
                git init &&
 
-               echo "git-stderr.log" >.gitignore &&
                echo "*.r filter=protocol" >.gitattributes &&
                git add . &&
-               git commit -m "test commit 1" &&
+               git commit -m "test commit 1" &&
                git branch empty-branch &&
 
                cp "$TEST_ROOT/test.o" test.r &&
                cp "$TEST_ROOT/test2.o" test2.r &&
                mkdir testsubdir &&
-               cp "$TEST_ROOT/test3 '\''sq'\'',\$x.o" "testsubdir/test3 '\''sq'\'',\$x.r" &&
+               cp "$TEST_ROOT/test3 '\''sq'\'',\$x=.o" "testsubdir/test3 '\''sq'\'',\$x=.r" &&
                >test4-empty.r &&
 
                S=$(file_size test.r) &&
                S2=$(file_size test2.r) &&
-               S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x.r") &&
+               S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
 
                filter_git add . &&
                cat >expected.log <<-EOF &&
@@ -373,35 +372,20 @@ test_expect_success PERL 'required process filter should filter data' '
                        IN: clean test.r $S [OK] -- OUT: $S . [OK]
                        IN: clean test2.r $S2 [OK] -- OUT: $S2 . [OK]
                        IN: clean test4-empty.r 0 [OK] -- OUT: 0  [OK]
-                       IN: clean testsubdir/test3 '\''sq'\'',\$x.r $S3 [OK] -- OUT: $S3 . [OK]
+                       IN: clean testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
                        STOP
                EOF
                test_cmp_count expected.log rot13-filter.log &&
 
-               filter_git commit . -m "test commit 2" &&
-               cat >expected.log <<-EOF &&
-                       START
-                       init handshake complete
-                       IN: clean test.r $S [OK] -- OUT: $S . [OK]
-                       IN: clean test2.r $S2 [OK] -- OUT: $S2 . [OK]
-                       IN: clean test4-empty.r 0 [OK] -- OUT: 0  [OK]
-                       IN: clean testsubdir/test3 '\''sq'\'',\$x.r $S3 [OK] -- OUT: $S3 . [OK]
-                       IN: clean test.r $S [OK] -- OUT: $S . [OK]
-                       IN: clean test2.r $S2 [OK] -- OUT: $S2 . [OK]
-                       IN: clean test4-empty.r 0 [OK] -- OUT: 0  [OK]
-                       IN: clean testsubdir/test3 '\''sq'\'',\$x.r $S3 [OK] -- OUT: $S3 . [OK]
-                       STOP
-               EOF
-               test_cmp_count expected.log rot13-filter.log &&
-
-               rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x.r" &&
+               git commit -m "test commit 2" &&
+               rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
 
                filter_git checkout --quiet --no-progress . &&
                cat >expected.log <<-EOF &&
                        START
                        init handshake complete
                        IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
-                       IN: smudge testsubdir/test3 '\''sq'\'',\$x.r $S3 [OK] -- OUT: $S3 . [OK]
+                       IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
                        STOP
                EOF
                test_cmp_exclude_clean expected.log rot13-filter.log &&
@@ -422,14 +406,14 @@ test_expect_success PERL 'required process filter should filter data' '
                        IN: smudge test.r $S [OK] -- OUT: $S . [OK]
                        IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
                        IN: smudge test4-empty.r 0 [OK] -- OUT: 0  [OK]
-                       IN: smudge testsubdir/test3 '\''sq'\'',\$x.r $S3 [OK] -- OUT: $S3 . [OK]
+                       IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
                        STOP
                EOF
                test_cmp_exclude_clean expected.log rot13-filter.log &&
 
                test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
                test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
-               test_cmp_committed_rot13 "$TEST_ROOT/test3 '\''sq'\'',\$x.o" "testsubdir/test3 '\''sq'\'',\$x.r"
+               test_cmp_committed_rot13 "$TEST_ROOT/test3 '\''sq'\'',\$x=.o" "testsubdir/test3 '\''sq'\'',\$x=.r"
        )
 '
 
index 4d5697ee51c673abbe8a1a90b58bf5b7b9856ce1..617f581e56cac95191d6f1301566fa6671ecaf6f 100644 (file)
@@ -109,14 +109,18 @@ sub packet_flush {
 $debug->flush();
 
 while (1) {
-       my ($command) = packet_txt_read() =~ /^command=([^=]+)$/;
+       my ($command) = packet_txt_read() =~ /^command=(.+)$/;
        print $debug "IN: $command";
        $debug->flush();
 
-       my ($pathname) = packet_txt_read() =~ /^pathname=([^=]+)$/;
+       my ($pathname) = packet_txt_read() =~ /^pathname=(.+)$/;
        print $debug " $pathname";
        $debug->flush();
 
+       if ( $pathname eq "" ) {
+               die "bad pathname '$pathname'";
+       }
+
        # Flush
        packet_bin_read();
 
index 2c10cb4693e28eecf7771978a2f3b702e5f3bd30..2cbf7b95907384b4b4b5ac91f801026810b85f0a 100755 (executable)
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use POSIX qw(:locale_h);
-use Test::More tests => 8;
+use Test::More tests => 13;
 use Git::I18N;
 
 my $has_gettext_library = $Git::I18N::__HAS_LIBRARY;
@@ -31,6 +31,8 @@
        # more gettext wrapper functions.
        my %prototypes = (qw(
                __      $
+               __n     $$$
+               N__     $
        ));
        while (my ($sub, $proto) = each %prototypes) {
                is(prototype(\&{"Git::I18N::$sub"}), $proto, "sanity: $sub has a $proto prototype");
        my ($got, $expect) = (('TEST: A Perl test string') x 2);
 
        is(__($got), $expect, "Passing a string through __() in the C locale works");
+
+       my ($got_singular, $got_plural, $expect_singular, $expect_plural) =
+               (('TEST: 1 file', 'TEST: n files') x 2);
+
+       is(__n($got_singular, $got_plural, 1), $expect_singular,
+               "Get singular string through __n() in C locale");
+       is(__n($got_singular, $got_plural, 2), $expect_plural,
+               "Get plural string through __n() in C locale");
+
+       is(N__($got), $expect, "Passing a string through N__() in the C locale works");
 }
 
 # Test a basic message on different locales
index 096dbffecc3d51478b643bd2f4dee92f507e1c1a..6fd264cff0d6de1961656c2cd1193d8ce37e9a1f 100755 (executable)
@@ -5,6 +5,12 @@ test_description='adding and checking out large blobs'
 
 . ./test-lib.sh
 
+# This should be moved to test-lib.sh together with the
+# copy in t0021 after both topics have graduated to 'master'.
+file_size () {
+       perl -e 'print -s $ARGV[0]' "$1"
+}
+
 test_expect_success setup '
        # clone does not allow us to pass core.bigfilethreshold to
        # new repos, so set core.bigfilethreshold globally
@@ -17,6 +23,29 @@ test_expect_success setup '
        export GIT_ALLOC_LIMIT
 '
 
+# add a large file with different settings
+while read expect config
+do
+       test_expect_success "add with $config" '
+               test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
+               git $config add large1 &&
+               sz=$(file_size .git/objects/pack/pack-*.pack) &&
+               case "$expect" in
+               small) test "$sz" -le 100000 ;;
+               large) test "$sz" -ge 100000 ;;
+               esac
+       '
+done <<\EOF
+large -c core.compression=0
+small -c core.compression=9
+large -c core.compression=0 -c pack.compression=0
+large -c core.compression=9 -c pack.compression=0
+small -c core.compression=0 -c pack.compression=9
+small -c core.compression=9 -c pack.compression=9
+large -c pack.compression=0
+small -c pack.compression=9
+EOF
+
 test_expect_success 'add a large file or two' '
        git add large1 huge large2 &&
        # make sure we got a single packfile and no loose objects
index 7655c94c2801f0070a7b60ea17f30414b16c8d12..ff50960ccaed9953c5738c9bbf602bf0d326e15a 100755 (executable)
@@ -219,14 +219,8 @@ test_expect_success 'check line errors for malformed values' '
 '
 
 test_expect_success 'error on modifying repo config without repo' '
-       mkdir no-repo &&
-       (
-               GIT_CEILING_DIRECTORIES=$(pwd) &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd no-repo &&
-               test_must_fail git config a.b c 2>err &&
-               grep "not in a git directory" err
-       )
+       nongit test_must_fail git config a.b c 2>err &&
+       grep "not in a git directory" err
 '
 
 cmdline_config="'foo.bar=from-cmdline'"
index 1b1b65a6b0fc7ace4e18e8642a6c47631d7e6a43..465eeeacd3de1971c7256c84583377b3b47d520b 100755 (executable)
@@ -96,4 +96,44 @@ test_expect_success 'bare repo cleanup' '
        rm -rf bare1
 '
 
+test_expect_success 'broken main worktree still at the top' '
+       git init broken-main &&
+       (
+               cd broken-main &&
+               test_commit new &&
+               git worktree add linked &&
+               cat >expected <<-EOF &&
+               worktree $(pwd)
+               HEAD $_z40
+
+               EOF
+               cd linked &&
+               echo "worktree $(pwd)" >expected &&
+               echo "ref: .broken" >../.git/HEAD &&
+               git worktree list --porcelain | head -n 3 >actual &&
+               test_cmp ../expected actual &&
+               git worktree list | head -n 1 >actual.2 &&
+               grep -F "(error)" actual.2
+       )
+'
+
+test_expect_success 'linked worktrees are sorted' '
+       mkdir sorted &&
+       git init sorted/main &&
+       (
+               cd sorted/main &&
+               test_tick &&
+               test_commit new &&
+               git worktree add ../first &&
+               git worktree add ../second &&
+               git worktree list --porcelain | grep ^worktree >actual
+       ) &&
+       cat >expected <<-EOF &&
+       worktree $(pwd)/sorted/main
+       worktree $(pwd)/sorted/first
+       worktree $(pwd)/sorted/second
+       EOF
+       test_cmp expected sorted/main/actual
+'
+
 test_done
index 470f33466ca561484da080a522add72bed51ad6e..9a893b5fe746f03521454972199ecb2d243d79ab 100755 (executable)
@@ -575,13 +575,13 @@ test_expect_success 'merge removes empty directories' '
        test_must_fail test -d d
 '
 
-test_expect_failure 'merge-recursive simple w/submodule' '
+test_expect_success 'merge-recursive simple w/submodule' '
 
        git checkout submod &&
        git merge remove
 '
 
-test_expect_failure 'merge-recursive simple w/submodule result' '
+test_expect_success 'merge-recursive simple w/submodule result' '
 
        git ls-files -s >actual &&
        (
index c6a3ccba1b992cff7412bcf8139da7557981de94..52283dfc8cdafabba485fa6896279d600230abf9 100755 (executable)
@@ -89,6 +89,11 @@ test_expect_success 'git branch --list -v pattern shows branch summaries' '
        awk "{print \$NF}" <tmp >actual &&
        test_cmp expect actual
 '
+test_expect_success 'git branch --ignore-case --list -v pattern shows branch summaries' '
+       git branch --list --ignore-case -v BRANCH* >tmp &&
+       awk "{print \$NF}" <tmp >actual &&
+       test_cmp expect actual
+'
 
 test_expect_success 'git branch -v pattern does not show branch summaries' '
        test_must_fail git branch -v branch*
@@ -196,4 +201,28 @@ test_expect_success 'local-branch symrefs shortened properly' '
        test_cmp expect actual
 '
 
+test_expect_success 'sort branches, ignore case' '
+       (
+               git init sort-icase &&
+               cd sort-icase &&
+               test_commit initial &&
+               git branch branch-one &&
+               git branch BRANCH-two &&
+               git branch --list | awk "{print \$NF}" >actual &&
+               cat >expected <<-\EOF &&
+               BRANCH-two
+               branch-one
+               master
+               EOF
+               test_cmp expected actual &&
+               git branch --list -i | awk "{print \$NF}" >actual &&
+               cat >expected <<-\EOF &&
+               branch-one
+               BRANCH-two
+               master
+               EOF
+               test_cmp expected actual
+       )
+'
+
 test_done
index a6a6c40a98512b190f8610391aa153a294e4b5cb..910f2182843476edf878bfc42f34d868c70d8cf5 100755 (executable)
@@ -99,4 +99,28 @@ testrebase() {
 testrebase "" .git/rebase-apply
 testrebase " --merge" .git/rebase-merge
 
+test_expect_success 'rebase --quit' '
+       cd "$work_dir" &&
+       # Clean up the state from the previous one
+       git reset --hard pre-rebase &&
+       test_must_fail git rebase master &&
+       test_path_is_dir .git/rebase-apply &&
+       head_before=$(git rev-parse HEAD) &&
+       git rebase --quit &&
+       test $(git rev-parse HEAD) = $head_before &&
+       test ! -d .git/rebase-apply
+'
+
+test_expect_success 'rebase --merge --quit' '
+       cd "$work_dir" &&
+       # Clean up the state from the previous one
+       git reset --hard pre-rebase &&
+       test_must_fail git rebase --merge master &&
+       test_path_is_dir .git/rebase-merge &&
+       head_before=$(git rev-parse HEAD) &&
+       git rebase --quit &&
+       test $(git rev-parse HEAD) = $head_before &&
+       test ! -d .git/rebase-merge
+'
+
 test_done
index d5b896d4459e82cdc7eb363af77d8eef28871229..ebf4f5e4b2c1c1cc20a49888df14cedd14b49a8b 100755 (executable)
@@ -38,9 +38,6 @@ git_rebase_interactive () {
        git rebase -i "$1"
 }
 
-KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
-# The real reason "replace directory with submodule" fails is because a
-# directory "sub1" exists, but we reuse the suppression added for merge here
 test_submodule_switch "git_rebase_interactive"
 
 test_done
index 394f0005a195c1fbc713226c97ecee5cf4600007..4f2a263b63e14348032959059c15b160fecba39c 100755 (executable)
@@ -141,4 +141,16 @@ test_expect_success 'cherry-pick "-" works with arguments' '
        test_cmp expect actual
 '
 
+test_expect_success 'cherry-pick works with dirty renamed file' '
+       test_commit to-rename &&
+       git checkout -b unrelated &&
+       test_commit unrelated &&
+       git checkout @{-1} &&
+       git mv to-rename.t renamed &&
+       test_tick &&
+       git commit -m renamed &&
+       echo modified >renamed &&
+       git cherry-pick refs/heads/unrelated
+'
+
 test_done
index 7b7a89dbd5ce578e0a722345a00f247e383689ef..372307c21b983437b870ac65ff4f91d2c36fab30 100755 (executable)
@@ -147,6 +147,16 @@ test_expect_success '--abort to cancel single cherry-pick' '
        git diff-index --exit-code HEAD
 '
 
+test_expect_success '--abort does not unsafely change HEAD' '
+       pristine_detach initial &&
+       test_must_fail git cherry-pick picked anotherpick &&
+       git reset --hard base &&
+       test_must_fail git cherry-pick picked anotherpick &&
+       git cherry-pick --abort 2>actual &&
+       test_i18ngrep "You seem to have moved HEAD" actual &&
+       test_cmp_rev base HEAD
+'
+
 test_expect_success 'cherry-pick --abort to cancel multiple revert' '
        pristine_detach anotherpick &&
        test_expect_code 1 git revert base..picked &&
index 9cce5ae8815a11e3453f5669b0592f7f7659009b..bf0a5c9887235afb5e336a34815d6bb3d64875d8 100755 (executable)
@@ -25,9 +25,8 @@ Signed-off-by: B.U. Thor <buthor@example.com>"
 
 mesg_broken_footer="$mesg_no_footer
 
-The signed-off-by string should begin with the words Signed-off-by followed
-by a colon and space, and then the signers name and email address. e.g.
-Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+This is not recognized as a footer because Myfooter is not a recognized token.
+Myfooter: A.U. Thor <author@example.com>"
 
 mesg_with_footer_sob="$mesg_with_footer
 Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
@@ -112,6 +111,17 @@ test_expect_success 'cherry-pick -s inserts blank line after non-conforming foot
        test_cmp expect actual
 '
 
+test_expect_success 'cherry-pick -s recognizes trailer config' '
+       pristine_detach initial &&
+       git -c "trailer.Myfooter.ifexists=add" cherry-pick -s mesg-broken-footer &&
+       cat <<-EOF >expect &&
+               $mesg_broken_footer
+               Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+       EOF
+       git log -1 --pretty=format:%B >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'cherry-pick -x inserts blank line when conforming footer not found' '
        pristine_detach initial &&
        sha1=$(git rev-parse mesg-no-footer^0) &&
index 14f0edca2b6f67e6ae98379702b5566e4083d8e0..5aa6db584cd0dbddf6060eeb46f4c1c9836bc935 100755 (executable)
@@ -111,21 +111,21 @@ test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
 '
 
 test_expect_success '"rm" command printed' '
-       echo frotz > test-file &&
+       echo frotz >test-file &&
        git add test-file &&
        git commit -m "add file for rm test" &&
-       git rm test-file > rm-output &&
+       git rm test-file >rm-output &&
        test $(grep "^rm " rm-output | wc -l) = 1 &&
        rm -f test-file rm-output &&
        git commit -m "remove file from rm test"
 '
 
 test_expect_success '"rm" command suppressed with --quiet' '
-       echo frotz > test-file &&
+       echo frotz >test-file &&
        git add test-file &&
        git commit -m "add file for rm --quiet test" &&
-       git rm --quiet test-file > rm-output &&
-       test $(wc -l < rm-output) = 0 &&
+       git rm --quiet test-file >rm-output &&
+       test_must_be_empty rm-output &&
        rm -f test-file rm-output &&
        git commit -m "remove file from rm --quiet test"
 '
@@ -221,7 +221,7 @@ test_expect_success 'Call "rm" from outside the work tree' '
        mkdir repo &&
        (cd repo &&
         git init &&
-        echo something > somefile &&
+        echo something >somefile &&
         git add somefile &&
         git commit -m "add a file" &&
         (cd .. &&
@@ -287,7 +287,7 @@ test_expect_success 'rm removes empty submodules from work tree' '
        git commit -m "add submodule" &&
        git rm submod &&
        test ! -e submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@ -298,7 +298,7 @@ test_expect_success 'rm removes removed submodule from index and .gitmodules' '
        git submodule update &&
        rm -rf submod &&
        git rm submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@ -309,7 +309,7 @@ test_expect_success 'rm removes work tree of unmodified submodules' '
        git submodule update &&
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@ -320,7 +320,7 @@ test_expect_success 'rm removes a submodule with a trailing /' '
        git submodule update &&
        git rm submod/ &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
@@ -335,17 +335,15 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' '
 test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               git checkout HEAD^
-       ) &&
+       git -C submod checkout HEAD^ &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@ -418,34 +416,30 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule
 test_expect_success 'rm of a populated submodule with modifications fails unless forced' '
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >empty
-       ) &&
+       echo X >submod/empty &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'rm of a populated submodule with untracked files fails unless forced' '
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >untracked
-       ) &&
+       echo X >submod/untracked &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
@@ -461,16 +455,12 @@ test_expect_success 'setup submodule conflict' '
        git add nitfol &&
        git commit -m "added nitfol 2" &&
        git checkout -b conflict1 master &&
-       (cd submod &&
-               git fetch &&
-               git checkout branch1
-       ) &&
+       git -C submod fetch &&
+       git -C submod checkout branch1 &&
        git add submod &&
        git commit -m "submod 1" &&
        git checkout -b conflict2 master &&
-       (cd submod &&
-               git checkout branch2
-       ) &&
+       git -C submod checkout branch2 &&
        git add submod &&
        git commit -m "submod 2"
 '
@@ -486,7 +476,7 @@ test_expect_success 'rm removes work tree of unmodified conflicted submodule' '
        test_must_fail git merge conflict2 &&
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
@@ -494,18 +484,16 @@ test_expect_success 'rm of a conflicted populated submodule with different HEAD
        git checkout conflict1 &&
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               git checkout HEAD^
-       ) &&
+       git -C submod checkout HEAD^ &&
        test_must_fail git merge conflict2 &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@ -515,18 +503,16 @@ test_expect_success 'rm of a conflicted populated submodule with modifications f
        git checkout conflict1 &&
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >empty
-       ) &&
+       echo X >submod/empty &&
        test_must_fail git merge conflict2 &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@ -536,18 +522,16 @@ test_expect_success 'rm of a conflicted populated submodule with untracked files
        git checkout conflict1 &&
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >untracked
-       ) &&
+       echo X >submod/untracked &&
        test_must_fail git merge conflict2 &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
@@ -564,12 +548,12 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
        test_must_fail git rm submod &&
        test -d submod &&
        test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        test_must_fail git rm -f submod &&
        test -d submod &&
        test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git merge --abort &&
        rm -rf submod
@@ -581,30 +565,26 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
        test_must_fail git merge conflict2 &&
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
-test_expect_success 'rm of a populated submodule with a .git directory fails even when forced' '
+test_expect_success 'rm of a populated submodule with a .git directory migrates git dir' '
        git checkout -f master &&
        git reset --hard &&
        git submodule update &&
        (cd submod &&
                rm .git &&
                cp -R ../.git/modules/sub .git &&
-               GIT_WORK_TREE=. git config --unset core.worktree
+               GIT_WORK_TREE=. git config --unset core.worktree &&
+               rm -r ../.git/modules/sub
        ) &&
-       test_must_fail git rm submod &&
-       test -d submod &&
-       test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
-       ! test -s actual &&
-       test_must_fail git rm -f submod &&
-       test -d submod &&
-       test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
-       ! test -s actual &&
-       rm -rf submod
+       git rm submod 2>output.err &&
+       ! test -d submod &&
+       ! test -d submod/.git &&
+       git status -s -uno --ignore-submodules=none >actual &&
+       test -s actual &&
+       test_i18ngrep Migrating output.err
 '
 
 cat >expect.deepmodified <<EOF
@@ -629,58 +609,52 @@ test_expect_success 'setup subsubmodule' '
 test_expect_success 'rm recursively removes work tree of unmodified submodules' '
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'rm of a populated nested submodule with different nested HEAD fails unless forced' '
        git reset --hard &&
        git submodule update --recursive &&
-       (cd submod/subsubmod &&
-               git checkout HEAD^
-       ) &&
+       git -C submod/subsubmod checkout HEAD^ &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'rm of a populated nested submodule with nested modifications fails unless forced' '
        git reset --hard &&
        git submodule update --recursive &&
-       (cd submod/subsubmod &&
-               echo X >empty
-       ) &&
+       echo X >submod/subsubmod/empty &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'rm of a populated nested submodule with nested untracked files fails unless forced' '
        git reset --hard &&
        git submodule update --recursive &&
-       (cd submod/subsubmod &&
-               echo X >untracked
-       ) &&
+       echo X >submod/subsubmod/untracked &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
 '
 
@@ -689,34 +663,29 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
        git submodule update --recursive &&
        (cd submod/subsubmod &&
                rm .git &&
-               cp -R ../../.git/modules/sub/modules/sub .git &&
+               mv ../../.git/modules/sub/modules/sub .git &&
                GIT_WORK_TREE=. git config --unset core.worktree
        ) &&
-       test_must_fail git rm submod &&
-       test -d submod &&
-       test -d submod/subsubmod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
-       ! test -s actual &&
-       test_must_fail git rm -f submod &&
-       test -d submod &&
-       test -d submod/subsubmod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
-       ! test -s actual &&
-       rm -rf submod
+       git rm submod 2>output.err &&
+       ! test -d submod &&
+       ! test -d submod/subsubmod/.git &&
+       git status -s -uno --ignore-submodules=none >actual &&
+       test -s actual &&
+       test_i18ngrep Migrating output.err
 '
 
 test_expect_success 'checking out a commit after submodule removal needs manual updates' '
-       git commit -m "submodule removal" submod &&
+       git commit -m "submodule removal" submod .gitmodules &&
        git checkout HEAD^ &&
        git submodule update &&
-       git checkout -q HEAD^ 2>actual &&
+       git checkout -q HEAD^ &&
        git checkout -q master 2>actual &&
        test_i18ngrep "^warning: unable to rmdir submod:" actual &&
        git status -s submod >actual &&
        echo "?? submod/" >expected &&
        test_cmp expected actual &&
        rm -rf submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        ! test -s actual
 '
 
index e1a6ccc00c5988cfa8808bccc49a5e21703166b6..2de3e18ce68a94111c8dfcca858b8515ea8919c1 100755 (executable)
@@ -766,4 +766,13 @@ test_expect_success 'stash list --cc shows combined diff' '
        test_cmp expect actual
 '
 
+test_expect_success 'stash is not confused by partial renames' '
+       mv file renamed &&
+       git add renamed &&
+       git stash &&
+       git stash apply &&
+       test_path_is_file renamed &&
+       test_path_is_missing file
+'
+
 test_done
index 566817e2efdccc4747e871f3bdabb90fa5b134ec..d09acfe48e81b2567fd7408d7cb6345c73d99754 100755 (executable)
@@ -311,6 +311,13 @@ diff --line-prefix=abc master master^ side
 diff --dirstat master~1 master~2
 diff --dirstat initial rearrange
 diff --dirstat-by-file initial rearrange
+# No-index --abbrev and --no-abbrev
+diff --raw initial
+diff --raw --abbrev=4 initial
+diff --raw --no-abbrev initial
+diff --no-index --raw dir2 dir
+diff --no-index --raw --abbrev=4 dir2 dir
+diff --no-index --raw --no-abbrev dir2 dir
 EOF
 
 test_expect_success 'log -S requires an argument' '
diff --git a/t/t4013/diff.diff_--no-index_--raw_--abbrev=4_dir2_dir b/t/t4013/diff.diff_--no-index_--raw_--abbrev=4_dir2_dir
new file mode 100644 (file)
index 0000000..a71b38a
--- /dev/null
@@ -0,0 +1,3 @@
+$ git diff --no-index --raw --abbrev=4 dir2 dir
+:000000 100644 0000... 0000... A       dir/sub
+$
diff --git a/t/t4013/diff.diff_--no-index_--raw_--no-abbrev_dir2_dir b/t/t4013/diff.diff_--no-index_--raw_--no-abbrev_dir2_dir
new file mode 100644 (file)
index 0000000..e0f0097
--- /dev/null
@@ -0,0 +1,3 @@
+$ git diff --no-index --raw --no-abbrev dir2 dir
+:000000 100644 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 A     dir/sub
+$
diff --git a/t/t4013/diff.diff_--no-index_--raw_dir2_dir b/t/t4013/diff.diff_--no-index_--raw_dir2_dir
new file mode 100644 (file)
index 0000000..3cb4ee7
--- /dev/null
@@ -0,0 +1,3 @@
+$ git diff --no-index --raw dir2 dir
+:000000 100644 0000000... 0000000... A dir/sub
+$
diff --git a/t/t4013/diff.diff_--raw_--abbrev=4_initial b/t/t4013/diff.diff_--raw_--abbrev=4_initial
new file mode 100644 (file)
index 0000000..c3641db
--- /dev/null
@@ -0,0 +1,6 @@
+$ git diff --raw --abbrev=4 initial
+:100644 100644 35d2... 9929... M       dir/sub
+:100644 100644 01e7... 10a8... M       file0
+:000000 100644 0000... b1e6... A       file1
+:100644 000000 01e7... 0000... D       file2
+$
diff --git a/t/t4013/diff.diff_--raw_--no-abbrev_initial b/t/t4013/diff.diff_--raw_--no-abbrev_initial
new file mode 100644 (file)
index 0000000..c87a125
--- /dev/null
@@ -0,0 +1,6 @@
+$ git diff --raw --no-abbrev initial
+:100644 100644 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e 992913c5aa0a5476d10c49ed0f21fc0c6d1aedf3 M     dir/sub
+:100644 100644 01e79c32a8c99c557f0757da7cb6d65b3414466d 10a8a9f3657f91a156b9f0184ed79a20adef9f7f M     file0
+:000000 100644 0000000000000000000000000000000000000000 b1e67221afe8461efd244b487afca22d46b95eb8 A     file1
+:100644 000000 01e79c32a8c99c557f0757da7cb6d65b3414466d 0000000000000000000000000000000000000000 D     file2
+$
diff --git a/t/t4013/diff.diff_--raw_initial b/t/t4013/diff.diff_--raw_initial
new file mode 100644 (file)
index 0000000..a3e9780
--- /dev/null
@@ -0,0 +1,6 @@
+$ git diff --raw initial
+:100644 100644 35d242b... 992913c... M dir/sub
+:100644 100644 01e79c3... 10a8a9f... M file0
+:000000 100644 0000000... b1e6722... A file1
+:100644 000000 01e79c3... 0000000... D file2
+$
index ba4902df2b605f89ec2abcac50abefc2f23fc9bf..482112ca339f05fc31e6f9c2c6168971a1121e87 100755 (executable)
@@ -1294,8 +1294,7 @@ EOF
 4:Subject: [PATCH] subject
 8:
 10:Signed-off-by: example happens to be wrapped here.
-11:
-12:Signed-off-by: C O Mitter <committer@example.com>
+11:Signed-off-by: C O Mitter <committer@example.com>
 EOF
        test_cmp expected actual
 '
@@ -1368,7 +1367,7 @@ EOF
        test_cmp expected actual
 '
 
-test_expect_success 'signoff: detect garbage in non-conforming footer' '
+test_expect_success 'signoff: tolerate garbage in conforming footer' '
        append_signoff <<\EOF >actual &&
 subject
 
@@ -1383,8 +1382,36 @@ EOF
 8:
 10:
 13:Signed-off-by: C O Mitter <committer@example.com>
-14:
-15:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+       test_cmp expected actual
+'
+
+test_expect_success 'signoff: respect trailer config' '
+       append_signoff <<\EOF >actual &&
+subject
+
+Myfooter: x
+Some Trash
+EOF
+       cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+11:
+12:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+       test_cmp expected actual &&
+
+       test_config trailer.Myfooter.ifexists add &&
+       append_signoff <<\EOF >actual &&
+subject
+
+Myfooter: x
+Some Trash
+EOF
+       cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+11:Signed-off-by: C O Mitter <committer@example.com>
 EOF
        test_cmp expected actual
 '
index ae08b57712e382a4cba7f7a51a499b4621a38c84..9df054bf05b8cd40011c0577aa0ce0f30cb8c23f 100755 (executable)
@@ -190,4 +190,23 @@ test_expect_success 'shortlog with --output=<file>' '
        test_line_count = 3 shortlog
 '
 
+test_expect_success 'shortlog --committer (internal)' '
+       git checkout --orphan side &&
+       git commit --allow-empty -m one &&
+       git commit --allow-empty -m two &&
+       GIT_COMMITTER_NAME="Sin Nombre" git commit --allow-empty -m three &&
+
+       cat >expect <<-\EOF &&
+            2  C O Mitter
+            1  Sin Nombre
+       EOF
+       git shortlog -nsc HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'shortlog --committer (external)' '
+       git log --format=full | git shortlog -nsc >actual &&
+       test_cmp expect actual
+'
+
 test_done
index f5435fd250baf7415fb6a205f4497cb5c118de65..21eb8c8587f2b4de01595d91d27c8ec6706d2a00 100755 (executable)
@@ -535,4 +535,30 @@ test_expect_success 'clean log decoration' '
        test_cmp expected actual1
 '
 
+cat >trailers <<EOF
+Signed-off-by: A U Thor <author@example.com>
+Acked-by: A U Thor <author@example.com>
+[ v2 updated patch description ]
+Signed-off-by: A U Thor <author@example.com>
+EOF
+
+test_expect_success 'pretty format %(trailers) shows trailers' '
+       echo "Some contents" >trailerfile &&
+       git add trailerfile &&
+       git commit -F - <<-EOF &&
+       trailers: this commit message has trailers
+
+       This commit is a test commit with trailers at the end. We parse this
+       message and display the trailers using %bT
+
+       $(cat trailers)
+       EOF
+       git log --no-walk --pretty="%(trailers)" >actual &&
+       cat >expect <<-EOF &&
+       $(cat trailers)
+
+       EOF
+       test_cmp expect actual
+'
+
 test_done
index 830bf2a2f6d4d85358a54f58f74b4ed9fdc954d5..886b6953e40f9fceae18642ebec031e0bdf511e3 100755 (executable)
@@ -94,20 +94,6 @@ check_tar() {
        '
 }
 
-# run "$@" inside a non-git directory
-nongit () {
-       test -d non-repo ||
-       mkdir non-repo ||
-       return 1
-
-       (
-               GIT_CEILING_DIRECTORIES=$(pwd) &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd non-repo &&
-               "$@"
-       )
-}
-
 test_expect_success \
     'populate workdir' \
     'mkdir a &&
index 899e52d50f0d73e4a755c4f7991364f34912b336..43a672c3451146f800852a6d8688c10e497b47cf 100755 (executable)
@@ -406,6 +406,21 @@ test_expect_success 'verify resulting packs' '
        git verify-pack test-11-*.pack
 '
 
+test_expect_success 'set up pack for non-repo tests' '
+       # make sure we have a pack with no matching index file
+       cp test-1-*.pack foo.pack
+'
+
+test_expect_success 'index-pack --stdin complains of non-repo' '
+       nongit test_must_fail git index-pack --stdin <foo.pack &&
+       test_path_is_missing non-repo/.git
+'
+
+test_expect_success 'index-pack <pack> works in non-repo' '
+       nongit git index-pack ../foo.pack &&
+       test_path_is_file foo.idx
+'
+
 #
 # WARNING!
 #
diff --git a/t/t5315-pack-objects-compression.sh b/t/t5315-pack-objects-compression.sh
new file mode 100755 (executable)
index 0000000..34c47da
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+test_description='pack-object compression configuration'
+
+. ./test-lib.sh
+
+# This should be moved to test-lib.sh together with the
+# copy in t0021 after both topics have graduated to 'master'.
+file_size () {
+       perl -e 'print -s $ARGV[0]' "$1"
+}
+
+test_expect_success setup '
+       printf "%2000000s" X |
+       git hash-object -w --stdin >object-name &&
+       # make sure it resulted in a loose object
+       ob=$(sed -e "s/\(..\).*/\1/" object-name) &&
+       ject=$(sed -e "s/..\(.*\)/\1/" object-name) &&
+       test -f .git/objects/$ob/$ject
+'
+
+while read expect config
+do
+       test_expect_success "pack-objects with $config" '
+               test_when_finished "rm -f pack-*.*" &&
+               git $config pack-objects pack <object-name &&
+               sz=$(file_size pack-*.pack) &&
+               case "$expect" in
+               small) test "$sz" -le 100000 ;;
+               large) test "$sz" -ge 100000 ;;
+               esac
+       '
+done <<\EOF
+large -c core.compression=0
+small -c core.compression=9
+large -c core.compression=0 -c pack.compression=0
+large -c core.compression=9 -c pack.compression=0
+small -c core.compression=0 -c pack.compression=9
+small -c core.compression=9 -c pack.compression=9
+large -c pack.compression=0
+small -c pack.compression=9
+EOF
+
+test_done
index bc44ac36d57615b516018a2602c15bea8085e316..75c570adcae4f474c15775ec8504521fc806e2a9 100755 (executable)
@@ -4,6 +4,7 @@ test_description='fetch/push involving ref namespaces'
 . ./test-lib.sh
 
 test_expect_success setup '
+       git config --global protocol.ext.allow user &&
        test_tick &&
        git init original &&
        (
index 551844584fc7b8ff71667dd61fcba62889ded69f..17f4d0fe4e7244cb58eaedcf41bcaa9c7b157bb4 100755 (executable)
@@ -255,6 +255,23 @@ test_expect_success '--rebase' '
        test new = "$(git show HEAD:file2)"
 '
 
+test_expect_success '--rebase fast forward' '
+       git reset --hard before-rebase &&
+       git checkout -b ff &&
+       echo another modification >file &&
+       git commit -m third file &&
+
+       git checkout to-rebase &&
+       git pull --rebase . ff &&
+       test "$(git rev-parse HEAD)" = "$(git rev-parse ff)" &&
+
+       # The above only validates the result.  Did we actually bypass rebase?
+       git reflog -1 >reflog.actual &&
+       sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
+       echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected &&
+       test_cmp reflog.expected reflog.fuzzy
+'
+
 test_expect_success '--rebase with conflicts shows advice' '
        test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
        git checkout -b seq &&
index 73f4bb63465e50aa12de824859903e5293696a85..44309566f13431fe5e70f834b4cd6bb0a674624e 100755 (executable)
@@ -98,6 +98,16 @@ test_expect_success 'push from/to new branch with upstream, matching and simple'
        test_push_failure upstream
 '
 
+test_expect_success 'push ambiguously named branch with upstream, matching and simple' '
+       git checkout -b ambiguous &&
+       test_config branch.ambiguous.remote parent1 &&
+       test_config branch.ambiguous.merge refs/heads/ambiguous &&
+       git tag ambiguous &&
+       test_push_success simple ambiguous &&
+       test_push_success matching ambiguous &&
+       test_push_success upstream ambiguous
+'
+
 test_expect_success 'push from/to new branch with current creates remote branch' '
        test_config branch.new-branch.remote repo1 &&
        git checkout new-branch &&
index 198ce8475416be494fc023de3835828332da424d..1524ff5ba692d9c962ec51ef0c7948aca6ddf240 100755 (executable)
@@ -427,7 +427,31 @@ test_expect_success 'push unpushable submodule recursively fails' '
                cd submodule.git &&
                git rev-parse master >../actual
        ) &&
+       test_when_finished git -C work reset --hard master^ &&
        test_cmp expected actual
 '
 
+test_expect_success 'push --dry-run does not recursively update submodules' '
+       (
+               cd work/gar/bage &&
+               git checkout master &&
+               git rev-parse master >../../../expected_submodule &&
+               > junk9 &&
+               git add junk9 &&
+               git commit -m "Ninth junk" &&
+
+               # Go up to 'work' directory
+               cd ../.. &&
+               git checkout master &&
+               git rev-parse master >../expected_pub &&
+               git add gar/bage &&
+               git commit -m "Ninth commit for gar/bage" &&
+               git push --dry-run --recurse-submodules=on-demand ../pub.git master
+       ) &&
+       git -C submodule.git rev-parse master >actual_submodule &&
+       git -C pub.git rev-parse master >actual_pub &&
+       test_cmp expected_pub actual_pub &&
+       test_cmp expected_submodule actual_submodule
+'
+
 test_done
index 1e5d32d068539098598b23fb3b489688ac140169..af9fcd833a5e9e4997dd5cb917ac13f4b07f10ab 100755 (executable)
@@ -33,4 +33,29 @@ test_expect_success 'rejected objects are removed' '
        test_cmp expect actual
 '
 
+test_expect_success 'push to repo path with path separator (colon)' '
+       # The interesting failure case here is when the
+       # receiving end cannot access its original object directory,
+       # so make it likely for us to generate a delta by having
+       # a non-trivial file with multiple versions.
+
+       test-genrandom foo 4096 >file.bin &&
+       git add file.bin &&
+       git commit -m bin &&
+
+       if test_have_prereq MINGW
+       then
+               pathsep=";"
+       else
+               pathsep=":"
+       fi &&
+       git clone --bare . "xxx${pathsep}yyy.git" &&
+
+       echo change >>file.bin &&
+       git commit -am change &&
+       # Note that we have to use the full path here, or it gets confused
+       # with the ssh host:path syntax.
+       git push "$(pwd)/xxx${pathsep}yyy.git" HEAD
+'
+
 test_done
index 7641417b4a3848fa9d065572e5a8248fea5c7574..aeb3a63f7c07caa3f53ff4da5096dc51493dd4e3 100755 (executable)
@@ -307,5 +307,76 @@ test_expect_success 'remote-http complains cleanly about malformed urls' '
        test_must_fail git remote-http http::/example.com/repo.git
 '
 
+test_expect_success 'redirects can be forbidden/allowed' '
+       test_must_fail git -c http.followRedirects=false \
+               clone $HTTPD_URL/dumb-redir/repo.git dumb-redir &&
+       git -c http.followRedirects=true \
+               clone $HTTPD_URL/dumb-redir/repo.git dumb-redir 2>stderr
+'
+
+test_expect_success 'redirects are reported to stderr' '
+       # just look for a snippet of the redirected-to URL
+       test_i18ngrep /dumb/ stderr
+'
+
+test_expect_success 'non-initial redirects can be forbidden' '
+       test_must_fail git -c http.followRedirects=initial \
+               clone $HTTPD_URL/redir-objects/repo.git redir-objects &&
+       git -c http.followRedirects=true \
+               clone $HTTPD_URL/redir-objects/repo.git redir-objects
+'
+
+test_expect_success 'http.followRedirects defaults to "initial"' '
+       test_must_fail git clone $HTTPD_URL/redir-objects/repo.git default
+'
+
+# The goal is for a clone of the "evil" repository, which has no objects
+# itself, to cause the client to fetch objects from the "victim" repository.
+test_expect_success 'set up evil alternates scheme' '
+       victim=$HTTPD_DOCUMENT_ROOT_PATH/victim.git &&
+       git init --bare "$victim" &&
+       git -C "$victim" --work-tree=. commit --allow-empty -m secret &&
+       git -C "$victim" repack -ad &&
+       git -C "$victim" update-server-info &&
+       sha1=$(git -C "$victim" rev-parse HEAD) &&
+
+       evil=$HTTPD_DOCUMENT_ROOT_PATH/evil.git &&
+       git init --bare "$evil" &&
+       # do this by hand to avoid object existence check
+       printf "%s\\t%s\\n" $sha1 refs/heads/master >"$evil/info/refs"
+'
+
+# Here we'll just redirect via HTTP. In a real-world attack these would be on
+# different servers, but we should reject it either way.
+test_expect_success 'http-alternates is a non-initial redirect' '
+       echo "$HTTPD_URL/dumb/victim.git/objects" \
+               >"$evil/objects/info/http-alternates" &&
+       test_must_fail git -c http.followRedirects=initial \
+               clone $HTTPD_URL/dumb/evil.git evil-initial &&
+       git -c http.followRedirects=true \
+               clone $HTTPD_URL/dumb/evil.git evil-initial
+'
+
+# Curl supports a lot of protocols that we'd prefer not to allow
+# http-alternates to use, but it's hard to test whether curl has
+# accessed, say, the SMTP protocol, because we are not running an SMTP server.
+# But we can check that it does not allow access to file://, which would
+# otherwise allow this clone to complete.
+test_expect_success 'http-alternates cannot point at funny protocols' '
+       echo "file://$victim/objects" >"$evil/objects/info/http-alternates" &&
+       test_must_fail git -c http.followRedirects=true \
+               clone "$HTTPD_URL/dumb/evil.git" evil-file
+'
+
+test_expect_success 'http-alternates triggers not-from-user protocol check' '
+       echo "$HTTPD_URL/dumb/victim.git/objects" \
+               >"$evil/objects/info/http-alternates" &&
+       test_config_global http.followRedirects true &&
+       test_must_fail git -c protocol.http.allow=user \
+               clone $HTTPD_URL/dumb/evil.git evil-user &&
+       git -c protocol.http.allow=always \
+               clone $HTTPD_URL/dumb/evil.git evil-user
+'
+
 stop_httpd
 test_done
index 1ec5b2747a2100d3ae043cde5a2436eed2d52aec..a51b7e20d32158d4b6609ba954e2ed59edaa6342 100755 (executable)
@@ -119,6 +119,10 @@ test_expect_success 'redirects re-root further requests' '
        git clone $HTTPD_URL/smart-redir-limited/repo.git repo-redir-limited
 '
 
+test_expect_success 're-rooting dies on insane schemes' '
+       test_must_fail git clone $HTTPD_URL/insane-redir/repo.git insane
+'
+
 test_expect_success 'clone from password-protected repository' '
        echo two >expect &&
        set_askpass user@host pass@host &&
@@ -276,6 +280,58 @@ test_expect_success 'large fetch-pack requests can be split across POSTs' '
        test_line_count = 2 posts
 '
 
+test_expect_success 'test allowreachablesha1inwant' '
+       test_when_finished "rm -rf test_reachable.git" &&
+       server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       master_sha=$(git -C "$server" rev-parse refs/heads/master) &&
+       git -C "$server" config uploadpack.allowreachablesha1inwant 1 &&
+
+       git init --bare test_reachable.git &&
+       git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
+       git -C test_reachable.git fetch origin "$master_sha"
+'
+
+test_expect_success 'test allowreachablesha1inwant with unreachable' '
+       test_when_finished "rm -rf test_reachable.git; git reset --hard $(git rev-parse HEAD)" &&
+
+       #create unreachable sha
+       echo content >file2 &&
+       git add file2 &&
+       git commit -m two &&
+       git push public HEAD:refs/heads/doomed &&
+       git push public :refs/heads/doomed &&
+
+       server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       master_sha=$(git -C "$server" rev-parse refs/heads/master) &&
+       git -C "$server" config uploadpack.allowreachablesha1inwant 1 &&
+
+       git init --bare test_reachable.git &&
+       git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
+       test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
+'
+
+test_expect_success 'test allowanysha1inwant with unreachable' '
+       test_when_finished "rm -rf test_reachable.git; git reset --hard $(git rev-parse HEAD)" &&
+
+       #create unreachable sha
+       echo content >file2 &&
+       git add file2 &&
+       git commit -m two &&
+       git push public HEAD:refs/heads/doomed &&
+       git push public :refs/heads/doomed &&
+
+       server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       master_sha=$(git -C "$server" rev-parse refs/heads/master) &&
+       git -C "$server" config uploadpack.allowreachablesha1inwant 1 &&
+
+       git init --bare test_reachable.git &&
+       git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
+       test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
+
+       git -C "$server" config uploadpack.allowanysha1inwant 1 &&
+       git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
+'
+
 test_expect_success EXPENSIVE 'http can handle enormous ref negotiation' '
        (
                cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
index eec4137ca5b392743e29068f4fffae1ffb78d812..26ebb0375deb67be38974c7c5610f090a5a2a9aa 100755 (executable)
@@ -68,4 +68,22 @@ test_expect_success 'access alternate via relative path (subdir)' '
        EOF
 '
 
+# set variables outside test to avoid quote insanity; the \057 is '/',
+# which doesn't need quoting, but just confirms that de-quoting
+# is working.
+quoted='"one.git\057objects"'
+unquoted='two.git/objects'
+test_expect_success 'mix of quoted and unquoted alternates' '
+       check_obj "$quoted:$unquoted" <<-EOF
+       $one blob
+       $two blob
+'
+
+test_expect_success !MINGW 'broken quoting falls back to interpreting raw' '
+       mv one.git \"one.git &&
+       check_obj \"one.git/objects <<-EOF
+       $one blob
+       EOF
+'
+
 test_done
index b7a7f9d5886f1e2f3fc2d65bfcf1785b890638ac..c6c2661878c0ca8a22ad11e1229a664f3d009fee 100755 (executable)
@@ -4,6 +4,7 @@ test_description='ext::cmd remote "connect" helper'
 . ./test-lib.sh
 
 test_expect_success setup '
+       git config --global protocol.ext.allow user &&
        test_tick &&
        git commit --allow-empty -m initial &&
        test_tick &&
index 0d105d54174e061b20707de808b284314f730667..d911afd24cd7d43fc412adb34144b90b66082b73 100755 (executable)
@@ -18,6 +18,7 @@ test_proto "smart http" http "$HTTPD_URL/smart/repo.git"
 
 test_expect_success 'curl redirects respect whitelist' '
        test_must_fail env GIT_ALLOW_PROTOCOL=http:https \
+                          GIT_SMART_HTTP=0 \
                git clone "$HTTPD_URL/ftp-redir/repo.git" 2>stderr &&
        {
                test_i18ngrep "ftp.*disabled" stderr ||
@@ -29,5 +30,12 @@ test_expect_success 'curl limits redirects' '
        test_must_fail git clone "$HTTPD_URL/loop-redir/smart/repo.git"
 '
 
+test_expect_success 'http can be limited to from-user' '
+       git -c protocol.http.allow=user \
+               clone "$HTTPD_URL/smart/repo.git" plain.git &&
+       test_must_fail git -c protocol.http.allow=user \
+               clone "$HTTPD_URL/smart-redir-perm/repo.git" redir.git
+'
+
 stop_httpd
 test_done
index 64a9850e3197dc2cbff00593f04a5fa196dbd632..8c617981a3a06c1ff49f03a2914bfdc31c0e293c 100755 (executable)
@@ -83,12 +83,24 @@ test_expect_success 'final^1^@ = final^1^1 final^1^2' '
        test_cmp expect actual
 '
 
+test_expect_success 'symbolic final^1^@ = final^1^1 final^1^2' '
+       git rev-parse --symbolic final^1^1 final^1^2 >expect &&
+       git rev-parse --symbolic final^1^@ >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' '
        git rev-parse final^1 ^final^1^1 ^final^1^2 >expect &&
        git rev-parse final^1^! >actual &&
        test_cmp expect actual
 '
 
+test_expect_success 'symbolic final^1^! = final^1 ^final^1^1 ^final^1^2' '
+       git rev-parse --symbolic final^1 ^final^1^1 ^final^1^2 >expect &&
+       git rev-parse --symbolic final^1^! >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'large graft octopus' '
        test_cmp_rev_output b31 "git rev-parse --verify b1^30"
 '
@@ -143,6 +155,12 @@ test_expect_success 'rev-parse merge^-2 = merge^2..merge' '
        test_cmp expect actual
 '
 
+test_expect_success 'symbolic merge^-1 = merge^1..merge' '
+       git rev-parse --symbolic merge^1..merge >expect &&
+       git rev-parse --symbolic merge^-1 >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'rev-parse merge^-0 (invalid parent)' '
        test_must_fail git rev-parse merge^-0
 '
index 039509a9cb94ef5c653df09e0453ac83157bf184..aea1dfc7148e4885e52a579ca60ee622c49b5693 100755 (executable)
@@ -563,4 +563,29 @@ test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
        test_cmp expect actual
 '
 
+cat >trailers <<EOF
+Reviewed-by: A U Thor <author@example.com>
+Signed-off-by: A U Thor <author@example.com>
+EOF
+
+test_expect_success 'basic atom: head contents:trailers' '
+       echo "Some contents" > two &&
+       git add two &&
+       git commit -F - <<-EOF &&
+       trailers: this commit message has trailers
+
+       Some message contents
+
+       $(cat trailers)
+       EOF
+       git for-each-ref --format="%(contents:trailers)" refs/heads/master >actual &&
+       sanitize_pgp <actual >actual.clean &&
+       # git for-each-ref ends with a blank line
+       cat >expect <<-EOF &&
+       $(cat trailers)
+
+       EOF
+       test_cmp expect actual.clean
+'
+
 test_done
index 8b0f71a2ac15d65f977b0daa2a53ad47b64a043a..07869b0c09da1313dd5564c2318dc5d44818f3a9 100755 (executable)
@@ -27,6 +27,30 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
        test $(git tag | wc -l) -eq 0
 '
 
+test_expect_success 'sort tags, ignore case' '
+       (
+               git init sort &&
+               cd sort &&
+               test_commit initial &&
+               git tag tag-one &&
+               git tag TAG-two &&
+               git tag -l >actual &&
+               cat >expected <<-\EOF &&
+               TAG-two
+               initial
+               tag-one
+               EOF
+               test_cmp expected actual &&
+               git tag -l -i >actual &&
+               cat >expected <<-\EOF &&
+               initial
+               tag-one
+               TAG-two
+               EOF
+               test_cmp expected actual
+       )
+'
+
 test_expect_success 'looking for a tag in an empty tree should fail' \
        '! (tag_exists mytag)'
 
@@ -81,6 +105,9 @@ test_expect_success 'listing all tags if one exists should output that tag' '
 test_expect_success 'listing a tag using a matching pattern should succeed' \
        'git tag -l mytag'
 
+test_expect_success 'listing a tag with --ignore-case' \
+       'test $(git tag -l --ignore-case MYTAG) = mytag'
+
 test_expect_success \
        'listing a tag using a matching pattern should output that tag' \
        'test $(git tag -l mytag) = mytag'
index 1c1e289ffd982ab74ed80fb776b3ecc4d7abf2f1..e159fc5035d08eee2c1577afd2ac792ddce2934c 100755 (executable)
@@ -125,4 +125,70 @@ test_expect_success 'ignoring missing submodule alternates passes clone and subm
        )
 '
 
+test_expect_success 'preparing second superproject with a nested submodule plus partial clone' '
+       test_create_repo supersuper &&
+       (
+               cd supersuper &&
+               echo "I am super super." >file &&
+               git add file &&
+               git commit -m B-super-super-initial
+               git submodule add "file://$base_dir/super" subwithsub &&
+               git commit -m B-super-super-added &&
+               git submodule update --init --recursive &&
+               git repack -ad
+       ) &&
+       git clone supersuper supersuper2 &&
+       (
+               cd supersuper2 &&
+               git submodule update --init
+       )
+'
+
+# At this point there are three root-level positories: A, B, super and super2
+
+test_expect_success 'nested submodule alternate in works and is actually used' '
+       test_when_finished "rm -rf supersuper-clone" &&
+       git clone --recursive --reference supersuper supersuper supersuper-clone &&
+       (
+               cd supersuper-clone &&
+               # test superproject has alternates setup correctly
+               test_alternate_is_used .git/objects/info/alternates . &&
+               # immediate submodule has alternate:
+               test_alternate_is_used .git/modules/subwithsub/objects/info/alternates subwithsub &&
+               # nested submodule also has alternate:
+               test_alternate_is_used .git/modules/subwithsub/modules/sub/objects/info/alternates subwithsub/sub
+       )
+'
+
+check_that_two_of_three_alternates_are_used() {
+       test_alternate_is_used .git/objects/info/alternates . &&
+       # immediate submodule has alternate:
+       test_alternate_is_used .git/modules/subwithsub/objects/info/alternates subwithsub &&
+       # but nested submodule has no alternate:
+       test_must_fail test_alternate_is_used .git/modules/subwithsub/modules/sub/objects/info/alternates subwithsub/sub
+}
+
+
+test_expect_success 'missing nested submodule alternate fails clone and submodule update' '
+       test_when_finished "rm -rf supersuper-clone" &&
+       test_must_fail git clone --recursive --reference supersuper2 supersuper2 supersuper-clone &&
+       (
+               cd supersuper-clone &&
+               check_that_two_of_three_alternates_are_used &&
+               # update of the submodule fails
+               test_must_fail git submodule update --init --recursive
+       )
+'
+
+test_expect_success 'missing nested submodule alternate in --reference-if-able mode' '
+       test_when_finished "rm -rf supersuper-clone" &&
+       git clone --recursive --reference-if-able supersuper2 supersuper2 supersuper-clone &&
+       (
+               cd supersuper-clone &&
+               check_that_two_of_three_alternates_are_used &&
+               # update of the submodule succeeds
+               git submodule update --init --recursive
+       )
+'
+
 test_done
index 47562ce4654db9d763cdf0c6d6b91724489110ff..d389ae5408ab783467f64368adc01325e258046b 100755 (executable)
@@ -93,6 +93,20 @@ test_expect_success 'error message contains blob reference' '
        )
 '
 
+test_expect_success 'using different treeishs works' '
+       (
+               cd super &&
+               git tag new_tag &&
+               tree=$(git rev-parse HEAD^{tree}) &&
+               commit=$(git rev-parse HEAD^{commit}) &&
+               test-submodule-config $commit b >expect &&
+               test-submodule-config $tree b >actual.1 &&
+               test-submodule-config new_tag b >actual.2 &&
+               test_cmp expect actual.1 &&
+               test_cmp expect actual.2
+       )
+'
+
 cat >super/expect_url <<EOF
 Submodule url: 'git@somewhere.else.net:a.git' for path 'b'
 Submodule url: 'git@somewhere.else.net:submodule.git' for path 'submodule'
diff --git a/t/t7412-submodule-absorbgitdirs.sh b/t/t7412-submodule-absorbgitdirs.sh
new file mode 100755 (executable)
index 0000000..1c47780
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+test_description='Test submodule absorbgitdirs
+
+This test verifies that `git submodue absorbgitdirs` moves a submodules git
+directory into the superproject.
+'
+
+. ./test-lib.sh
+
+test_expect_success 'setup a real submodule' '
+       git init sub1 &&
+       test_commit -C sub1 first &&
+       git submodule add ./sub1 &&
+       test_tick &&
+       git commit -m superproject
+'
+
+test_expect_success 'absorb the git dir' '
+       >expect.1 &&
+       >expect.2 &&
+       >actual.1 &&
+       >actual.2 &&
+       git status >expect.1 &&
+       git -C sub1 rev-parse HEAD >expect.2 &&
+       git submodule absorbgitdirs &&
+       git fsck &&
+       test -f sub1/.git &&
+       test -d .git/modules/sub1 &&
+       git status >actual.1 &&
+       git -C sub1 rev-parse HEAD >actual.2 &&
+       test_cmp expect.1 actual.1 &&
+       test_cmp expect.2 actual.2
+'
+
+test_expect_success 'absorbing does not fail for deinitalized submodules' '
+       test_when_finished "git submodule update --init" &&
+       git submodule deinit --all &&
+       git submodule absorbgitdirs &&
+       test -d .git/modules/sub1 &&
+       test -d sub1 &&
+       ! test -e sub1/.git
+'
+
+test_expect_success 'setup nested submodule' '
+       git init sub1/nested &&
+       test_commit -C sub1/nested first_nested &&
+       git -C sub1 submodule add ./nested &&
+       test_tick &&
+       git -C sub1 commit -m "add nested" &&
+       git add sub1 &&
+       git commit -m "sub1 to include nested submodule"
+'
+
+test_expect_success 'absorb the git dir in a nested submodule' '
+       git status >expect.1 &&
+       git -C sub1/nested rev-parse HEAD >expect.2 &&
+       git submodule absorbgitdirs &&
+       test -f sub1/nested/.git &&
+       test -d .git/modules/sub1/modules/nested &&
+       git status >actual.1 &&
+       git -C sub1/nested rev-parse HEAD >actual.2 &&
+       test_cmp expect.1 actual.1 &&
+       test_cmp expect.2 actual.2
+'
+
+test_expect_success 'setup a gitlink with missing .gitmodules entry' '
+       git init sub2 &&
+       test_commit -C sub2 first &&
+       git add sub2 &&
+       git commit -m superproject
+'
+
+test_expect_success 'absorbing the git dir fails for incomplete submodules' '
+       git status >expect.1 &&
+       git -C sub2 rev-parse HEAD >expect.2 &&
+       test_must_fail git submodule absorbgitdirs &&
+       git -C sub2 fsck &&
+       test -d sub2/.git &&
+       git status >actual &&
+       git -C sub2 rev-parse HEAD >actual.2 &&
+       test_cmp expect.1 actual.1 &&
+       test_cmp expect.2 actual.2
+'
+
+test_expect_success 'setup a submodule with multiple worktrees' '
+       # first create another unembedded git dir in a new submodule
+       git init sub3 &&
+       test_commit -C sub3 first &&
+       git submodule add ./sub3 &&
+       test_tick &&
+       git commit -m "add another submodule" &&
+       git -C sub3 worktree add ../sub3_second_work_tree
+'
+
+test_expect_success 'absorbing fails for a submodule with multiple worktrees' '
+       test_must_fail git submodule absorbgitdirs sub3 2>error &&
+       test_i18ngrep "not supported" error
+'
+
+test_done
index d84897a67a3c365e280f88b36f43fc49e1ac9d7b..0b6da7ae1fd3d15f0d47783d3af50cb17d2c66df 100755 (executable)
@@ -155,6 +155,15 @@ test_expect_success 'amend --only ignores staged contents' '
        git diff --exit-code
 '
 
+test_expect_success 'allow-empty --only ignores staged contents' '
+       echo changed-again >file &&
+       git add file &&
+       git commit --allow-empty --only -m "empty" &&
+       git cat-file blob HEAD:file >file.actual &&
+       test_cmp file.expect file.actual &&
+       git diff --exit-code
+'
+
 test_expect_success 'set up editor' '
        cat >editor <<-\EOF &&
        #!/bin/sh
@@ -460,6 +469,42 @@ $alt" &&
        test_cmp expected actual
 '
 
+test_expect_success 'signoff respects trailer config' '
+
+       echo 5 >positive &&
+       git add positive &&
+       git commit -s -m "subject
+
+non-trailer line
+Myfooter: x" &&
+       git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+       (
+               echo subject
+               echo
+               echo non-trailer line
+               echo Myfooter: x
+               echo
+               echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+       ) >expected &&
+       test_cmp expected actual &&
+
+       echo 6 >positive &&
+       git add positive &&
+       git -c "trailer.Myfooter.ifexists=add" commit -s -m "subject
+
+non-trailer line
+Myfooter: x" &&
+       git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+       (
+               echo subject
+               echo
+               echo non-trailer line
+               echo Myfooter: x
+               echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+       ) >expected &&
+       test_cmp expected actual
+'
+
 test_expect_success 'multiple -m' '
 
        >negative &&
index 85248a14b61d68b61932d595eb0fa8fcaa8506b1..2ebda509ac337f99c7ab5651734a5b20d4a0b6f4 100755 (executable)
@@ -154,6 +154,10 @@ test_expect_success 'test option parsing' '
        test_must_fail git merge -s foobar c1 &&
        test_must_fail git merge -s=foobar c1 &&
        test_must_fail git merge -m &&
+       test_must_fail git merge --abort foobar &&
+       test_must_fail git merge --abort --quiet &&
+       test_must_fail git merge --continue foobar &&
+       test_must_fail git merge --continue --quiet &&
        test_must_fail git merge
 '
 
@@ -763,4 +767,11 @@ test_expect_success 'merge nothing into void' '
        )
 '
 
+test_expect_success 'merge can be completed with --continue' '
+       git reset --hard c0 &&
+       git merge --no-ff --no-commit c1 &&
+       git merge --continue &&
+       verify_parents $c0 $c1
+'
+
 test_done
index f80bdb81e1f12124e32d5cd2c5c0ecdcd82dc782..e90413204ee32cafc3380244a5cf013eadcd72c1 100755 (executable)
@@ -105,7 +105,7 @@ test_expect_success 'not uptodate file porcelain checkout error' '
 '
 
 cat >expect <<\EOF
-error: Updating the following directories would lose untracked files in it:
+error: Updating the following directories would lose untracked files in them:
        rep
        rep2
 
index 6d9f21511fe1062565d8d08f60c385cffd94cac6..63d36fb28e44426708a743979c4bc341bdac714e 100755 (executable)
@@ -591,7 +591,8 @@ test_expect_success 'filenames seen by tools start with ./' '
 
 test_lazy_prereq MKTEMP '
        tempdir=$(mktemp -d -t foo.XXXXXX) &&
-       test -d "$tempdir"
+       test -d "$tempdir" &&
+       rmdir "$tempdir"
 '
 
 test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
index 70a2de461af58119f507a915104ba139dd0245df..99d4123461096196c11368864c1f8c3d524d5c1a 100755 (executable)
@@ -374,6 +374,7 @@ test_expect_success PERL 'setup change in subdirectory' '
        echo master >sub/sub &&
        git add sub/sub &&
        git commit -m "added sub/sub" &&
+       git tag v1 &&
        echo test >>file &&
        echo test >>sub/sub &&
        git add file sub/sub &&
@@ -409,12 +410,49 @@ run_dir_diff_test 'difftool --dir-diff ignores --prompt' '
        grep file output
 '
 
-run_dir_diff_test 'difftool --dir-diff from subdirectory' '
+run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
        (
                cd sub &&
                git difftool --dir-diff $symlinks --extcmd ls branch >output &&
-               grep sub output &&
-               grep file output
+               # "sub" must only exist in "right"
+               # "file" and "file2" must be listed in both "left" and "right"
+               test "1" = $(grep sub output | wc -l) &&
+               test "2" = $(grep file"$" output | wc -l) &&
+               test "2" = $(grep file2 output | wc -l)
+       )
+'
+
+run_dir_diff_test 'difftool --dir-diff v1 from subdirectory' '
+       (
+               cd sub &&
+               git difftool --dir-diff $symlinks --extcmd ls v1 >output &&
+               # "sub" and "file" exist in both v1 and HEAD.
+               # "file2" is unchanged.
+               test "2" = $(grep sub output | wc -l) &&
+               test "2" = $(grep file output | wc -l) &&
+               test "0" = $(grep file2 output | wc -l)
+       )
+'
+
+run_dir_diff_test 'difftool --dir-diff branch from subdirectory w/ pathspec' '
+       (
+               cd sub &&
+               git difftool --dir-diff $symlinks --extcmd ls branch -- .>output &&
+               # "sub" only exists in "right"
+               # "file" and "file2" must not be listed
+               test "1" = $(grep sub output | wc -l) &&
+               test "0" = $(grep file output | wc -l)
+       )
+'
+
+run_dir_diff_test 'difftool --dir-diff v1 from subdirectory w/ pathspec' '
+       (
+               cd sub &&
+               git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output &&
+               # "sub" exists in v1 and HEAD
+               # "file" is filtered out by the pathspec
+               test "2" = $(grep sub output | wc -l) &&
+               test "0" = $(grep file output | wc -l)
        )
 '
 
diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh
new file mode 100755 (executable)
index 0000000..67247a0
--- /dev/null
@@ -0,0 +1,241 @@
+#!/bin/sh
+
+test_description='Test grep recurse-submodules feature
+
+This test verifies the recurse-submodules feature correctly greps across
+submodules.
+'
+
+. ./test-lib.sh
+
+test_expect_success 'setup directory structure and submodule' '
+       echo "foobar" >a &&
+       mkdir b &&
+       echo "bar" >b/b &&
+       git add a b &&
+       git commit -m "add a and b" &&
+       git init submodule &&
+       echo "foobar" >submodule/a &&
+       git -C submodule add a &&
+       git -C submodule commit -m "add a" &&
+       git submodule add ./submodule &&
+       git commit -m "added submodule"
+'
+
+test_expect_success 'grep correctly finds patterns in a submodule' '
+       cat >expect <<-\EOF &&
+       a:foobar
+       b/b:bar
+       submodule/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep and basic pathspecs' '
+       cat >expect <<-\EOF &&
+       submodule/a:foobar
+       EOF
+
+       git grep -e. --recurse-submodules -- submodule >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep and nested submodules' '
+       git init submodule/sub &&
+       echo "foobar" >submodule/sub/a &&
+       git -C submodule/sub add a &&
+       git -C submodule/sub commit -m "add a" &&
+       git -C submodule submodule add ./sub &&
+       git -C submodule add sub &&
+       git -C submodule commit -m "added sub" &&
+       git add submodule &&
+       git commit -m "updated submodule" &&
+
+       cat >expect <<-\EOF &&
+       a:foobar
+       b/b:bar
+       submodule/a:foobar
+       submodule/sub/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep and multiple patterns' '
+       cat >expect <<-\EOF &&
+       a:foobar
+       submodule/a:foobar
+       submodule/sub/a:foobar
+       EOF
+
+       git grep -e "bar" --and -e "foo" --recurse-submodules >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep and multiple patterns' '
+       cat >expect <<-\EOF &&
+       b/b:bar
+       EOF
+
+       git grep -e "bar" --and --not -e "foo" --recurse-submodules >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'basic grep tree' '
+       cat >expect <<-\EOF &&
+       HEAD:a:foobar
+       HEAD:b/b:bar
+       HEAD:submodule/a:foobar
+       HEAD:submodule/sub/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep tree HEAD^' '
+       cat >expect <<-\EOF &&
+       HEAD^:a:foobar
+       HEAD^:b/b:bar
+       HEAD^:submodule/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD^ >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep tree HEAD^^' '
+       cat >expect <<-\EOF &&
+       HEAD^^:a:foobar
+       HEAD^^:b/b:bar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD^^ >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep tree and pathspecs' '
+       cat >expect <<-\EOF &&
+       HEAD:submodule/a:foobar
+       HEAD:submodule/sub/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD -- submodule >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep tree and pathspecs' '
+       cat >expect <<-\EOF &&
+       HEAD:submodule/a:foobar
+       HEAD:submodule/sub/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD -- "submodule*a" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep tree and more pathspecs' '
+       cat >expect <<-\EOF &&
+       HEAD:submodule/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD -- "submodul?/a" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep tree and more pathspecs' '
+       cat >expect <<-\EOF &&
+       HEAD:submodule/sub/a:foobar
+       EOF
+
+       git grep -e "bar" --recurse-submodules HEAD -- "submodul*/sub/a" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success !MINGW 'grep recurse submodule colon in name' '
+       git init parent &&
+       test_when_finished "rm -rf parent" &&
+       echo "foobar" >"parent/fi:le" &&
+       git -C parent add "fi:le" &&
+       git -C parent commit -m "add fi:le" &&
+
+       git init "su:b" &&
+       test_when_finished "rm -rf su:b" &&
+       echo "foobar" >"su:b/fi:le" &&
+       git -C "su:b" add "fi:le" &&
+       git -C "su:b" commit -m "add fi:le" &&
+
+       git -C parent submodule add "../su:b" "su:b" &&
+       git -C parent commit -m "add submodule" &&
+
+       cat >expect <<-\EOF &&
+       fi:le:foobar
+       su:b/fi:le:foobar
+       EOF
+       git -C parent grep -e "foobar" --recurse-submodules >actual &&
+       test_cmp expect actual &&
+
+       cat >expect <<-\EOF &&
+       HEAD:fi:le:foobar
+       HEAD:su:b/fi:le:foobar
+       EOF
+       git -C parent grep -e "foobar" --recurse-submodules HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep history with moved submoules' '
+       git init parent &&
+       test_when_finished "rm -rf parent" &&
+       echo "foobar" >parent/file &&
+       git -C parent add file &&
+       git -C parent commit -m "add file" &&
+
+       git init sub &&
+       test_when_finished "rm -rf sub" &&
+       echo "foobar" >sub/file &&
+       git -C sub add file &&
+       git -C sub commit -m "add file" &&
+
+       git -C parent submodule add ../sub dir/sub &&
+       git -C parent commit -m "add submodule" &&
+
+       cat >expect <<-\EOF &&
+       dir/sub/file:foobar
+       file:foobar
+       EOF
+       git -C parent grep -e "foobar" --recurse-submodules >actual &&
+       test_cmp expect actual &&
+
+       git -C parent mv dir/sub sub-moved &&
+       git -C parent commit -m "moved submodule" &&
+
+       cat >expect <<-\EOF &&
+       file:foobar
+       sub-moved/file:foobar
+       EOF
+       git -C parent grep -e "foobar" --recurse-submodules >actual &&
+       test_cmp expect actual &&
+
+       cat >expect <<-\EOF &&
+       HEAD^:dir/sub/file:foobar
+       HEAD^:file:foobar
+       EOF
+       git -C parent grep -e "foobar" --recurse-submodules HEAD^ >actual &&
+       test_cmp expect actual
+'
+
+test_incompatible_with_recurse_submodules ()
+{
+       test_expect_success "--recurse-submodules and $1 are incompatible" "
+               test_must_fail git grep -e. --recurse-submodules $1 2>actual &&
+               test_i18ngrep 'not supported with --recurse-submodules' actual
+       "
+}
+
+test_incompatible_with_recurse_submodules --untracked
+test_incompatible_with_recurse_submodules --no-index
+
+test_done
index 92a3aa8063f810bd2b8df68f3f0f30c2faf3bdc6..8a8ba65a2ae583aa5d0b0526e604a8f9613b5a5e 100755 (executable)
@@ -17,25 +17,12 @@ case "$GIT_SVN_LC_ALL" in
        ;;
 esac
 
-deepdir=nothing-above
-ceiling=$PWD
-
 test_expect_success 'git svn --version works anywhere' '
-       mkdir -p "$deepdir" && (
-               GIT_CEILING_DIRECTORIES="$ceiling" &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd "$deepdir" &&
-               git svn --version
-       )
+       nongit git svn --version
 '
 
 test_expect_success 'git svn help works anywhere' '
-       mkdir -p "$deepdir" && (
-               GIT_CEILING_DIRECTORIES="$ceiling" &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd "$deepdir" &&
-               git svn help
-       )
+       nongit git svn help
 '
 
 test_expect_success \
index 83acf68bc3c19770eb690ece139892ca75329216..dadc70b7d5705d11437d40a701dd5079247e6357 100755 (executable)
@@ -483,6 +483,48 @@ test_expect_success 'verify that lots of notes trigger a fanout scheme' '
 
 '
 
+# Create another notes tree from the one above
+SP=" "
+cat >>input <<INPUT_END
+commit refs/heads/other_commits
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+commit #$(($num_commit + 1))
+COMMIT
+
+from refs/heads/many_commits
+M 644 inline file
+data <<EOF
+file contents in commit #$(($num_commit + 1))
+EOF
+
+commit refs/notes/other_notes
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+committing one more note on a tree imported from a previous notes tree
+COMMIT
+
+M 040000 $(git log --no-walk --format=%T refs/notes/many_notes)$SP
+N inline :$(($num_commit + 1))
+data <<EOF
+note for commit #$(($num_commit + 1))
+EOF
+INPUT_END
+
+test_expect_success 'verify that importing a notes tree respects the fanout scheme' '
+       git fast-import <input &&
+
+       # None of the entries in the top-level notes tree should be a full SHA1
+       git ls-tree --name-only refs/notes/other_notes |
+       while read path
+       do
+               if test $(expr length "$path") -ge 40
+               then
+                       return 1
+               fi
+       done
+'
+
 cat >>expect_non-note1 << EOF
 This is not a note, but rather a regular file residing in a notes tree
 EOF
diff --git a/t/t9303-fast-import-compression.sh b/t/t9303-fast-import-compression.sh
new file mode 100755 (executable)
index 0000000..856219f
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+test_description='compression setting of fast-import utility'
+. ./test-lib.sh
+
+# This should be moved to test-lib.sh together with the
+# copy in t0021 after both topics have graduated to 'master'.
+file_size () {
+       perl -e 'print -s $ARGV[0]' "$1"
+}
+
+import_large () {
+       (
+               echo blob
+               echo "data <<EOD"
+               printf "%2000000s\n" "$*"
+               echo EOD
+       ) | git "$@" fast-import
+}
+
+while read expect config
+do
+       test_expect_success "fast-import (packed) with $config" '
+               test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
+               test_when_finished "rm -rf .git/objects/??" &&
+               import_large -c fastimport.unpacklimit=0 $config &&
+               sz=$(file_size .git/objects/pack/pack-*.pack) &&
+               case "$expect" in
+               small) test "$sz" -le 100000 ;;
+               large) test "$sz" -ge 100000 ;;
+               esac
+       '
+done <<\EOF
+large -c core.compression=0
+small -c core.compression=9
+large -c core.compression=0 -c pack.compression=0
+large -c core.compression=9 -c pack.compression=0
+small -c core.compression=0 -c pack.compression=9
+small -c core.compression=9 -c pack.compression=9
+large -c pack.compression=0
+small -c pack.compression=9
+EOF
+
+while read expect config
+do
+       test_expect_success "fast-import (loose) with $config" '
+               test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
+               test_when_finished "rm -rf .git/objects/??" &&
+               import_large -c fastimport.unpacklimit=9 $config &&
+               sz=$(file_size .git/objects/??/????*) &&
+               case "$expect" in
+               small) test "$sz" -le 100000 ;;
+               large) test "$sz" -ge 100000 ;;
+               esac
+       '
+done <<\EOF
+large -c core.compression=0
+small -c core.compression=9
+large -c core.compression=0 -c core.loosecompression=0
+large -c core.compression=9 -c core.loosecompression=0
+small -c core.compression=0 -c core.loosecompression=9
+small -c core.compression=9 -c core.loosecompression=9
+large -c core.loosecompression=0
+small -c core.loosecompression=9
+EOF
+
+test_done
index 0730f18d0f83f4145c5a0dbfde784d71bdc57a1d..4849edc4ef6733b8cf42950b3cd5fe809a80cdde 100755 (executable)
@@ -131,6 +131,26 @@ test_expect_success 'clone two dirs, @all, conflicting files' '
        )
 '
 
+test_expect_success 'clone two dirs, each edited by submit, single git commit' '
+       (
+               cd "$cli" &&
+               echo sub1/f4 >sub1/f4 &&
+               p4 add sub1/f4 &&
+               echo sub2/f4 >sub2/f4 &&
+               p4 add sub2/f4 &&
+               p4 submit -d "sub1/f4 and sub2/f4"
+       ) &&
+       git p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git ls-files >lines &&
+               test_line_count = 4 lines &&
+               git log --oneline p4/master >lines &&
+               test_line_count = 5 lines
+       )
+'
+
 revision_ranges="2000/01/01,#head \
                 1,2080/01/01 \
                 2000/01/01,2080/01/01 \
@@ -147,7 +167,7 @@ test_expect_success 'clone using non-numeric revision ranges' '
                (
                        cd "$git" &&
                        git ls-files >lines &&
-                       test_line_count = 6 lines
+                       test_line_count = 8 lines
                )
        done
 '
@@ -257,6 +277,26 @@ test_expect_success 'submit from detached head' '
        )
 '
 
+test_expect_success 'submit from worktree' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$git" &&
+               git worktree add ../worktree-test
+       ) &&
+       (
+               cd "$git/../worktree-test" &&
+               test_commit "worktree-commit" &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit
+       ) &&
+       (
+               cd "$cli" &&
+               p4 sync &&
+               test_path_is_file worktree-commit.t
+       )
+'
+
 test_expect_success 'kill p4d' '
        kill_p4d
 '
index 254d428b73fe4983298f57e0d87405002abdfbc2..1ab76c4246f215cfc0082bdbfd090e1622362140 100755 (executable)
@@ -269,6 +269,38 @@ test_expect_success 'submit works with two branches' '
        )
 '
 
+test_expect_success 'use --git-dir option and GIT_DIR' '
+       test_when_finished cleanup_git &&
+       git p4 clone //depot --destination="$git" &&
+       (
+               cd "$git" &&
+               git config git-p4.skipSubmitEdit true &&
+               test_commit first-change &&
+               git p4 submit --git-dir "$git"
+       ) &&
+       (
+               cd "$cli" &&
+               p4 sync &&
+               test_path_is_file first-change.t &&
+               echo "cli_file" >cli_file.t &&
+               p4 add cli_file.t &&
+               p4 submit -d "cli change"
+       ) &&
+       (git --git-dir "$git" p4 sync) &&
+       (cd "$git" && git checkout -q p4/master) &&
+       test_path_is_file "$git"/cli_file.t &&
+       (
+               cd "$cli" &&
+               echo "cli_file2" >cli_file2.t &&
+               p4 add cli_file2.t  &&
+               p4 submit -d "cli change2"
+       ) &&
+       (GIT_DIR="$git" git p4 sync) &&
+       (cd "$git" && git checkout -q p4/master) &&
+       test_path_is_file "$git"/cli_file2.t
+'
+
+
 test_expect_success 'kill p4d' '
        kill_p4d
 '
index 593152817dadaf1804f4a851c51b8bf1cbf52db9..e37239e657964e948e51e5ac186f5fdf4fab6003 100755 (executable)
@@ -413,6 +413,75 @@ test_expect_success 'submit --prepare-p4-only' '
        )
 '
 
+test_expect_success 'submit --shelve' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$cli" &&
+               p4 revert ... &&
+               cd "$git" &&
+               git config git-p4.skipSubmitEdit true &&
+               test_commit "shelveme1" &&
+               git p4 submit --origin=HEAD^ &&
+
+               echo 654321 >shelveme2.t &&
+               echo 123456 >>shelveme1.t &&
+               git add shelveme* &&
+               git commit -m"shelvetest" &&
+               git p4 submit --shelve --origin=HEAD^ &&
+
+               test_path_is_file shelveme1.t &&
+               test_path_is_file shelveme2.t
+       ) &&
+       (
+               cd "$cli" &&
+               change=$(p4 -G changes -s shelved -m 1 //depot/... | \
+                        marshal_dump change) &&
+               p4 describe -S $change | grep shelveme2 &&
+               p4 describe -S $change | grep 123456 &&
+               test_path_is_file shelveme1.t &&
+               test_path_is_missing shelveme2.t
+       )
+'
+
+# Update an existing shelved changelist
+
+test_expect_success 'submit --update-shelve' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$cli" &&
+               p4 revert ... &&
+               cd "$git" &&
+               git config git-p4.skipSubmitEdit true &&
+               test_commit "test-update-shelved-change" &&
+               git p4 submit --origin=HEAD^ --shelve &&
+
+               shelf_cl=$(p4 -G changes -s shelved -m 1 |\
+                       marshal_dump change) &&
+               test -n $shelf_cl &&
+               echo "updating shelved change list $shelf_cl" &&
+
+               echo "updated-line" >>shelf.t &&
+               echo added-file.t >added-file.t &&
+               git add shelf.t added-file.t &&
+               git rm -f test-update-shelved-change.t &&
+               git commit --amend -C HEAD &&
+               git show --stat HEAD &&
+               git p4 submit -v --origin HEAD^ --update-shelve $shelf_cl &&
+               echo "done git p4 submit"
+       ) &&
+       (
+               cd "$cli" &&
+               change=$(p4 -G changes -s shelved -m 1 //depot/... | \
+                        marshal_dump change) &&
+               p4 unshelve -c $change -s $change &&
+               grep -q updated-line shelf.t &&
+               p4 describe -S $change | grep added-file.t &&
+               test_path_is_missing test-update-shelved-change.t
+       )
+'
+
 test_expect_success 'kill p4d' '
        kill_p4d
 '
index 110a7e792475fcf19ef782fae1d265ae81653853..ed80ca858c8f8352bd5a26b9a30e0c182d102ee9 100755 (executable)
@@ -42,6 +42,8 @@ test_expect_success 'Create repo with binary files' '
        (
                cd "$cli" &&
 
+               >file0.dat &&
+               p4 add file0.dat &&
                echo "content 1 txt 23 bytes" >file1.txt &&
                p4 add file1.txt &&
                echo "content 2-3 bin 25 bytes" >file2.dat &&
@@ -81,9 +83,9 @@ test_expect_success 'Store files in LFS based on size (>24 bytes)' '
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               /file2.dat filter=lfs -text
-               /file4.bin filter=lfs -text
-               /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
+               /file2.dat filter=lfs diff=lfs merge=lfs -text
+               /file4.bin filter=lfs diff=lfs merge=lfs -text
+               /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
@@ -109,7 +111,7 @@ test_expect_success 'Store files in LFS based on size (>25 bytes)' '
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               /file4.bin filter=lfs -text
+               /file4.bin filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
@@ -135,7 +137,7 @@ test_expect_success 'Store files in LFS based on extension (dat)' '
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               *.dat filter=lfs -text
+               *.dat filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
@@ -163,8 +165,8 @@ test_expect_success 'Store files in LFS based on size (>25 bytes) and extension
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               *.dat filter=lfs -text
-               /file4.bin filter=lfs -text
+               *.dat filter=lfs diff=lfs merge=lfs -text
+               /file4.bin filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
@@ -199,8 +201,8 @@ test_expect_success 'Remove file from repo and store files in LFS based on size
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               /file2.dat filter=lfs -text
-               /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
+               /file2.dat filter=lfs diff=lfs merge=lfs -text
+               /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
@@ -237,8 +239,8 @@ test_expect_success 'Add .gitattributes and store files in LFS based on size (>2
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               /file2.dat filter=lfs -text
-               /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
+               /file2.dat filter=lfs diff=lfs merge=lfs -text
+               /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
@@ -278,7 +280,7 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
                #
                # Git LFS (see https://git-lfs.github.com/)
                #
-               /file6.bin filter=lfs -text
+               /file6.bin filter=lfs diff=lfs merge=lfs -text
                EOF
                test_path_is_file .gitattributes &&
                test_cmp expect .gitattributes
diff --git a/t/t9830-git-p4-symlink-dir.sh b/t/t9830-git-p4-symlink-dir.sh
new file mode 100755 (executable)
index 0000000..3dc528b
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='git p4 symlinked directories'
+
+. ./lib-git-p4.sh
+
+test_expect_success 'start p4d' '
+       start_p4d
+'
+
+test_expect_success 'symlinked directory' '
+       (
+               cd "$cli" &&
+               : >first_file.t &&
+               p4 add first_file.t &&
+               p4 submit -d "first change"
+       ) &&
+       git p4 clone --dest "$git" //depot &&
+       (
+               cd "$git" &&
+               mkdir -p some/sub/directory &&
+               mkdir -p other/subdir2 &&
+               : > other/subdir2/file.t &&
+               (cd some/sub/directory && ln -s ../../../other/subdir2 .) &&
+               git add some other &&
+               git commit -m "symlinks" &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit -v
+       ) &&
+       (
+               cd "$cli" &&
+               p4 sync &&
+               test -L some/sub/directory/subdir2
+               test_path_is_file some/sub/directory/subdir2/file.t
+       )
+
+'
+
+test_expect_success 'kill p4d' '
+       kill_p4d
+'
+
+test_done
index 2ba62fbc178e1c92dff493beebdc9683b36efd2a..a34e55f874ca06da4cae6ab5d46bc3263c58d521 100755 (executable)
@@ -257,12 +257,7 @@ test_expect_success SYMLINKS '__gitdir - resulting path avoids symlinks' '
 '
 
 test_expect_success '__gitdir - not a git repository' '
-       (
-               cd subdir/subsubdir &&
-               GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY" &&
-               export GIT_CEILING_DIRECTORIES &&
-               test_must_fail __gitdir
-       )
+       nongit test_must_fail __gitdir
 '
 
 test_expect_success '__gitcomp - trailing space - options' '
index fdaeb3a96bed361f53030cb6ea5c6bdde445163f..bd357704cce987afa79ec8fce038aa05f8c0a762 100644 (file)
@@ -157,16 +157,21 @@ debug () {
         GIT_TEST_GDB=1 "$@"
 }
 
-# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
+# Call test_commit with the arguments
+# [-C <directory>] <message> [<file> [<contents> [<tag>]]]"
 #
 # This will commit a file with the given contents and the given commit
 # message, and tag the resulting commit with the given tag name.
 #
 # <file>, <contents>, and <tag> all default to <message>.
+#
+# If the first argument is "-C", the second argument is used as a path for
+# the git invocations.
 
 test_commit () {
        notick= &&
        signoff= &&
+       indir= &&
        while test $# != 0
        do
                case "$1" in
@@ -176,21 +181,26 @@ test_commit () {
                --signoff)
                        signoff="$1"
                        ;;
+               -C)
+                       indir="$2"
+                       shift
+                       ;;
                *)
                        break
                        ;;
                esac
                shift
        done &&
+       indir=${indir:+"$indir"/} &&
        file=${2:-"$1.t"} &&
-       echo "${3-$1}" > "$file" &&
-       git add "$file" &&
+       echo "${3-$1}" > "$indir$file" &&
+       git ${indir:+ -C "$indir"} add "$file" &&
        if test -z "$notick"
        then
                test_tick
        fi &&
-       git commit $signoff -m "$1" &&
-       git tag "${4:-$1}"
+       git ${indir:+ -C "$indir"} commit $signoff -m "$1" &&
+       git ${indir:+ -C "$indir"} tag "${4:-$1}"
 }
 
 # Call test_merge with the arguments "<message> <commit>", where <commit>
@@ -994,3 +1004,17 @@ test_copy_bytes () {
                }
        ' - "$1"
 }
+
+# run "$@" inside a non-git directory
+nongit () {
+       test -d non-repo ||
+       mkdir non-repo ||
+       return 1
+
+       (
+               GIT_CEILING_DIRECTORIES=$(pwd) &&
+               export GIT_CEILING_DIRECTORIES &&
+               cd non-repo &&
+               "$@"
+       )
+}
index 64435f23a483dfc40e91437f0689bdfb9ac4b8f8..b2d9280f104aec7095dd2b37ff1f7165355b5388 100644 (file)
@@ -5,6 +5,7 @@
 #include "string-list.h"
 #include "strbuf.h"
 #include "argv-array.h"
+#include "quote.h"
 
 struct tmp_objdir {
        struct strbuf path;
@@ -79,12 +80,27 @@ static void remove_tmp_objdir_on_signal(int signo)
  */
 static void env_append(struct argv_array *env, const char *key, const char *val)
 {
-       const char *old = getenv(key);
+       struct strbuf quoted = STRBUF_INIT;
+       const char *old;
 
+       /*
+        * Avoid quoting if it's not necessary, for maximum compatibility
+        * with older parsers which don't understand the quoting.
+        */
+       if (*val == '"' || strchr(val, PATH_SEP)) {
+               strbuf_addch(&quoted, '"');
+               quote_c_style(val, &quoted, NULL, 1);
+               strbuf_addch(&quoted, '"');
+               val = quoted.buf;
+       }
+
+       old = getenv(key);
        if (!old)
                argv_array_pushf(env, "%s=%s", key, val);
        else
                argv_array_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val);
+
+       strbuf_release(&quoted);
 }
 
 static void env_replace(struct argv_array *env, const char *key, const char *val)
index f0ecde2d2f8b35c565ab176c76882a5fee8d8fb2..11f0b9fb40bcedbfcd3111fa8076ce0d9e1eb20f 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -46,6 +46,8 @@ static LIST_HEAD(conf_head);
 
 static char *separators = ":";
 
+static int configured;
+
 #define TRAILER_ARG_STRING "$ARG"
 
 static const char *git_generated_prefixes[] = {
@@ -102,12 +104,12 @@ static int same_trailer(struct trailer_item *a, struct arg_item *b)
        return same_token(a, b) && same_value(a, b);
 }
 
-static inline int contains_only_spaces(const char *str)
+static inline int is_blank_line(const char *str)
 {
        const char *s = str;
-       while (*s && isspace(*s))
+       while (*s && *s != '\n' && isspace(*s))
                s++;
-       return !*s;
+       return !*s || *s == '\n';
 }
 
 static inline void strbuf_replace(struct strbuf *sb, const char *a, const char *b)
@@ -546,6 +548,17 @@ static int git_trailer_config(const char *conf_key, const char *value, void *cb)
        return 0;
 }
 
+static void ensure_configured(void)
+{
+       if (configured)
+               return;
+
+       /* Default config must be setup first */
+       git_config(git_trailer_default_config, NULL);
+       git_config(git_trailer_config, NULL);
+       configured = 1;
+}
+
 static const char *token_from_item(struct arg_item *item, char *tok)
 {
        if (item->conf.key)
@@ -563,15 +576,32 @@ static int token_matches_item(const char *tok, struct arg_item *item, int tok_le
 }
 
 /*
- * Return the location of the first separator in line, or -1 if there is no
- * separator.
+ * If the given line is of the form
+ * "<token><optional whitespace><separator>..." or "<separator>...", return the
+ * location of the separator. Otherwise, return -1.  The optional whitespace
+ * is allowed there primarily to allow things like "Bug #43" where <token> is
+ * "Bug" and <separator> is "#".
+ *
+ * The separator-starts-line case (in which this function returns 0) is
+ * distinguished from the non-well-formed-line case (in which this function
+ * returns -1) because some callers of this function need such a distinction.
  */
 static int find_separator(const char *line, const char *separators)
 {
-       int loc = strcspn(line, separators);
-       if (!line[loc])
-               return -1;
-       return loc;
+       int whitespace_found = 0;
+       const char *c;
+       for (c = line; *c; c++) {
+               if (strchr(separators, *c))
+                       return c - line;
+               if (!whitespace_found && (isalnum(*c) || *c == '-'))
+                       continue;
+               if (c != line && (*c == ' ' || *c == '\t')) {
+                       whitespace_found = 1;
+                       continue;
+               }
+               break;
+       }
+       return -1;
 }
 
 /*
@@ -685,51 +715,71 @@ static void process_command_line_args(struct list_head *arg_head,
        free(cl_separators);
 }
 
-static struct strbuf **read_input_file(const char *file)
+static void read_input_file(struct strbuf *sb, const char *file)
 {
-       struct strbuf **lines;
-       struct strbuf sb = STRBUF_INIT;
-
        if (file) {
-               if (strbuf_read_file(&sb, file, 0) < 0)
+               if (strbuf_read_file(sb, file, 0) < 0)
                        die_errno(_("could not read input file '%s'"), file);
        } else {
-               if (strbuf_read(&sb, fileno(stdin), 0) < 0)
+               if (strbuf_read(sb, fileno(stdin), 0) < 0)
                        die_errno(_("could not read from stdin"));
        }
+}
 
-       lines = strbuf_split(&sb, '\n');
+static const char *next_line(const char *str)
+{
+       const char *nl = strchrnul(str, '\n');
+       return nl + !!*nl;
+}
 
-       strbuf_release(&sb);
+/*
+ * Return the position of the start of the last line. If len is 0, return -1.
+ */
+static int last_line(const char *buf, size_t len)
+{
+       int i;
+       if (len == 0)
+               return -1;
+       if (len == 1)
+               return 0;
+       /*
+        * Skip the last character (in addition to the null terminator),
+        * because if the last character is a newline, it is considered as part
+        * of the last line anyway.
+        */
+       i = len - 2;
 
-       return lines;
+       for (; i >= 0; i--) {
+               if (buf[i] == '\n')
+                       return i + 1;
+       }
+       return 0;
 }
 
 /*
- * Return the (0 based) index of the start of the patch or the line
- * count if there is no patch in the message.
+ * Return the position of the start of the patch or the length of str if there
+ * is no patch in the message.
  */
-static int find_patch_start(struct strbuf **lines, int count)
+static int find_patch_start(const char *str)
 {
-       int i;
+       const char *s;
 
-       /* Get the start of the patch part if any */
-       for (i = 0; i < count; i++) {
-               if (starts_with(lines[i]->buf, "---"))
-                       return i;
+       for (s = str; *s; s = next_line(s)) {
+               if (starts_with(s, "---"))
+                       return s - str;
        }
 
-       return count;
+       return s - str;
 }
 
 /*
- * Return the (0 based) index of the first trailer line or count if
- * there are no trailers. Trailers are searched only in the lines from
- * index (count - 1) down to index 0.
+ * Return the position of the first trailer line or len if there are no
+ * trailers.
  */
-static int find_trailer_start(struct strbuf **lines, int count)
+static int find_trailer_start(const char *buf, size_t len)
 {
-       int start, end_of_title, only_spaces = 1;
+       const char *s;
+       int end_of_title, l, only_spaces = 1;
        int recognized_prefix = 0, trailer_lines = 0, non_trailer_lines = 0;
        /*
         * Number of possible continuation lines encountered. This will be
@@ -741,13 +791,13 @@ static int find_trailer_start(struct strbuf **lines, int count)
        int possible_continuation_lines = 0;
 
        /* The first paragraph is the title and cannot be trailers */
-       for (start = 0; start < count; start++) {
-               if (lines[start]->buf[0] == comment_line_char)
+       for (s = buf; s < buf + len; s = next_line(s)) {
+               if (s[0] == comment_line_char)
                        continue;
-               if (contains_only_spaces(lines[start]->buf))
+               if (is_blank_line(s))
                        break;
        }
-       end_of_title = start;
+       end_of_title = s - buf;
 
        /*
         * Get the start of the trailers by looking starting from the end for a
@@ -755,30 +805,33 @@ static int find_trailer_start(struct strbuf **lines, int count)
         * trailers, or (ii) contains at least one Git-generated trailer and
         * consists of at least 25% trailers.
         */
-       for (start = count - 1; start >= end_of_title; start--) {
+       for (l = last_line(buf, len);
+            l >= end_of_title;
+            l = last_line(buf, l)) {
+               const char *bol = buf + l;
                const char **p;
                int separator_pos;
 
-               if (lines[start]->buf[0] == comment_line_char) {
+               if (bol[0] == comment_line_char) {
                        non_trailer_lines += possible_continuation_lines;
                        possible_continuation_lines = 0;
                        continue;
                }
-               if (contains_only_spaces(lines[start]->buf)) {
+               if (is_blank_line(bol)) {
                        if (only_spaces)
                                continue;
                        non_trailer_lines += possible_continuation_lines;
                        if (recognized_prefix &&
                            trailer_lines * 3 >= non_trailer_lines)
-                               return start + 1;
-                       if (trailer_lines && !non_trailer_lines)
-                               return start + 1;
-                       return count;
+                               return next_line(bol) - buf;
+                       else if (trailer_lines && !non_trailer_lines)
+                               return next_line(bol) - buf;
+                       return len;
                }
                only_spaces = 0;
 
                for (p = git_generated_prefixes; *p; p++) {
-                       if (starts_with(lines[start]->buf, *p)) {
+                       if (starts_with(bol, *p)) {
                                trailer_lines++;
                                possible_continuation_lines = 0;
                                recognized_prefix = 1;
@@ -786,8 +839,8 @@ static int find_trailer_start(struct strbuf **lines, int count)
                        }
                }
 
-               separator_pos = find_separator(lines[start]->buf, separators);
-               if (separator_pos >= 1 && !isspace(lines[start]->buf[0])) {
+               separator_pos = find_separator(bol, separators);
+               if (separator_pos >= 1 && !isspace(bol[0])) {
                        struct list_head *pos;
 
                        trailer_lines++;
@@ -797,13 +850,13 @@ static int find_trailer_start(struct strbuf **lines, int count)
                        list_for_each(pos, &conf_head) {
                                struct arg_item *item;
                                item = list_entry(pos, struct arg_item, list);
-                               if (token_matches_item(lines[start]->buf, item,
+                               if (token_matches_item(bol, item,
                                                       separator_pos)) {
                                        recognized_prefix = 1;
                                        break;
                                }
                        }
-               } else if (isspace(lines[start]->buf[0]))
+               } else if (isspace(bol[0]))
                        possible_continuation_lines++;
                else {
                        non_trailer_lines++;
@@ -814,97 +867,64 @@ static int find_trailer_start(struct strbuf **lines, int count)
                ;
        }
 
-       return count;
-}
-
-/* Get the index of the end of the trailers */
-static int find_trailer_end(struct strbuf **lines, int patch_start)
-{
-       struct strbuf sb = STRBUF_INIT;
-       int i, ignore_bytes;
-
-       for (i = 0; i < patch_start; i++)
-               strbuf_addbuf(&sb, lines[i]);
-       ignore_bytes = ignore_non_trailer(&sb);
-       strbuf_release(&sb);
-       for (i = patch_start - 1; i >= 0 && ignore_bytes > 0; i--)
-               ignore_bytes -= lines[i]->len;
-
-       return i + 1;
+       return len;
 }
 
-static int has_blank_line_before(struct strbuf **lines, int start)
+/* Return the position of the end of the trailers. */
+static int find_trailer_end(const char *buf, size_t len)
 {
-       for (;start >= 0; start--) {
-               if (lines[start]->buf[0] == comment_line_char)
-                       continue;
-               return contains_only_spaces(lines[start]->buf);
-       }
-       return 0;
+       return len - ignore_non_trailer(buf, len);
 }
 
-static void print_lines(FILE *outfile, struct strbuf **lines, int start, int end)
+static int ends_with_blank_line(const char *buf, size_t len)
 {
-       int i;
-       for (i = start; lines[i] && i < end; i++)
-               fprintf(outfile, "%s", lines[i]->buf);
+       int ll = last_line(buf, len);
+       if (ll < 0)
+               return 0;
+       return is_blank_line(buf + ll);
 }
 
 static int process_input_file(FILE *outfile,
-                             struct strbuf **lines,
+                             const char *str,
                              struct list_head *head)
 {
-       int count = 0;
-       int patch_start, trailer_start, trailer_end, i;
+       struct trailer_info info;
        struct strbuf tok = STRBUF_INIT;
        struct strbuf val = STRBUF_INIT;
-       struct trailer_item *last = NULL;
-
-       /* Get the line count */
-       while (lines[count])
-               count++;
+       int i;
 
-       patch_start = find_patch_start(lines, count);
-       trailer_end = find_trailer_end(lines, patch_start);
-       trailer_start = find_trailer_start(lines, trailer_end);
+       trailer_info_get(&info, str);
 
        /* Print lines before the trailers as is */
-       print_lines(outfile, lines, 0, trailer_start);
+       fwrite(str, 1, info.trailer_start - str, outfile);
 
-       if (!has_blank_line_before(lines, trailer_start - 1))
+       if (!info.blank_line_before_trailer)
                fprintf(outfile, "\n");
 
-       /* Parse trailer lines */
-       for (i = trailer_start; i < trailer_end; i++) {
+       for (i = 0; i < info.trailer_nr; i++) {
                int separator_pos;
-               if (lines[i]->buf[0] == comment_line_char)
+               char *trailer = info.trailers[i];
+               if (trailer[0] == comment_line_char)
                        continue;
-               if (last && isspace(lines[i]->buf[0])) {
-                       struct strbuf sb = STRBUF_INIT;
-                       strbuf_addf(&sb, "%s\n%s", last->value, lines[i]->buf);
-                       strbuf_strip_suffix(&sb, "\n");
-                       free(last->value);
-                       last->value = strbuf_detach(&sb, NULL);
-                       continue;
-               }
-               separator_pos = find_separator(lines[i]->buf, separators);
+               separator_pos = find_separator(trailer, separators);
                if (separator_pos >= 1) {
-                       parse_trailer(&tok, &val, NULL, lines[i]->buf,
+                       parse_trailer(&tok, &val, NULL, trailer,
                                      separator_pos);
-                       last = add_trailer_item(head,
-                                               strbuf_detach(&tok, NULL),
-                                               strbuf_detach(&val, NULL));
+                       add_trailer_item(head,
+                                        strbuf_detach(&tok, NULL),
+                                        strbuf_detach(&val, NULL));
                } else {
-                       strbuf_addbuf(&val, lines[i]);
+                       strbuf_addstr(&val, trailer);
                        strbuf_strip_suffix(&val, "\n");
                        add_trailer_item(head,
                                         NULL,
                                         strbuf_detach(&val, NULL));
-                       last = NULL;
                }
        }
 
-       return trailer_end;
+       trailer_info_release(&info);
+
+       return info.trailer_end - str;
 }
 
 static void free_all(struct list_head *head)
@@ -951,21 +971,19 @@ void process_trailers(const char *file, int in_place, int trim_empty, struct str
 {
        LIST_HEAD(head);
        LIST_HEAD(arg_head);
-       struct strbuf **lines;
+       struct strbuf sb = STRBUF_INIT;
        int trailer_end;
        FILE *outfile = stdout;
 
-       /* Default config must be setup first */
-       git_config(git_trailer_default_config, NULL);
-       git_config(git_trailer_config, NULL);
+       ensure_configured();
 
-       lines = read_input_file(file);
+       read_input_file(&sb, file);
 
        if (in_place)
                outfile = create_in_place_tempfile(file);
 
        /* Print the lines before the trailers */
-       trailer_end = process_input_file(outfile, lines, &head);
+       trailer_end = process_input_file(outfile, sb.buf, &head);
 
        process_command_line_args(&arg_head, trailers);
 
@@ -976,11 +994,62 @@ void process_trailers(const char *file, int in_place, int trim_empty, struct str
        free_all(&head);
 
        /* Print the lines after the trailers as is */
-       print_lines(outfile, lines, trailer_end, INT_MAX);
+       fwrite(sb.buf + trailer_end, 1, sb.len - trailer_end, outfile);
 
        if (in_place)
                if (rename_tempfile(&trailers_tempfile, file))
                        die_errno(_("could not rename temporary file to %s"), file);
 
-       strbuf_list_free(lines);
+       strbuf_release(&sb);
+}
+
+void trailer_info_get(struct trailer_info *info, const char *str)
+{
+       int patch_start, trailer_end, trailer_start;
+       struct strbuf **trailer_lines, **ptr;
+       char **trailer_strings = NULL;
+       size_t nr = 0, alloc = 0;
+       char **last = NULL;
+
+       ensure_configured();
+
+       patch_start = find_patch_start(str);
+       trailer_end = find_trailer_end(str, patch_start);
+       trailer_start = find_trailer_start(str, trailer_end);
+
+       trailer_lines = strbuf_split_buf(str + trailer_start,
+                                        trailer_end - trailer_start,
+                                        '\n',
+                                        0);
+       for (ptr = trailer_lines; *ptr; ptr++) {
+               if (last && isspace((*ptr)->buf[0])) {
+                       struct strbuf sb = STRBUF_INIT;
+                       strbuf_attach(&sb, *last, strlen(*last), strlen(*last));
+                       strbuf_addbuf(&sb, *ptr);
+                       *last = strbuf_detach(&sb, NULL);
+                       continue;
+               }
+               ALLOC_GROW(trailer_strings, nr + 1, alloc);
+               trailer_strings[nr] = strbuf_detach(*ptr, NULL);
+               last = find_separator(trailer_strings[nr], separators) >= 1
+                       ? &trailer_strings[nr]
+                       : NULL;
+               nr++;
+       }
+       strbuf_list_free(trailer_lines);
+
+       info->blank_line_before_trailer = ends_with_blank_line(str,
+                                                              trailer_start);
+       info->trailer_start = str + trailer_start;
+       info->trailer_end = str + trailer_end;
+       info->trailers = trailer_strings;
+       info->trailer_nr = nr;
+}
+
+void trailer_info_release(struct trailer_info *info)
+{
+       int i;
+       for (i = 0; i < info->trailer_nr; i++)
+               free(info->trailers[i]);
+       free(info->trailers);
 }
index 36b40b81761f95742c9c6fe7e94ba89f19aabfde..65cc5d79c6cecfce5cf3302dd7dcb6323f9f85dc 100644 (file)
--- a/trailer.h
+++ b/trailer.h
@@ -1,7 +1,32 @@
 #ifndef TRAILER_H
 #define TRAILER_H
 
+struct trailer_info {
+       /*
+        * True if there is a blank line before the location pointed to by
+        * trailer_start.
+        */
+       int blank_line_before_trailer;
+
+       /*
+        * Pointers to the start and end of the trailer block found. If there
+        * is no trailer block found, these 2 pointers point to the end of the
+        * input string.
+        */
+       const char *trailer_start, *trailer_end;
+
+       /*
+        * Array of trailers found.
+        */
+       char **trailers;
+       size_t trailer_nr;
+};
+
 void process_trailers(const char *file, int in_place, int trim_empty,
                      struct string_list *trailers);
 
+void trailer_info_get(struct trailer_info *info, const char *str);
+
+void trailer_info_release(struct trailer_info *info);
+
 #endif /* TRAILER_H */
index d57e8dec28d6890ce981a8422e9b8b60b697ecd6..c86ba2eb897f4ee2e45dadd418587ee4cb76401e 100644 (file)
@@ -664,21 +664,89 @@ static const struct string_list *protocol_whitelist(void)
        return enabled ? &allowed : NULL;
 }
 
-int is_transport_allowed(const char *type)
+enum protocol_allow_config {
+       PROTOCOL_ALLOW_NEVER = 0,
+       PROTOCOL_ALLOW_USER_ONLY,
+       PROTOCOL_ALLOW_ALWAYS
+};
+
+static enum protocol_allow_config parse_protocol_config(const char *key,
+                                                       const char *value)
 {
-       const struct string_list *allowed = protocol_whitelist();
-       return !allowed || string_list_has_string(allowed, type);
+       if (!strcasecmp(value, "always"))
+               return PROTOCOL_ALLOW_ALWAYS;
+       else if (!strcasecmp(value, "never"))
+               return PROTOCOL_ALLOW_NEVER;
+       else if (!strcasecmp(value, "user"))
+               return PROTOCOL_ALLOW_USER_ONLY;
+
+       die("unknown value for config '%s': %s", key, value);
 }
 
-void transport_check_allowed(const char *type)
+static enum protocol_allow_config get_protocol_config(const char *type)
 {
-       if (!is_transport_allowed(type))
-               die("transport '%s' not allowed", type);
+       char *key = xstrfmt("protocol.%s.allow", type);
+       char *value;
+
+       /* first check the per-protocol config */
+       if (!git_config_get_string(key, &value)) {
+               enum protocol_allow_config ret =
+                       parse_protocol_config(key, value);
+               free(key);
+               free(value);
+               return ret;
+       }
+       free(key);
+
+       /* if defined, fallback to user-defined default for unknown protocols */
+       if (!git_config_get_string("protocol.allow", &value)) {
+               enum protocol_allow_config ret =
+                       parse_protocol_config("protocol.allow", value);
+               free(value);
+               return ret;
+       }
+
+       /* fallback to built-in defaults */
+       /* known safe */
+       if (!strcmp(type, "http") ||
+           !strcmp(type, "https") ||
+           !strcmp(type, "git") ||
+           !strcmp(type, "ssh") ||
+           !strcmp(type, "file"))
+               return PROTOCOL_ALLOW_ALWAYS;
+
+       /* known scary; err on the side of caution */
+       if (!strcmp(type, "ext"))
+               return PROTOCOL_ALLOW_NEVER;
+
+       /* unknown; by default let them be used only directly by the user */
+       return PROTOCOL_ALLOW_USER_ONLY;
+}
+
+int is_transport_allowed(const char *type, int from_user)
+{
+       const struct string_list *whitelist = protocol_whitelist();
+       if (whitelist)
+               return string_list_has_string(whitelist, type);
+
+       switch (get_protocol_config(type)) {
+       case PROTOCOL_ALLOW_ALWAYS:
+               return 1;
+       case PROTOCOL_ALLOW_NEVER:
+               return 0;
+       case PROTOCOL_ALLOW_USER_ONLY:
+               if (from_user < 0)
+                       from_user = git_env_bool("GIT_PROTOCOL_FROM_USER", 1);
+               return from_user;
+       }
+
+       die("BUG: invalid protocol_allow_config type");
 }
 
-int transport_restrict_protocols(void)
+void transport_check_allowed(const char *type)
 {
-       return !!protocol_whitelist();
+       if (!is_transport_allowed(type, -1))
+               die("transport '%s' not allowed", type);
 }
 
 struct transport *transport_get(struct remote *remote, const char *url)
@@ -949,23 +1017,39 @@ int transport_push(struct transport *transport,
 
                if ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) && !is_bare_repository()) {
                        struct ref *ref = remote_refs;
+                       struct sha1_array commits = SHA1_ARRAY_INIT;
+
                        for (; ref; ref = ref->next)
-                               if (!is_null_oid(&ref->new_oid) &&
-                                   !push_unpushed_submodules(ref->new_oid.hash,
-                                           transport->remote->name))
-                                   die ("Failed to push all needed submodules!");
+                               if (!is_null_oid(&ref->new_oid))
+                                       sha1_array_append(&commits, ref->new_oid.hash);
+
+                       if (!push_unpushed_submodules(&commits,
+                                                     transport->remote->name,
+                                                     pretend)) {
+                               sha1_array_clear(&commits);
+                               die("Failed to push all needed submodules!");
+                       }
+                       sha1_array_clear(&commits);
                }
 
-               if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND |
-                             TRANSPORT_RECURSE_SUBMODULES_CHECK)) && !is_bare_repository()) {
+               if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) ||
+                    ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) &&
+                     !pretend)) && !is_bare_repository()) {
                        struct ref *ref = remote_refs;
                        struct string_list needs_pushing = STRING_LIST_INIT_DUP;
+                       struct sha1_array commits = SHA1_ARRAY_INIT;
 
                        for (; ref; ref = ref->next)
-                               if (!is_null_oid(&ref->new_oid) &&
-                                   find_unpushed_submodules(ref->new_oid.hash,
-                                           transport->remote->name, &needs_pushing))
-                                       die_with_unpushed_submodules(&needs_pushing);
+                               if (!is_null_oid(&ref->new_oid))
+                                       sha1_array_append(&commits, ref->new_oid.hash);
+
+                       if (find_unpushed_submodules(&commits, transport->remote->name,
+                                               &needs_pushing)) {
+                               sha1_array_clear(&commits);
+                               die_with_unpushed_submodules(&needs_pushing);
+                       }
+                       string_list_clear(&needs_pushing, 0);
+                       sha1_array_clear(&commits);
                }
 
                push_ret = transport->push_refs(transport, remote_refs, flags);
@@ -1130,7 +1214,7 @@ static int refs_from_alternate_cb(struct alternate_object_database *e,
        const struct ref *extra;
        struct alternate_refs_data *cb = data;
 
-       other = xstrdup(real_path(e->path));
+       other = real_pathdup(e->path);
        len = strlen(other);
 
        while (other[len-1] == '/')
index b8e4ee8099260a74e5207048cf2837c9fd686568..9820f10b8e41c6aa6ff6131e5660866d30bf541a 100644 (file)
@@ -153,10 +153,17 @@ extern int transport_summary_width(const struct ref *refs);
 struct transport *transport_get(struct remote *, const char *);
 
 /*
- * Check whether a transport is allowed by the environment. Type should
- * generally be the URL scheme, as described in Documentation/git.txt
+ * Check whether a transport is allowed by the environment.
+ *
+ * Type should generally be the URL scheme, as described in
+ * Documentation/git.txt
+ *
+ * from_user specifies if the transport was given by the user.  If unknown pass
+ * a -1 to read from the environment to determine if the transport was given by
+ * the user.
+ *
  */
-int is_transport_allowed(const char *type);
+int is_transport_allowed(const char *type, int from_user);
 
 /*
  * Check whether a transport is allowed by the environment,
@@ -164,12 +171,6 @@ int is_transport_allowed(const char *type);
  */
 void transport_check_allowed(const char *type);
 
-/*
- * Returns true if the user has attempted to turn on protocol
- * restrictions at all.
- */
-int transport_restrict_protocols(void);
-
 /* Transport options which apply to git:// and scp-style URLs */
 
 /* The program to use on the remote side to send a pack */
index 828f4356be039bc07ec09665ac725341515a36ea..ff776056806dd40ddfb02f566b0cbd4222d0d970 100644 (file)
@@ -1004,6 +1004,19 @@ static enum interesting do_match(const struct name_entry *entry,
                                 */
                                if (ps->recursive && S_ISDIR(entry->mode))
                                        return entry_interesting;
+
+                               /*
+                                * When matching against submodules with
+                                * wildcard characters, ensure that the entry
+                                * at least matches up to the first wild
+                                * character.  More accurate matching can then
+                                * be performed in the submodule itself.
+                                */
+                               if (ps->recursive && S_ISGITLINK(entry->mode) &&
+                                   !ps_strncmp(item, match + baselen,
+                                               entry->path,
+                                               item->nowildcard_len - baselen))
+                                       return entry_interesting;
                        }
 
                        continue;
@@ -1040,6 +1053,21 @@ static enum interesting do_match(const struct name_entry *entry,
                        strbuf_setlen(base, base_offset + baselen);
                        return entry_interesting;
                }
+
+               /*
+                * When matching against submodules with
+                * wildcard characters, ensure that the entry
+                * at least matches up to the first wild
+                * character.  More accurate matching can then
+                * be performed in the submodule itself.
+                */
+               if (ps->recursive && S_ISGITLINK(entry->mode) &&
+                   !ps_strncmp(item, match, base->buf + base_offset,
+                               item->nowildcard_len)) {
+                       strbuf_setlen(base, base_offset + baselen);
+                       return entry_interesting;
+               }
+
                strbuf_setlen(base, base_offset + baselen);
 
                /*
index 47cdd2369d1919b7b7b267c622ad31e2ad6f24c0..02207be4fc47537168d1b1a7d1455af7e4c0df60 100644 (file)
@@ -25,7 +25,7 @@ static const struct interval zero_width[] = {
 { 0x0825, 0x0827 },
 { 0x0829, 0x082D },
 { 0x0859, 0x085B },
-{ 0x08E4, 0x0902 },
+{ 0x08D4, 0x0902 },
 { 0x093A, 0x093A },
 { 0x093C, 0x093C },
 { 0x0941, 0x0948 },
@@ -120,6 +120,7 @@ static const struct interval zero_width[] = {
 { 0x17C9, 0x17D3 },
 { 0x17DD, 0x17DD },
 { 0x180B, 0x180E },
+{ 0x1885, 0x1886 },
 { 0x18A9, 0x18A9 },
 { 0x1920, 0x1922 },
 { 0x1927, 0x1928 },
@@ -158,7 +159,7 @@ static const struct interval zero_width[] = {
 { 0x1CF4, 0x1CF4 },
 { 0x1CF8, 0x1CF9 },
 { 0x1DC0, 0x1DF5 },
-{ 0x1DFC, 0x1DFF },
+{ 0x1DFB, 0x1DFF },
 { 0x200B, 0x200F },
 { 0x202A, 0x202E },
 { 0x2060, 0x2064 },
@@ -171,13 +172,13 @@ static const struct interval zero_width[] = {
 { 0x3099, 0x309A },
 { 0xA66F, 0xA672 },
 { 0xA674, 0xA67D },
-{ 0xA69F, 0xA69F },
+{ 0xA69E, 0xA69F },
 { 0xA6F0, 0xA6F1 },
 { 0xA802, 0xA802 },
 { 0xA806, 0xA806 },
 { 0xA80B, 0xA80B },
 { 0xA825, 0xA826 },
-{ 0xA8C4, 0xA8C4 },
+{ 0xA8C4, 0xA8C5 },
 { 0xA8E0, 0xA8F1 },
 { 0xA926, 0xA92D },
 { 0xA947, 0xA951 },
@@ -204,7 +205,7 @@ static const struct interval zero_width[] = {
 { 0xABED, 0xABED },
 { 0xFB1E, 0xFB1E },
 { 0xFE00, 0xFE0F },
-{ 0xFE20, 0xFE2D },
+{ 0xFE20, 0xFE2F },
 { 0xFEFF, 0xFEFF },
 { 0xFFF9, 0xFFFB },
 { 0x101FD, 0x101FD },
@@ -228,16 +229,21 @@ static const struct interval zero_width[] = {
 { 0x11173, 0x11173 },
 { 0x11180, 0x11181 },
 { 0x111B6, 0x111BE },
+{ 0x111CA, 0x111CC },
 { 0x1122F, 0x11231 },
 { 0x11234, 0x11234 },
 { 0x11236, 0x11237 },
+{ 0x1123E, 0x1123E },
 { 0x112DF, 0x112DF },
 { 0x112E3, 0x112EA },
-{ 0x11301, 0x11301 },
+{ 0x11300, 0x11301 },
 { 0x1133C, 0x1133C },
 { 0x11340, 0x11340 },
 { 0x11366, 0x1136C },
 { 0x11370, 0x11374 },
+{ 0x11438, 0x1143F },
+{ 0x11442, 0x11444 },
+{ 0x11446, 0x11446 },
 { 0x114B3, 0x114B8 },
 { 0x114BA, 0x114BA },
 { 0x114BF, 0x114C0 },
@@ -245,6 +251,7 @@ static const struct interval zero_width[] = {
 { 0x115B2, 0x115B5 },
 { 0x115BC, 0x115BD },
 { 0x115BF, 0x115C0 },
+{ 0x115DC, 0x115DD },
 { 0x11633, 0x1163A },
 { 0x1163D, 0x1163D },
 { 0x1163F, 0x11640 },
@@ -252,6 +259,16 @@ static const struct interval zero_width[] = {
 { 0x116AD, 0x116AD },
 { 0x116B0, 0x116B5 },
 { 0x116B7, 0x116B7 },
+{ 0x1171D, 0x1171F },
+{ 0x11722, 0x11725 },
+{ 0x11727, 0x1172B },
+{ 0x11C30, 0x11C36 },
+{ 0x11C38, 0x11C3D },
+{ 0x11C3F, 0x11C3F },
+{ 0x11C92, 0x11CA7 },
+{ 0x11CAA, 0x11CB0 },
+{ 0x11CB2, 0x11CB3 },
+{ 0x11CB5, 0x11CB6 },
 { 0x16AF0, 0x16AF4 },
 { 0x16B30, 0x16B36 },
 { 0x16F8F, 0x16F92 },
@@ -262,31 +279,59 @@ static const struct interval zero_width[] = {
 { 0x1D185, 0x1D18B },
 { 0x1D1AA, 0x1D1AD },
 { 0x1D242, 0x1D244 },
+{ 0x1DA00, 0x1DA36 },
+{ 0x1DA3B, 0x1DA6C },
+{ 0x1DA75, 0x1DA75 },
+{ 0x1DA84, 0x1DA84 },
+{ 0x1DA9B, 0x1DA9F },
+{ 0x1DAA1, 0x1DAAF },
+{ 0x1E000, 0x1E006 },
+{ 0x1E008, 0x1E018 },
+{ 0x1E01B, 0x1E021 },
+{ 0x1E023, 0x1E024 },
+{ 0x1E026, 0x1E02A },
 { 0x1E8D0, 0x1E8D6 },
+{ 0x1E944, 0x1E94A },
 { 0xE0001, 0xE0001 },
 { 0xE0020, 0xE007F },
 { 0xE0100, 0xE01EF }
 };
 static const struct interval double_width[] = {
-{ /* plane */ 0x0, 0x1C },
-{ /* plane */ 0x1C, 0x21 },
-{ /* plane */ 0x21, 0x22 },
-{ /* plane */ 0x22, 0x23 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
-{ /* plane */ 0x0, 0x0 },
 { 0x1100, 0x115F },
+{ 0x231A, 0x231B },
 { 0x2329, 0x232A },
+{ 0x23E9, 0x23EC },
+{ 0x23F0, 0x23F0 },
+{ 0x23F3, 0x23F3 },
+{ 0x25FD, 0x25FE },
+{ 0x2614, 0x2615 },
+{ 0x2648, 0x2653 },
+{ 0x267F, 0x267F },
+{ 0x2693, 0x2693 },
+{ 0x26A1, 0x26A1 },
+{ 0x26AA, 0x26AB },
+{ 0x26BD, 0x26BE },
+{ 0x26C4, 0x26C5 },
+{ 0x26CE, 0x26CE },
+{ 0x26D4, 0x26D4 },
+{ 0x26EA, 0x26EA },
+{ 0x26F2, 0x26F3 },
+{ 0x26F5, 0x26F5 },
+{ 0x26FA, 0x26FA },
+{ 0x26FD, 0x26FD },
+{ 0x2705, 0x2705 },
+{ 0x270A, 0x270B },
+{ 0x2728, 0x2728 },
+{ 0x274C, 0x274C },
+{ 0x274E, 0x274E },
+{ 0x2753, 0x2755 },
+{ 0x2757, 0x2757 },
+{ 0x2795, 0x2797 },
+{ 0x27B0, 0x27B0 },
+{ 0x27BF, 0x27BF },
+{ 0x2B1B, 0x2B1C },
+{ 0x2B50, 0x2B50 },
+{ 0x2B55, 0x2B55 },
 { 0x2E80, 0x2E99 },
 { 0x2E9B, 0x2EF3 },
 { 0x2F00, 0x2FD5 },
@@ -313,11 +358,49 @@ static const struct interval double_width[] = {
 { 0xFE68, 0xFE6B },
 { 0xFF01, 0xFF60 },
 { 0xFFE0, 0xFFE6 },
+{ 0x16FE0, 0x16FE0 },
+{ 0x17000, 0x187EC },
+{ 0x18800, 0x18AF2 },
 { 0x1B000, 0x1B001 },
+{ 0x1F004, 0x1F004 },
+{ 0x1F0CF, 0x1F0CF },
+{ 0x1F18E, 0x1F18E },
+{ 0x1F191, 0x1F19A },
 { 0x1F200, 0x1F202 },
-{ 0x1F210, 0x1F23A },
+{ 0x1F210, 0x1F23B },
 { 0x1F240, 0x1F248 },
 { 0x1F250, 0x1F251 },
+{ 0x1F300, 0x1F320 },
+{ 0x1F32D, 0x1F335 },
+{ 0x1F337, 0x1F37C },
+{ 0x1F37E, 0x1F393 },
+{ 0x1F3A0, 0x1F3CA },
+{ 0x1F3CF, 0x1F3D3 },
+{ 0x1F3E0, 0x1F3F0 },
+{ 0x1F3F4, 0x1F3F4 },
+{ 0x1F3F8, 0x1F43E },
+{ 0x1F440, 0x1F440 },
+{ 0x1F442, 0x1F4FC },
+{ 0x1F4FF, 0x1F53D },
+{ 0x1F54B, 0x1F54E },
+{ 0x1F550, 0x1F567 },
+{ 0x1F57A, 0x1F57A },
+{ 0x1F595, 0x1F596 },
+{ 0x1F5A4, 0x1F5A4 },
+{ 0x1F5FB, 0x1F64F },
+{ 0x1F680, 0x1F6C5 },
+{ 0x1F6CC, 0x1F6CC },
+{ 0x1F6D0, 0x1F6D2 },
+{ 0x1F6EB, 0x1F6EC },
+{ 0x1F6F4, 0x1F6F6 },
+{ 0x1F910, 0x1F91E },
+{ 0x1F920, 0x1F927 },
+{ 0x1F930, 0x1F930 },
+{ 0x1F933, 0x1F93E },
+{ 0x1F940, 0x1F94B },
+{ 0x1F950, 0x1F95E },
+{ 0x1F980, 0x1F991 },
+{ 0x1F9C0, 0x1F9C0 },
 { 0x20000, 0x2FFFD },
 { 0x30000, 0x3FFFD }
 };
index ea6bdd20e0491554e88f4b84bd3b6354867021bc..7a6df99d10e1dbabc9f7df74316fd91bd55c1fd5 100644 (file)
@@ -78,7 +78,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
                xstrfmt(msg, cmd, cmd);
 
        msgs[ERROR_NOT_UPTODATE_DIR] =
-               _("Updating the following directories would lose untracked files in it:\n%s");
+               _("Updating the following directories would lose untracked files in them:\n%s");
 
        if (!strcmp(cmd, "checkout"))
                msg = advice_commit_before_merge
diff --git a/update_unicode.sh b/update_unicode.sh
deleted file mode 100755 (executable)
index 27af77c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-#See http://www.unicode.org/reports/tr44/
-#
-#Me Enclosing_Mark  an enclosing combining mark
-#Mn Nonspacing_Mark a nonspacing combining mark (zero advance width)
-#Cf Format          a format control character
-#
-UNICODEWIDTH_H=../unicode_width.h
-if ! test -d unicode; then
-       mkdir unicode
-fi &&
-( cd unicode &&
-       if ! test -f UnicodeData.txt; then
-               wget http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
-       fi &&
-       if ! test -f EastAsianWidth.txt; then
-               wget http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
-       fi &&
-       if ! test -d uniset; then
-               git clone https://github.com/depp/uniset.git
-       fi &&
-       (
-               cd uniset &&
-               if ! test -x uniset; then
-                       autoreconf -i &&
-                       ./configure --enable-warnings=-Werror CFLAGS='-O0 -ggdb'
-               fi &&
-               make
-       ) &&
-       UNICODE_DIR=. && export UNICODE_DIR &&
-       cat >$UNICODEWIDTH_H <<-EOF
-       static const struct interval zero_width[] = {
-               $(uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD |
-                 grep -v plane)
-       };
-       static const struct interval double_width[] = {
-               $(uniset/uniset --32 eaw:F,W)
-       };
-       EOF
-)
index e0db8b42be2d6ba400da987f8cb2ba573c5eda01..7597ba3405e161d59608e18ec580946c60f9e6d2 100644 (file)
@@ -46,6 +46,8 @@ static int no_progress, daemon_mode;
 #define ALLOW_TIP_SHA1 01
 /* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
 #define ALLOW_REACHABLE_SHA1   02
+/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
+#define ALLOW_ANY_SHA1 07
 static unsigned int allow_unadvertised_object_request;
 static int shallow_nr;
 static struct object_array have_obj;
@@ -825,7 +827,8 @@ static void receive_needs(void)
                            sha1_to_hex(sha1_buf));
                if (!(o->flags & WANTED)) {
                        o->flags |= WANTED;
-                       if (!is_our_ref(o))
+                       if (!((allow_unadvertised_object_request & ALLOW_ANY_SHA1) == ALLOW_ANY_SHA1
+                             || is_our_ref(o)))
                                has_non_tip = 1;
                        add_object_array(o, NULL, &want_obj);
                }
@@ -1008,6 +1011,11 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
                        allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
                else
                        allow_unadvertised_object_request &= ~ALLOW_REACHABLE_SHA1;
+       } else if (!strcmp("uploadpack.allowanysha1inwant", var)) {
+               if (git_config_bool(var, value))
+                       allow_unadvertised_object_request |= ALLOW_ANY_SHA1;
+               else
+                       allow_unadvertised_object_request &= ~ALLOW_ANY_SHA1;
        } else if (!strcmp("uploadpack.keepalive", var)) {
                keepalive = git_config_int(var, value);
                if (!keepalive)
diff --git a/utf8.c b/utf8.c
index 00e10c86ad7ea7bcc2d53a90a2f608dd66d47462..0c8e011a58cae3c683851007ec81828ad8284471 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -489,6 +489,28 @@ char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, int *outs
        return out;
 }
 
+static const char *fallback_encoding(const char *name)
+{
+       /*
+        * Some platforms do not have the variously spelled variants of
+        * UTF-8, so let's fall back to trying the most official
+        * spelling. We do so only as a fallback in case the platform
+        * does understand the user's spelling, but not our official
+        * one.
+        */
+       if (is_encoding_utf8(name))
+               return "UTF-8";
+
+       /*
+        * Even though latin-1 is still seen in e-mail
+        * headers, some platforms only install ISO-8859-1.
+        */
+       if (!strcasecmp(name, "latin-1"))
+               return "ISO-8859-1";
+
+       return name;
+}
+
 char *reencode_string_len(const char *in, int insz,
                          const char *out_encoding, const char *in_encoding,
                          int *outsz)
@@ -501,17 +523,9 @@ char *reencode_string_len(const char *in, int insz,
 
        conv = iconv_open(out_encoding, in_encoding);
        if (conv == (iconv_t) -1) {
-               /*
-                * Some platforms do not have the variously spelled variants of
-                * UTF-8, so let's fall back to trying the most official
-                * spelling. We do so only as a fallback in case the platform
-                * does understand the user's spelling, but not our official
-                * one.
-                */
-               if (is_encoding_utf8(in_encoding))
-                       in_encoding = "UTF-8";
-               if (is_encoding_utf8(out_encoding))
-                       out_encoding = "UTF-8";
+               in_encoding = fallback_encoding(in_encoding);
+               out_encoding = fallback_encoding(out_encoding);
+
                conv = iconv_open(out_encoding, in_encoding);
                if (conv == (iconv_t) -1)
                        return NULL;
index f7869f8d6072c98c3e9be3387a9a3c19508e13ea..53b4771c04a2b9de15379fdd213f20f213b1be60 100644 (file)
@@ -88,21 +88,13 @@ static struct worktree *get_main_worktree(void)
 
        strbuf_addf(&path, "%s/HEAD", get_git_common_dir());
 
-       if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
-               goto done;
-
-       worktree = xmalloc(sizeof(struct worktree));
+       worktree = xcalloc(1, sizeof(*worktree));
        worktree->path = strbuf_detach(&worktree_path, NULL);
-       worktree->id = NULL;
        worktree->is_bare = is_bare;
-       worktree->head_ref = NULL;
        worktree->is_detached = is_detached;
-       worktree->is_current = 0;
-       add_head_info(&head_ref, worktree);
-       worktree->lock_reason = NULL;
-       worktree->lock_reason_valid = 0;
+       if (!parse_ref(path.buf, &head_ref, &is_detached))
+               add_head_info(&head_ref, worktree);
 
-done:
        strbuf_release(&path);
        strbuf_release(&worktree_path);
        strbuf_release(&head_ref);
@@ -138,16 +130,11 @@ static struct worktree *get_linked_worktree(const char *id)
        if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
                goto done;
 
-       worktree = xmalloc(sizeof(struct worktree));
+       worktree = xcalloc(1, sizeof(*worktree));
        worktree->path = strbuf_detach(&worktree_path, NULL);
        worktree->id = xstrdup(id);
-       worktree->is_bare = 0;
-       worktree->head_ref = NULL;
        worktree->is_detached = is_detached;
-       worktree->is_current = 0;
        add_head_info(&head_ref, worktree);
-       worktree->lock_reason = NULL;
-       worktree->lock_reason_valid = 0;
 
 done:
        strbuf_release(&path);
@@ -173,7 +160,14 @@ static void mark_current_worktree(struct worktree **worktrees)
        free(git_dir);
 }
 
-struct worktree **get_worktrees(void)
+static int compare_worktree(const void *a_, const void *b_)
+{
+       const struct worktree *const *a = a_;
+       const struct worktree *const *b = b_;
+       return fspathcmp((*a)->path, (*b)->path);
+}
+
+struct worktree **get_worktrees(unsigned flags)
 {
        struct worktree **list = NULL;
        struct strbuf path = STRBUF_INIT;
@@ -183,8 +177,7 @@ struct worktree **get_worktrees(void)
 
        list = xmalloc(alloc * sizeof(struct worktree *));
 
-       if ((list[counter] = get_main_worktree()))
-               counter++;
+       list[counter++] = get_main_worktree();
 
        strbuf_addf(&path, "%s/worktrees", get_git_common_dir());
        dir = opendir(path.buf);
@@ -205,6 +198,13 @@ struct worktree **get_worktrees(void)
        ALLOC_GROW(list, counter + 1, alloc);
        list[counter] = NULL;
 
+       if (flags & GWT_SORT_LINKED)
+               /*
+                * don't sort the first item (main worktree), which will
+                * always be the first
+                */
+               QSORT(list + 1, counter - 1, compare_worktree);
+
        mark_current_worktree(list);
        return list;
 }
@@ -255,7 +255,7 @@ struct worktree *find_worktree(struct worktree **list,
                return wt;
 
        arg = prefix_filename(prefix, strlen(prefix), arg);
-       path = xstrdup(real_path(arg));
+       path = real_pathdup(arg);
        for (; *list; list++)
                if (!fspathcmp(path, real_path((*list)->path)))
                        break;
@@ -341,7 +341,7 @@ const struct worktree *find_shared_symref(const char *symref,
 
        if (worktrees)
                free_worktrees(worktrees);
-       worktrees = get_worktrees();
+       worktrees = get_worktrees(0);
 
        for (i = 0; worktrees[i]; i++) {
                struct worktree *wt = worktrees[i];
@@ -380,3 +380,53 @@ const struct worktree *find_shared_symref(const char *symref,
 
        return existing;
 }
+
+int submodule_uses_worktrees(const char *path)
+{
+       char *submodule_gitdir;
+       struct strbuf sb = STRBUF_INIT;
+       DIR *dir;
+       struct dirent *d;
+       int ret = 0;
+       struct repository_format format;
+
+       submodule_gitdir = git_pathdup_submodule(path, "%s", "");
+       if (!submodule_gitdir)
+               return 0;
+
+       /* The env would be set for the superproject. */
+       get_common_dir_noenv(&sb, submodule_gitdir);
+
+       /*
+        * The check below is only known to be good for repository format
+        * version 0 at the time of writing this code.
+        */
+       strbuf_addstr(&sb, "/config");
+       read_repository_format(&format, sb.buf);
+       if (format.version != 0) {
+               strbuf_release(&sb);
+               return 1;
+       }
+
+       /* Replace config by worktrees. */
+       strbuf_setlen(&sb, sb.len - strlen("config"));
+       strbuf_addstr(&sb, "worktrees");
+
+       /* See if there is any file inside the worktrees directory. */
+       dir = opendir(sb.buf);
+       strbuf_release(&sb);
+       free(submodule_gitdir);
+
+       if (!dir)
+               return 0;
+
+       while ((d = readdir(dir)) != NULL) {
+               if (is_dot_or_dotdot(d->d_name))
+                       continue;
+
+               ret = 1;
+               break;
+       }
+       closedir(dir);
+       return ret;
+}
index 90e1311fa73fa6bdde5249d68818eacb6dc8edd0..6bfb985203070e3051f82348568840f5577bf0dc 100644 (file)
@@ -15,6 +15,8 @@ struct worktree {
 
 /* Functions for acting on the information about worktrees. */
 
+#define GWT_SORT_LINKED (1 << 0) /* keeps linked worktrees sorted */
+
 /*
  * Get the worktrees.  The primary worktree will always be the first returned,
  * and linked worktrees will be pointed to by 'next' in each subsequent
@@ -23,7 +25,12 @@ struct worktree {
  * The caller is responsible for freeing the memory from the returned
  * worktree(s).
  */
-extern struct worktree **get_worktrees(void);
+extern struct worktree **get_worktrees(unsigned flags);
+
+/*
+ * Returns 1 if linked worktrees exist, 0 otherwise.
+ */
+extern int submodule_uses_worktrees(const char *path);
 
 /*
  * Return git dir of the worktree. Note that the path may be relative.
index a2e9d332d8332bb1dbeea26b683c5e3f032a822e..a715e71906a9a2fbd62180dd017d140f68ad14a0 100644 (file)
@@ -2258,11 +2258,12 @@ int has_uncommitted_changes(int ignore_submodules)
 int require_clean_work_tree(const char *action, const char *hint, int ignore_submodules, int gently)
 {
        struct lock_file *lock_file = xcalloc(1, sizeof(*lock_file));
-       int err = 0;
+       int err = 0, fd;
 
-       hold_locked_index(lock_file, 0);
+       fd = hold_locked_index(lock_file, 0);
        refresh_cache(REFRESH_QUIET);
-       update_index_if_able(&the_index, lock_file);
+       if (0 <= fd)
+               update_index_if_able(&the_index, lock_file);
        rollback_lock_file(lock_file);
 
        if (has_unstaged_changes(ignore_submodules)) {
index 8db16d4ae6def5657bc51fa2b9b354a7c0267201..b090ad8eacfe6ed171aa14b39901a8042ab678d9 100644 (file)
@@ -41,8 +41,7 @@ extern "C" {
 
 #define XDF_IGNORE_BLANK_LINES (1 << 7)
 
-#define XDF_COMPACTION_HEURISTIC (1 << 8)
-#define XDF_INDENT_HEURISTIC (1 << 9)
+#define XDF_INDENT_HEURISTIC (1 << 8)
 
 #define XDL_EMIT_FUNCNAMES (1 << 0)
 #define XDL_EMIT_FUNCCONTEXT (1 << 2)
index 760fbb6db7583f6d0ec5eed9b9c63ea6a0e7abe7..93a65680a18284041ce57f61191d20dcc763e022 100644 (file)
@@ -400,11 +400,6 @@ static xdchange_t *xdl_add_change(xdchange_t *xscr, long i1, long i2, long chg1,
 }
 
 
-static int is_blank_line(xrecord_t *rec, long flags)
-{
-       return xdl_blankline(rec->ptr, rec->size, flags);
-}
-
 static int recs_match(xrecord_t *rec1, xrecord_t *rec2, long flags)
 {
        return (rec1->ha == rec2->ha &&
@@ -821,7 +816,6 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
        struct xdlgroup g, go;
        long earliest_end, end_matching_other;
        long groupsize;
-       unsigned int blank_lines;
 
        group_init(xdf, &g);
        group_init(xdfo, &go);
@@ -846,13 +840,6 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
                         */
                        end_matching_other = -1;
 
-                       /*
-                        * Boolean value that records whether there are any blank
-                        * lines that could be made to be the last line of this
-                        * group.
-                        */
-                       blank_lines = 0;
-
                        /* Shift the group backward as much as possible: */
                        while (!group_slide_up(xdf, &g, flags))
                                if (group_previous(xdfo, &go))
@@ -869,11 +856,6 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
 
                        /* Now shift the group forward as far as possible: */
                        while (1) {
-                               if (!blank_lines)
-                                       blank_lines = is_blank_line(
-                                                       xdf->recs[g.end - 1],
-                                                       flags);
-
                                if (group_slide_down(xdf, &g, flags))
                                        break;
                                if (group_next(xdfo, &go))
@@ -906,21 +888,6 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
                                if (group_previous(xdfo, &go))
                                        xdl_bug("group sync broken sliding to match");
                        }
-               } else if ((flags & XDF_COMPACTION_HEURISTIC) && blank_lines) {
-                       /*
-                        * Compaction heuristic: if it is possible to shift the
-                        * group to make its bottom line a blank line, do so.
-                        *
-                        * As we already shifted the group forward as far as
-                        * possible in the earlier loop, we only need to handle
-                        * backward shifts, not forward ones.
-                        */
-                       while (!is_blank_line(xdf->recs[g.end - 1], flags)) {
-                               if (group_slide_up(xdf, &g, flags))
-                                       xdl_bug("blank line disappeared");
-                               if (group_previous(xdfo, &go))
-                                       xdl_bug("group sync broken sliding to blank line");
-                       }
                } else if (flags & XDF_INDENT_HEURISTIC) {
                        /*
                         * Indent heuristic: a group of pure add/delete lines
index 027192a1c7f12214c0ff6787296769ce708ba407..04d7b32e4e4a75b9d5762f3d3a2a2f9c236075a0 100644 (file)
@@ -264,110 +264,6 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
        return ha;
 }
 
-#ifdef XDL_FAST_HASH
-
-#define REPEAT_BYTE(x)  ((~0ul / 0xff) * (x))
-
-#define ONEBYTES       REPEAT_BYTE(0x01)
-#define NEWLINEBYTES   REPEAT_BYTE(0x0a)
-#define HIGHBITS       REPEAT_BYTE(0x80)
-
-/* Return the high bit set in the first byte that is a zero */
-static inline unsigned long has_zero(unsigned long a)
-{
-       return ((a - ONEBYTES) & ~a) & HIGHBITS;
-}
-
-static inline long count_masked_bytes(unsigned long mask)
-{
-       if (sizeof(long) == 8) {
-               /*
-                * Jan Achrenius on G+: microoptimized version of
-                * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
-                * that works for the bytemasks without having to
-                * mask them first.
-                */
-               /*
-                * return mask * 0x0001020304050608 >> 56;
-                *
-                * Doing it like this avoids warnings on 32-bit machines.
-                */
-               long a = (REPEAT_BYTE(0x01) / 0xff + 1);
-               return mask * a >> (sizeof(long) * 7);
-       } else {
-               /* Carl Chatfield / Jan Achrenius G+ version for 32-bit */
-               /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
-               long a = (0x0ff0001 + mask) >> 23;
-               /* Fix the 1 for 00 case */
-               return a & mask;
-       }
-}
-
-unsigned long xdl_hash_record(char const **data, char const *top, long flags)
-{
-       unsigned long hash = 5381;
-       unsigned long a = 0, mask = 0;
-       char const *ptr = *data;
-       char const *end = top - sizeof(unsigned long) + 1;
-
-       if (flags & XDF_WHITESPACE_FLAGS)
-               return xdl_hash_record_with_whitespace(data, top, flags);
-
-       ptr -= sizeof(unsigned long);
-       do {
-               hash += hash << 5;
-               hash ^= a;
-               ptr += sizeof(unsigned long);
-               if (ptr >= end)
-                       break;
-               a = *(unsigned long *)ptr;
-               /* Do we have any '\n' bytes in this word? */
-               mask = has_zero(a ^ NEWLINEBYTES);
-       } while (!mask);
-
-       if (ptr >= end) {
-               /*
-                * There is only a partial word left at the end of the
-                * buffer. Because we may work with a memory mapping,
-                * we have to grab the rest byte by byte instead of
-                * blindly reading it.
-                *
-                * To avoid problems with masking in a signed value,
-                * we use an unsigned char here.
-                */
-               const char *p;
-               for (p = top - 1; p >= ptr; p--)
-                       a = (a << 8) + *((const unsigned char *)p);
-               mask = has_zero(a ^ NEWLINEBYTES);
-               if (!mask)
-                       /*
-                        * No '\n' found in the partial word.  Make a
-                        * mask that matches what we read.
-                        */
-                       mask = 1UL << (8 * (top - ptr) + 7);
-       }
-
-       /* The mask *below* the first high bit set */
-       mask = (mask - 1) & ~mask;
-       mask >>= 7;
-       hash += hash << 5;
-       hash ^= a & mask;
-
-       /* Advance past the last (possibly partial) word */
-       ptr += count_masked_bytes(mask);
-
-       if (ptr < top) {
-               assert(*ptr == '\n');
-               ptr++;
-       }
-
-       *data = ptr;
-
-       return hash;
-}
-
-#else /* XDL_FAST_HASH */
-
 unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
        unsigned long ha = 5381;
        char const *ptr = *data;
@@ -384,8 +280,6 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
        return ha;
 }
 
-#endif /* XDL_FAST_HASH */
-
 unsigned int xdl_hashbits(unsigned int size) {
        unsigned int val = 1, bits = 0;