Merge branch 'rs/daemon-hostname-in-strbuf'
authorJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 20:11:47 +0000 (13:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 20:11:47 +0000 (13:11 -0700)
Code in "git daemon" to parse out and hold hostnames used in
request interpolation has been simplified.

* rs/daemon-hostname-in-strbuf:
daemon: deglobalize hostname information
daemon: use strbuf for hostname info

88 files changed:
Documentation/RelNotes/2.3.2.txt [new file with mode: 0644]
Documentation/RelNotes/2.3.3.txt [new file with mode: 0644]
Documentation/RelNotes/2.4.0.txt [new file with mode: 0644]
Documentation/config.txt
Documentation/git-am.txt
Documentation/git-clean.txt
Documentation/git-commit.txt
Documentation/git-reflog.txt
Documentation/git-remote.txt
Documentation/git-submodule.txt
Documentation/git.txt
Documentation/gitmodules.txt
GIT-VERSION-GEN
RelNotes [changed from file to symlink]
archive-zip.c
branch.c
builtin/branch.c
builtin/clean.c
builtin/commit.c
builtin/fetch.c
builtin/for-each-ref.c
builtin/grep.c
builtin/index-pack.c
builtin/pack-objects.c
builtin/receive-pack.c
builtin/reflog.c
builtin/replace.c
builtin/tag.c
builtin/update-ref.c
bulk-checkin.c
cache.h
connect.c
contrib/completion/git-completion.bash
ctype.c
diff.c
diffcore-rename.c
fast-import.c
gettext.c
gettext.h
git-compat-util.h
git-rebase--interactive.sh
git-svn.perl
git.c
http-push.c
http.c
kwset.c
kwset.h
perl/Git/SVN.pm
perl/Git/SVN/Editor.pm
perl/Git/SVN/Fetcher.pm
perl/Git/SVN/Ra.pm
pretty.c
refs.c
refs.h
remote-curl.c
sequencer.c
sha1_file.c
sha1_name.c
t/diff-lib.sh
t/diff-lib/COPYING [new file with mode: 0644]
t/diff-lib/README [new file with mode: 0644]
t/t0056-git-C.sh
t/t3203-branch-output.sh
t/t3404-rebase-interactive.sh
t/t3511-cherry-pick-x.sh
t/t4003-diff-rename-1.sh
t/t4005-diff-rename-2.sh
t/t4007-rename-3.sh
t/t4008-diff-break-rewrite.sh
t/t4009-diff-rename-4.sh
t/t4010-diff-pathspec.sh
t/t4047-diff-dirstat.sh
t/t4058-diff-duplicates.sh [new file with mode: 0755]
t/t5003-archive-zip.sh
t/t5500-fetch-pack.sh
t/t5516-fetch-push.sh
t/t5601-clone.sh
t/t7004-tag.sh
t/t7508-status.sh
t/t7516-commit-races.sh [new file with mode: 0755]
t/t9300-fast-import.sh
t/t9902-completion.sh
t/test-lib-functions.sh
versioncmp.c
walker.c
wt-status.c
wt-status.h
zlib.c
diff --git a/Documentation/RelNotes/2.3.2.txt b/Documentation/RelNotes/2.3.2.txt
new file mode 100644 (file)
index 0000000..f4caf54
--- /dev/null
@@ -0,0 +1,79 @@
+Git v2.3.2 Release Notes
+========================
+
+Fixes since v2.3.1
+------------------
+
+ * "update-index --refresh" used to leak when an entry cannot be
+   refreshed for whatever reason.
+
+ * "git fast-import" used to crash when it could not close and
+   conclude the resulting packfile cleanly.
+
+ * "git blame" died, trying to free an uninitialized piece of memory.
+
+ * "git merge-file" did not work correctly in a subdirectory.
+
+ * "git submodule add" failed to squash "path/to/././submodule" to
+   "path/to/submodule".
+
+ * In v2.2.0, we broke "git prune" that runs in a repository that
+   borrows from an alternate object store.
+
+ * Certain older vintages of cURL give irregular output from
+   "curl-config --vernum", which confused our build system.
+
+ * An earlier workaround to squelch unhelpful deprecation warnings
+   from the complier on Mac OSX unnecessarily set minimum required
+   version of the OS, which the user might want to raise (or lower)
+   for other reasons.
+
+ * Longstanding configuration variable naming rules has been added to
+   the documentation.
+
+ * The credential helper for Windows (in contrib/) used to mishandle
+   a user name with an at-sign in it.
+
+ * Older GnuPG implementations may not correctly import the keyring
+   material we prepare for the tests to use.
+
+ * Clarify in the documentation that "remote.<nick>.pushURL" and
+   "remote.<nick>.URL" are there to name the same repository accessed
+   via different transports, not two separate repositories.
+
+ * The pack bitmap support did not build with older versions of GCC.
+
+ * Reading configuration from a blob object, when it ends with a lone
+   CR, use to confuse the configuration parser.
+
+ * We didn't format an integer that wouldn't fit in "int" but in
+   "uintmax_t" correctly.
+
+ * "git push --signed" gave an incorrectly worded error message when
+   the other side did not support the capability.
+
+ * "git fetch" over a remote-helper that cannot respond to "list"
+   command could not fetch from a symbolic reference e.g. HEAD.
+
+ * The insn sheet "git rebase -i" creates did not fully honor
+   core.abbrev settings.
+
+ * The tests that wanted to see that file becomes unreadable after
+   running "chmod a-r file", and the tests that wanted to make sure it
+   is not run as root, we used "can we write into the / directory?" as
+   a cheap substitute, but on some platforms that is not a good
+   heuristics.  The tests and their prerequisites have been updated to
+   check what they really require.
+
+ * The configuration variable 'mailinfo.scissors' was hard to
+   discover in the documentation.
+
+ * Correct a breakage to git-svn around v2.2 era that triggers
+   premature closing of FileHandle.
+
+ * Even though we officially haven't dropped Perl 5.8 support, the
+   Getopt::Long package that came with it does not support "--no-"
+   prefix to negate a boolean option; manually add support to help
+   people with older Getopt::Long package.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/2.3.3.txt b/Documentation/RelNotes/2.3.3.txt
new file mode 100644 (file)
index 0000000..5ef1264
--- /dev/null
@@ -0,0 +1,39 @@
+Git v2.3.3 Release Notes
+========================
+
+Fixes since v2.3.2
+------------------
+
+ * A corrupt input to "git diff -M" used cause us to segfault.
+
+ * The borrowed code in kwset API did not follow our usual convention
+   to use "unsigned char" to store values that range from 0-255.
+
+ * Description given by "grep -h" for its --exclude-standard option
+   was phrased poorly.
+
+ * Documentaton for "git remote add" mentioned "--tags" and
+   "--no-tags" and it was not clear that fetch from the remote in
+   the future will use the default behaviour when neither is given
+   to override it.
+
+ * "git diff --shortstat --dirstat=changes" showed a dirstat based on
+   lines that was never asked by the end user in addition to the
+   dirstat that the user asked for.
+
+ * The interaction between "git submodule update" and the
+   submodule.*.update configuration was not clearly documented.
+
+ * "git apply" was not very careful about reading from, removing,
+   updating and creating paths outside the working tree (under
+   --index/--cached) or the current directory (when used as a
+   replacement for GNU patch).
+
+ * "git daemon" looked up the hostname even when "%CH" and "%IP"
+   interpolations are not requested, which was unnecessary.
+
+ * The "interpolated-path" option of "git daemon" inserted any string
+   client declared on the "host=" capability request without checking.
+   Sanitize and limit %H and %CH to a saner and a valid DNS name.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/2.4.0.txt b/Documentation/RelNotes/2.4.0.txt
new file mode 100644 (file)
index 0000000..072309e
--- /dev/null
@@ -0,0 +1,319 @@
+Git 2.4 Release Notes
+=====================
+
+Updates since v2.3
+------------------
+
+Ports
+
+ * Our default I/O size (8 MiB) for large files was too large for some
+   platforms with smaller SSIZE_MAX, leading to read(2)/write(2)
+   failures.
+
+ * We did not check the curl library version before using
+   CURLOPT_PROXYAUTH feature that may not exist.
+
+
+UI, Workflows & Features
+
+ * The command usage info strings given by "git cmd -h" and in
+   documentation have been tweaked for consistency.
+
+ * The "sync" subcommand of "git p4" now allows users to exclude
+   subdirectories like its "clone" subcommand does.
+
+ * "git log --invert-grep --grep=WIP" will show only commits that do
+   not have the string "WIP" in their messages.
+
+ * "git push" has been taught a "--atomic" option that makes push to
+   update more than one ref an "all-or-none" affair.
+
+ * Extending the "push to deploy" added in 2.3, the behaviour of "git
+   push" when updating the branch that is checked out can now be
+   tweaked by push-to-checkout hook.
+
+ * Using environment variable LANGUAGE and friends on the client side,
+   HTTP-based transports now send Accept-Language when making requests.
+
+ * "git send-email" used to accept a mistaken "y" (or "yes") as an
+   answer to "What encoding do you want to use [UTF-8]? " without
+   questioning.  Now it asks for confirmation when the answer looks
+   too short to be a valid encoding name.
+
+ * When "git apply --whitespace=fix" fixed whitespace errors in the
+   common context lines, the command reports that it did so.
+
+ * "git status" now allows the "-v" to be given twice to show the
+   differences that are left in the working tree not to be committed.
+
+ * "git cherry-pick" used to clean-up the log message even when it is
+   merely replaying an existing commit.  It now replays the message
+   verbatim unless you are editing the message of resulting commits.
+
+ * "git archive" can now be told to set the 'text' attribute in the
+   resulting zip archive.
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ * Implementation of N_() macro has been updated slightly to help us
+   detect mistakes.
+
+ * Implementation of "reflog expire" has been restructured to fit the
+   reflogs better with the recently updated ref API.
+
+ * The transport-helper did not give transport options such as
+   verbosity, progress, cloning, etc. to import and export based
+   helpers, like it did for fetch and push based helpers, robbing them
+   the chance to honor the wish of the end-users better.
+
+ * The tests that wanted to see that file becomes unreadable after
+   running "chmod a-r file", and the tests that wanted to make sure it
+   is not run as root, we used "can we write into the / directory?" as
+   a cheap substitute, but on some platforms that is not a good
+   heuristics.  The tests and their prerequisites have been updated to
+   check what they really require.
+   (merge f400e51 jk/sanity later to maint).
+
+ * Various issues around "reflog expire", e.g. using --updateref when
+   expiring a reflog for a symbolic reference, have been corrected
+   and/or made saner.
+
+ * The strbuf API was explained between the API documentation and in
+   the header file.  Move missing bits to strbuf.h so that programmers
+   can check only one place for all necessary information.
+
+ * The error handling functions and conventions are now documented in
+   the API manual.
+
+ * Optimize attribute look-up, mostly useful in "git grep" on a
+   project that does not use many attributes, by avoiding it when we
+   (should) know that the attributes are not defined in the first
+   place.
+
+ * Typofix in comments.
+   (merge ef2956a ak/git-pm-typofix later to maint).
+
+ * Code clean-up.
+   (merge 0b868f0 sb/hex-object-name-is-at-most-41-bytes-long later to maint).
+   (merge 5d30851 dp/remove-duplicated-header-inclusion later to maint).
+
+ * Simplify the ref transaction API around how "the ref should be
+   pointing at this object" is specified.
+
+
+Also contains various documentation updates and code clean-ups.
+
+
+Fixes since v2.3
+----------------
+
+Unless otherwise noted, all the fixes since v2.3 in the maintenance
+track are contained in this release (see the maintenance releases'
+notes for details).
+
+ * "git blame HEAD -- missing" failed to correctly say "HEAD" when it
+   tried to say "No such path 'missing' in HEAD".
+   (merge a46442f jk/blame-commit-label later to maint).
+
+ * "git rerere" (invoked internally from many mergy operations) did
+   not correctly signal errors when told to update the working tree
+   files and failed to do so for whatever reason.
+   (merge 89ea903 jn/rerere-fail-on-auto-update-failure later to maint).
+
+ * Setting diff.submodule to 'log' made "git format-patch" produce
+   broken patches.
+   (merge 339de50 dk/format-patch-ignore-diff-submodule later to maint).
+
+ * After attempting and failing a password-less authentication
+   (e.g. kerberos), libcURL refuses to fall back to password based
+   Basic authentication without a bit of help/encouragement.
+   (merge 4dbe664 bc/http-fallback-to-password-after-krb-fails later to maint).
+
+ * The "git push" documentation made the "--repo=<there>" option
+   easily misunderstood.
+   (merge 57b92a7 mg/push-repo-option-doc later to maint).
+
+ * Code to read branch name from various files in .git/ directory
+   would have misbehaved if the code to write them left an empty file.
+   (merge 66ec904 jk/status-read-branch-name-fix later to maint).
+
+ * A misspelled conditional that is always true has been fixed.
+   (merge 94ee8e2 jk/remote-curl-an-array-in-struct-cannot-be-null later to maint).
+
+ * The documentation incorrectly said that C(opy) and R(ename) are the
+   only ones that can be followed by the score number in the output in
+   the --raw format.
+   (merge ac1c2d9 jc/diff-format-doc later to maint).
+
+ * A broken pack .idx file in the receiving repository prevented the
+   dumb http transport from fetching a good copy of it from the other
+   side.
+   (merge 8b9c2dd jk/dumb-http-idx-fetch-fix later to maint).
+
+ * The error message from "git commit", when a non-existing author
+   name was given as value to the "--author=" parameter, has been
+   reworded to avoid misunderstanding.
+   (merge 1044b1f mg/commit-author-no-match-malformed-message later to maint).
+
+ * "git log --help" used to show rev-list options that are irrelevant
+   to the "log" command.
+   (merge 3cab02d jc/doc-log-rev-list-options later to maint).
+
+ * "git apply --whitespace=fix" used to under-allocate the memory when
+   the fix resulted in a longer text than the original patch.
+   (merge 407a792 jc/apply-ws-fix-expands later to maint).
+
+ * The interactive "show a list and let the user choose from it"
+   interface "add -i" used showed and prompted to the user even when
+   the candidate list was empty, against which the only "choice" the
+   user could have made was to choose nothing.
+   (merge a9c4641 ak/add-i-empty-candidates later to maint).
+
+ * The insn sheet "git rebase -i" creates did not fully honor
+   core.abbrev settings.
+   (merge edb72d5 ks/rebase-i-abbrev later to maint).
+
+ * "git fetch" over a remote-helper that cannot respond to "list"
+   command could not fetch from a symbolic reference e.g. HEAD.
+   (merge 33cae54 mh/deref-symref-over-helper-transport later to maint).
+
+ * "git push --signed" gave an incorrectly worded error message when
+   the other side did not support the capability.
+   (merge 45917f0 jc/push-cert later to maint).
+
+ * We didn't format an integer that wouldn't fit in "int" but in
+   "uintmax_t" correctly.
+   (merge d306f3d jk/decimal-width-for-uintmax later to maint).
+
+ * Reading configuration from a blob object, when it ends with a lone
+   CR, use to confuse the configuration parser.
+   (merge 1d0655c jk/config-no-ungetc-eof later to maint).
+
+ * The pack bitmap support did not build with older versions of GCC.
+   (merge bd4e882 jk/pack-bitmap later to maint).
+
+ * The documentation wasn't clear that "remote.<nick>.pushURL" and
+   "remote.<nick>.URL" are there to name the same repository accessed
+   via different transports, not two separate repositories.
+   (merge 697f652 jc/remote-set-url-doc later to maint).
+
+ * Older GnuPG implementations may not correctly import the keyring
+   material we prepare for the tests to use.
+   (merge 1f985d6 ch/new-gpg-drops-rfc-1991 later to maint).
+
+ * The credential helper for Windows (in contrib/) used to mishandle
+   a user name with an at-sign in it.
+   (merge 13d261e av/wincred-with-at-in-username-fix later to maint).
+
+ * Longstanding configuration variable naming rules has been added to
+   the documentation.
+   (merge 35840a3 jc/conf-var-doc later to maint).
+
+ * An earlier workaround to squelch unhelpful deprecation warnings
+   from the complier on Mac OSX unnecessarily set minimum required
+   version of the OS, which the user might want to raise (or lower)
+   for other reasons.
+   (merge 88c03eb es/squelch-openssl-warnings-on-macosx later to maint).
+
+ * Certain older vintages of cURL give irregular output from
+   "curl-config --vernum", which confused our build system.
+   (merge 3af6792 tc/curl-vernum-output-broken-in-7.11 later to maint).
+
+ * In v2.2.0, we broke "git prune" that runs in a repository that
+   borrows from an alternate object store.
+   (merge b0a4264 jk/prune-mtime later to maint).
+
+ * "git submodule add" failed to squash "path/to/././submodule" to
+   "path/to/submodule".
+   (merge 8196e72 ps/submodule-sanitize-path-upon-add later to maint).
+
+ * "git merge-file" did not work correctly in a subdirectory.
+   (merge 204a8ff ab/merge-file-prefix later to maint).
+
+ * "git blame" died, trying to free an uninitialized piece of memory.
+   (merge e600592 es/blame-commit-info-fix later to maint).
+
+ * "git fast-import" used to crash when it could not close and
+   conclude the resulting packfile cleanly.
+   (merge 5e915f3 jk/fast-import-die-nicely-fix later to maint).
+
+ * "update-index --refresh" used to leak when an entry cannot be
+   refreshed for whatever reason.
+   (merge bc1c2ca sb/plug-leak-in-make-cache-entry later to maint).
+
+ * The "interpolated-path" option of "git daemon" inserted any string
+   client declared on the "host=" capability request without checking.
+   Sanitize and limit %H and %CH to a saner and a valid DNS name.
+   (merge b485373 jk/daemon-interpolate later to maint).
+
+ * "git daemon" looked up the hostname even when "%CH" and "%IP"
+   interpolations are not requested, which was unnecessary.
+   (merge dc8edc8 rs/daemon-interpolate later to maint).
+
+ * Even though we officially haven't dropped Perl 5.8 support, the
+   Getopt::Long package that came with it does not support "--no-"
+   prefix to negate a boolean option; manually add support to help
+   people with older Getopt::Long package.
+   (merge f471494 km/send-email-getopt-long-workarounds later to maint).
+
+ * "git apply" was not very careful about reading from, removing,
+   updating and creating paths outside the working tree (under
+   --index/--cached) or the current directory (when used as a
+   replacement for GNU patch).
+   (merge e0d201b jc/apply-beyond-symlink later to maint).
+
+ * A breakage to git-svn around v2.2 era that triggers premature
+   closing of FileHandle has been corrected.
+   (merge e426311 ew/svn-maint-fixes later to maint).
+
+ * We did not parse username followed by literal IPv6 address in SSH
+   transport URLs, e.g. ssh://user@[2001:db8::1]:22/repo.git
+   correctly.
+   (merge 3f55cca tb/connect-ipv6-parse-fix later to maint).
+
+ * The configuration variable 'mailinfo.scissors' was hard to
+   discover in the documentation.
+   (merge afb5de7 mm/am-c-doc later to maint).
+
+ * The interaction between "git submodule update" and the
+   submodule.*.update configuration was not clearly documented.
+   (merge 5c31acf ms/submodule-update-config-doc later to maint).
+
+ * "git diff --shortstat --dirstat=changes" showed a dirstat based on
+   lines that was never asked by the end user in addition to the
+   dirstat that the user asked for.
+   (merge ab27389 mk/diff-shortstat-dirstat-fix later to maint).
+
+ * "git remote add" mentioned "--tags" and "--no-tags" and was not
+   clear that fetch from the remote in the future will use the default
+   behaviour when neither is given to override it.
+   (merge aaba0ab mg/doc-remote-tags-or-not later to maint).
+
+ * Description given by "grep -h" for its --exclude-standard option
+   was phrased poorly.
+   (merge 77fdb8a nd/grep-exclude-standard-help-fix later to maint).
+
+ * "git rebase -i" recently started to include the number of
+   commits in the insn sheet to be processed, but on a platform
+   that prepends leading whitespaces to "wc -l" output, the numbers
+   are shown with extra whitespaces that aren't necessary.
+   (merge 2185d3b es/rebase-i-count-todo later to maint).
+
+ * The borrowed code in kwset API did not follow our usual convention
+   to use "unsigned char" to store values that range from 0-255.
+   (merge 189c860 bw/kwset-use-unsigned later to maint).
+
+ * A corrupt input to "git diff -M" used to cause it to segfault.
+   (merge 4d6be03 jk/diffcore-rename-duplicate later to maint).
+
+ * Code cleanups and documentaiton updates.
+   (merge 2ce63e9 rs/simple-cleanups later to maint).
+   (merge 33baa69 rj/no-xopen-source-for-cygwin later to maint).
+   (merge 817d03e jc/diff-test-updates later to maint).
+   (merge eb32c66 ak/t5516-typofix later to maint).
+   (merge bcd57cb mr/doc-clean-f-f later to maint).
+   (merge 0d6accc mg/doc-status-color-slot later to maint).
+   (merge 53e53c7 sg/completion-remote later to maint).
+   (merge 8fa7975 ak/git-done-help-cleanup later to maint).
+   (merge 9a6f128 rs/deflate-init-cleanup later to maint).
index 440784cbdd4eaca18e295e382b7568146c0c1e78..35a5198856184f3e9f28bca2544de87a016c4b50 100644 (file)
@@ -956,9 +956,11 @@ color.status.<slot>::
        `added` or `updated` (files which are added but not committed),
        `changed` (files which are changed but not added in the index),
        `untracked` (files which are not tracked by Git),
-       `branch` (the current branch), or
+       `branch` (the current branch),
        `nobranch` (the color the 'no branch' warning is shown in, defaulting
-       to red). The values of these variables may be specified as in
+       to red), or
+       `unmerged` (files which have unmerged changes).
+       The values of these variables may be specified as in
        color.branch.<slot>.
 
 color.ui::
@@ -1739,6 +1741,13 @@ log.mailmap::
        If true, makes linkgit:git-log[1], linkgit:git-show[1], and
        linkgit:git-whatchanged[1] assume `--use-mailmap`.
 
+mailinfo.scissors::
+       If true, makes linkgit:git-mailinfo[1] (and therefore
+       linkgit:git-am[1]) act by default as if the --scissors option
+       was provided on the command-line. When active, this features
+       removes everything from the message body before a scissors
+       line (i.e. consisting mainly of ">8", "8<" and "-").
+
 mailmap.file::
        The location of an augmenting mailmap file. The default
        mailmap, located in the root of the repository, is loaded
@@ -2410,12 +2419,16 @@ status.submodulesummary::
 
 submodule.<name>.path::
 submodule.<name>.url::
+       The path within this project and URL for a submodule. These
+       variables are initially populated by 'git submodule init'. See
+       linkgit:git-submodule[1] and linkgit:gitmodules[5] for
+       details.
+
 submodule.<name>.update::
-       The path within this project, URL, and the updating strategy
-       for a submodule.  These variables are initially populated
-       by 'git submodule init'; edit them to override the
-       URL and other values found in the `.gitmodules` file.  See
-       linkgit:git-submodule[1] and linkgit:gitmodules[5] for details.
+       The default update procedure for a submodule. This variable
+       is populated by `git submodule init` from the
+       linkgit:gitmodules[5] file. See description of 'update'
+       command in linkgit:git-submodule[1].
 
 submodule.<name>.branch::
        The remote branch name for a submodule, used by `git submodule
@@ -2547,6 +2560,18 @@ user.signingkey::
        This option is passed unchanged to gpg's --local-user parameter,
        so you may specify a key using any method that gpg supports.
 
+versionsort.prereleaseSuffix::
+       When version sort is used in linkgit:git-tag[1], prerelease
+       tags (e.g. "1.0-rc1") may appear after the main release
+       "1.0". By specifying the suffix "-rc" in this variable,
+       "1.0-rc1" will appear before "1.0".
++
+This variable can be specified multiple times, once per suffix. The
+order of suffixes in the config file determines the sorting order
+(e.g. if "-pre" appears before "-rc" in the config file then 1.0-preXX
+is sorted before 1.0-rcXX). The sorting order between different
+suffixes is undefined if they are in multiple config files.
+
 web.browser::
        Specify a web browser that may be used by some commands.
        Currently only linkgit:git-instaweb[1] and linkgit:git-help[1]
index f4eea28dc4d03e02f9af3eedba5d15743b8553f6..0d8ba48f792ae82237a56aa0dd2aca03f4e16020 100644 (file)
@@ -52,7 +52,8 @@ OPTIONS
 -c::
 --scissors::
        Remove everything in body before a scissors line (see
-       linkgit:git-mailinfo[1]).
+       linkgit:git-mailinfo[1]). Can be activated by default using
+       the `mailinfo.scissors` configuration variable.
 
 --no-scissors::
        Ignore scissors lines (see linkgit:git-mailinfo[1]).
index 94b6d19cf2a658a9258ee54b141b4eb9b1a6cae3..641681f61ad360fcfd5aa98f81a9e3d49c44c8a7 100644 (file)
@@ -34,8 +34,12 @@ OPTIONS
 -f::
 --force::
        If the Git configuration variable clean.requireForce is not set
-       to false, 'git clean' will refuse to run unless given -f, -n or
-       -i.
+       to false, 'git clean' will refuse to delete files or directories
+       unless given -f, -n or -i. Git will refuse to delete directories
+       with .git sub directory or file unless a second -f
+       is given. This affects also git submodules where the storage area
+       of the removed submodule under .git/modules/ is not removed until
+       -f is given twice.
 
 -i::
 --interactive::
index 1e74b75d383838b3828f3fee20750c399d77cba0..f14d2ececde44fba0aafcddbbca7dbb80bcb53f0 100644 (file)
@@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].
        would be committed at the bottom of the commit message
        template.  Note that this diff output doesn't have its
        lines prefixed with '#'.
++
+If specified twice, show in addition the unified diff between
+what would be committed and the worktree files, i.e. the unstaged
+changes to tracked files.
 
 -q::
 --quiet::
index 70791b9fd88b4c64260523a5fcadcb46ce504f8f..5e7908e4f705d858dca8483069fd3b89c8f7e31c 100644 (file)
@@ -17,85 +17,113 @@ The command takes various subcommands, and different options
 depending on the subcommand:
 
 [verse]
-'git reflog expire' [--dry-run] [--stale-fix] [--verbose]
-       [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
-'git reflog delete' ref@\{specifier\}...
 'git reflog' ['show'] [log-options] [<ref>]
+'git reflog expire' [--expire=<time>] [--expire-unreachable=<time>]
+       [--rewrite] [--updateref] [--stale-fix]
+       [--dry-run] [--verbose] [--all | <refs>...]
+'git reflog delete' [--rewrite] [--updateref]
+       [--dry-run] [--verbose] ref@\{specifier\}...
+
+Reference logs, or "reflogs", record when the tips of branches and
+other references were updated in the local repository. Reflogs are
+useful in various Git commands, to specify the old value of a
+reference. For example, `HEAD@{2}` means "where HEAD used to be two
+moves ago", `master@{one.week.ago}` means "where master used to point
+to one week ago in this local repository", and so on. See
+linkgit:gitrevisions[7] for more details.
+
+This command manages the information recorded in the reflogs.
+
+The "show" subcommand (which is also the default, in the absence of
+any subcommands) shows the log of the reference provided in the
+command-line (or `HEAD`, by default). The reflog covers all recent
+actions, and in addition the `HEAD` reflog records branch switching.
+`git reflog show` is an alias for `git log -g --abbrev-commit
+--pretty=oneline`; see linkgit:git-log[1] for more information.
+
+The "expire" subcommand prunes older reflog entries. Entries older
+than `expire` time, or entries older than `expire-unreachable` time
+and not reachable from the current tip, are removed from the reflog.
+This is typically not used directly by end users -- instead, see
+linkgit:git-gc[1].
+
+The "delete" subcommand deletes single entries from the reflog. Its
+argument must be an _exact_ entry (e.g. "`git reflog delete
+master@{2}`"). This subcommand is also typically not used directly by
+end users.
 
-Reflog is a mechanism to record when the tip of branches are
-updated.  This command is to manage the information recorded in it.
 
-The subcommand "expire" is used to prune older reflog entries.
-Entries older than `expire` time, or entries older than
-`expire-unreachable` time and not reachable from the current
-tip, are removed from the reflog.  This is typically not used
-directly by the end users -- instead, see linkgit:git-gc[1].
-
-The subcommand "show" (which is also the default, in the absence of any
-subcommands) will take all the normal log options, and show the log of
-the reference provided in the command-line (or `HEAD`, by default).
-The reflog will cover all recent actions (HEAD reflog records branch switching
-as well).  It is an alias for `git log -g --abbrev-commit --pretty=oneline`;
-see linkgit:git-log[1].
+OPTIONS
+-------
 
-The reflog is useful in various Git commands, to specify the old value
-of a reference. For example, `HEAD@{2}` means "where HEAD used to be
-two moves ago", `master@{one.week.ago}` means "where master used to
-point to one week ago", and so on. See linkgit:gitrevisions[7] for
-more details.
+Options for `show`
+~~~~~~~~~~~~~~~~~~
 
-To delete single entries from the reflog, use the subcommand "delete"
-and specify the _exact_ entry (e.g. "`git reflog delete master@{2}`").
+`git reflog show` accepts any of the options accepted by `git log`.
 
 
-OPTIONS
--------
+Options for `expire`
+~~~~~~~~~~~~~~~~~~~~
 
---stale-fix::
-       This revamps the logic -- the definition of "broken commit"
-       becomes: a commit that is not reachable from any of the refs and
-       there is a missing object among the commit, tree, or blob
-       objects reachable from it that is not reachable from any of the
-       refs.
-+
-This computation involves traversing all the reachable objects, i.e. it
-has the same cost as 'git prune'.  Fortunately, once this is run, we
-should not have to ever worry about missing objects, because the current
-prune and pack-objects know about reflogs and protect objects referred by
-them.
+--all::
+       Process the reflogs of all references.
 
 --expire=<time>::
-       Entries older than this time are pruned.  Without the
-       option it is taken from configuration `gc.reflogExpire`,
-       which in turn defaults to 90 days.  --expire=all prunes
-       entries regardless of their age; --expire=never turns off
-       pruning of reachable entries (but see --expire-unreachable).
+       Prune entries older than the specified time. If this option is
+       not specified, the expiration time is taken from the
+       configuration setting `gc.reflogExpire`, which in turn
+       defaults to 90 days. `--expire=all` prunes entries regardless
+       of their age; `--expire=never` turns off pruning of reachable
+       entries (but see `--expire-unreachable`).
 
 --expire-unreachable=<time>::
-       Entries older than this time and not reachable from
-       the current tip of the branch are pruned.  Without the
-       option it is taken from configuration
-       `gc.reflogExpireUnreachable`, which in turn defaults to
-       30 days.  --expire-unreachable=all prunes unreachable
-       entries regardless of their age; --expire-unreachable=never
+       Prune entries older than `<time>` that are not reachable from
+       the current tip of the branch. If this option is not
+       specified, the expiration time is taken from the configuration
+       setting `gc.reflogExpireUnreachable`, which in turn defaults
+       to 30 days. `--expire-unreachable=all` prunes unreachable
+       entries regardless of their age; `--expire-unreachable=never`
        turns off early pruning of unreachable entries (but see
-       --expire).
-
---all::
-       Instead of listing <refs> explicitly, prune all refs.
+       `--expire`).
 
 --updateref::
-       Update the ref with the sha1 of the top reflog entry (i.e.
-       <ref>@\{0\}) after expiring or deleting.
+       Update the reference to the value of the top reflog entry (i.e.
+       <ref>@\{0\}) if the previous top entry was pruned.  (This
+       option is ignored for symbolic references.)
 
 --rewrite::
-       While expiring or deleting, adjust each reflog entry to ensure
-       that the `old` sha1 field points to the `new` sha1 field of the
-       previous entry.
+       If a reflog entry's predecessor is pruned, adjust its "old"
+       SHA-1 to be equal to the "new" SHA-1 field of the entry that
+       now precedes it.
+
+--stale-fix::
+       Prune any reflog entries that point to "broken commits". A
+       broken commit is a commit that is not reachable from any of
+       the reference tips and that refers, directly or indirectly, to
+       a missing commit, tree, or blob object.
++
+This computation involves traversing all the reachable objects, i.e. it
+has the same cost as 'git prune'.  It is primarily intended to fix
+corruption caused by garbage collecting using older versions of Git,
+which didn't protect objects referred to by reflogs.
+
+-n::
+--dry-run::
+       Do not actually prune any entries; just show what would have
+       been pruned.
 
 --verbose::
        Print extra information on screen.
 
+
+Options for `delete`
+~~~~~~~~~~~~~~~~~~~~
+
+`git reflog delete` accepts options `--updateref`, `--rewrite`, `-n`,
+`--dry-run`, and `--verbose`, with the same meanings as when they are
+used with `expire`.
+
+
 GIT
 ---
 Part of the linkgit:git[1] suite
index a77607b852c1f9cbcea7b9d1a359e5c467933aa0..4c6d6de7b77c2f1a70e2335fed0e65e956f99c6f 100644 (file)
@@ -58,6 +58,9 @@ remote repository.
 With `--no-tags` option, `git fetch <name>` does not import tags from
 the remote repository.
 +
+By default, only tags on fetched branches are imported
+(see linkgit:git-fetch[1]).
++
 With `-t <branch>` option, instead of the default glob
 refspec for the remote to track all branches under
 the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>`
index 8e6af65da0e0f234315c42391a8bab42fc39abb6..2c25916f8f7cd0a7ca69c3b980d85251a29b681b 100644 (file)
@@ -154,27 +154,51 @@ If `--force` is specified, the submodule's work tree will be removed even if
 it contains local modifications.
 
 update::
-       Update the registered submodules, i.e. clone missing submodules and
-       checkout the commit specified in the index of the containing repository.
-       This will make the submodules HEAD be detached unless `--rebase` or
-       `--merge` is specified or the key `submodule.$name.update` is set to
-       `rebase`, `merge` or `none`. `none` can be overridden by specifying
-       `--checkout`. Setting the key `submodule.$name.update` to `!command`
-       will cause `command` to be run. `command` can be any arbitrary shell
-       command that takes a single argument, namely the sha1 to update to.
 +
+--
+Update the registered submodules to match what the superproject
+expects by cloning missing submodules and updating the working tree of
+the submodules. The "updating" can be done in several ways depending
+on command line options and the value of `submodule.<name>.update`
+configuration variable. Supported update procedures are:
+
+       checkout;; the commit recorded in the superproject will be
+           checked out in the submodule on a detached HEAD. This is
+           done when `--checkout` option is given, or no option is
+           given, and `submodule.<name>.update` is unset, or if it is
+           set to 'checkout'.
++
+If `--force` is specified, the submodule will be checked out (using
+`git checkout --force` if appropriate), even if the commit specified
+in the index of the containing repository already matches the commit
+checked out in the submodule.
+
+       rebase;; the current branch of the submodule will be rebased
+           onto the commit recorded in the superproject. This is done
+           when `--rebase` option is given, or no option is given, and
+           `submodule.<name>.update` is set to 'rebase'.
+
+       merge;; the commit recorded in the superproject will be merged
+           into the current branch in the submodule. This is done
+           when `--merge` option is given, or no option is given, and
+           `submodule.<name>.update` is set to 'merge'.
+
+       custom command;; arbitrary shell command that takes a single
+           argument (the sha1 of the commit recorded in the
+           superproject) is executed. This is done when no option is
+           given, and `submodule.<name>.update` has the form of
+           '!command'.
+
+When no option is given and `submodule.<name>.update` is set to 'none',
+the submodule is not updated.
+
 If the submodule is not yet initialized, and you just want to use the
 setting as stored in .gitmodules, you can automatically initialize the
 submodule with the `--init` option.
-+
+
 If `--recursive` is specified, this command will recurse into the
 registered submodules, and update any nested submodules within.
-+
-If `--force` is specified, the submodule will be checked out (using
-`git checkout --force` if appropriate), even if the commit specified in the
-index of the containing repository already matches the commit checked out in
-the submodule.
-
+--
 summary::
        Show commit summary between the given commit (defaults to HEAD) and
        working tree/index. For a submodule in question, a series of commits
@@ -238,10 +262,12 @@ OPTIONS
        When running add, allow adding an otherwise ignored submodule path.
        When running deinit the submodule work trees will be removed even if
        they contain local changes.
-       When running update, throw away local changes in submodules when
-       switching to a different commit; and always run a checkout operation
-       in the submodule, even if the commit listed in the index of the
-       containing repository matches the commit checked out in the submodule.
+       When running update (only effective with the checkout procedure),
+       throw away local changes in submodules when switching to a
+       different commit; and always run a checkout operation in the
+       submodule, even if the commit listed in the index of the
+       containing repository matches the commit checked out in the
+       submodule.
 
 --cached::
        This option is only valid for status and summary commands.  These
@@ -302,7 +328,7 @@ the submodule itself.
        Checkout the commit recorded in the superproject on a detached HEAD
        in the submodule. This is the default behavior, the main use of
        this option is to override `submodule.$name.update` when set to
-       `merge`, `rebase` or `none`.
+       a value other than `checkout`.
        If the key `submodule.$name.update` is either not explicitly set or
        set to `checkout`, this option is implicit.
 
index b37f1abe8c72cac5a8bfb2fca05fc6ff3f7335c4..af306209e936e0387e08d779815f995988565cc4 100644 (file)
@@ -43,9 +43,11 @@ unreleased) version of Git, that is available from the 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v2.3.1/git.html[documentation for release 2.3.1]
+* link:v2.3.3/git.html[documentation for release 2.3.3]
 
 * release notes for
+  link:RelNotes/2.3.3.txt[2.3.3],
+  link:RelNotes/2.3.2.txt[2.3.2],
   link:RelNotes/2.3.1.txt[2.3.1],
   link:RelNotes/2.3.0.txt[2.3].
 
index f6c0dfd0290a9b2174c645630998d2a62cdb9f5e..ac70eca321cd1747e2916646c691ac18cb4dbd97 100644 (file)
@@ -38,18 +38,15 @@ submodule.<name>.url::
 In addition, there are a number of optional keys:
 
 submodule.<name>.update::
-       Defines what to do when the submodule is updated by the superproject.
-       If 'checkout' (the default), the new commit specified in the
-       superproject will be checked out in the submodule on a detached HEAD.
-       If 'rebase', the current branch of the submodule will be rebased onto
-       the commit specified in the superproject. If 'merge', the commit
-       specified in the superproject will be merged into the current branch
-       in the submodule.
-       If 'none', the submodule with name `$name` will not be updated
-       by default.
-
-       This config option is overridden if 'git submodule update' is given
-       the '--merge', '--rebase' or '--checkout' options.
+       Defines the default update procedure for the named submodule,
+       i.e. how the submodule is updated by "git submodule update"
+       command in the superproject. This is only used by `git
+       submodule init` to initialize the configuration variable of
+       the same name. Allowed values here are 'checkout', 'rebase',
+       'merge' or 'none'. See description of 'update' command in
+       linkgit:git-submodule[1] for their meaning. Note that the
+       '!command' form is intentionally ignored here for security
+       reasons.
 
 submodule.<name>.branch::
        A remote branch name for tracking updates in the upstream submodule.
index 04077889761666d454cefb3fb8e38255a35efede..734fa9b4347ac1f65ad35ada88098404d92fcb25 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v2.3.1
+DEF_VER=v2.3.3.GIT
 
 LF='
 '
deleted file mode 100644 (file)
index 2b46ebac0aa55b776b5076def426cd52e2b5daf3..0000000000000000000000000000000000000000
--- a/RelNotes
+++ /dev/null
@@ -1,224 +0,0 @@
-Git ???? Release Notes
-======================
-
-Updates since v2.3
-------------------
-
-Ports
-
- * Our default I/O size (8 MiB) for large files was too large for some
-   platforms with smaller SSIZE_MAX, leading to read(2)/write(2)
-   failures.
-
- * We did not check the curl library version before using
-   CURLOPT_PROXYAUTH feature that may not exist.
-
-
-UI, Workflows & Features
-
- * The command usage info strings given by "git cmd -h" and in
-   documentation have been tweaked for consistency.
-
- * The "sync" subcommand of "git p4" now allows users to exclude
-   subdirectories like its "clone" subcommand does.
-
- * "git log --invert-grep --grep=WIP" will show only commits that do
-   not have the string "WIP" in their messages.
-
- * "git push" has been taught a "--atomic" option that makes push to
-   update more than one ref an "all-or-none" affair.
-
- * Extending the "push to deploy" added in 2.3, the behaviour of "git
-   push" when updating the branch that is checked out can now be
-   tweaked by push-to-checkout hook.
-
- * Using environment variable LANGUAGE and friends on the client side,
-   HTTP-based transports now send Accept-Language when making requests.
-
- * "git send-email" used to accept a mistaken "y" (or "yes") as an
-   answer to "What encoding do you want to use [UTF-8]? " without
-   questioning.  Now it asks for confirmation when the answer looks
-   too short to be a valid encoding name.
-
-
-Performance, Internal Implementation, Development Support etc.
-
- * Implementation of N_() macro has been updated slightly to help us
-   detect mistakes.
-
- * Implementation of "reflog expire" has been restructured to fit the
-   reflogs better with the recently updated ref API.
-
- * The transport-helper did not give transport options such as
-   verbosity, progress, cloning, etc. to import and export based
-   helpers, like it did for fetch and push based helpers, robbing them
-   the chance to honor the wish of the end-users better.
-
- * The tests that wanted to see that file becomes unreadable after
-   running "chmod a-r file", and the tests that wanted to make sure it
-   is not run as root, we used "can we write into the / directory?" as
-   a cheap substitute, but on some platforms that is not a good
-   heuristics.  The tests and their prerequisites have been updated to
-   check what they really require.
-   (merge f400e51 jk/sanity later to maint).
-
- * The strbuf API was explained between the API documentation and in
-   the header file.  Move missing bits to strbuf.h so that programmers
-   can check only one place for all necessary information.
-
- * The error handling functions and conventions are now documented in
-   the API manual.
-
- * Optimize attribute look-up, mostly useful in "git grep" on a
-   project that does not use many attributes, by avoiding it when we
-   (should) know that the attributes are not defined in the first
-   place.
-
- * Typofix in comments.
-   (merge ef2956a ak/git-pm-typofix later to maint).
-
- * Code clean-up.
-   (merge 0b868f0 sb/hex-object-name-is-at-most-41-bytes-long later to maint).
-   (merge 5d30851 dp/remove-duplicated-header-inclusion later to maint).
-
-
-
-Also contains various documentation updates and code clean-ups.
-
-
-Fixes since v2.3
-----------------
-
-Unless otherwise noted, all the fixes since v2.3 in the maintenance
-track are contained in this release (see the maintenance releases'
-notes for details).
-
- * "git blame HEAD -- missing" failed to correctly say "HEAD" when it
-   tried to say "No such path 'missing' in HEAD".
-   (merge a46442f jk/blame-commit-label later to maint).
-
- * "git rerere" (invoked internally from many mergy operations) did
-   not correctly signal errors when told to update the working tree
-   files and failed to do so for whatever reason.
-   (merge 89ea903 jn/rerere-fail-on-auto-update-failure later to maint).
-
- * Setting diff.submodule to 'log' made "git format-patch" produce
-   broken patches.
-   (merge 339de50 dk/format-patch-ignore-diff-submodule later to maint).
-
- * After attempting and failing a password-less authentication
-   (e.g. kerberos), libcURL refuses to fall back to password based
-   Basic authentication without a bit of help/encouragement.
-   (merge 4dbe664 bc/http-fallback-to-password-after-krb-fails later to maint).
-
- * The "git push" documentation made the "--repo=<there>" option
-   easily misunderstood.
-   (merge 57b92a7 mg/push-repo-option-doc later to maint).
-
- * Code to read branch name from various files in .git/ directory
-   would have misbehaved if the code to write them left an empty file.
-   (merge 66ec904 jk/status-read-branch-name-fix later to maint).
-
- * A misspelled conditional that is always true has been fixed.
-   (merge 94ee8e2 jk/remote-curl-an-array-in-struct-cannot-be-null later to maint).
-
- * The documentation incorrectly said that C(opy) and R(ename) are the
-   only ones that can be followed by the score number in the output in
-   the --raw format.
-   (merge ac1c2d9 jc/diff-format-doc later to maint).
-
- * A broken pack .idx file in the receiving repository prevented the
-   dumb http transport from fetching a good copy of it from the other
-   side.
-   (merge 8b9c2dd jk/dumb-http-idx-fetch-fix later to maint).
-
- * The error message from "git commit", when a non-existing author
-   name was given as value to the "--author=" parameter, has been
-   reworded to avoid misunderstanding.
-   (merge 1044b1f mg/commit-author-no-match-malformed-message later to maint).
-
- * "git log --help" used to show rev-list options that are irrelevant
-   to the "log" command.
-   (merge 3cab02d jc/doc-log-rev-list-options later to maint).
-
- * "git apply --whitespace=fix" used to under-allocate the memory when
-   the fix resulted in a longer text than the original patch.
-   (merge 407a792 jc/apply-ws-fix-expands later to maint).
-
- * The interactive "show a list and let the user choose from it"
-   interface "add -i" used showed and prompted to the user even when
-   the candidate list was empty, against which the only "choice" the
-   user could have made was to choose nothing.
-   (merge a9c4641 ak/add-i-empty-candidates later to maint).
-
- * The insn sheet "git rebase -i" creates did not fully honor
-   core.abbrev settings.
-   (merge edb72d5 ks/rebase-i-abbrev later to maint).
-
- * "git fetch" over a remote-helper that cannot respond to "list"
-   command could not fetch from a symbolic reference e.g. HEAD.
-   (merge 33cae54 mh/deref-symref-over-helper-transport later to maint).
-
- * "git push --signed" gave an incorrectly worded error message when
-   the other side did not support the capability.
-   (merge 45917f0 jc/push-cert later to maint).
-
- * We didn't format an integer that wouldn't fit in "int" but in
-   "uintmax_t" correctly.
-   (merge d306f3d jk/decimal-width-for-uintmax later to maint).
-
- * Reading configuration from a blob object, when it ends with a lone
-   CR, use to confuse the configuration parser.
-   (merge 1d0655c jk/config-no-ungetc-eof later to maint).
-
- * The pack bitmap support did not build with older versions of GCC.
-   (merge bd4e882 jk/pack-bitmap later to maint).
-
- * The documentation wasn't clear that "remote.<nick>.pushURL" and
-   "remote.<nick>.URL" are there to name the same repository accessed
-   via different transports, not two separate repositories.
-   (merge 697f652 jc/remote-set-url-doc later to maint).
-
- * Older GnuPG implementations may not correctly import the keyring
-   material we prepare for the tests to use.
-   (merge 1f985d6 ch/new-gpg-drops-rfc-1991 later to maint).
-
- * The credential helper for Windows (in contrib/) used to mishandle
-   a user name with an at-sign in it.
-   (merge 13d261e av/wincred-with-at-in-username-fix later to maint).
-
- * Longstanding configuration variable naming rules has been added to
-   the documentation.
-   (merge 35840a3 jc/conf-var-doc later to maint).
-
- * An earlier workaround to squelch unhelpful deprecation warnings
-   from the complier on Mac OSX unnecessarily set minimum required
-   version of the OS, which the user might want to raise (or lower)
-   for other reasons.
-   (merge 88c03eb es/squelch-openssl-warnings-on-macosx later to maint).
-
- * Certain older vintages of cURL give irregular output from
-   "curl-config --vernum", which confused our build system.
-   (merge 3af6792 tc/curl-vernum-output-broken-in-7.11 later to maint).
-
- * In v2.2.0, we broke "git prune" that runs in a repository that
-   borrows from an alternate object store.
-   (merge b0a4264 jk/prune-mtime later to maint).
-
- * "git submodule add" failed to squash "path/to/././submodule" to
-   "path/to/submodule".
-   (merge 8196e72 ps/submodule-sanitize-path-upon-add later to maint).
-
- * "git merge-file" did not work correctly in a subdirectory.
-   (merge 204a8ff ab/merge-file-prefix later to maint).
-
- * "git blame" died, trying to free an uninitialized piece of memory.
-   (merge e600592 es/blame-commit-info-fix later to maint).
-
- * "git fast-import" used to crash when it could not close and
-   conclude the resulting packfile cleanly.
-   (merge 5e915f3 jk/fast-import-die-nicely-fix later to maint).
-
- * "update-index --refresh" used to leak when an entry cannot be
-   refreshed for whatever reason.
-   (merge bc1c2ca sb/plug-leak-in-make-cache-entry later to maint).
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..1addbec92533510e6e368c607deb36e504bbc438
--- /dev/null
+++ b/RelNotes
@@ -0,0 +1 @@
+Documentation/RelNotes/2.4.0.txt
\ No newline at end of file
index 4bde019bce632703d4e336d6404693487cdbcdfb..ffb3535e93dca2135724d998657b80c2bc4d6f20 100644 (file)
@@ -5,6 +5,8 @@
 #include "archive.h"
 #include "streaming.h"
 #include "utf8.h"
+#include "userdiff.h"
+#include "xdiff-interface.h"
 
 static int zip_date;
 static int zip_time;
@@ -120,7 +122,6 @@ static void *zlib_deflate_raw(void *data, unsigned long size,
        void *buffer;
        int result;
 
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init_raw(&stream, compression_level);
        maxsize = git_deflate_bound(&stream, size);
        buffer = xmalloc(maxsize);
@@ -189,6 +190,16 @@ static int has_only_ascii(const char *s)
        }
 }
 
+static int entry_is_binary(const char *path, const void *buffer, size_t size)
+{
+       struct userdiff_driver *driver = userdiff_find_by_path(path);
+       if (!driver)
+               driver = userdiff_find_by_name("default");
+       if (driver->binary != -1)
+               return driver->binary;
+       return buffer_is_binary(buffer, size);
+}
+
 #define STREAM_BUFFER_SIZE (1024 * 16)
 
 static int write_zip_entry(struct archiver_args *args,
@@ -210,6 +221,8 @@ static int write_zip_entry(struct archiver_args *args,
        struct git_istream *stream = NULL;
        unsigned long flags = 0;
        unsigned long size;
+       int is_binary = -1;
+       const char *path_without_prefix = path + args->baselen;
 
        crc = crc32(0, NULL, 0);
 
@@ -256,6 +269,8 @@ static int write_zip_entry(struct archiver_args *args,
                                return error("cannot read %s",
                                             sha1_to_hex(sha1));
                        crc = crc32(crc, buffer, size);
+                       is_binary = entry_is_binary(path_without_prefix,
+                                                   buffer, size);
                        out = buffer;
                }
                compressed_size = (method == 0) ? size : 0;
@@ -300,7 +315,6 @@ static int write_zip_entry(struct archiver_args *args,
        copy_le16(dirent.extra_length, ZIP_EXTRA_MTIME_SIZE);
        copy_le16(dirent.comment_length, 0);
        copy_le16(dirent.disk, 0);
-       copy_le16(dirent.attr1, 0);
        copy_le32(dirent.attr2, attr2);
        copy_le32(dirent.offset, zip_offset);
 
@@ -328,6 +342,9 @@ static int write_zip_entry(struct archiver_args *args,
                        if (readlen <= 0)
                                break;
                        crc = crc32(crc, buf, readlen);
+                       if (is_binary == -1)
+                               is_binary = entry_is_binary(path_without_prefix,
+                                                           buf, readlen);
                        write_or_die(1, buf, readlen);
                }
                close_istream(stream);
@@ -349,7 +366,6 @@ static int write_zip_entry(struct archiver_args *args,
                size_t out_len;
                unsigned char compressed[STREAM_BUFFER_SIZE * 2];
 
-               memset(&zstream, 0, sizeof(zstream));
                git_deflate_init_raw(&zstream, args->compression_level);
 
                compressed_size = 0;
@@ -361,6 +377,9 @@ static int write_zip_entry(struct archiver_args *args,
                        if (readlen <= 0)
                                break;
                        crc = crc32(crc, buf, readlen);
+                       if (is_binary == -1)
+                               is_binary = entry_is_binary(path_without_prefix,
+                                                           buf, readlen);
 
                        zstream.next_in = buf;
                        zstream.avail_in = readlen;
@@ -405,6 +424,8 @@ static int write_zip_entry(struct archiver_args *args,
        free(deflated);
        free(buffer);
 
+       copy_le16(dirent.attr1, !is_binary);
+
        memcpy(zip_dir + zip_dir_offset, &dirent, ZIP_DIR_HEADER_SIZE);
        zip_dir_offset += ZIP_DIR_HEADER_SIZE;
        memcpy(zip_dir + zip_dir_offset, path, pathlen);
index 4bab55a9a85e187e2a3906312f1e771f4a214f45..b0024353f4409c8b54c4b569b8fb7c435b26cdae 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -284,8 +284,9 @@ void create_branch(const char *head,
 
                transaction = ref_transaction_begin(&err);
                if (!transaction ||
-                   ref_transaction_update(transaction, ref.buf, sha1,
-                                          null_sha1, 0, !forcing, msg, &err) ||
+                   ref_transaction_update(transaction, ref.buf,
+                                          sha1, forcing ? NULL : null_sha1,
+                                          0, msg, &err) ||
                    ref_transaction_commit(transaction, &err))
                        die("%s", err.buf);
                ref_transaction_free(transaction);
index 6a25957e9f9daff6ab127f8feb91d9349075741e..1d150378e91cd47c4cd555bfc858ec0b7ea9d604 100644 (file)
@@ -589,9 +589,16 @@ static char *get_head_description(void)
        else if (state.bisect_in_progress)
                strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
                            state.branch);
-       else if (state.detached_from)
-               strbuf_addf(&desc, _("(detached from %s)"),
-                           state.detached_from);
+       else if (state.detached_from) {
+               /* TRANSLATORS: make sure these match _("HEAD detached at ")
+                  and _("HEAD detached from ") in wt-status.c */
+               if (state.detached_at)
+                       strbuf_addf(&desc, _("(HEAD detached at %s)"),
+                               state.detached_from);
+               else
+                       strbuf_addf(&desc, _("(HEAD detached from %s)"),
+                               state.detached_from);
+       }
        else
                strbuf_addstr(&desc, _("(no branch)"));
        free(state.branch);
index 7e7fdcfe54a547c90a5a6911eb59b0ec22151ac6..98c103fa8b4faa83c33a62e5d7871c1e9d888c38 100644 (file)
@@ -754,7 +754,8 @@ static int ask_each_cmd(void)
                /* Ctrl-D should stop removing files */
                if (!eof) {
                        qname = quote_path_relative(item->string, NULL, &buf);
-                       printf(_("remove %s? "), qname);
+                       /* TRANSLATORS: Make sure to keep [y/N] as is */
+                       printf(_("Remove %s [y/N]? "), qname);
                        if (strbuf_getline(&confirm, stdin, '\n') != EOF) {
                                strbuf_trim(&confirm);
                        } else {
index 6055c760f037617637eb7bffebe82213748b5e59..961e467242747dac07aa6f5e619e2d1a50570b06 100644 (file)
@@ -1766,8 +1766,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (!transaction ||
            ref_transaction_update(transaction, "HEAD", sha1,
                                   current_head
-                                  ? current_head->object.sha1 : NULL,
-                                  0, !!current_head, sb.buf, &err) ||
+                                  ? current_head->object.sha1 : null_sha1,
+                                  0, sb.buf, &err) ||
            ref_transaction_commit(transaction, &err)) {
                rollback_index_files();
                die("%s", err.buf);
index 75a55e590bdc3411e5e4aeee6275fbfff4451904..f9512652cf1389a770bd94fd170d123206e024c5 100644 (file)
@@ -415,8 +415,10 @@ static int s_update_ref(const char *action,
 
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
-           ref_transaction_update(transaction, ref->name, ref->new_sha1,
-                                  ref->old_sha1, 0, check_old, msg, &err))
+           ref_transaction_update(transaction, ref->name,
+                                  ref->new_sha1,
+                                  check_old ? ref->old_sha1 : NULL,
+                                  0, msg, &err))
                goto fail;
 
        ret = ref_transaction_commit(transaction, &err);
index 19be78a943d303700379f665d64c8843c69848d5..83f9cf91633a514e9301762fe774ee91be092848 100644 (file)
@@ -178,11 +178,10 @@ static const char *find_next(const char *cp)
 static int verify_format(const char *format)
 {
        const char *cp, *sp;
-       static const char color_reset[] = "color:reset";
 
        need_color_reset_at_eol = 0;
        for (cp = format; *cp && (sp = find_next(cp)); ) {
-               const char *ep = strchr(sp, ')');
+               const char *color, *ep = strchr(sp, ')');
                int at;
 
                if (!ep)
@@ -191,8 +190,8 @@ static int verify_format(const char *format)
                at = parse_atom(sp + 2, ep);
                cp = ep + 1;
 
-               if (starts_with(used_atom[at], "color:"))
-                       need_color_reset_at_eol = !!strcmp(used_atom[at], color_reset);
+               if (skip_prefix(used_atom[at], "color:", &color))
+                       need_color_reset_at_eol = !!strcmp(color, "reset");
        }
        return 0;
 }
index 9262b73b6f5efd28756db221f2775671430c7fd2..335f25d0ad69a41ee2ea1e1e38aecbc2c121cb8c 100644 (file)
@@ -641,7 +641,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "untracked", &untracked,
                        N_("search in both tracked and untracked files")),
                OPT_SET_INT(0, "exclude-standard", &opt_exclude,
-                           N_("search also in ignored files"), 1),
+                           N_("ignore files specified via '.gitignore'"), 1),
                OPT_GROUP(""),
                OPT_BOOL('v', "invert-match", &opt.invert,
                        N_("show non-matching lines")),
index 46321176719808dd53a38675dd0d9c558ae336dd..cf654df09b3734063f415b2b735f3062706f75a0 100644 (file)
@@ -1204,7 +1204,6 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
        int status;
        unsigned char outbuf[4096];
 
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, zlib_compression_level);
        stream.next_in = in;
        stream.avail_in = size;
index d8165878e1d466e49719038b1badc524d5627270..c3a75166bd10918d21d3df19832880c4373dc8d7 100644 (file)
@@ -125,7 +125,6 @@ static unsigned long do_compress(void **pptr, unsigned long size)
        void *in, *out;
        unsigned long maxsize;
 
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, pack_compression_level);
        maxsize = git_deflate_bound(&stream, size);
 
@@ -153,7 +152,6 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct sha1fi
        unsigned char obuf[1024 * 16];
        unsigned long olen = 0;
 
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, pack_compression_level);
 
        for (;;) {
index e0ce78e5a069670b00da6f3d67b991525c6dd29c..70e9ce5f96f3e8da78e4b5746580869f9ae65330 100644 (file)
@@ -953,8 +953,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
                if (ref_transaction_delete(transaction,
                                           namespaced_name,
                                           old_sha1,
-                                          0, old_sha1 != NULL,
-                                          "push", &err)) {
+                                          0, "push", &err)) {
                        rp_error("%s", err.buf);
                        strbuf_release(&err);
                        return "failed to delete";
@@ -971,7 +970,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
                if (ref_transaction_update(transaction,
                                           namespaced_name,
                                           new_sha1, old_sha1,
-                                          0, 1, "push",
+                                          0, "push",
                                           &err)) {
                        rp_error("%s", err.buf);
                        strbuf_release(&err);
index 49c64f96d8adba41261741cfa48f0e36fcd9f3bb..8182b648b9c9693ec6f23f6b2100e432bfa794ba 100644 (file)
@@ -8,14 +8,11 @@
 #include "revision.h"
 #include "reachable.h"
 
-/*
- * reflog expire
- */
-
+/* NEEDSWORK: switch to using parse_options */
 static const char reflog_expire_usage[] =
-"git reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git reflog expire [--expire=<time>] [--expire-unreachable=<time>] [--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all] <refs>...";
 static const char reflog_delete_usage[] =
-"git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>...";
+"git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] <refs>...";
 
 static unsigned long default_reflog_expire;
 static unsigned long default_reflog_expire_unreachable;
index 85d39b58d8aa35f0cd644273821ffd047ac50df0..54bf01acb4ca060a1dae43b399a6aefb1abe4eee 100644 (file)
@@ -172,7 +172,7 @@ static int replace_object_sha1(const char *object_ref,
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_update(transaction, ref, repl, prev,
-                                  0, 1, NULL, &err) ||
+                                  0, NULL, &err) ||
            ref_transaction_commit(transaction, &err))
                die("%s", err.buf);
 
index 6dc85a9d5e16e921a99a9f90c5d1f453bf9450bd..4194b9a711d88e6d3575cd8896b1a81de74b087f 100644 (file)
@@ -733,7 +733,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_update(transaction, ref.buf, object, prev,
-                                  0, 1, NULL, &err) ||
+                                  0, NULL, &err) ||
            ref_transaction_commit(transaction, &err))
                die("%s", err.buf);
        ref_transaction_free(transaction);
index 2497ba4303a03fa244b4f3913c22b45acd0a989c..3d79a46b036fa7bea29bbc0941442b5dd92f648c 100644 (file)
@@ -198,8 +198,9 @@ static const char *parse_cmd_update(struct ref_transaction *transaction,
        if (*next != line_termination)
                die("update %s: extra input: %s", refname, next);
 
-       if (ref_transaction_update(transaction, refname, new_sha1, old_sha1,
-                                  update_flags, have_old, msg, &err))
+       if (ref_transaction_update(transaction, refname,
+                                  new_sha1, have_old ? old_sha1 : NULL,
+                                  update_flags, msg, &err))
                die("%s", err.buf);
 
        update_flags = 0;
@@ -264,8 +265,9 @@ static const char *parse_cmd_delete(struct ref_transaction *transaction,
        if (*next != line_termination)
                die("delete %s: extra input: %s", refname, next);
 
-       if (ref_transaction_delete(transaction, refname, old_sha1,
-                                  update_flags, have_old, msg, &err))
+       if (ref_transaction_delete(transaction, refname,
+                                  have_old ? old_sha1 : NULL,
+                                  update_flags, msg, &err))
                die("%s", err.buf);
 
        update_flags = 0;
@@ -280,7 +282,6 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,
 {
        struct strbuf err = STRBUF_INIT;
        char *refname;
-       unsigned char new_sha1[20];
        unsigned char old_sha1[20];
 
        refname = parse_refname(input, &next);
@@ -291,13 +292,11 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,
                            PARSE_SHA1_OLD))
                hashclr(old_sha1);
 
-       hashcpy(new_sha1, old_sha1);
-
        if (*next != line_termination)
                die("verify %s: extra input: %s", refname, next);
 
-       if (ref_transaction_update(transaction, refname, new_sha1, old_sha1,
-                                  update_flags, 1, msg, &err))
+       if (ref_transaction_verify(transaction, refname, old_sha1,
+                                  update_flags, &err))
                die("%s", err.buf);
 
        update_flags = 0;
@@ -353,7 +352,8 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 {
        const char *refname, *oldval;
        unsigned char sha1[20], oldsha1[20];
-       int delete = 0, no_deref = 0, read_stdin = 0, end_null = 0, flags = 0;
+       int delete = 0, no_deref = 0, read_stdin = 0, end_null = 0;
+       unsigned int flags = 0;
        struct option options[] = {
                OPT_STRING( 'm', NULL, &msg, N_("reason"), N_("reason of the update")),
                OPT_BOOL('d', NULL, &delete, N_("delete the reference")),
index 0c4b8a7cad085fa1c7760e6290f21213830eda3d..8d157eba455f15a00cc7bf9b970f1862167ee1bb 100644 (file)
@@ -105,7 +105,6 @@ static int stream_to_pack(struct bulk_checkin_state *state,
        int write_object = (flags & HASH_WRITE_OBJECT);
        off_t offset = 0;
 
-       memset(&s, 0, sizeof(s));
        git_deflate_init(&s, pack_compression_level);
 
        hdrlen = encode_in_pack_object_header(type, size, obuf);
diff --git a/cache.h b/cache.h
index 4d02efc905456e61ce841ec1db2cc19491346257..761c5704b2e21f5dcd68fdcc9c3b1247ab0cfd18 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -568,7 +568,7 @@ extern void update_index_if_able(struct index_state *, struct lock_file *);
 extern int hold_locked_index(struct lock_file *, int);
 extern void set_alternate_index_output(const char *);
 
-extern int delete_ref(const char *, const unsigned char *sha1, int delopt);
+extern int delete_ref(const char *, const unsigned char *sha1, unsigned int flags);
 
 /* Environment bits from configuration mechanism */
 extern int trust_executable_bit;
index 372ac5ad9d16b7bc3f7e03012656b1541af5ba4c..ce0e1214234244236a407e9f3004e619d26c54a8 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -157,8 +157,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
                        server_capabilities = xstrdup(name + name_len + 1);
                }
 
-               if (extra_have &&
-                   name_len == 5 && !memcmp(".have", name, 5)) {
+               if (extra_have && !strcmp(name, ".have")) {
                        sha1_array_append(extra_have, old_sha1);
                        continue;
                }
@@ -274,28 +273,44 @@ static enum protocol get_protocol(const char *name)
        die("I don't handle protocol '%s'", name);
 }
 
+static char *host_end(char **hoststart, int removebrackets)
+{
+       char *host = *hoststart;
+       char *end;
+       char *start = strstr(host, "@[");
+       if (start)
+               start++; /* Jump over '@' */
+       else
+               start = host;
+       if (start[0] == '[') {
+               end = strchr(start + 1, ']');
+               if (end) {
+                       if (removebrackets) {
+                               *end = 0;
+                               memmove(start, start + 1, end - start);
+                               end++;
+                       }
+               } else
+                       end = host;
+       } else
+               end = host;
+       return end;
+}
+
 #define STR_(s)        # s
 #define STR(s) STR_(s)
 
 static void get_host_and_port(char **host, const char **port)
 {
        char *colon, *end;
-
-       if (*host[0] == '[') {
-               end = strchr(*host + 1, ']');
-               if (end) {
-                       *end = 0;
-                       end++;
-                       (*host)++;
-               } else
-                       end = *host;
-       } else
-               end = *host;
+       end = host_end(host, 1);
        colon = strchr(end, ':');
-
        if (colon) {
-               *colon = 0;
-               *port = colon + 1;
+               long portnr = strtol(colon + 1, &end, 10);
+               if (end != colon + 1 && *end == '\0' && 0 <= portnr && portnr < 65536) {
+                       *colon = 0;
+                       *port = colon + 1;
+               }
        }
 }
 
@@ -547,13 +562,16 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
        return proxy;
 }
 
-static const char *get_port_numeric(const char *p)
+static char *get_port(char *host)
 {
        char *end;
+       char *p = strchr(host, ':');
+
        if (p) {
                long port = strtol(p + 1, &end, 10);
                if (end != p + 1 && *end == '\0' && 0 <= port && port < 65536) {
-                       return p;
+                       *p = '\0';
+                       return p+1;
                }
        }
 
@@ -595,14 +613,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
         * Don't do destructive transforms as protocol code does
         * '[]' unwrapping in get_host_and_port()
         */
-       if (host[0] == '[') {
-               end = strchr(host + 1, ']');
-               if (end) {
-                       end++;
-               } else
-                       end = host;
-       } else
-               end = host;
+       end = host_end(&host, 0);
 
        if (protocol == PROTO_LOCAL)
                path = end;
@@ -663,7 +674,7 @@ struct child_process *git_connect(int fd[2], const char *url,
        signal(SIGCHLD, SIG_DFL);
 
        protocol = parse_connect_url(url, &hostandport, &path);
-       if (flags & CONNECT_DIAG_URL) {
+       if ((flags & CONNECT_DIAG_URL) && (protocol != PROTO_SSH)) {
                printf("Diag: url=%s\n", url ? url : "NULL");
                printf("Diag: protocol=%s\n", prot_name(protocol));
                printf("Diag: hostandport=%s\n", hostandport ? hostandport : "NULL");
@@ -715,28 +726,42 @@ struct child_process *git_connect(int fd[2], const char *url,
                        char *ssh_host = hostandport;
                        const char *port = NULL;
                        get_host_and_port(&ssh_host, &port);
-                       port = get_port_numeric(port);
 
-                       ssh = getenv("GIT_SSH_COMMAND");
-                       if (ssh) {
-                               conn->use_shell = 1;
-                               putty = 0;
-                       } else {
-                               ssh = getenv("GIT_SSH");
-                               if (!ssh)
-                                       ssh = "ssh";
-                               putty = !!strcasestr(ssh, "plink");
-                       }
+                       if (!port)
+                               port = get_port(ssh_host);
+
+                       if (flags & CONNECT_DIAG_URL) {
+                               printf("Diag: url=%s\n", url ? url : "NULL");
+                               printf("Diag: protocol=%s\n", prot_name(protocol));
+                               printf("Diag: userandhost=%s\n", ssh_host ? ssh_host : "NULL");
+                               printf("Diag: port=%s\n", port ? port : "NONE");
+                               printf("Diag: path=%s\n", path ? path : "NULL");
 
-                       argv_array_push(&conn->args, ssh);
-                       if (putty && !strcasestr(ssh, "tortoiseplink"))
-                               argv_array_push(&conn->args, "-batch");
-                       if (port) {
-                               /* P is for PuTTY, p is for OpenSSH */
-                               argv_array_push(&conn->args, putty ? "-P" : "-p");
-                               argv_array_push(&conn->args, port);
+                               free(hostandport);
+                               free(path);
+                               return NULL;
+                       } else {
+                               ssh = getenv("GIT_SSH_COMMAND");
+                               if (ssh) {
+                                       conn->use_shell = 1;
+                                       putty = 0;
+                               } else {
+                                       ssh = getenv("GIT_SSH");
+                                       if (!ssh)
+                                               ssh = "ssh";
+                                       putty = !!strcasestr(ssh, "plink");
+                               }
+
+                               argv_array_push(&conn->args, ssh);
+                               if (putty && !strcasestr(ssh, "tortoiseplink"))
+                                       argv_array_push(&conn->args, "-batch");
+                               if (port) {
+                                       /* P is for PuTTY, p is for OpenSSH */
+                                       argv_array_push(&conn->args, putty ? "-P" : "-p");
+                                       argv_array_push(&conn->args, port);
+                               }
+                               argv_array_push(&conn->args, ssh_host);
                        }
-                       argv_array_push(&conn->args, ssh_host);
                } else {
                        /* remove repo-local variables from the environment */
                        conn->env = local_repo_env;
index c21190d7510c173482b7784f9e8c4bf0b56cb1e1..731c28998f4d2ec6a2339b40a8380c97394b220e 100644 (file)
@@ -411,12 +411,9 @@ __git_refs_remotes ()
 
 __git_remotes ()
 {
-       local i IFS=$'\n' d="$(__gitdir)"
+       local d="$(__gitdir)"
        test -d "$d/remotes" && ls -1 "$d/remotes"
-       for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
-               i="${i#remote.}"
-               echo "${i/.url*/}"
-       done
+       git --git-dir="$d" remote
 }
 
 __git_list_merge_strategies ()
@@ -2014,6 +2011,7 @@ _git_config ()
                color.status.changed
                color.status.header
                color.status.nobranch
+               color.status.unmerged
                color.status.untracked
                color.status.updated
                color.ui
diff --git a/ctype.c b/ctype.c
index 0bfebb4e75866ba0e97713fab5394490290831c0..fc0225cebd1a4b43654772270826e06fd941a128 100644 (file)
--- a/ctype.c
+++ b/ctype.c
@@ -30,7 +30,7 @@ const unsigned char sane_ctype[256] = {
 };
 
 /* For case-insensitive kwset */
-const char tolower_trans_tbl[256] = {
+const unsigned char tolower_trans_tbl[256] = {
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
diff --git a/diff.c b/diff.c
index d1bd534caeaf662b0ee0d547d3aa2012310fff57..7500c5509550ccd9a86d620e06c51a71d61f8b6c 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -2093,7 +2093,6 @@ static unsigned char *deflate_it(char *data,
        unsigned char *deflated;
        git_zstream stream;
 
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, zlib_compression_level);
        bound = git_deflate_bound(&stream, size);
        deflated = xmalloc(bound);
@@ -4541,7 +4540,7 @@ void diff_flush(struct diff_options *options)
                        show_stats(&diffstat, options);
                if (output_format & DIFF_FORMAT_SHORTSTAT)
                        show_shortstats(&diffstat, options);
-               if (output_format & DIFF_FORMAT_DIRSTAT)
+               if (output_format & DIFF_FORMAT_DIRSTAT && dirstat_by_line)
                        show_dirstat_by_line(&diffstat, options);
                free_diffstat_info(&diffstat);
                separator++;
index 4e132f1fdb68ed3c930ca8224a5403c9b406cc3b..af1fe08861e6862985ac8fb9311b17568cb9e547 100644 (file)
@@ -15,8 +15,7 @@ static struct diff_rename_dst {
 } *rename_dst;
 static int rename_dst_nr, rename_dst_alloc;
 
-static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
-                                                int insert_ok)
+static int find_rename_dst(struct diff_filespec *two)
 {
        int first, last;
 
@@ -27,16 +26,33 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
                struct diff_rename_dst *dst = &(rename_dst[next]);
                int cmp = strcmp(two->path, dst->two->path);
                if (!cmp)
-                       return dst;
+                       return next;
                if (cmp < 0) {
                        last = next;
                        continue;
                }
                first = next+1;
        }
-       /* not found */
-       if (!insert_ok)
-               return NULL;
+       return -first - 1;
+}
+
+static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two)
+{
+       int ofs = find_rename_dst(two);
+       return ofs < 0 ? NULL : &rename_dst[ofs];
+}
+
+/*
+ * Returns 0 on success, -1 if we found a duplicate.
+ */
+static int add_rename_dst(struct diff_filespec *two)
+{
+       int first = find_rename_dst(two);
+
+       if (first >= 0)
+               return -1;
+       first = -first - 1;
+
        /* insert to make it at "first" */
        ALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);
        rename_dst_nr++;
@@ -46,7 +62,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
        rename_dst[first].two = alloc_filespec(two->path);
        fill_filespec(rename_dst[first].two, two->sha1, two->sha1_valid, two->mode);
        rename_dst[first].pair = NULL;
-       return &(rename_dst[first]);
+       return 0;
 }
 
 /* Table of rename/copy src files */
@@ -450,8 +466,12 @@ void diffcore_rename(struct diff_options *options)
                        else if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&
                                 is_empty_blob_sha1(p->two->sha1))
                                continue;
-                       else
-                               locate_rename_dst(p->two, 1);
+                       else if (add_rename_dst(p->two) < 0) {
+                               warning("skipping rename detection, detected"
+                                       " duplicate destination '%s'",
+                                       p->two->path);
+                               goto cleanup;
+                       }
                }
                else if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&
                         is_empty_blob_sha1(p->one->sha1))
@@ -582,8 +602,7 @@ void diffcore_rename(struct diff_options *options)
                         * We would output this create record if it has
                         * not been turned into a rename/copy already.
                         */
-                       struct diff_rename_dst *dst =
-                               locate_rename_dst(p->two, 0);
+                       struct diff_rename_dst *dst = locate_rename_dst(p->two);
                        if (dst && dst->pair) {
                                diff_q(&outq, dst->pair);
                                pair_to_free = p;
@@ -613,8 +632,7 @@ void diffcore_rename(struct diff_options *options)
                         */
                        if (DIFF_PAIR_BROKEN(p)) {
                                /* broken delete */
-                               struct diff_rename_dst *dst =
-                                       locate_rename_dst(p->one, 0);
+                               struct diff_rename_dst *dst = locate_rename_dst(p->one);
                                if (dst && dst->pair)
                                        /* counterpart is now rename/copy */
                                        pair_to_free = p;
index aac2c24f74e496d11b66e1cc2806c55555f71496..e78ca107b3d66d7e537c86eb10dc7503be8681b9 100644 (file)
@@ -1062,7 +1062,6 @@ static int store_object(
        } else
                delta = NULL;
 
-       memset(&s, 0, sizeof(s));
        git_deflate_init(&s, pack_compression_level);
        if (delta) {
                s.next_in = delta;
@@ -1090,7 +1089,6 @@ static int store_object(
                        free(delta);
                        delta = NULL;
 
-                       memset(&s, 0, sizeof(s));
                        git_deflate_init(&s, pack_compression_level);
                        s.next_in = (void *)dat->buf;
                        s.avail_in = dat->len;
@@ -1190,7 +1188,6 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
 
        crc32_begin(pack_file);
 
-       memset(&s, 0, sizeof(s));
        git_deflate_init(&s, pack_compression_level);
 
        hdrlen = encode_in_pack_object_header(OBJ_BLOB, len, out_buf);
@@ -1720,7 +1717,7 @@ static int update_branch(struct branch *b)
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_update(transaction, b->name, b->sha1, old_sha1,
-                                  0, 1, msg, &err) ||
+                                  0, msg, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
                error("%s", err.buf);
@@ -1760,8 +1757,8 @@ static void dump_tags(void)
                strbuf_reset(&ref_name);
                strbuf_addf(&ref_name, "refs/tags/%s", t->name);
 
-               if (ref_transaction_update(transaction, ref_name.buf, t->sha1,
-                                          NULL, 0, 0, msg, &err)) {
+               if (ref_transaction_update(transaction, ref_name.buf,
+                                          t->sha1, NULL, 0, msg, &err)) {
                        failure |= error("%s", err.buf);
                        goto cleanup;
                }
index 8b2da4641f8b20ff3cc70c63636de878eec72470..7378ba287f0c449810250fb7b019f69e4f6a3497 100644 (file)
--- a/gettext.c
+++ b/gettext.c
 #      endif
 #endif
 
+/*
+ * Guess the user's preferred languages from the value in LANGUAGE environment
+ * variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
+ *
+ * The result can be a colon-separated list like "ko:ja:en".
+ */
+const char *get_preferred_languages(void)
+{
+       const char *retval;
+
+       retval = getenv("LANGUAGE");
+       if (retval && *retval)
+               return retval;
+
+#ifndef NO_GETTEXT
+       retval = setlocale(LC_MESSAGES, NULL);
+       if (retval && *retval &&
+               strcmp(retval, "C") &&
+               strcmp(retval, "POSIX"))
+               return retval;
+#endif
+
+       return NULL;
+}
+
 #ifdef GETTEXT_POISON
 int use_gettext_poison(void)
 {
index dc1722dd4bc6b1aa7d998cb055a40000c05a0b5e..33696a40b8a11262d090a2eec4dfdce0fed6af0f 100644 (file)
--- a/gettext.h
+++ b/gettext.h
@@ -89,4 +89,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
 #define N_(msgid) (msgid)
 #endif
 
+const char *get_preferred_languages(void);
+
 #endif
index 3455c5ece68359c70e04284b1c25b97716678172..a3095be962c04d5b55c54ec39c6c3e6989372c36 100644 (file)
 typedef long intptr_t;
 typedef unsigned long uintptr_t;
 #endif
-#if defined(__CYGWIN__)
-#undef _XOPEN_SOURCE
-#include <grp.h>
-#define _XOPEN_SOURCE 600
-#else
 #undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
 #include <grp.h>
 #define _ALL_SOURCE 1
 #endif
-#endif
 
 /* used on Mac OS X */
 #ifdef PRECOMPOSE_UNICODE
@@ -694,7 +688,7 @@ static inline size_t xsize_t(off_t len)
 }
 
 /* in ctype.c, for kwset users */
-extern const char tolower_trans_tbl[256];
+extern const unsigned char tolower_trans_tbl[256];
 
 /* Sane ctype - no locale, and works with signed chars */
 #undef isascii
index c96b9847e9fc2aaf67997c74a8d5c0abe78b607d..f7deeb096e24f4de69bdfe08f0aa35ebf170577a 100644 (file)
@@ -1030,10 +1030,11 @@ test -n "$autosquash" && rearrange_squash "$todo"
 test -n "$cmd" && add_exec_commands "$todo"
 
 todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
+todocount=${todocount##* }
 
 cat >>"$todo" <<EOF
 
-$comment_char Rebase $shortrevisions onto $shortonto ($todocount TODO item(s))
+$comment_char Rebase $shortrevisions onto $shortonto ($todocount command(s))
 EOF
 append_todo_help
 git stripspace --comment-lines >>"$todo" <<\EOF
index 32d109ebdf89399ac0d834cc98393324dfca7850..36f7240c99249198512689ffecdd9c95f06b8eff 100755 (executable)
 $VERSION = '@@GIT_VERSION@@';
 
 use Carp qw/croak/;
-use Digest::MD5;
-use IO::File qw//;
 use File::Basename qw/dirname basename/;
 use File::Path qw/mkpath/;
 use File::Spec;
-use File::Find;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
-use IPC::Open3;
 use Memoize;
 
 use Git::SVN;
@@ -298,7 +294,6 @@ sub _req_svn {
                {} ],
 );
 
-use Term::ReadLine;
 package FakeTerm;
 sub new {
        my ($class, $reason) = @_;
@@ -313,6 +308,7 @@ package main;
 my $term;
 sub term_init {
        $term = eval {
+               require Term::ReadLine;
                $ENV{"GIT_SVN_NOTTY"}
                        ? new Term::ReadLine 'git-svn', \*STDIN, \*STDOUT
                        : new Term::ReadLine 'git-svn';
@@ -1173,6 +1169,7 @@ sub cmd_branch {
        }
 
        ::_req_svn();
+       require SVN::Client;
 
        my $ctx = SVN::Client->new(
                config => SVN::Core::config_get_config(
@@ -1693,11 +1690,13 @@ sub cmd_reset {
 }
 
 sub cmd_gc {
+       require File::Find;
        if (!can_compress()) {
                warn "Compress::Zlib could not be found; unhandled.log " .
                     "files will not be compressed.\n";
        }
-       find({ wanted => \&gc_directory, no_chdir => 1}, "$ENV{GIT_DIR}/svn");
+       File::Find::find({ wanted => \&gc_directory, no_chdir => 1},
+                        "$ENV{GIT_DIR}/svn");
 }
 
 ########################### utility functions #########################
@@ -2122,6 +2121,7 @@ sub find_file_type_and_diff_status {
 sub md5sum {
        my $arg = shift;
        my $ref = ref $arg;
+       require Digest::MD5;
        my $md5 = Digest::MD5->new();
         if ($ref eq 'GLOB' || $ref eq 'IO::File' || $ref eq 'File::Temp') {
                $md5->addfile($arg) or croak $!;
@@ -2148,6 +2148,7 @@ sub gc_directory {
                        $gz->gzwrite($str) or
                                die "Unable to write: ".$gz->gzerror()."!\n";
                }
+               no warnings 'once'; # $File::Find::name would warn
                unlink $_ or die "unlink $File::Find::name: $!\n";
        } elsif (-f $_ && basename($_) eq "index") {
                unlink $_ or die "unlink $_: $!\n";
diff --git a/git.c b/git.c
index 8c7ee9c83000765afa3808f3dd0941aa484ca1ec..42a4ee57843f569fb754121f01bb8c46feee2fd3 100644 (file)
--- a/git.c
+++ b/git.c
@@ -204,10 +204,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                                fprintf(stderr, "No directory given for -C.\n" );
                                usage(git_usage_string);
                        }
-                       if (chdir((*argv)[1]))
-                               die_errno("Cannot change to '%s'", (*argv)[1]);
-                       if (envchanged)
-                               *envchanged = 1;
+                       if ((*argv)[1][0]) {
+                               if (chdir((*argv)[1]))
+                                       die_errno("Cannot change to '%s'", (*argv)[1]);
+                               if (envchanged)
+                                       *envchanged = 1;
+                       }
                        (*argv)++;
                        (*argc)--;
                } else {
@@ -618,6 +620,7 @@ int main(int argc, char **av)
 {
        const char **argv = (const char **) av;
        const char *cmd;
+       int done_help = 0;
 
        startup_info = &git_startup_info;
 
@@ -680,9 +683,7 @@ int main(int argc, char **av)
        setup_path();
 
        while (1) {
-               static int done_help = 0;
-               static int was_alias = 0;
-               was_alias = run_argv(&argc, &argv);
+               int was_alias = run_argv(&argc, &argv);
                if (errno != ENOENT)
                        break;
                if (was_alias) {
index 0beb7ab67ffc93a6c8fe8517d711945e2c033b7d..bfb1c9605b46e8308e91a80c38643ea920cd4d1b 100644 (file)
@@ -365,7 +365,6 @@ static void start_put(struct transfer_request *request)
        hdrlen = sprintf(hdr, "%s %lu", typename(type), len) + 1;
 
        /* Set it up */
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, zlib_compression_level);
        size = git_deflate_bound(&stream, len + hdrlen);
        strbuf_init(&request->buffer.buf, size);
diff --git a/http.c b/http.c
index 0153fb0b626d1fc28eba1bece2406b64fcaa0ecb..9c825afefdda70b8f8ccda0b9ed06e5d54333a50 100644 (file)
--- a/http.c
+++ b/http.c
@@ -8,6 +8,7 @@
 #include "credential.h"
 #include "version.h"
 #include "pkt-line.h"
+#include "gettext.h"
 
 int active_requests;
 int http_is_verbose;
@@ -1002,32 +1003,6 @@ static void extract_content_type(struct strbuf *raw, struct strbuf *type,
                strbuf_addstr(charset, "ISO-8859-1");
 }
 
-
-/*
- * Guess the user's preferred languages from the value in LANGUAGE environment
- * variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
- *
- * The result can be a colon-separated list like "ko:ja:en".
- */
-static const char *get_preferred_languages(void)
-{
-       const char *retval;
-
-       retval = getenv("LANGUAGE");
-       if (retval && *retval)
-               return retval;
-
-#ifndef NO_GETTEXT
-       retval = setlocale(LC_MESSAGES, NULL);
-       if (retval && *retval &&
-               strcmp(retval, "C") &&
-               strcmp(retval, "POSIX"))
-               return retval;
-#endif
-
-       return NULL;
-}
-
 static void write_accept_language(struct strbuf *buf)
 {
        /*
diff --git a/kwset.c b/kwset.c
index a0f49b3aca934008465842dd37e52d11d099e23e..e6236a0359cb3661acb8b1e609be236f6fb9d4bf 100644 (file)
--- a/kwset.c
+++ b/kwset.c
@@ -80,13 +80,13 @@ struct kwset
   struct trie *next[NCHAR];    /* Table of children of the root. */
   char *target;                        /* Target string if there's only one. */
   int mind2;                   /* Used in Boyer-Moore search for one string. */
-  char const *trans;           /* Character translation table. */
+  unsigned char const *trans;  /* Character translation table. */
 };
 
 /* Allocate and initialize a keyword set object, returning an opaque
    pointer to it.  Return NULL if memory is not available. */
 kwset_t
-kwsalloc (char const *trans)
+kwsalloc (unsigned char const *trans)
 {
   struct kwset *kwset;
 
@@ -381,7 +381,7 @@ kwsprep (kwset_t kws)
   register struct kwset *kwset;
   register int i;
   register struct trie *curr;
-  register char const *trans;
+  register unsigned char const *trans;
   unsigned char delta[NCHAR];
 
   kwset = (struct kwset *) kws;
@@ -590,7 +590,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
   register int d;
   register char const *end, *qlim;
   register struct tree const *tree;
-  register char const *trans;
+  register unsigned char const *trans;
 
   accept = NULL;
 
diff --git a/kwset.h b/kwset.h
index a21b2eadfdf9f760c170f10c069a06853105eee5..61a134f256cee951f726c9619861b614fb66f9d6 100644 (file)
--- a/kwset.h
+++ b/kwset.h
@@ -39,7 +39,7 @@ typedef struct kwset_t* kwset_t;
    if enough memory cannot be obtained.  The argument if non-NULL
    specifies a table of character translations to be applied to all
    pattern and search text. */
-extern kwset_t kwsalloc(char const *);
+extern kwset_t kwsalloc(unsigned char const *);
 
 /* Incrementally extend the keyword set to include the given string.
    Return NULL for success, or an error message.  Remember an index
index 8e4af7153eb8a8957bd4172e0c044c1bfc748ddb..152fb7e9274c779cb66de099878b4de40e5406e4 100644 (file)
@@ -9,11 +9,10 @@ package Git::SVN;
            $_use_log_author $_add_author_from $_localtime/;
 use Carp qw/croak/;
 use File::Path qw/mkpath/;
-use File::Copy qw/copy/;
 use IPC::Open3;
 use Memoize;  # core since 5.8.0, Jul 2002
-use Memoize::Storable;
 use POSIX qw(:signal_h);
+use Time::Local;
 
 use Git qw(
     command
@@ -32,11 +31,7 @@ package Git::SVN;
        add_path_to_url
 );
 
-my $can_use_yaml;
-BEGIN {
-       $can_use_yaml = eval { require Git::SVN::Memoize::YAML; 1};
-}
-
+my $memo_backend;
 our $_follow_parent  = 1;
 our $_minimize_url   = 'unset';
 our $default_repo_id = 'svn';
@@ -1332,7 +1327,7 @@ sub parse_svn_date {
                $ENV{TZ} = 'UTC';
 
                my $epoch_in_UTC =
-                   POSIX::strftime('%s', $S, $M, $H, $d, $m - 1, $Y - 1900);
+                   Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y - 1900);
 
                # Determine our local timezone (including DST) at the
                # time of $epoch_in_UTC.  $Git::SVN::Log::TZ stored the
@@ -1578,7 +1573,16 @@ sub tie_for_persistent_memoization {
        my $hash = shift;
        my $path = shift;
 
-       if ($can_use_yaml) {
+       unless ($memo_backend) {
+               if (eval { require Git::SVN::Memoize::YAML; 1}) {
+                       $memo_backend = 1;
+               } else {
+                       require Memoize::Storable;
+                       $memo_backend = -1;
+               }
+       }
+
+       if ($memo_backend > 0) {
                tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml";
        } else {
                tie %$hash => 'Memoize::Storable', "$path.db", 'nstore';
@@ -2188,8 +2192,9 @@ sub rev_map_set {
        # both of these options make our .rev_db file very, very important
        # and we can't afford to lose it because rebuild() won't work
        if ($self->use_svm_props || $self->no_metadata) {
+               require File::Copy;
                $sync = 1;
-               copy($db, $db_lock) or die "rev_map_set(@_): ",
+               File::Copy::copy($db, $db_lock) or die "rev_map_set(@_): ",
                                           "Failed to copy: ",
                                           "$db => $db_lock ($!)\n";
        } else {
index 4088f13e723a51a6e1cee0c616a7c279a780461d..c50176eec9418c50e5c63921c24e76a87b6123ab 100644 (file)
@@ -5,7 +5,6 @@ package Git::SVN::Editor;
 use SVN::Core;
 use SVN::Delta;
 use Carp qw/croak/;
-use IO::File;
 use Git qw/command command_oneline command_noisy command_output_pipe
            command_input_pipe command_close_pipe
            command_bidi_pipe command_close_bidi_pipe/;
@@ -586,7 +585,7 @@ =head1 DESCRIPTION
 =head1 DEPENDENCIES
 
 Subversion perl bindings,
-the core L<Carp> and L<IO::File> modules,
+the core L<Carp> module,
 and git's L<Git> helper module.
 
 C<Git::SVN::Editor> has not been tested using callers other than
index 10edb27732f439e5290a7b354efefeb10d219669..d8c21ad91549b4e52ce95c5e694db2f53f9931c9 100644 (file)
@@ -7,7 +7,6 @@ package Git::SVN::Fetcher;
 use SVN::Delta;
 use Carp qw/croak/;
 use File::Basename qw/dirname/;
-use IO::File qw//;
 use Git qw/command command_oneline command_noisy command_output_pipe
            command_input_pipe command_close_pipe
            command_bidi_pipe command_close_bidi_pipe/;
@@ -322,6 +321,14 @@ sub apply_textdelta {
        # (but $base does not,) so dup() it for reading in close_file
        open my $dup, '<&', $fh or croak $!;
        my $base = $::_repository->temp_acquire("git_blob_${$}_$suffix");
+       # close_file may call temp_acquire on 'svn_hash', but because of the
+       # call chain, if the temp_acquire call from close_file ends up being the
+       # call that first creates the 'svn_hash' temp file, then the FileHandle
+       # that's created as a result will end up in an SVN::Pool that we clear
+       # in SVN::Ra::gs_fetch_loop_common.  Avoid that by making sure the
+       # 'svn_hash' FileHandle is already created before close_file is called.
+       my $tmp_fh = $::_repository->temp_acquire('svn_hash');
+       $::_repository->temp_release($tmp_fh, 1);
 
        if ($fb->{blob}) {
                my ($base_is_link, $size);
@@ -600,7 +607,7 @@ =head1 DESCRIPTION
 =head1 DEPENDENCIES
 
 L<SVN::Delta> from the Subversion perl bindings,
-the core L<Carp>, L<File::Basename>, and L<IO::File> modules,
+the core L<Carp> and L<File::Basename> modules,
 and git's L<Git> helper module.
 
 C<Git::SVN::Fetcher> has not been tested using callers other than
index 622535e21760f9fd5c6b63f97d41b48be9c04db6..4a499fcb38daf4ab8d3e20ca0fa10e5732e684a9 100644 (file)
@@ -3,7 +3,6 @@ package Git::SVN::Ra;
 use strict;
 use warnings;
 use Memoize;
-use SVN::Client;
 use Git::SVN::Utils qw(
        canonicalize_url
        canonicalize_path
@@ -42,6 +41,7 @@ END
 }
 
 sub _auth_providers () {
+       require SVN::Client;
        my @rv = (
          SVN::Client::get_simple_provider(),
          SVN::Client::get_ssl_server_trust_file_provider(),
@@ -247,7 +247,10 @@ sub get_log {
        $ret;
 }
 
+# uncommon, only for ancient SVN (<= 1.4.2)
 sub trees_match {
+       require IO::File;
+       require SVN::Client;
        my ($self, $url1, $rev1, $url2, $rev2) = @_;
        my $ctx = SVN::Client->new(auth => _auth_providers);
        my $out = IO::File->new_tmpfile;
@@ -391,6 +394,9 @@ sub longest_common_path {
 sub gs_fetch_loop_common {
        my ($self, $base, $head, $gsv, $globs) = @_;
        return if ($base > $head);
+       # Make sure the cat_blob open2 FileHandle is created before calling
+       # SVN::Pool::new_default so that it does not incorrectly end up in the pool.
+       $::_repository->_open_cat_blob_if_needed;
        my $gpool = SVN::Pool->new_default;
        my $ra_url = $self->url;
        my $reload_ra = sub {
index 9d34d02db11bd6761d48484327fbc6d1704ad555..7b493041814dc8514bde0778497d39868c8455d7 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -567,7 +567,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
        char *cp = buf;
 
        /* guess if there is an encoding header before a \n\n */
-       while (strncmp(cp, "encoding ", strlen("encoding "))) {
+       while (!starts_with(cp, "encoding ")) {
                cp = strchr(cp, '\n');
                if (!cp || *++cp == '\n')
                        return buf;
diff --git a/refs.c b/refs.c
index ab2f2a92cd9119a3c67d8b3b7741ae1279d747f3..e23542b3869b38e47f59f102d28648d30d506574 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -12,7 +12,6 @@ struct ref_lock {
        struct lock_file *lk;
        unsigned char old_sha1[20];
        int lock_fd;
-       int force_write;
 };
 
 /*
@@ -35,10 +34,29 @@ static unsigned char refname_disposition[256] = {
 };
 
 /*
- * Used as a flag to ref_transaction_delete when a loose ref is being
+ * Flag passed to lock_ref_sha1_basic() telling it to tolerate broken
+ * refs (i.e., because the reference is about to be deleted anyway).
+ */
+#define REF_DELETING   0x02
+
+/*
+ * Used as a flag in ref_update::flags when a loose ref is being
  * pruned.
  */
-#define REF_ISPRUNING  0x0100
+#define REF_ISPRUNING  0x04
+
+/*
+ * Used as a flag in ref_update::flags when the reference should be
+ * updated to new_sha1.
+ */
+#define REF_HAVE_NEW   0x08
+
+/*
+ * Used as a flag in ref_update::flags when old_sha1 should be
+ * checked.
+ */
+#define REF_HAVE_OLD   0x10
+
 /*
  * Try to read one refname component from the front of refname.
  * Return the length of the component found, or -1 if the component is
@@ -2249,7 +2267,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
 static struct ref_lock *lock_ref_sha1_basic(const char *refname,
                                            const unsigned char *old_sha1,
                                            const struct string_list *skip,
-                                           int flags, int *type_p)
+                                           unsigned int flags, int *type_p)
 {
        char *ref_file;
        const char *orig_refname = refname;
@@ -2258,7 +2276,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
        int type, lflags;
        int mustexist = (old_sha1 && !is_null_sha1(old_sha1));
        int resolve_flags = 0;
-       int missing = 0;
        int attempts_remaining = 3;
 
        lock = xcalloc(1, sizeof(struct ref_lock));
@@ -2297,13 +2314,13 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
                        orig_refname, strerror(errno));
                goto error_return;
        }
-       missing = is_null_sha1(lock->old_sha1);
-       /* When the ref did not exist and we are creating it,
-        * make sure there is no existing ref that is packed
-        * whose name begins with our refname, nor a ref whose
-        * name is a proper prefix of our refname.
+       /*
+        * If the ref did not exist and we are creating it, make sure
+        * there is no existing packed ref whose name begins with our
+        * refname, nor a packed ref whose name is a proper prefix of
+        * our refname.
         */
-       if (missing &&
+       if (is_null_sha1(lock->old_sha1) &&
             !is_refname_available(refname, skip, get_packed_refs(&ref_cache))) {
                last_errno = ENOTDIR;
                goto error_return;
@@ -2319,10 +2336,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
        lock->ref_name = xstrdup(refname);
        lock->orig_ref_name = xstrdup(orig_refname);
        ref_file = git_path("%s", refname);
-       if (missing)
-               lock->force_write = 1;
-       if ((flags & REF_NODEREF) && (type & REF_ISSYMREF))
-               lock->force_write = 1;
 
  retry:
        switch (safe_create_leading_directories(ref_file)) {
@@ -2563,7 +2576,7 @@ static void prune_ref(struct ref_to_prune *r)
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_delete(transaction, r->name, r->sha1,
-                                  REF_ISPRUNING, 1, NULL, &err) ||
+                                  REF_ISPRUNING, NULL, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
                error("%s", err.buf);
@@ -2733,15 +2746,16 @@ static int delete_ref_loose(struct ref_lock *lock, int flag, struct strbuf *err)
        return 0;
 }
 
-int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
+int delete_ref(const char *refname, const unsigned char *sha1, unsigned int flags)
 {
        struct ref_transaction *transaction;
        struct strbuf err = STRBUF_INIT;
 
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
-           ref_transaction_delete(transaction, refname, sha1, delopt,
-                                  sha1 && !is_null_sha1(sha1), NULL, &err) ||
+           ref_transaction_delete(transaction, refname,
+                                  (sha1 && !is_null_sha1(sha1)) ? sha1 : NULL,
+                                  flags, NULL, &err) ||
            ref_transaction_commit(transaction, &err)) {
                error("%s", err.buf);
                ref_transaction_free(transaction);
@@ -2877,7 +2891,6 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
                error("unable to lock %s for update", newrefname);
                goto rollback;
        }
-       lock->force_write = 1;
        hashcpy(lock->old_sha1, orig_sha1);
        if (write_ref_sha1(lock, orig_sha1, logmsg)) {
                error("unable to write current sha1 into %s", newrefname);
@@ -2893,7 +2906,6 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
                goto rollbacklog;
        }
 
-       lock->force_write = 1;
        flag = log_all_ref_updates;
        log_all_ref_updates = 0;
        if (write_ref_sha1(lock, orig_sha1, NULL))
@@ -3079,14 +3091,6 @@ static int write_ref_sha1(struct ref_lock *lock,
        static char term = '\n';
        struct object *o;
 
-       if (!lock) {
-               errno = EINVAL;
-               return -1;
-       }
-       if (!lock->force_write && !hashcmp(lock->old_sha1, sha1)) {
-               unlock_ref(lock);
-               return 0;
-       }
        o = parse_object(sha1);
        if (!o) {
                error("Trying to write ref %s with nonexistent object %s",
@@ -3556,16 +3560,27 @@ int for_each_reflog(each_ref_fn fn, void *cb_data)
 }
 
 /**
- * Information needed for a single ref update.  Set new_sha1 to the
- * new value or to zero to delete the ref.  To check the old value
- * while locking the ref, set have_old to 1 and set old_sha1 to the
- * value or to zero to ensure the ref does not exist before update.
+ * Information needed for a single ref update. Set new_sha1 to the new
+ * value or to null_sha1 to delete the ref. To check the old value
+ * while the ref is locked, set (flags & REF_HAVE_OLD) and set
+ * old_sha1 to the old value, or to null_sha1 to ensure the ref does
+ * not exist before update.
  */
 struct ref_update {
+       /*
+        * If (flags & REF_HAVE_NEW), set the reference to this value:
+        */
        unsigned char new_sha1[20];
+       /*
+        * If (flags & REF_HAVE_OLD), check that the reference
+        * previously had this value:
+        */
        unsigned char old_sha1[20];
-       int flags; /* REF_NODEREF? */
-       int have_old; /* 1 if old_sha1 is valid, 0 otherwise */
+       /*
+        * One or more of REF_HAVE_NEW, REF_HAVE_OLD, REF_NODEREF,
+        * REF_DELETING, and REF_ISPRUNING:
+        */
+       unsigned int flags;
        struct ref_lock *lock;
        int type;
        char *msg;
@@ -3637,7 +3652,7 @@ int ref_transaction_update(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *new_sha1,
                           const unsigned char *old_sha1,
-                          int flags, int have_old, const char *msg,
+                          unsigned int flags, const char *msg,
                           struct strbuf *err)
 {
        struct ref_update *update;
@@ -3647,10 +3662,7 @@ int ref_transaction_update(struct ref_transaction *transaction,
        if (transaction->state != REF_TRANSACTION_OPEN)
                die("BUG: update called for transaction that is not open");
 
-       if (have_old && !old_sha1)
-               die("BUG: have_old is true but old_sha1 is NULL");
-
-       if (!is_null_sha1(new_sha1) &&
+       if (new_sha1 && !is_null_sha1(new_sha1) &&
            check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
                strbuf_addf(err, "refusing to update ref with bad name %s",
                            refname);
@@ -3658,11 +3670,15 @@ int ref_transaction_update(struct ref_transaction *transaction,
        }
 
        update = add_update(transaction, refname);
-       hashcpy(update->new_sha1, new_sha1);
-       update->flags = flags;
-       update->have_old = have_old;
-       if (have_old)
+       if (new_sha1) {
+               hashcpy(update->new_sha1, new_sha1);
+               flags |= REF_HAVE_NEW;
+       }
+       if (old_sha1) {
                hashcpy(update->old_sha1, old_sha1);
+               flags |= REF_HAVE_OLD;
+       }
+       update->flags = flags;
        if (msg)
                update->msg = xstrdup(msg);
        return 0;
@@ -3671,34 +3687,52 @@ int ref_transaction_update(struct ref_transaction *transaction,
 int ref_transaction_create(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *new_sha1,
-                          int flags, const char *msg,
+                          unsigned int flags, const char *msg,
                           struct strbuf *err)
 {
+       if (!new_sha1 || is_null_sha1(new_sha1))
+               die("BUG: create called without valid new_sha1");
        return ref_transaction_update(transaction, refname, new_sha1,
-                                     null_sha1, flags, 1, msg, err);
+                                     null_sha1, flags, msg, err);
 }
 
 int ref_transaction_delete(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *old_sha1,
-                          int flags, int have_old, const char *msg,
+                          unsigned int flags, const char *msg,
+                          struct strbuf *err)
+{
+       if (old_sha1 && is_null_sha1(old_sha1))
+               die("BUG: delete called with old_sha1 set to zeros");
+       return ref_transaction_update(transaction, refname,
+                                     null_sha1, old_sha1,
+                                     flags, msg, err);
+}
+
+int ref_transaction_verify(struct ref_transaction *transaction,
+                          const char *refname,
+                          const unsigned char *old_sha1,
+                          unsigned int flags,
                           struct strbuf *err)
 {
-       return ref_transaction_update(transaction, refname, null_sha1,
-                                     old_sha1, flags, have_old, msg, err);
+       if (!old_sha1)
+               die("BUG: verify called with old_sha1 set to NULL");
+       return ref_transaction_update(transaction, refname,
+                                     NULL, old_sha1,
+                                     flags, NULL, err);
 }
 
-int update_ref(const char *action, const char *refname,
-              const unsigned char *sha1, const unsigned char *oldval,
-              int flags, enum action_on_err onerr)
+int update_ref(const char *msg, const char *refname,
+              const unsigned char *new_sha1, const unsigned char *old_sha1,
+              unsigned int flags, enum action_on_err onerr)
 {
        struct ref_transaction *t;
        struct strbuf err = STRBUF_INIT;
 
        t = ref_transaction_begin(&err);
        if (!t ||
-           ref_transaction_update(t, refname, sha1, oldval, flags,
-                                  !!oldval, action, &err) ||
+           ref_transaction_update(t, refname, new_sha1, old_sha1,
+                                  flags, msg, &err) ||
            ref_transaction_commit(t, &err)) {
                const char *str = "update_ref failed for ref '%s': %s";
 
@@ -3774,17 +3808,17 @@ int ref_transaction_commit(struct ref_transaction *transaction,
        /* Acquire all locks while verifying old values */
        for (i = 0; i < n; i++) {
                struct ref_update *update = updates[i];
-               int flags = update->flags;
+               unsigned int flags = update->flags;
 
-               if (is_null_sha1(update->new_sha1))
+               if ((flags & REF_HAVE_NEW) && is_null_sha1(update->new_sha1))
                        flags |= REF_DELETING;
-               update->lock = lock_ref_sha1_basic(update->refname,
-                                                  (update->have_old ?
-                                                   update->old_sha1 :
-                                                   NULL),
-                                                  NULL,
-                                                  flags,
-                                                  &update->type);
+               update->lock = lock_ref_sha1_basic(
+                               update->refname,
+                               ((update->flags & REF_HAVE_OLD) ?
+                                update->old_sha1 : NULL),
+                               NULL,
+                               flags,
+                               &update->type);
                if (!update->lock) {
                        ret = (errno == ENOTDIR)
                                ? TRANSACTION_NAME_CONFLICT
@@ -3798,31 +3832,46 @@ int ref_transaction_commit(struct ref_transaction *transaction,
        /* Perform updates first so live commits remain referenced */
        for (i = 0; i < n; i++) {
                struct ref_update *update = updates[i];
+               int flags = update->flags;
+
+               if ((flags & REF_HAVE_NEW) && !is_null_sha1(update->new_sha1)) {
+                       int overwriting_symref = ((update->type & REF_ISSYMREF) &&
+                                                 (update->flags & REF_NODEREF));
 
-               if (!is_null_sha1(update->new_sha1)) {
-                       if (write_ref_sha1(update->lock, update->new_sha1,
-                                          update->msg)) {
+                       if (!overwriting_symref
+                           && !hashcmp(update->lock->old_sha1, update->new_sha1)) {
+                               /*
+                                * The reference already has the desired
+                                * value, so we don't need to write it.
+                                */
+                               unlock_ref(update->lock);
+                               update->lock = NULL;
+                       } else if (write_ref_sha1(update->lock, update->new_sha1,
+                                                 update->msg)) {
                                update->lock = NULL; /* freed by write_ref_sha1 */
                                strbuf_addf(err, "Cannot update the ref '%s'.",
                                            update->refname);
                                ret = TRANSACTION_GENERIC_ERROR;
                                goto cleanup;
+                       } else {
+                               /* freed by write_ref_sha1(): */
+                               update->lock = NULL;
                        }
-                       update->lock = NULL; /* freed by write_ref_sha1 */
                }
        }
 
        /* Perform deletes now that updates are safely completed */
        for (i = 0; i < n; i++) {
                struct ref_update *update = updates[i];
+               int flags = update->flags;
 
-               if (update->lock) {
+               if ((flags & REF_HAVE_NEW) && is_null_sha1(update->new_sha1)) {
                        if (delete_ref_loose(update->lock, update->type, err)) {
                                ret = TRANSACTION_GENERIC_ERROR;
                                goto cleanup;
                        }
 
-                       if (!(update->flags & REF_ISPRUNING))
+                       if (!(flags & REF_ISPRUNING))
                                string_list_append(&refs_to_delete,
                                                   update->lock->ref_name);
                }
@@ -4031,6 +4080,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
        struct ref_lock *lock;
        char *log_file;
        int status = 0;
+       int type;
 
        memset(&cb, 0, sizeof(cb));
        cb.flags = flags;
@@ -4042,7 +4092,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
         * reference itself, plus we might need to update the
         * reference if --updateref was specified:
         */
-       lock = lock_ref_sha1_basic(refname, sha1, NULL, 0, NULL);
+       lock = lock_ref_sha1_basic(refname, sha1, NULL, 0, &type);
        if (!lock)
                return error("cannot lock ref '%s'", refname);
        if (!reflog_exists(refname)) {
@@ -4079,10 +4129,21 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
        (*cleanup_fn)(cb.policy_cb);
 
        if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
+               /*
+                * It doesn't make sense to adjust a reference pointed
+                * to by a symbolic ref based on expiring entries in
+                * the symbolic reference's reflog. Nor can we update
+                * a reference if there are no remaining reflog
+                * entries.
+                */
+               int update = (flags & EXPIRE_REFLOGS_UPDATE_REF) &&
+                       !(type & REF_ISSYMREF) &&
+                       !is_null_sha1(cb.last_kept_sha1);
+
                if (close_lock_file(&reflog_lock)) {
                        status |= error("couldn't write %s: %s", log_file,
                                        strerror(errno));
-               } else if ((flags & EXPIRE_REFLOGS_UPDATE_REF) &&
+               } else if (update &&
                        (write_in_full(lock->lock_fd,
                                sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
                         write_str_in_full(lock->lock_fd, "\n") != 1 ||
@@ -4093,7 +4154,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
                } else if (commit_lock_file(&reflog_lock)) {
                        status |= error("unable to commit reflog '%s' (%s)",
                                        log_file, strerror(errno));
-               } else if ((flags & EXPIRE_REFLOGS_UPDATE_REF) && commit_ref(lock)) {
+               } else if (update && commit_ref(lock)) {
                        status |= error("couldn't set %s", lock->ref_name);
                }
        }
diff --git a/refs.h b/refs.h
index afa3c4decd5562c85978e49a9e1c2a34c128b055..cf642e6ddc438be77d64797a4dbcf790262a9fed 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -183,12 +183,10 @@ extern int peel_ref(const char *refname, unsigned char *sha1);
  * Flags controlling ref_transaction_update(), ref_transaction_create(), etc.
  * REF_NODEREF: act on the ref directly, instead of dereferencing
  *              symbolic references.
- * REF_DELETING: tolerate broken refs
  *
- * Flags >= 0x100 are reserved for internal use.
+ * Other flags are reserved for internal use.
  */
 #define REF_NODEREF    0x01
-#define REF_DELETING   0x02
 
 /*
  * Setup reflog before using. Set errno to something meaningful on failure.
@@ -257,57 +255,95 @@ enum action_on_err {
 struct ref_transaction *ref_transaction_begin(struct strbuf *err);
 
 /*
- * The following functions add a reference check or update to a
- * ref_transaction.  In all of them, refname is the name of the
- * reference to be affected.  The functions make internal copies of
- * refname and msg, so the caller retains ownership of these parameters.
- * flags can be REF_NODEREF; it is passed to update_ref_lock().
+ * Reference transaction updates
+ *
+ * The following four functions add a reference check or update to a
+ * ref_transaction.  They have some common similar parameters:
+ *
+ *     transaction -- a pointer to an open ref_transaction, obtained
+ *         from ref_transaction_begin().
+ *
+ *     refname -- the name of the reference to be affected.
+ *
+ *     flags -- flags affecting the update, passed to
+ *         update_ref_lock(). Can be REF_NODEREF, which means that
+ *         symbolic references should not be followed.
+ *
+ *     msg -- a message describing the change (for the reflog).
+ *
+ *     err -- a strbuf for receiving a description of any error that
+ *         might have occured.
+ *
+ * The functions make internal copies of refname and msg, so the
+ * caller retains ownership of these parameters.
+ *
+ * The functions return 0 on success and non-zero on failure. A
+ * failure means that the transaction as a whole has failed and needs
+ * to be rolled back.
  */
 
 /*
- * Add a reference update to transaction.  new_sha1 is the value that
- * the reference should have after the update, or null_sha1 if it should
- * be deleted.  If have_old is true, then old_sha1 holds the value
- * that the reference should have had before the update, or zeros if
- * it must not have existed beforehand.
- * Function returns 0 on success and non-zero on failure. A failure to update
- * means that the transaction as a whole has failed and will need to be
- * rolled back.
+ * Add a reference update to transaction. new_sha1 is the value that
+ * the reference should have after the update, or null_sha1 if it
+ * should be deleted. If new_sha1 is NULL, then the reference is not
+ * changed at all. old_sha1 is the value that the reference must have
+ * before the update, or null_sha1 if it must not have existed
+ * beforehand. The old value is checked after the lock is taken to
+ * prevent races. If the old value doesn't agree with old_sha1, the
+ * whole transaction fails. If old_sha1 is NULL, then the previous
+ * value is not checked.
+ *
+ * See the above comment "Reference transaction updates" for more
+ * information.
  */
 int ref_transaction_update(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *new_sha1,
                           const unsigned char *old_sha1,
-                          int flags, int have_old, const char *msg,
+                          unsigned int flags, const char *msg,
                           struct strbuf *err);
 
 /*
- * Add a reference creation to transaction.  new_sha1 is the value
- * that the reference should have after the update; it must not be the
- * null SHA-1.  It is verified that the reference does not exist
+ * Add a reference creation to transaction. new_sha1 is the value that
+ * the reference should have after the update; it must not be
+ * null_sha1. It is verified that the reference does not exist
  * already.
- * Function returns 0 on success and non-zero on failure. A failure to create
- * means that the transaction as a whole has failed and will need to be
- * rolled back.
+ *
+ * See the above comment "Reference transaction updates" for more
+ * information.
  */
 int ref_transaction_create(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *new_sha1,
-                          int flags, const char *msg,
+                          unsigned int flags, const char *msg,
                           struct strbuf *err);
 
 /*
- * Add a reference deletion to transaction.  If have_old is true, then
- * old_sha1 holds the value that the reference should have had before
- * the update (which must not be the null SHA-1).
- * Function returns 0 on success and non-zero on failure. A failure to delete
- * means that the transaction as a whole has failed and will need to be
- * rolled back.
+ * Add a reference deletion to transaction. If old_sha1 is non-NULL,
+ * then it holds the value that the reference should have had before
+ * the update (which must not be null_sha1).
+ *
+ * See the above comment "Reference transaction updates" for more
+ * information.
  */
 int ref_transaction_delete(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *old_sha1,
-                          int flags, int have_old, const char *msg,
+                          unsigned int flags, const char *msg,
+                          struct strbuf *err);
+
+/*
+ * Verify, within a transaction, that refname has the value old_sha1,
+ * or, if old_sha1 is null_sha1, then verify that the reference
+ * doesn't exist. old_sha1 must be non-NULL.
+ *
+ * See the above comment "Reference transaction updates" for more
+ * information.
+ */
+int ref_transaction_verify(struct ref_transaction *transaction,
+                          const char *refname,
+                          const unsigned char *old_sha1,
+                          unsigned int flags,
                           struct strbuf *err);
 
 /*
@@ -328,10 +364,17 @@ int ref_transaction_commit(struct ref_transaction *transaction,
  */
 void ref_transaction_free(struct ref_transaction *transaction);
 
-/** Lock a ref and then write its file */
-int update_ref(const char *action, const char *refname,
-               const unsigned char *sha1, const unsigned char *oldval,
-               int flags, enum action_on_err onerr);
+/**
+ * Lock, update, and unlock a single reference. This function
+ * basically does a transaction containing a single call to
+ * ref_transaction_update(). The parameters to this function have the
+ * same meaning as the corresponding parameters to
+ * ref_transaction_update(). Handle errors as requested by the `onerr`
+ * argument.
+ */
+int update_ref(const char *msg, const char *refname,
+              const unsigned char *new_sha1, const unsigned char *old_sha1,
+              unsigned int flags, enum action_on_err onerr);
 
 extern int parse_hide_refs_config(const char *var, const char *value, const char *);
 extern int ref_is_hidden(const char *);
index deb4bfe684512ea48fbc0d2663270e44722db26b..af7b6786dc091035e3216c710dbc0ebc3c234a8a 100644 (file)
@@ -567,7 +567,6 @@ static int post_rpc(struct rpc_state *rpc)
                git_zstream stream;
                int ret;
 
-               memset(&stream, 0, sizeof(stream));
                git_deflate_init_gzip(&stream, Z_BEST_COMPRESSION);
                gzip_size = git_deflate_bound(&stream, rpc->len);
                gzip_body = xmalloc(gzip_size);
index 77a1266760718b8e5b029636409634e241981888..c4f4b7d571fa088f80a0dbba815491a35f0c153f 100644 (file)
@@ -252,7 +252,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
        if (!transaction ||
            ref_transaction_update(transaction, "HEAD",
                                   to, unborn ? null_sha1 : from,
-                                  0, 1, sb.buf, &err) ||
+                                  0, sb.buf, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
                error("%s", err.buf);
@@ -373,6 +373,7 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
 {
        struct argv_array array;
        int rc;
+       const char *value;
 
        argv_array_init(&array);
        argv_array_push(&array, "commit");
@@ -385,6 +386,10 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
        if (!opts->edit) {
                argv_array_push(&array, "-F");
                argv_array_push(&array, defmsg);
+               if (!opts->signoff &&
+                   !opts->record_origin &&
+                   git_config_get_value("commit.cleanup", &value))
+                       argv_array_push(&array, "--cleanup=verbatim");
        }
 
        if (allow_empty)
index 69a60ec88bad190f885cd89a93573236a88ddbd9..88f06bac926008dd40b6a53e0696274438278cfc 100644 (file)
@@ -2943,7 +2943,6 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
        }
 
        /* Set it up */
-       memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, zlib_compression_level);
        stream.next_out = compressed;
        stream.avail_out = sizeof(compressed);
index cf2a83b14381ae02e737e6135561aab401f1f7e8..95f9f8fa1a72693757bbafe0f2a7773d8ae2de05 100644 (file)
@@ -1391,9 +1391,7 @@ static int get_sha1_with_context_1(const char *name,
                        namelen = strlen(cp);
                }
 
-               strncpy(oc->path, cp,
-                       sizeof(oc->path));
-               oc->path[sizeof(oc->path)-1] = '\0';
+               strlcpy(oc->path, cp, sizeof(oc->path));
 
                if (!active_cache)
                        read_cache();
@@ -1443,9 +1441,7 @@ static int get_sha1_with_context_1(const char *name,
                                                           name, len);
                        }
                        hashcpy(oc->tree, tree_sha1);
-                       strncpy(oc->path, filename,
-                               sizeof(oc->path));
-                       oc->path[sizeof(oc->path)-1] = '\0';
+                       strlcpy(oc->path, filename, sizeof(oc->path));
 
                        free(new_filename);
                        return ret;
index 75a35fcd0699940aea51534b5fe954847bed7bb9..c211dc40eed98fc58c953d2e3b1f7ba752f98a02 100644 (file)
@@ -1,6 +1,6 @@
 :
 
-sanitize_diff_raw='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*  / X X \1#       /'
+sanitize_diff_raw='/^:/s/ '"\($_x40\)"' '"\($_x40\)"' \([A-Z]\)[0-9]*  / \1 \2 \3#     /'
 compare_diff_raw () {
     # When heuristics are improved, the score numbers would change.
     # Ignore them while comparing.
diff --git a/t/diff-lib/COPYING b/t/diff-lib/COPYING
new file mode 100644 (file)
index 0000000..6ff87c4
--- /dev/null
@@ -0,0 +1,361 @@
+
+ Note that the only valid version of the GPL as far as this project
+ is concerned is _this_ particular version of the license (ie v2, not
+ v2.2 or v3.x or whatever), unless explicitly otherwise stated.
+
+ HOWEVER, in order to allow a migration to GPLv3 if that seems like
+ a good idea, I also ask that people involved with the project make
+ their preferences known. In particular, if you trust me to make that
+ decision, you might note so in your copyright message, ie something
+ like
+
+       This file is licensed under the GPL v2, or a later version
+       at the discretion of Linus.
+
+  might avoid issues. But we can also just decide to synchronize and
+  contact all copyright holders on record if/when the occasion arises.
+
+                       Linus Torvalds
+
+----------------------------------------
+
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/t/diff-lib/README b/t/diff-lib/README
new file mode 100644 (file)
index 0000000..548142c
--- /dev/null
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////
+
+       GIT - the stupid content tracker
+
+////////////////////////////////////////////////////////////////
+
+"git" can mean anything, depending on your mood.
+
+ - random three-letter combination that is pronounceable, and not
+   actually used by any common UNIX command.  The fact that it is a
+   mispronunciation of "get" may or may not be relevant.
+ - stupid. contemptible and despicable. simple. Take your pick from the
+   dictionary of slang.
+ - "global information tracker": you're in a good mood, and it actually
+   works for you. Angels sing, and a light suddenly fills the room.
+ - "goddamn idiotic truckload of sh*t": when it breaks
+
+Git is a fast, scalable, distributed revision control system with an
+unusually rich command set that provides both high-level operations
+and full access to internals.
+
+Git is an Open Source project covered by the GNU General Public License.
+It was originally written by Linus Torvalds with help of a group of
+hackers around the net. It is currently maintained by Junio C Hamano.
+
+Please read the file INSTALL for installation instructions.
+See Documentation/tutorial.txt to get started, then see
+Documentation/everyday.txt for a useful minimum set of commands,
+and "man git-commandname" for documentation of each command.
+CVS users may also want to read Documentation/cvs-migration.txt.
+
+Many Git online resources are accessible from http://git.or.cz/
+including full documentation and Git related tools.
+
+The user discussion and development of Git take place on the Git
+mailing list -- everyone is welcome to post bug reports, feature
+requests, comments and patches to git@vger.kernel.org. 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://marc.theaimsgroup.com/?l=git and other archival sites.
+
+The messages titled "A note from the maintainer", "What's in
+git.git (stable)" and "What's cooking in git.git (topics)" and
+the discussion following them on the mailing list give a good
+reference for project status, development direction and
+remaining tasks.
index 99c037703a676dd63e4c2b53ea87601fc2503b88..2630e756dab7322a5360a67766a648a80a5a7222 100755 (executable)
@@ -14,6 +14,16 @@ test_expect_success '"git -C <path>" runs git from the directory <path>' '
        test_cmp expected actual
 '
 
+test_expect_success '"git -C <path>" with an empty <path> is a no-op' '
+       (
+               mkdir -p dir1/subdir &&
+               cd dir1/subdir &&
+               git -C "" rev-parse --show-prefix >actual &&
+               echo subdir/ >expect &&
+               test_cmp expect actual
+       )
+'
+
 test_expect_success 'Multiple -C options: "-C dir1 -C dir2" is equivalent to "-C dir1/dir2"' '
        test_create_repo dir1/dir2 &&
        echo 1 >dir1/dir2/b.txt &&
index ba4f98e800f262242ef7925f82dc8d13272fe3ca..f51d0f3cadcb4f97f4cf9f2d79aad9ed401781d8 100755 (executable)
@@ -96,7 +96,7 @@ test_expect_success 'git branch -v pattern does not show branch summaries' '
 
 test_expect_success 'git branch shows detached HEAD properly' '
        cat >expect <<EOF &&
-* (detached from $(git rev-parse --short HEAD^0))
+* (HEAD detached at $(git rev-parse --short HEAD^0))
   branch-one
   branch-two
   master
@@ -106,4 +106,41 @@ EOF
        test_i18ncmp expect actual
 '
 
+test_expect_success 'git branch shows detached HEAD properly after moving' '
+       cat >expect <<EOF &&
+* (HEAD detached from $(git rev-parse --short HEAD))
+  branch-one
+  branch-two
+  master
+EOF
+       git reset --hard HEAD^1 &&
+       git branch >actual &&
+       test_i18ncmp expect actual
+'
+
+test_expect_success 'git branch shows detached HEAD properly from tag' '
+       cat >expect <<EOF &&
+* (HEAD detached at fromtag)
+  branch-one
+  branch-two
+  master
+EOF
+       git tag fromtag master &&
+       git checkout fromtag &&
+       git branch >actual &&
+       test_i18ncmp expect actual
+'
+
+test_expect_success 'git branch shows detached HEAD properly after moving from tag' '
+       cat >expect <<EOF &&
+* (HEAD detached from fromtag)
+  branch-one
+  branch-two
+  master
+EOF
+       git reset --hard HEAD^1 &&
+       git branch >actual &&
+       test_i18ncmp expect actual
+'
+
 test_done
index a31f7e0430e107c1fbe036ce412d4466fa5bd2c2..034eb35cdf3f13686f10737267567c08e749ad1c 100755 (executable)
@@ -1046,4 +1046,13 @@ test_expect_success 'respect core.abbrev' '
        test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
 '
 
+test_expect_success 'todo count' '
+       write_script dump-raw.sh <<-\EOF &&
+               cat "$1"
+       EOF
+       test_set_editor "$(pwd)/dump-raw.sh" &&
+       git rebase -i HEAD~4 >actual &&
+       grep "^# Rebase ..* onto ..* ([0-9]" actual
+'
+
 test_done
index f97727975b880ae52394c6af11dde15b71ac6eb7..b7dff09d0656930332f347bd3106d1473015abd0 100755 (executable)
@@ -36,6 +36,20 @@ mesg_with_cherry_footer="$mesg_with_footer_sob
 (cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
 Tested-by: C.U. Thor <cuthor@example.com>"
 
+mesg_unclean="$mesg_one_line
+
+
+leading empty lines
+
+
+consecutive empty lines
+
+# hash tag comment
+
+trailing empty lines
+
+
+"
 
 test_expect_success setup '
        git config advice.detachedhead false &&
@@ -53,6 +67,10 @@ test_expect_success setup '
        test_commit "$mesg_with_footer_sob" foo b mesg-with-footer-sob &&
        git reset --hard initial &&
        test_commit "$mesg_with_cherry_footer" foo b mesg-with-cherry-footer &&
+       git reset --hard initial &&
+       test_config commit.cleanup verbatim &&
+       test_commit "$mesg_unclean" foo b mesg-unclean &&
+       test_unconfig commit.cleanup &&
        pristine_detach initial &&
        test_commit conflicting unrelated
 '
@@ -216,4 +234,14 @@ test_expect_success 'cherry-pick -x -s treats "(cherry picked from..." line as p
        test_cmp expect actual
 '
 
+test_expect_success 'cherry-pick preserves commit message' '
+       pristine_detach initial &&
+       printf "$mesg_unclean" >expect &&
+       git log -1 --pretty=format:%B mesg-unclean >actual &&
+       test_cmp expect actual &&
+       git cherry-pick mesg-unclean &&
+       git log -1 --pretty=format:%B >actual &&
+       test_cmp expect actual
+'
+
 test_done
index bfa88356382ab9f37e6e510516bf1fc6a3811961..df2accb6555d4202c789b8ffb13ae3943268586d 100755 (executable)
@@ -11,7 +11,7 @@ test_description='More rename detection
 
 test_expect_success \
     'prepare reference tree' \
-    'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
+    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
      echo frotz >rezrov &&
     git update-index --add COPYING rezrov &&
     tree=$(git write-tree) &&
@@ -99,7 +99,7 @@ test_expect_success \
 
 test_expect_success \
     'prepare work tree once again' \
-    'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
+    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
      git update-index --add --remove COPYING COPYING.1'
 
 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
index 7d2c6e13a2a7f5d8e9e863d83e6b7b716810c970..135addbfbdae8e39ba0462e71278f41dfc552620 100755 (executable)
@@ -11,7 +11,7 @@ test_description='Same rename detection as t4003 but testing diff-raw.
 
 test_expect_success \
     'prepare reference tree' \
-    'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
+    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
      echo frotz >rezrov &&
     git update-index --add COPYING rezrov &&
     tree=$(git write-tree) &&
@@ -71,7 +71,7 @@ test_expect_success \
 
 test_expect_success \
     'prepare work tree once again' \
-    'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
+    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
      git update-index --add --remove COPYING COPYING.1'
 
 git diff-index -C --find-copies-harder $tree >current
index 11502b750997aba0ecfb6aa5b07c9aad1c45d592..dae327fabbfe390a3dc707ef2ebc665c9c6e3cb3 100755 (executable)
@@ -11,7 +11,7 @@ test_description='Rename interaction with pathspec.
 
 test_expect_success 'prepare reference tree' '
        mkdir path0 path1 &&
-       cp "$TEST_DIRECTORY"/../COPYING path0/COPYING &&
+       cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
        git update-index --add path0/COPYING &&
        tree=$(git write-tree) &&
        echo $tree
index 89204648965b2b6b7d7984e3398b3ef21a8d7c7e..9dd1bc5e162bb0b8821337a1e43cd8ad85423507 100755 (executable)
@@ -10,179 +10,145 @@ We have two very different files, file0 and file1, registered in a tree.
 We update file1 so drastically that it is more similar to file0, and
 then remove file0.  With -B, changes to file1 should be broken into
 separate delete and create, resulting in removal of file0, removal of
-original file1 and creation of completely rewritten file1.
+original file1 and creation of completely rewritten file1.  The latter
+two are then merged back into a single "complete rewrite".
 
 Further, with -B and -M together, these three modifications should
 turn into rename-edit of file0 into file1.
 
 Starting from the same two files in the tree, we swap file0 and file1.
-With -B, this should be detected as two complete rewrites, resulting in
-four changes in total.
+With -B, this should be detected as two complete rewrites.
 
 Further, with -B and -M together, these should turn into two renames.
 '
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
 
-test_expect_success \
-    setup \
-    'cat "$TEST_DIRECTORY"/../README >file0 &&
-     cat "$TEST_DIRECTORY"/../COPYING >file1 &&
-    git update-index --add file0 file1 &&
-    tree=$(git write-tree) &&
-    echo "$tree"'
-
-test_expect_success \
-    'change file1 with copy-edit of file0 and remove file0' \
-    'sed -e "s/git/GIT/" file0 >file1 &&
-     rm -f file0 &&
-    git update-index --remove file0 file1'
-
-test_expect_success \
-    'run diff with -B' \
-    'git diff-index -B --cached "$tree" >current'
-
-cat >expected <<\EOF
-:100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D     file0
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 11e331465a89c394dc25c780de230043750c1ec8 M100  file1
-EOF
-
-test_expect_success \
-    'validate result of -B (#1)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'run diff with -B and -M' \
-    'git diff-index -B -M "$tree" >current'
-
-cat >expected <<\EOF
-:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c R100  file0   file1
-EOF
-
-test_expect_success \
-    'validate result of -B -M (#2)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'swap file0 and file1' \
-    'rm -f file0 file1 &&
-     git read-tree -m $tree &&
-     git checkout-index -f -u -a &&
-     mv file0 tmp &&
-     mv file1 file0 &&
-     mv tmp file1 &&
-     git update-index file0 file1'
-
-test_expect_success \
-    'run diff with -B' \
-    'git diff-index -B "$tree" >current'
-
-cat >expected <<\EOF
-:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100  file0
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 M100  file1
-EOF
-
-test_expect_success \
-    'validate result of -B (#3)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'run diff with -B and -M' \
-    'git diff-index -B -M "$tree" >current'
-
-cat >expected <<\EOF
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100  file1   file0
-:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 R100  file0   file1
-EOF
-
-test_expect_success \
-    'validate result of -B -M (#4)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'make file0 into something completely different' \
-    'rm -f file0 &&
-     test_ln_s_add frotz file0 &&
-     git update-index file1'
-
-test_expect_success \
-    'run diff with -B' \
-    'git diff-index -B "$tree" >current'
-
-cat >expected <<\EOF
-:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T     file0
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 M100  file1
-EOF
-
-test_expect_success \
-    'validate result of -B (#5)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'run diff with -B -M' \
-    'git diff-index -B -M "$tree" >current'
-
-# file0 changed from regular to symlink.  file1 is very close to the preimage of file0.
-# the change does not make file0 disappear, so file1 is denoted as a copy of file0
-cat >expected <<\EOF
-:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T     file0
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 C     file0   file1
-EOF
-
-test_expect_success \
-    'validate result of -B -M (#6)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'run diff with -M' \
-    'git diff-index -M "$tree" >current'
-
-# This should not mistake file0 as the copy source of new file1
-# due to type differences.
-cat >expected <<\EOF
-:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T     file0
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 M     file1
-EOF
-
-test_expect_success \
-    'validate result of -M (#7)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'file1 edited to look like file0 and file0 rename-edited to file2' \
-    'rm -f file0 file1 &&
-     git read-tree -m $tree &&
-     git checkout-index -f -u -a &&
-     sed -e "s/git/GIT/" file0 >file1 &&
-     sed -e "s/git/GET/" file0 >file2 &&
-     rm -f file0 &&
-     git update-index --add --remove file0 file1 file2'
-
-test_expect_success \
-    'run diff with -B' \
-    'git diff-index -B "$tree" >current'
-
-cat >expected <<\EOF
-:100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D     file0
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 08bb2fb671deff4c03a4d4a0a1315dff98d5732c M100  file1
-:000000 100644 0000000000000000000000000000000000000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 A     file2
-EOF
-
-test_expect_success \
-    'validate result of -B (#8)' \
-    'compare_diff_raw expected current'
-
-test_expect_success \
-    'run diff with -B -C' \
-    'git diff-index -B -C "$tree" >current'
-
-cat >expected <<\EOF
-:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095  file0   file1
-:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 59f832e5c8b3f7e486be15ad0cd3e95ba9af8998 R095  file0   file2
-EOF
-
-test_expect_success \
-    'validate result of -B -M (#9)' \
-    'compare_diff_raw expected current'
+test_expect_success setup '
+       cat "$TEST_DIRECTORY"/diff-lib/README >file0 &&
+       cat "$TEST_DIRECTORY"/diff-lib/COPYING >file1 &&
+       git update-index --add file0 file1 &&
+       git tag reference $(git write-tree)
+'
+
+test_expect_success 'change file1 with copy-edit of file0 and remove file0' '
+       sed -e "s/git/GIT/" file0 >file1 &&
+       rm -f file0 &&
+       git update-index --remove file0 file1
+'
+
+test_expect_success 'run diff with -B (#1)' '
+       git diff-index -B --cached reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 000000 548142c327a6790ff8821d67c2ee1eff7a656b52 0000000000000000000000000000000000000000 D      file0
+       :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec M100   file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'run diff with -B and -M (#2)' '
+       git diff-index -B -M reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec R100   file0   file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'swap file0 and file1' '
+       rm -f file0 file1 &&
+       git read-tree -m reference &&
+       git checkout-index -f -u -a &&
+       mv file0 tmp &&
+       mv file1 file0 &&
+       mv tmp file1 &&
+       git update-index file0 file1
+'
+
+test_expect_success 'run diff with -B (#3)' '
+       git diff-index -B reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100   file0
+       :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100   file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'run diff with -B and -M (#4)' '
+       git diff-index -B -M reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100   file1   file0
+       :100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 R100   file0   file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'make file0 into something completely different' '
+       rm -f file0 &&
+       test_ln_s_add frotz file0 &&
+       git update-index file1
+'
+
+test_expect_success 'run diff with -B (#5)' '
+       git diff-index -B reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T      file0
+       :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100   file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'run diff with -B -M (#6)' '
+       git diff-index -B -M reference >current &&
+
+       # file0 changed from regular to symlink.  file1 is the same as the preimage
+       # of file0.  Because the change does not make file0 disappear, file1 is
+       # denoted as a copy of file0
+       cat >expect <<-\EOF &&
+       :100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T      file0
+       :100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 C      file0   file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'run diff with -M (#7)' '
+       git diff-index -M reference >current &&
+
+       # This should not mistake file0 as the copy source of new file1
+       # due to type differences.
+       cat >expect <<-\EOF &&
+       :100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T      file0
+       :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M      file1
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'file1 edited to look like file0 and file0 rename-edited to file2' '
+       rm -f file0 file1 &&
+       git read-tree -m reference &&
+       git checkout-index -f -u -a &&
+       sed -e "s/git/GIT/" file0 >file1 &&
+       sed -e "s/git/GET/" file0 >file2 &&
+       rm -f file0 &&
+       git update-index --add --remove file0 file1 file2
+'
+
+test_expect_success 'run diff with -B (#8)' '
+       git diff-index -B reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 000000 548142c327a6790ff8821d67c2ee1eff7a656b52 0000000000000000000000000000000000000000 D      file0
+       :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec M100   file1
+       :000000 100644 0000000000000000000000000000000000000000 69a939f651686f56322566e2fd76715947a24162 A      file2
+       EOF
+       compare_diff_raw expect current
+'
+
+test_expect_success 'run diff with -B -C (#9)' '
+       git diff-index -B -C reference >current &&
+       cat >expect <<-\EOF &&
+       :100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec C095   file0   file1
+       :100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 69a939f651686f56322566e2fd76715947a24162 R095   file0   file2
+       EOF
+       compare_diff_raw expect current
+'
 
 test_done
index 57c094fdcea160a7816680d66efac9c05dd57cc8..3641fd84d68612786ab55beb780209c89311e105 100755 (executable)
@@ -11,7 +11,7 @@ test_description='Same rename detection as t4003 but testing diff-raw -z.
 
 test_expect_success \
     'prepare reference tree' \
-    'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
+    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
      echo frotz >rezrov &&
     git update-index --add COPYING rezrov &&
     tree=$(git write-tree) &&
@@ -78,7 +78,7 @@ test_expect_success \
 
 test_expect_success \
     'prepare work tree once again' \
-    'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
+    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
      git update-index --add --remove COPYING COPYING.1'
 
 git diff-index -z -C --find-copies-harder $tree >current
index bf078418662c4bab4e512be8fc22a5aa76466119..43c488b545e6acc02bab9d496e33c37b99f49c7a 100755 (executable)
@@ -56,7 +56,7 @@ test_expect_success \
      compare_diff_raw current expected'
 
 cat >expected <<\EOF
-:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M     file0
+:100644 100644 8e4020bb5a8d8c873b25de15933e75cc0fc275df dca6b92303befc93086aa025d90a5facd7eb2812 M     file0
 EOF
 test_expect_success \
     'limit to file0 should show file0' \
index ed7e093366bcbdaa177bac4294a07fc52d4233ed..0d50dce97e86a26bac7c798f020a1807936cc3c3 100755 (executable)
@@ -973,4 +973,18 @@ test_expect_success 'diff.dirstat=future_param,0,lines should warn, but still wo
        test_i18ngrep -q "diff\\.dirstat" actual_error
 '
 
+test_expect_success '--shortstat --dirstat should output only one dirstat' '
+       git diff --shortstat --dirstat=changes HEAD^..HEAD >out &&
+       grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_changes &&
+       test_line_count = 1 actual_diff_shortstat_dirstat_changes &&
+
+       git diff --shortstat --dirstat=lines HEAD^..HEAD >out &&
+       grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_lines &&
+       test_line_count = 1 actual_diff_shortstat_dirstat_lines &&
+
+       git diff --shortstat --dirstat=files HEAD^..HEAD >out &&
+       grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_files &&
+       test_line_count = 1 actual_diff_shortstat_dirstat_files
+'
+
 test_done
diff --git a/t/t4058-diff-duplicates.sh b/t/t4058-diff-duplicates.sh
new file mode 100755 (executable)
index 0000000..0a23242
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+test_description='test tree diff when trees have duplicate entries'
+. ./test-lib.sh
+
+# make_tree_entry <mode> <mode> <sha1>
+#
+# We have to rely on perl here because not all printfs understand
+# hex escapes (only octal), and xxd is not portable.
+make_tree_entry () {
+       printf '%s %s\0' "$1" "$2" &&
+       perl -e 'print chr(hex($_)) for ($ARGV[0] =~ /../g)' "$3"
+}
+
+# Like git-mktree, but without all of the pesky sanity checking.
+# Arguments come in groups of three, each group specifying a single
+# tree entry (see make_tree_entry above).
+make_tree () {
+       while test $# -gt 2; do
+               make_tree_entry "$1" "$2" "$3"
+               shift; shift; shift
+       done |
+       git hash-object -w -t tree --stdin
+}
+
+# this is kind of a convoluted setup, but matches
+# a real-world case. Each tree contains four entries
+# for the given path, one with one sha1, and three with
+# the other. The first tree has them split across
+# two subtrees (which are themselves duplicate entries in
+# the root tree), and the second has them all in a single subtree.
+test_expect_success 'create trees with duplicate entries' '
+       blob_one=$(echo one | git hash-object -w --stdin) &&
+       blob_two=$(echo two | git hash-object -w --stdin) &&
+       inner_one_a=$(make_tree \
+               100644 inner $blob_one
+       ) &&
+       inner_one_b=$(make_tree \
+               100644 inner $blob_two \
+               100644 inner $blob_two \
+               100644 inner $blob_two
+       ) &&
+       outer_one=$(make_tree \
+               040000 outer $inner_one_a \
+               040000 outer $inner_one_b
+       ) &&
+       inner_two=$(make_tree \
+               100644 inner $blob_one \
+               100644 inner $blob_two \
+               100644 inner $blob_two \
+               100644 inner $blob_two
+       ) &&
+       outer_two=$(make_tree \
+               040000 outer $inner_two
+       ) &&
+       git tag one $outer_one &&
+       git tag two $outer_two
+'
+
+test_expect_success 'diff-tree between trees' '
+       {
+               printf ":000000 100644 $_z40 $blob_two A\touter/inner\n" &&
+               printf ":000000 100644 $_z40 $blob_two A\touter/inner\n" &&
+               printf ":000000 100644 $_z40 $blob_two A\touter/inner\n" &&
+               printf ":100644 000000 $blob_two $_z40 D\touter/inner\n" &&
+               printf ":100644 000000 $blob_two $_z40 D\touter/inner\n" &&
+               printf ":100644 000000 $blob_two $_z40 D\touter/inner\n"
+       } >expect &&
+       git diff-tree -r --no-abbrev one two >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'diff-tree with renames' '
+       # same expectation as above, since we disable rename detection
+       git diff-tree -M -r --no-abbrev one two >actual &&
+       test_cmp expect actual
+'
+
+test_done
index c929db563326614e01962b3e322f087640fa19d9..14744b2a4b1e646890176ec53970d36de6f8ec3b 100755 (executable)
@@ -33,6 +33,37 @@ check_zip() {
        test_expect_success UNZIP " validate file contents" "
                diff -r a ${dir_with_prefix}a
        "
+
+       dir=eol_$1
+       dir_with_prefix=$dir/$2
+       extracted=${dir_with_prefix}a
+       original=a
+
+       test_expect_success UNZIP " extract ZIP archive with EOL conversion" '
+               (mkdir $dir && cd $dir && "$GIT_UNZIP" -a ../$zipfile)
+       '
+
+       test_expect_success UNZIP " validate that text files are converted" "
+               test_cmp_bin $extracted/text.cr $extracted/text.crlf &&
+               test_cmp_bin $extracted/text.cr $extracted/text.lf
+       "
+
+       test_expect_success UNZIP " validate that binary files are unchanged" "
+               test_cmp_bin $original/binary.cr   $extracted/binary.cr &&
+               test_cmp_bin $original/binary.crlf $extracted/binary.crlf &&
+               test_cmp_bin $original/binary.lf   $extracted/binary.lf
+       "
+
+       test_expect_success UNZIP " validate that diff files are converted" "
+               test_cmp_bin $extracted/diff.cr $extracted/diff.crlf &&
+               test_cmp_bin $extracted/diff.cr $extracted/diff.lf
+       "
+
+       test_expect_success UNZIP " validate that -diff files are unchanged" "
+               test_cmp_bin $original/nodiff.cr   $extracted/nodiff.cr &&
+               test_cmp_bin $original/nodiff.crlf $extracted/nodiff.crlf &&
+               test_cmp_bin $original/nodiff.lf   $extracted/nodiff.lf
+       "
 }
 
 test_expect_success \
@@ -41,6 +72,18 @@ test_expect_success \
      echo simple textfile >a/a &&
      mkdir a/bin &&
      cp /bin/sh a/bin &&
+     printf "text\r"   >a/text.cr &&
+     printf "text\r\n" >a/text.crlf &&
+     printf "text\n"   >a/text.lf &&
+     printf "text\r"   >a/nodiff.cr &&
+     printf "text\r\n" >a/nodiff.crlf &&
+     printf "text\n"   >a/nodiff.lf &&
+     printf "\0\r"     >a/binary.cr &&
+     printf "\0\r\n"   >a/binary.crlf &&
+     printf "\0\n"     >a/binary.lf &&
+     printf "\0\r"     >a/diff.cr &&
+     printf "\0\r\n"   >a/diff.crlf &&
+     printf "\0\n"     >a/diff.lf &&
      printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
      printf "A not substituted O" >a/substfile2 &&
      (p=long_path_to_a_file && cd a &&
@@ -66,7 +109,9 @@ test_expect_success 'add files to repository' '
        GIT_COMMITTER_DATE="2005-05-27 22:00" git commit -m initial
 '
 
-test_expect_success 'setup export-subst' '
+test_expect_success 'setup export-subst and diff attributes' '
+       echo "a/nodiff.* -diff" >>.git/info/attributes &&
+       echo "a/diff.* diff" >>.git/info/attributes &&
        echo "substfile?" export-subst >>.git/info/attributes &&
        git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
                >a/substfile1
index 5b2b1c2c130387332778f6e49043b739dd2d7d21..bd37f040b6ce13406ef009944d46d2f1cc6c8d7b 100755 (executable)
@@ -541,13 +541,30 @@ check_prot_path () {
        test_cmp expected actual
 }
 
-check_prot_host_path () {
-       cat >expected <<-EOF &&
+check_prot_host_port_path () {
+       local diagport
+       case "$2" in
+               *ssh*)
+               pp=ssh
+               uah=userandhost
+               ehost=$(echo $3 | tr -d "[]")
+               diagport="Diag: port=$4"
+               ;;
+               *)
+               pp=$p
+               uah=hostandport
+               ehost=$(echo $3$4 | sed -e "s/22$/:22/" -e "s/NONE//")
+               diagport=""
+               ;;
+       esac
+       cat >exp <<-EOF &&
        Diag: url=$1
-       Diag: protocol=$2
-       Diag: hostandport=$3
-       Diag: path=$4
+       Diag: protocol=$pp
+       Diag: $uah=$ehost
+       $diagport
+       Diag: path=$5
        EOF
+       grep -v "^$" exp >expected
        git fetch-pack --diag-url "$1" >actual &&
        test_cmp expected actual
 }
@@ -557,22 +574,20 @@ do
        # git or ssh with scheme
        for p in "ssh+git" "git+ssh" git ssh
        do
-               for h in host host:12 [::1] [::1]:23
+               for h in host user@host user@[::1] user@::1
                do
-                       case "$p" in
-                       *ssh*)
-                               pp=ssh
-                               ;;
-                       *)
-                               pp=$p
-                       ;;
-                       esac
                        test_expect_success "fetch-pack --diag-url $p://$h/$r" '
-                               check_prot_host_path $p://$h/$r $pp "$h" "/$r"
+                               check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r"
                        '
                        # "/~" -> "~" conversion
                        test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
-                               check_prot_host_path $p://$h/~$r $pp "$h" "~$r"
+                               check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r"
+                       '
+               done
+               for h in host User@host User@[::1]
+               do
+                       test_expect_success "fetch-pack --diag-url $p://$h:22/$r" '
+                               check_prot_host_port_path $p://$h:22/$r $p "$h" 22 "/$r"
                        '
                done
        done
@@ -603,11 +618,11 @@ do
        for h in host [::1]
        do
                test_expect_success "fetch-pack --diag-url $h:$r" '
-                       check_prot_path $h:$r $p "$r"
+                       check_prot_host_port_path $h:$r $p "$h" NONE "$r"
                '
                # Do "/~" -> "~" conversion
                test_expect_success "fetch-pack --diag-url $h:/~$r" '
-                       check_prot_host_path $h:/~$r $p "$h" "~$r"
+                       check_prot_host_port_path $h:/~$r $p "$h" NONE "~$r"
                '
        done
 done
index e4436c170088a69b9efc5712a55bbe1d4bb8113f..630885d6df2fed0b8ba35005f150ccd3838dfcca 100755 (executable)
@@ -238,7 +238,7 @@ test_expect_success 'push with pushInsteadOf' '
 test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
        mk_empty testrepo &&
        test_config "url.trash2/.pushInsteadOf" testrepo/ &&
-       test_config "url.trash3/.pusnInsteadOf" trash/wrong &&
+       test_config "url.trash3/.pushInsteadOf" trash/wrong &&
        test_config remote.r.url trash/wrong &&
        test_config remote.r.pushurl "testrepo/" &&
        git push r refs/heads/master:refs/remotes/origin/master &&
index e4f10c0f68b94bfa719c3d208f622541506c86b3..02b40b117faa1c6de816001018d1c7deda15ad7d 100755 (executable)
@@ -301,11 +301,17 @@ expect_ssh () {
                (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
        ' &&
        {
-               case "$1" in
-               none)
+               case "$#" in
+               1)
                        ;;
-               *)
+               2)
                        echo "ssh: $1 git-upload-pack '$2'"
+                       ;;
+               3)
+                       echo "ssh: $1 $2 git-upload-pack '$3'"
+                       ;;
+               *)
+                       echo "ssh: $1 $2 git-upload-pack '$3' $4"
                esac
        } >"$TRASH_DIRECTORY/ssh-expect" &&
        (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
@@ -326,7 +332,7 @@ test_expect_success !MINGW,!CYGWIN 'clone local path foo:bar' '
 
 test_expect_success 'bracketed hostnames are still ssh' '
        git clone "[myhost:123]:src" ssh-bracket-clone &&
-       expect_ssh myhost:123 src
+       expect_ssh myhost '-p 123' src
 '
 
 counter=0
@@ -336,7 +342,8 @@ counter=0
 test_clone_url () {
        counter=$(($counter + 1))
        test_might_fail git clone "$1" tmp$counter &&
-       expect_ssh "$2" "$3"
+       shift &&
+       expect_ssh "$@"
 }
 
 test_expect_success !MINGW 'clone c:temp is ssl' '
@@ -359,7 +366,7 @@ done
 for repo in rep rep/home/project 123
 do
        test_expect_success "clone [::1]:$repo" '
-               test_clone_url [::1]:$repo ::1 $repo
+               test_clone_url [::1]:$repo ::1 "$repo"
        '
 done
 #home directory
@@ -400,24 +407,40 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '
 '
 
 #IPv6
-test_expect_success 'clone ssh://[::1]/home/user/repo' '
-       test_clone_url "ssh://[::1]/home/user/repo" "::1" "/home/user/repo"
-'
+for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
+do
+       ehost=$(echo $tuah | tr -d "[]")
+       test_expect_success "clone ssh://$tuah/home/user/repo" "
+         test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
+       "
+done
 
 #IPv6 from home directory
-test_expect_success 'clone ssh://[::1]/~repo' '
-       test_clone_url "ssh://[::1]/~repo" "::1" "~repo"
-'
+for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
+do
+       euah=$(echo $tuah | tr -d "[]")
+       test_expect_success "clone ssh://$tuah/~repo" "
+         test_clone_url ssh://$tuah/~repo $euah '~repo'
+       "
+done
 
 #IPv6 with port number
-test_expect_success 'clone ssh://[::1]:22/home/user/repo' '
-       test_clone_url "ssh://[::1]:22/home/user/repo" "-p 22 ::1" "/home/user/repo"
-'
+for tuah in [::1] user@[::1] [user@::1]
+do
+       euah=$(echo $tuah | tr -d "[]")
+       test_expect_success "clone ssh://$tuah:22/home/user/repo" "
+         test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
+       "
+done
 
 #IPv6 from home directory with port number
-test_expect_success 'clone ssh://[::1]:22/~repo' '
-       test_clone_url "ssh://[::1]:22/~repo" "-p 22 ::1" "~repo"
-'
+for tuah in [::1] user@[::1] [user@::1]
+do
+       euah=$(echo $tuah | tr -d "[]")
+       test_expect_success "clone ssh://$tuah:22/~repo" "
+         test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
+       "
+done
 
 test_expect_success 'clone from a repository with two identical branches' '
 
index 35c805a44e817c637c667b1d1d14d97b4ee46803..8bfeef9b0bf6eedcd1f0b31a141efc87a37041f8 100755 (executable)
@@ -1459,6 +1459,34 @@ test_expect_success 'invalid sort parameter in configuratoin' '
        test_cmp expect actual
 '
 
+test_expect_success 'version sort with prerelease reordering' '
+       git config --unset tag.sort &&
+       git config versionsort.prereleaseSuffix -rc &&
+       git tag foo1.6-rc1 &&
+       git tag foo1.6-rc2 &&
+       git tag -l --sort=version:refname "foo*" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.3
+       foo1.6-rc1
+       foo1.6-rc2
+       foo1.6
+       foo1.10
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'reverse version sort with prerelease reordering' '
+       git tag -l --sort=-version:refname "foo*" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.10
+       foo1.6
+       foo1.6-rc2
+       foo1.6-rc1
+       foo1.3
+       EOF
+       test_cmp expect actual
+'
+
 run_with_limited_stack () {
        (ulimit -s 128 && "$@")
 }
index 8ed5788808055889208ac9451054f098538a6878..6b16bcb64031e32c7200deac8ceb46711a8e7bed 100755 (executable)
@@ -66,6 +66,12 @@ strip_comments () {
        rm "$1" && mv "$1".tmp "$1"
 }
 
+cat >.gitignore <<\EOF
+.gitignore
+expect*
+output*
+EOF
+
 test_expect_success 'status --column' '
        cat >expect <<\EOF &&
 # On branch master
@@ -83,8 +89,8 @@ test_expect_success 'status --column' '
 # Untracked files:
 #   (use "git add <file>..." to include in what will be committed)
 #
-#      dir1/untracked dir2/untracked output
-#      dir2/modified  expect         untracked
+#      dir1/untracked dir2/untracked
+#      dir2/modified  untracked
 #
 EOF
        COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
@@ -116,8 +122,6 @@ cat >expect <<\EOF
 #      dir1/untracked
 #      dir2/modified
 #      dir2/untracked
-#      expect
-#      output
 #      untracked
 #
 EOF
@@ -133,6 +137,23 @@ test_expect_success 'status with status.displayCommentPrefix=false' '
        test_i18ncmp expect output
 '
 
+test_expect_success 'status -v' '
+       (cat expect && git diff --cached) >expect-with-v &&
+       git status -v >output &&
+       test_i18ncmp expect-with-v output
+'
+
+test_expect_success 'status -v -v' '
+       (cat expect &&
+        echo "Changes to be committed:" &&
+        git -c diff.mnemonicprefix=true diff --cached &&
+        echo "--------------------------------------------------" &&
+        echo "Changes not staged for commit:" &&
+        git -c diff.mnemonicprefix=true diff) >expect-with-v &&
+       git status -v -v >output &&
+       test_i18ncmp expect-with-v output
+'
+
 test_expect_success 'setup fake editor' '
        cat >.git/editor <<-\EOF &&
        #! /bin/sh
@@ -167,8 +188,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -186,8 +205,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -201,7 +218,7 @@ test_expect_success 'status -s' '
 test_expect_success 'status with gitignore' '
        {
                echo ".gitignore" &&
-               echo "expect" &&
+               echo "expect*" &&
                echo "output" &&
                echo "untracked"
        } >.gitignore &&
@@ -222,6 +239,7 @@ test_expect_success 'status with gitignore' '
        !! dir1/untracked
        !! dir2/untracked
        !! expect
+       !! expect-with-v
        !! output
        !! untracked
        EOF
@@ -253,6 +271,7 @@ Ignored files:
        dir1/untracked
        dir2/untracked
        expect
+       expect-with-v
        output
        untracked
 
@@ -264,7 +283,7 @@ EOF
 test_expect_success 'status with gitignore (nothing untracked)' '
        {
                echo ".gitignore" &&
-               echo "expect" &&
+               echo "expect*" &&
                echo "dir2/modified" &&
                echo "output" &&
                echo "untracked"
@@ -285,6 +304,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '
        !! dir2/modified
        !! dir2/untracked
        !! expect
+       !! expect-with-v
        !! output
        !! untracked
        EOF
@@ -312,6 +332,7 @@ Ignored files:
        dir2/modified
        dir2/untracked
        expect
+       expect-with-v
        output
        untracked
 
@@ -320,7 +341,11 @@ EOF
        test_i18ncmp expect output
 '
 
-rm -f .gitignore
+cat >.gitignore <<\EOF
+.gitignore
+expect*
+output*
+EOF
 
 cat >expect <<\EOF
 ## master
@@ -329,8 +354,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -434,8 +457,6 @@ Untracked files:
        dir2/modified
        dir2/untracked
        dir3/
-       expect
-       output
        untracked
 
 EOF
@@ -456,8 +477,6 @@ A  dir2/added
 ?? dir2/modified
 ?? dir2/untracked
 ?? dir3/
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s -unormal' '
@@ -493,8 +512,6 @@ Untracked files:
        dir2/untracked
        dir3/untracked1
        dir3/untracked2
-       expect
-       output
        untracked
 
 EOF
@@ -518,8 +535,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s -uall' '
@@ -554,8 +569,6 @@ Untracked files:
        untracked
        ../dir2/modified
        ../dir2/untracked
-       ../expect
-       ../output
        ../untracked
 
 EOF
@@ -569,8 +582,6 @@ A  ../dir2/added
 ?? untracked
 ?? ../dir2/modified
 ?? ../dir2/untracked
-?? ../expect
-?? ../output
 ?? ../untracked
 EOF
 test_expect_success 'status -s with relative paths' '
@@ -586,8 +597,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -625,8 +634,6 @@ Untracked files:
        <BLUE>dir1/untracked<RESET>
        <BLUE>dir2/modified<RESET>
        <BLUE>dir2/untracked<RESET>
-       <BLUE>expect<RESET>
-       <BLUE>output<RESET>
        <BLUE>untracked<RESET>
 
 EOF
@@ -647,8 +654,6 @@ cat >expect <<\EOF
 <BLUE>??<RESET> dir1/untracked
 <BLUE>??<RESET> dir2/modified
 <BLUE>??<RESET> dir2/untracked
-<BLUE>??<RESET> expect
-<BLUE>??<RESET> output
 <BLUE>??<RESET> untracked
 EOF
 
@@ -676,8 +681,6 @@ cat >expect <<\EOF
 <BLUE>??<RESET> dir1/untracked
 <BLUE>??<RESET> dir2/modified
 <BLUE>??<RESET> dir2/untracked
-<BLUE>??<RESET> expect
-<BLUE>??<RESET> output
 <BLUE>??<RESET> untracked
 EOF
 
@@ -694,8 +697,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -755,8 +756,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -772,8 +771,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -798,8 +795,6 @@ Untracked files:
 
        dir1/untracked
        dir2/
-       expect
-       output
        untracked
 
 EOF
@@ -848,8 +843,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -870,8 +863,6 @@ A  sm
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary is disabled by default' '
@@ -913,8 +904,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -940,8 +929,6 @@ A  sm
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary' '
@@ -964,8 +951,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 no changes added to commit (use "git add" and/or "git commit -a")
@@ -983,8 +968,6 @@ cat >expect <<EOF
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary (clean submodule)' '
@@ -1025,8 +1008,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -1080,8 +1061,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -1192,8 +1171,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -1254,8 +1231,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
@@ -1336,8 +1311,6 @@ cat > expect << EOF
 ;      dir1/untracked
 ;      dir2/modified
 ;      dir2/untracked
-;      expect
-;      output
 ;      untracked
 ;
 EOF
@@ -1369,8 +1342,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 no changes added to commit (use "git add" and/or "git commit -a")
@@ -1400,8 +1371,6 @@ Untracked files:
        dir1/untracked
        dir2/modified
        dir2/untracked
-       expect
-       output
        untracked
 
 EOF
diff --git a/t/t7516-commit-races.sh b/t/t7516-commit-races.sh
new file mode 100755 (executable)
index 0000000..f2ce14e
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='git commit races'
+. ./test-lib.sh
+
+test_expect_success 'race to create orphan commit' '
+       write_script hare-editor <<-\EOF &&
+       git commit --allow-empty -m hare
+       EOF
+       test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
+       git show -s --pretty=format:%s >subject &&
+       grep hare subject &&
+       test -z "$(git show -s --pretty=format:%P)"
+'
+
+test_expect_success 'race to create non-orphan commit' '
+       write_script airplane-editor <<-\EOF &&
+       git commit --allow-empty -m airplane
+       EOF
+       git checkout --orphan branch &&
+       git commit --allow-empty -m base &&
+       git rev-parse HEAD >base &&
+       test_must_fail env EDITOR=./airplane-editor git commit --allow-empty -m ship -e &&
+       git show -s --pretty=format:%s >subject &&
+       grep airplane subject &&
+       git rev-parse HEAD^ >parent &&
+       test_cmp base parent
+'
+
+test_done
index 37c2d633f0d2fefdb530266b8b250ef59e8704d3..c538e0a4e97c942dcb64b3e5bdd9afa10591f33e 100755 (executable)
@@ -552,8 +552,8 @@ test_expect_success 'D: verify pack' '
 '
 
 cat >expect <<EOF
-:000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A     newdir/exec.sh
-:000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A     newdir/interesting
+:000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A     newdir/exec.sh
+:000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A     newdir/interesting
 EOF
 git diff-tree -M -r branch^ branch >actual
 test_expect_success \
index f10a75290e6e854763d10fa571b8c50901dce981..7a883d1a674dbed174611470c93ffe32f4f8a4bc 100755 (executable)
@@ -351,6 +351,25 @@ test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name
        __gitcomp_nl "$invalid_variable_name"
 '
 
+test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' '
+       cat >expect <<-EOF &&
+       remote_from_file_1
+       remote_from_file_2
+       remote_in_config_1
+       remote_in_config_2
+       EOF
+       test_when_finished "rm -rf .git/remotes" &&
+       mkdir -p .git/remotes &&
+       >.git/remotes/remote_from_file_1 &&
+       >.git/remotes/remote_from_file_2 &&
+       test_when_finished "git remote remove remote_in_config_1" &&
+       git remote add remote_in_config_1 git://remote_1 &&
+       test_when_finished "git remote remove remote_in_config_2" &&
+       git remote add remote_in_config_2 git://remote_2 &&
+       __git_remotes >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'basic' '
        run_completion "git " &&
        # built-in
index 0d93e33de4759bff71739c19be803cac981f0770..0698ce7908cb958c6e94a8cfa11c1019de692710 100644 (file)
@@ -745,7 +745,9 @@ test_ln_s_add () {
        else
                printf '%s' "$1" >"$2" &&
                ln_s_obj=$(git hash-object -w "$2") &&
-               git update-index --add --cacheinfo 120000 $ln_s_obj "$2"
+               git update-index --add --cacheinfo 120000 $ln_s_obj "$2" &&
+               # pick up stat info from the file
+               git update-index "$2"
        fi
 }
 
index 7511e08271fb60276008c0b364a45b9512f49cea..80bfd109fa1285a24dbfa8e9aabdfc3b3bd59801 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "string-list.h"
 
 /*
  * versioncmp(): copied from string/strverscmp.c in glibc commit
 #define  CMP    2
 #define  LEN    3
 
+static const struct string_list *prereleases;
+static int initialized;
+
+/*
+ * p1 and p2 point to the first different character in two strings. If
+ * either p1 or p2 starts with a prerelease suffix, it will be forced
+ * to be on top.
+ *
+ * If both p1 and p2 start with (different) suffix, the order is
+ * determined by config file.
+ *
+ * Note that we don't have to deal with the situation when both p1 and
+ * p2 start with the same suffix because the common part is already
+ * consumed by the caller.
+ *
+ * Return non-zero if *diff contains the return value for versioncmp()
+ */
+static int swap_prereleases(const void *p1_,
+                           const void *p2_,
+                           int *diff)
+{
+       const char *p1 = p1_;
+       const char *p2 = p2_;
+       int i, i1 = -1, i2 = -1;
+
+       for (i = 0; i < prereleases->nr; i++) {
+               const char *suffix = prereleases->items[i].string;
+               if (i1 == -1 && starts_with(p1, suffix))
+                       i1 = i;
+               if (i2 == -1 && starts_with(p2, suffix))
+                       i2 = i;
+       }
+       if (i1 == -1 && i2 == -1)
+               return 0;
+       if (i1 >= 0 && i2 >= 0)
+               *diff = i1 - i2;
+       else if (i1 >= 0)
+               *diff = -1;
+       else /* if (i2 >= 0) */
+               *diff = 1;
+       return 1;
+}
 
 /*
  * Compare S1 and S2 as strings holding indices/version numbers,
@@ -74,6 +117,13 @@ int versioncmp(const char *s1, const char *s2)
                state += (c1 == '0') + (isdigit (c1) != 0);
        }
 
+       if (!initialized) {
+               initialized = 1;
+               prereleases = git_config_get_value_multi("versionsort.prereleasesuffix");
+       }
+       if (prereleases && swap_prereleases(p1 - 1, p2 - 1, &diff))
+               return diff;
+
        state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];
 
        switch (state) {
index 483da4e0fb5771b8a64d62648624258dcf3fdcb0..58ffeca264b765326a234b21356a02a3152e1c38 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -299,7 +299,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
                strbuf_reset(&refname);
                strbuf_addf(&refname, "refs/%s", write_ref[i]);
                if (ref_transaction_update(transaction, refname.buf,
-                                          &sha1[20 * i], NULL, 0, 0,
+                                          &sha1[20 * i], NULL, 0,
                                           msg ? msg : "fetch (unknown)",
                                           &err)) {
                        error("%s", err.buf);
index 29666d0dbaa5af768aca86f3ca0b644ac9720648..7036fa28dc39f72ed2064ca0ad15f2e381808020 100644 (file)
@@ -849,6 +849,8 @@ static void wt_status_print_verbose(struct wt_status *s)
 {
        struct rev_info rev;
        struct setup_revision_opt opt;
+       int dirty_submodules;
+       const char *c = color(WT_STATUS_HEADER, s);
 
        init_revisions(&rev, NULL);
        DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
@@ -873,7 +875,25 @@ static void wt_status_print_verbose(struct wt_status *s)
                rev.diffopt.use_color = 0;
                wt_status_add_cut_line(s->fp);
        }
+       if (s->verbose > 1 && s->commitable) {
+               /* print_updated() printed a header, so do we */
+               if (s->fp != stdout)
+                       wt_status_print_trailer(s);
+               status_printf_ln(s, c, _("Changes to be committed:"));
+               rev.diffopt.a_prefix = "c/";
+               rev.diffopt.b_prefix = "i/";
+       } /* else use prefix as per user config */
        run_diff_index(&rev, 1);
+       if (s->verbose > 1 &&
+           wt_status_check_worktree_changes(s, &dirty_submodules)) {
+               status_printf_ln(s, c,
+                       "--------------------------------------------------");
+               status_printf_ln(s, c, _("Changes not staged for commit:"));
+               setup_work_tree();
+               rev.diffopt.a_prefix = "i/";
+               rev.diffopt.b_prefix = "w/";
+               run_diff_files(&rev, 0);
+       }
 }
 
 static void wt_status_print_tracking(struct wt_status *s)
@@ -1222,6 +1242,8 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
                state->detached_from =
                        xstrdup(find_unique_abbrev(cb.nsha1, DEFAULT_ABBREV));
        hashcpy(state->detached_sha1, cb.nsha1);
+       state->detached_at = !get_sha1("HEAD", sha1) &&
+                            !hashcmp(sha1, state->detached_sha1);
 
        free(ref);
        strbuf_release(&cb.buf);
@@ -1310,10 +1332,8 @@ void wt_status_print(struct wt_status *s)
                                on_what = _("rebase in progress; onto ");
                                branch_name = state.onto;
                        } else if (state.detached_from) {
-                               unsigned char sha1[20];
                                branch_name = state.detached_from;
-                               if (!get_sha1("HEAD", sha1) &&
-                                   !hashcmp(sha1, state.detached_sha1))
+                               if (state.detached_at)
                                        on_what = _("HEAD detached at ");
                                else
                                        on_what = _("HEAD detached from ");
index 283a9fef0335ce272c6799a5af17274e4798e15f..e0a99f75c745acd3e7fb6fd8aecd06a4d3bd5522 100644 (file)
@@ -84,6 +84,7 @@ struct wt_status_state {
        int cherry_pick_in_progress;
        int bisect_in_progress;
        int revert_in_progress;
+       int detached_at;
        char *branch;
        char *onto;
        char *detached_from;
diff --git a/zlib.c b/zlib.c
index 61e6df0fdce6dfaf38da7af996d7fe801db8f00c..4223f1a8c57a281d5e41c329a4f983a7bb3b57a0 100644 (file)
--- a/zlib.c
+++ b/zlib.c
@@ -159,6 +159,7 @@ void git_deflate_init(git_zstream *strm, int level)
 {
        int status;
 
+       memset(strm, 0, sizeof(*strm));
        zlib_pre_call(strm);
        status = deflateInit(&strm->z, level);
        zlib_post_call(strm);
@@ -172,6 +173,7 @@ static void do_git_deflate_init(git_zstream *strm, int level, int windowBits)
 {
        int status;
 
+       memset(strm, 0, sizeof(*strm));
        zlib_pre_call(strm);
        status = deflateInit2(&strm->z, level,
                                  Z_DEFLATED, windowBits,