Merge branch 'kb/status-ignored-optim-2'
authorJunio C Hamano <gitster@pobox.com>
Tue, 23 Apr 2013 18:21:23 +0000 (11:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Apr 2013 18:21:23 +0000 (11:21 -0700)
Fixes a handful of issues in the code to traverse working tree to
find untracked and/or ignored files, cleans up and optimizes the
codepath in general.

* kb/status-ignored-optim-2:
dir.c: git-status --ignored: don't scan the work tree twice
dir.c: git-status --ignored: don't scan the work tree three times
dir.c: git-status: avoid is_excluded checks for tracked files
dir.c: replace is_path_excluded with now equivalent is_excluded API
dir.c: unify is_excluded and is_path_excluded APIs
dir.c: move prep_exclude
dir.c: factor out parts of last_exclude_matching for later reuse
dir.c: git-clean -d -X: don't delete tracked directories
dir.c: make 'git-status --ignored' work within leading directories
dir.c: git-status --ignored: don't list empty directories as ignored
dir.c: git-ls-files --directories: don't hide empty directories
dir.c: git-status --ignored: don't list empty ignored directories
dir.c: git-status --ignored: don't list files in ignored directories
dir.c: git-status --ignored: don't drop ignored directories

126 files changed:
Documentation/RelNotes/1.8.2.2.txt [new file with mode: 0644]
Documentation/RelNotes/1.8.3.txt
Documentation/config.txt
Documentation/git-add.txt
Documentation/git-cat-file.txt
Documentation/git-checkout.txt
Documentation/git-count-objects.txt
Documentation/git-daemon.txt
Documentation/git-describe.txt
Documentation/git-format-patch.txt
Documentation/git-fsck.txt
Documentation/git-http-backend.txt
Documentation/git-index-pack.txt
Documentation/git-ls-files.txt
Documentation/git-merge-index.txt
Documentation/git-pack-objects.txt
Documentation/git-patch-id.txt
Documentation/git-replace.txt
Documentation/git-rev-parse.txt
Documentation/git-send-email.txt
Documentation/git-show-branch.txt
Documentation/git-show-index.txt
Documentation/git-show-ref.txt
Documentation/git-tag.txt
Documentation/git-update-index.txt
Documentation/git-verify-pack.txt
Documentation/git-verify-tag.txt
Documentation/git.txt
Documentation/gitcore-tutorial.txt
Documentation/gitdiffcore.txt
Documentation/githooks.txt
Documentation/gitrepository-layout.txt
Documentation/gittutorial-2.txt
Documentation/gitweb.conf.txt
Documentation/glossary-content.txt
Documentation/howto/recover-corrupted-blob-object.txt
Documentation/merge-strategies.txt
Documentation/pretty-formats.txt
Documentation/revisions.txt
Documentation/technical/api-sha1-array.txt
Documentation/technical/api-strbuf.txt
Documentation/technical/pack-format.txt
Documentation/technical/pack-heuristics.txt
Documentation/technical/shallow.txt
attr.c
branch.c
builtin/add.c
builtin/blame.c
builtin/branch.c
builtin/cat-file.c
builtin/checkout.c
builtin/clone.c
builtin/count-objects.c
builtin/fmt-merge-msg.c
builtin/log.c
builtin/merge-tree.c
builtin/receive-pack.c
builtin/show-branch.c
bundle.c
cache.h
config.mak.uname
contrib/completion/git-completion.bash
contrib/completion/git-prompt.sh
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/git-remote-hg
contrib/remote-helpers/test-hg-bidi.sh
contrib/remote-helpers/test-hg-hg-git.sh
contrib/remote-helpers/test-hg.sh
convert.c
diff.c
git-bisect.sh
git-compat-util.h
git-rebase--am.sh
git-send-email.perl
gitweb/INSTALL
help.c
http-backend.c
http-push.c
http.c
http.h
perl/Git.pm
pretty.c
progress.c
read-cache.c
remote-curl.c
revision.c
run-command.c
sequencer.c
sha1_file.c
strbuf.c
strbuf.h
submodule.c
submodule.h
t/lib-httpd/apache.conf
t/t1006-cat-file.sh
t/t1011-read-tree-sparse-checkout.sh
t/t2200-add-update.sh
t/t3001-ls-files-others-exclude.sh
t/t3508-cherry-pick-many-commits.sh
t/t4014-format-patch.sh
t/t4212-log-corrupt.sh [new file with mode: 0755]
t/t4300-merge-tree.sh
t/t5004-archive-corner-cases.sh
t/t5404-tracking-branches.sh
t/t5505-remote.sh
t/t5516-fetch-push.sh
t/t5517-push-mirror.sh
t/t5519-push-alternates.sh
t/t5531-deep-submodule-push.sh
t/t5541-http-push.sh
t/t5550-http-fetch.sh
t/t5551-http-fetch.sh
t/t5570-git-daemon.sh
t/t5700-clone-reference.sh
t/t5704-bundle.sh
t/t6030-bisect-porcelain.sh
t/t6200-fmt-merge-msg.sh
t/t7406-submodule-update.sh
t/t9400-git-cvsserver-server.sh
t/t9401-git-cvsserver-crlf.sh
t/t9700/test.pl
t/t9902-completion.sh
t/t9903-bash-prompt.sh
t/test-lib.sh
usage.c
zlib.c
diff --git a/Documentation/RelNotes/1.8.2.2.txt b/Documentation/RelNotes/1.8.2.2.txt
new file mode 100644 (file)
index 0000000..3b919e8
--- /dev/null
@@ -0,0 +1,25 @@
+Git v1.8.2.2 Release Notes
+==========================
+
+Fixes since v1.8.2.1
+--------------------
+
+ * Perl scripts like "git-svn" closed (not redirecting to /dev/null)
+   the standard error stream, which is not a very smart thing to do.
+   Later open may return file descriptor #2 for unrelated purpose, and
+   error reporting code may write into them.
+
+ * "git apply --whitespace=fix" was not prepared to see a line getting
+   longer after fixing whitespaces (e.g. tab-in-indent aka Python).
+
+ * "git diff/log --cc" did not work well with options that ignore
+   whitespace changes.
+
+ * Documentation on setting up a http server that requires
+   authentication only on the push but not fetch has been clarified.
+
+ * A few bugfixes to "git rerere" working on corner case merge
+   conflicts have been applied.
+
+ * "git bundle" did not like a bundle created using a commit without
+   any message as its one of the prerequistes.
index bcbcf1569651d5aff9d0af738db7b912285954dd..15ad460b594b5b1243cfb1f611f45ab5962a0d8f 100644 (file)
@@ -24,14 +24,57 @@ mechanism to make "git add -u" behave as if "git add -u .", it is
 important for those who are used to "git add -u" (without pathspec)
 updating the index only for paths in the current subdirectory to start
 training their fingers to explicitly say "git add -u ." when they mean
-it before Git 2.0 comes.
+it before Git 2.0 comes.  A warning is issued when these commands are
+run without a pathspec and when you have local changes outside the
+current directory, because the behaviour in Git 2.0 will be different
+from today's version in such a situation.
 
 
 Updates since v1.8.2
 --------------------
 
+Foreign interface
+
+ * remote-hg helper (in contrib/) has been updated.
+
+
 UI, Workflows & Features
 
+ * "git branch --vv" learned to paint the name of the branch it
+   integrates with in a different color (color.branch.upstream,
+   which defaults to blue).
+
+ * In a sparsely populated working tree, "git checkout <pathspec>" no
+   longer unmarks paths that match the given pathspec that were
+   originally ignored with "--sparse" (use --ignore-skip-worktree-bits
+   option to resurrect these paths out of the index if you really want
+   to).
+
+ * "git bisect" leaves the final outcome as a comment in its bisect
+   log file.
+
+ * "git clone --reference" can now refer to a gitfile "textual symlink"
+   that points at the real location of the repository.
+
+ * "git count-objects" learned "--human-readable" aka "-H" option to
+   show various large numbers in Ki/Mi/GiB scaled as necessary.
+
+ * "git cherry-pick $blob" and "git cherry-pick $tree" are nonsense,
+   and a more readable error message e.g. "can't cherry-pick a tree"
+   is given (we used to say "expected exactly one commit").
+
+ * The "--annotate" option to "git send-email" can be turned on (or
+   off) by default with sendemail.annotate configuration variable (you
+   can use --no-annotate from the command line to override it).
+
+ * The "--cover-letter" option to "git format-patch" can be turned on
+   (or off) by default with format.coverLetter configuration
+   variable. By setting it to 'auto', you can turn it on only for a
+   series with two or more patches.
+
+ * The bash completion support (in contrib/) learned that cherry-pick
+   takes a few more options than it already knew about.
+
  * "git help" learned "-g" option to show the list of guides just like
    list of commands are given with "-a".
 
@@ -67,6 +110,9 @@ UI, Workflows & Features
    ref by specifying a raw object name from the command line when the
    server side supports this feature.
 
+ * Output from "git log --graph" works better with submodule log
+   output now.
+
  * "git count-objects -v" learned to report leftover temporary
    packfiles and other garbage in the object store.
 
@@ -116,6 +162,9 @@ Performance, Internal Implementation, etc.
 
  * Updates for building under msvc.
 
+ * The stack footprint of some codepaths that access an object from a
+   pack has been shrunk.
+
  * The logic to coalesce the same lines removed from the parents in
    the output from "diff -c/--cc" has been updated, but with an O(n^2)
    complexity, so this might turn out to be undesirable.
@@ -150,7 +199,7 @@ Performance, Internal Implementation, etc.
    conflicts have been applied.
 
 
-Also contains minor documentation updates and code clean-ups.
+Also contains various documentation updates and code clean-ups.
 
 
 Fixes since v1.8.2
@@ -160,6 +209,54 @@ Unless otherwise noted, all the fixes since v1.8.2 in the maintenance
 track are contained in this release (see release notes to them for
 details).
 
+ * A commit object whose author or committer ident are malformed
+   crashed some code that trusted that a name, an email and an
+   timestamp can always be found in it.
+   (merge de5abe9 jk/chopped-ident later to maint).
+
+ * When "upload-pack" fails while generating a pack in response to
+   "git fetch" (or "git clone"), the receiving side mistakenly said
+   there was a programming error to trigger the die handler
+   recursively.
+   (merge 1ece66b jk/a-thread-only-dies-once later to maint).
+
+ * "rev-list --stdin" and friends kept bogus pointers into input
+   buffer around as human readble object names.  This was not a huge
+   problem but was exposed by a new change that uses these names in
+   error output.
+   (merge 70d26c6 tr/copy-revisions-from-stdin later to maint).
+
+ * Smart-capable HTTP servers were not restricted via the
+   GIT_NAMESPACE mechanism when talking with commit-walker clients,
+   like they do when talking with smart HTTP clients.
+   (merge 6130f86 jk/http-dumb-namespaces later to maint).
+
+ * "git merge-tree" did not omit a merge result that is identical to
+   "our" side in certain cases.
+   (merge aacecc3 jk/merge-tree-added-identically later to maint).
+
+ * Perl scripts like "git-svn" closed (not redirecting to /dev/null)
+   the standard error stream, which is not a very smart thing to do.
+   Later open may return file descriptor #2 for unrelated purpose, and
+   error reporting code may write into them.
+   (merge a749c0b tr/perl-keep-stderr-open later to maint).
+
+ * "git show-branch" was not prepared to show a very long run of
+   ancestor operators e.g. foobar^2~2^2^2^2...^2~4 correctly.
+   (merge aaa07e3 jk/show-branch-strbuf later to maint).
+
+ * "git diff --diff-algorithm algo" is also understood as "git diff
+   --diff-algorithm=algo".
+   (merge 0895c6d jk/diff-algo-finishing-touches later to maint).
+
+ * The new core.commentchar configuration was not applied to a few
+   places.
+   (merge 89c3bbd rt/commentchar-fmt-merge-msg later to maint).
+
+ * "git bundle" did not like a bundle created using a commit without
+   any message as its one of the prerequistes.
+   (merge 5446e33 lf/bundle-with-tip-wo-message later to maint).
+
  * "git log -S/-G" started paying attention to textconv filter, but
    there was no way to disable this.  Make it honor --no-textconv
    option.
index 3d750e0452308a4d3bf15053bfc5131d43c8c913..c67038b56dd4165e12d74fe81c3dcbddd943b1f8 100644 (file)
@@ -412,7 +412,7 @@ repository's usual working tree).
 core.logAllRefUpdates::
        Enable the reflog. Updates to a ref <ref> is logged to the file
        "$GIT_DIR/logs/<ref>", by appending the new and old
-       SHA1, the date/time and the reason of the update, but
+       SHA-1, the date/time and the reason of the update, but
        only when the file exists.  If this configuration
        variable is set to true, missing "$GIT_DIR/logs/<ref>"
        file is automatically created for branch heads (i.e. under
@@ -807,7 +807,8 @@ color.branch::
 color.branch.<slot>::
        Use customized color for branch coloration. `<slot>` is one of
        `current` (the current branch), `local` (a local branch),
-       `remote` (a remote-tracking branch in refs/remotes/), `plain` (other
+       `remote` (a remote-tracking branch in refs/remotes/),
+       `upstream` (upstream tracking branch), `plain` (other
        refs).
 +
 The value for these configuration variables is a list of colors (at most
@@ -1109,6 +1110,11 @@ format.signoff::
     the rights to submit this work under the same open source license.
     Please see the 'SubmittingPatches' document for further discussion.
 
+format.coverLetter::
+       A boolean that controls whether to generate a cover-letter when
+       format-patch is invoked, but in addition can be set to "auto", to
+       generate a cover-letter only when there's more than one patch.
+
 filter.<driver>.clean::
        The command which is used to convert the content of a worktree
        file to a blob upon checkin.  See linkgit:gitattributes[5] for
@@ -1460,6 +1466,14 @@ http.sslCAPath::
        with when fetching or pushing over HTTPS. Can be overridden
        by the 'GIT_SSL_CAPATH' environment variable.
 
+http.sslTry::
+       Attempt to use AUTH SSL/TLS and encrypted data transfers
+       when connecting via regular FTP protocol. This might be needed
+       if the FTP server requires it for security reasons or you wish
+       to connect securely whenever remote FTP server supports it.
+       Default is false since it might trigger certificate verification
+       errors on misconfigured servers.
+
 http.maxRequests::
        How many HTTP requests to launch in parallel. Can be overridden
        by the 'GIT_HTTP_MAX_REQUESTS' environment variable. Default is 5.
@@ -2016,6 +2030,7 @@ sendemail.<identity>.*::
 
 sendemail.aliasesfile::
 sendemail.aliasfiletype::
+sendemail.annotate::
 sendemail.bcc::
 sendemail.cc::
 sendemail.cccmd::
index b0944e57d52546d725d0d9d71692ff74f9fac55f..5c501a299e2d88f3c3565b180a59187dea042fcb 100644 (file)
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
-         [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
+         [--edit | -e] [--[no-]all | [--update | -u]] [--intent-to-add | -N]
          [--refresh] [--ignore-errors] [--ignore-missing] [--]
          [<pathspec>...]
 
@@ -121,6 +121,18 @@ If no <pathspec> is given, the current version of Git defaults to
 and its subdirectories. This default will change in a future version
 of Git, hence the form without <pathspec> should not be used.
 
+--no-all::
+       Update the index by adding new files that are unknown to the
+       index and files modified in the working tree, but ignore
+       files that have been removed from the working tree.  This
+       option is a no-op when no <pathspec> is used.
++
+This option is primarily to help the current users of Git, whose
+"git add <pathspec>..." ignores removed files.  In future versions
+of Git, "git add <pathspec>..." will be a synonym to "git add -A
+<pathspec>..." and "git add --no-all <pathspec>..." will behave like
+today's "git add <pathspec>...", ignoring removed files.
+
 -N::
 --intent-to-add::
        Record only the fact that the path will be added later. An entry
index 2fb95bbd19f26317a542abfdb78d3b2be72f577b..30d585af5d92515cc047b4844ee906265850c195 100644 (file)
@@ -20,7 +20,7 @@ object type, or '-s' is used to find the object size, or '--textconv' is used
 (which implies type "blob").
 
 In the second form, a list of objects (separated by linefeeds) is provided on
-stdin, and the SHA1, type, and size of each object is printed on stdout.
+stdin, and the SHA-1, type, and size of each object is printed on stdout.
 
 OPTIONS
 -------
@@ -58,11 +58,11 @@ OPTIONS
        to apply the filter to the content recorded in the index at <path>.
 
 --batch::
-       Print the SHA1, type, size, and contents of each object provided on
+       Print the SHA-1, type, size, and contents of each object provided on
        stdin. May not be combined with any other options or arguments.
 
 --batch-check::
-       Print the SHA1, type, and size of each object provided on stdin. May not
+       Print the SHA-1, type, and size of each object provided on stdin. May not
        be combined with any other options or arguments.
 
 OUTPUT
index 8edcdcae9d0082928073a85c77bdc30593ad5361..23a9413525d4f90435c4996af4d4866b326783bb 100644 (file)
@@ -180,6 +180,12 @@ branch by running "git rm -rf ." from the top level of the working tree.
 Afterwards you will be ready to prepare your new files, repopulating the
 working tree, by copying them from elsewhere, extracting a tarball, etc.
 
+--ignore-skip-worktree-bits::
+       In sparse checkout mode, `git checkout -- <paths>` would
+       update only entries matched by <paths> and sparse patterns
+       in $GIT_DIR/info/sparse-checkout. This option ignores
+       the sparse patterns and adds back any files in <paths>.
+
 -m::
 --merge::
        When switching branches,
index da6e72e696d4af013b3c717d31a0e98cd41922d4..b300e846f13d6a7f340286b4624dc3b0da4ac740 100644 (file)
@@ -8,7 +8,7 @@ git-count-objects - Count unpacked number of objects and their disk consumption
 SYNOPSIS
 --------
 [verse]
-'git count-objects' [-v]
+'git count-objects' [-v] [-H | --human-readable]
 
 DESCRIPTION
 -----------
@@ -24,11 +24,11 @@ OPTIONS
 +
 count: the number of loose objects
 +
-size: disk space consumed by loose objects, in KiB
+size: disk space consumed by loose objects, in KiB (unless -H is specified)
 +
 in-pack: the number of in-pack objects
 +
-size-pack: disk space consumed by the packs, in KiB
+size-pack: disk space consumed by the packs, in KiB (unless -H is specified)
 +
 prune-packable: the number of loose objects that are also present in
 the packs. These objects could be pruned using `git prune-packed`.
@@ -36,7 +36,13 @@ the packs. These objects could be pruned using `git prune-packed`.
 garbage: the number of files in object database that are not valid
 loose objects nor valid packs
 +
-size-garbage: disk space consumed by garbage files, in KiB
+size-garbage: disk space consumed by garbage files, in KiB (unless -H is
+specified)
+
+-H::
+--human-readable::
+
+Print sizes in human readable format
 
 GIT
 ---
index 77da564134f92e692e078888d7f87bd6710e821f..bfb106cccd5880f0cd40b03059aa79a5569acb63 100644 (file)
@@ -147,6 +147,13 @@ OPTIONS
 Giving these options is an error when used with `--inetd`; use
 the facility of inet daemon to achieve the same before spawning
 'git daemon' if needed.
++
+Like many programs that switch user id, the daemon does not reset
+environment variables such as `$HOME` when it runs git programs,
+e.g. `upload-pack` and `receive-pack`. When using this option, you
+may also want to set and export `HOME` to point at the home
+directory of `<user>` before starting the daemon, and make sure any
+Git configuration files in that directory are readable by `<user>`.
 
 --enable=<service>::
 --disable=<service>::
index 3c81e85ec5cf1b3090a879d49ad2445176312872..28e5ec0e2c1466f37e1e91680fb438658e050102 100644 (file)
@@ -149,7 +149,7 @@ is found, its name will be output and searching will stop.
 If an exact match was not found, 'git describe' will walk back
 through the commit history to locate an ancestor commit which
 has been tagged.  The ancestor's tag will be output along with an
-abbreviation of the input committish's SHA1.
+abbreviation of the input committish's SHA-1.
 
 If multiple tags were found during the walk then the tag which
 has the fewest commits different from the input committish will be
index 3a62f50edae9cdc772cb1009cf839b18e0079a9c..39118774afbbd730e4464f44e24a05af91432c30 100644 (file)
@@ -20,7 +20,7 @@ SYNOPSIS
                   [--ignore-if-in-upstream]
                   [--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>]
                   [--to=<email>] [--cc=<email>]
-                  [--cover-letter] [--quiet] [--notes[=<ref>]]
+                  [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]
                   [<common diff options>]
                   [ <since> | <revision range> ]
 
@@ -195,7 +195,7 @@ will want to ensure that threading is disabled for `git send-email`.
        `Cc:`, and custom) headers added so far from config or command
        line.
 
---cover-letter::
+--[no-]cover-letter::
        In addition to the patches, generate a cover letter file
        containing the shortlog and the overall diffstat.  You can
        fill in a description in the file before sending it out.
@@ -260,6 +260,7 @@ attachments, and sign off patches with configuration variables.
        cc = <email>
        attach [ = mime-boundary-string ]
        signoff = true
+       coverletter = auto
 ------------
 
 
index eff91889d7aab1a5262aad2f22855b52716a820d..e5878bd97be849046951b06235fa19bf8aef7b1c 100644 (file)
@@ -23,7 +23,7 @@ OPTIONS
        An object to treat as the head of an unreachability trace.
 +
 If no objects are given, 'git fsck' defaults to using the
-index file, all SHA1 references in `refs` namespace, and all reflogs
+index file, all SHA-1 references in `refs` namespace, and all reflogs
 (unless --no-reflogs is given) as heads.
 
 --unreachable::
@@ -89,7 +89,7 @@ index file, all SHA1 references in `refs` namespace, and all reflogs
 DISCUSSION
 ----------
 
-git-fsck tests SHA1 and general object sanity, and it does full tracking
+git-fsck tests SHA-1 and general object sanity, and it does full tracking
 of the resulting reachability and everything else. It prints out any
 corruption it finds (missing or bad objects), and if you use the
 '--unreachable' flag it will also print out objects that exist but that
index 7b1e85cd15b8ced793e56b8accc1e32dfa5aabc9..e3bcdb50e30ea984cb8ae842df0cf1e561e32a62 100644 (file)
@@ -80,7 +80,30 @@ ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
 ----------------------------------------------------------------
 +
 To enable anonymous read access but authenticated write access,
-require authorization with a LocationMatch directive:
+require authorization for both the initial ref advertisement (which we
+detect as a push via the service parameter in the query string), and the
+receive-pack invocation itself:
++
+----------------------------------------------------------------
+RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
+RewriteCond %{REQUEST_URI} /git-receive-pack$
+RewriteRule ^/git/ - [E=AUTHREQUIRED:yes]
+
+<LocationMatch "^/git/">
+       Order Deny,Allow
+       Deny from env=AUTHREQUIRED
+
+       AuthType Basic
+       AuthName "Git Access"
+       Require group committers
+       Satisfy Any
+       ...
+</LocationMatch>
+----------------------------------------------------------------
++
+If you do not have `mod_rewrite` available to match against the query
+string, it is sufficient to just protect `git-receive-pack` itself,
+like:
 +
 ----------------------------------------------------------------
 <LocationMatch "^/git/.*/git-receive-pack$">
@@ -91,6 +114,15 @@ require authorization with a LocationMatch directive:
 </LocationMatch>
 ----------------------------------------------------------------
 +
+In this mode, the server will not request authentication until the
+client actually starts the object negotiation phase of the push, rather
+than during the initial contact.  For this reason, you must also enable
+the `http.receivepack` config option in any repositories that should
+accept a push. The default behavior, if `http.receivepack` is not set,
+is to reject any pushes by unauthenticated users; the initial request
+will therefore report `403 Forbidden` to the client, without even giving
+an opportunity for authentication.
++
 To require authentication for both reads and writes, use a Location
 directive around the repository, or one of its parent directories:
 +
@@ -158,6 +190,54 @@ ScriptAliasMatch \
 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------
 
+Lighttpd::
+       Ensure that `mod_cgi`, `mod_alias, `mod_auth`, `mod_setenv` are
+       loaded, then set `GIT_PROJECT_ROOT` appropriately and redirect
+       all requests to the CGI:
++
+----------------------------------------------------------------
+alias.url += ( "/git" => "/usr/lib/git-core/git-http-backend" )
+$HTTP["url"] =~ "^/git" {
+       cgi.assign = ("" => "")
+       setenv.add-environment = (
+               "GIT_PROJECT_ROOT" => "/var/www/git",
+               "GIT_HTTP_EXPORT_ALL" => ""
+       )
+}
+----------------------------------------------------------------
++
+To enable anonymous read access but authenticated write access:
++
+----------------------------------------------------------------
+$HTTP["querystring"] =~ "service=git-receive-pack" {
+       include "git-auth.conf"
+}
+$HTTP["url"] =~ "^/git/.*/git-receive-pack$" {
+       include "git-auth.conf"
+}
+----------------------------------------------------------------
++
+where `git-auth.conf` looks something like:
++
+----------------------------------------------------------------
+auth.require = (
+       "/" => (
+               "method" => "basic",
+               "realm" => "Git Access",
+               "require" => "valid-user"
+              )
+)
+# ...and set up auth.backend here
+----------------------------------------------------------------
++
+To require authentication for both reads and writes:
++
+----------------------------------------------------------------
+$HTTP["url"] =~ "^/git/private" {
+       include "git-auth.conf"
+}
+----------------------------------------------------------------
+
 
 ENVIRONMENT
 -----------
index 36adc5fc147d758ecc636ffd57ead2d1e63399e7..bde8eec30db19accd80d960518b45fbc29f37bf8 100644 (file)
@@ -89,7 +89,7 @@ Note
 ----
 
 Once the index has been created, the list of object names is sorted
-and the SHA1 hash of that list is printed to stdout. If --stdin was
+and the SHA-1 hash of that list is printed to stdout. If --stdin was
 also used then this is prefixed by either "pack\t", or "keep\t" if a
 new .keep file was successfully created. This is useful to remove a
 .keep file used as a lock to prevent the race with 'git repack'
index 0bdebff6f7985918855286b5fc5072dce4b644e5..c0856a6e0a0a625fcc4c394057597d633a0487ac 100644 (file)
@@ -164,7 +164,7 @@ which case it outputs:
 'git ls-files --unmerged' and 'git ls-files --stage' can be used to examine
 detailed information on unmerged paths.
 
-For an unmerged path, instead of recording a single mode/SHA1 pair,
+For an unmerged path, instead of recording a single mode/SHA-1 pair,
 the index records up to three such pairs; one from tree O in stage
 1, A in stage 2, and B in stage 3.  This information can be used by
 the user (or the porcelain) to see what should eventually be recorded at the
index 0c80cec0e8d6bd2bf5798e9c34316b57b7afc776..02676fb39197d8c4ae33b3d6aa3e8fa27b8e3350 100644 (file)
@@ -14,7 +14,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 This looks up the <file>(s) in the index and, if there are any merge
-entries, passes the SHA1 hash for those files as arguments 1, 2, 3 (empty
+entries, passes the SHA-1 hash for those files as arguments 1, 2, 3 (empty
 argument if no file), and <file> as argument 4.  File modes for the three
 files are passed as arguments 5, 6 and 7.
 
index 69c9313cf59cde569b08e905fe4f732ad4c4c517..d94edcd4b4fdd8bd57150bd0ad8f870a45e0249c 100644 (file)
@@ -50,7 +50,7 @@ base-name::
        Write into a pair of files (.pack and .idx), using
        <base-name> to determine the name of the created file.
        When this option is used, the two files are written in
-       <base-name>-<SHA1>.{pack,idx} files.  <SHA1> is a hash
+       <base-name>-<SHA-1>.{pack,idx} files.  <SHA-1> is a hash
        of the sorted object names to make the resulting filename
        based on the pack content, and written to the standard
        output of the command.
index 90268f02e7381b6f1403e54103988bfde6522073..312c3b1fe5f970a5fdab0e7e1ba0fcbe021eaaa5 100644 (file)
@@ -12,7 +12,7 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-A "patch ID" is nothing but a SHA1 of the diff associated with a patch, with
+A "patch ID" is nothing but a SHA-1 of the diff associated with a patch, with
 whitespace and line numbers ignored.  As such, it's "reasonably stable", but at
 the same time also reasonably unique, i.e., two patches that have the same "patch
 ID" are almost guaranteed to be the same thing.
index 0142cd18ae7c1f78f345c9a511891a4d962a2677..e0b405797630c066f57082abc98fb1c03a1b219d 100644 (file)
@@ -16,8 +16,8 @@ DESCRIPTION
 -----------
 Adds a 'replace' reference in `refs/replace/` namespace.
 
-The name of the 'replace' reference is the SHA1 of the object that is
-replaced. The content of the 'replace' reference is the SHA1 of the
+The name of the 'replace' reference is the SHA-1 of the object that is
+replaced. The content of the 'replace' reference is the SHA-1 of the
 replacement object.
 
 Unless `-f` is given, the 'replace' reference must not yet exist.
index 1f9ed6cfd28622afcf269eb8dac05fb9414d9901..947d62fd25e4b326af44a6f6933e98d9cc3e7153 100644 (file)
@@ -95,7 +95,7 @@ can be used.
        one.
 
 --symbolic::
-       Usually the object names are output in SHA1 form (with
+       Usually the object names are output in SHA-1 form (with
        possible '{caret}' prefix); this option makes them output in a
        form as close to the original input as possible.
 
@@ -180,7 +180,7 @@ print a message to stderr and exit with nonzero status.
 
 --short::
 --short=number::
-       Instead of outputting the full SHA1 values of object names try to
+       Instead of outputting the full SHA-1 values of object names try to
        abbreviate them to a shorter unique name. When no length is specified
        7 is used. The minimum length is 4.
 
index 0cffef8aa51cc5c2f34393e39e45e84c4997b195..40a9a9abc14f175738986b244207655b296cc31d 100644 (file)
@@ -45,8 +45,9 @@ Composing
 ~~~~~~~~~
 
 --annotate::
-       Review and edit each patch you're about to send. See the
-       CONFIGURATION section for 'sendemail.multiedit'.
+       Review and edit each patch you're about to send. Default is the value
+       of 'sendemail.annotate'. See the CONFIGURATION section for
+       'sendemail.multiedit'.
 
 --bcc=<address>::
        Specify a "Bcc:" value for each email. Default is the value of
index a8e77b5350c8c6a3cf62c22f811974ea64cff8ae..a515648ab018b849897dd3506183f57359be598a 100644 (file)
@@ -31,7 +31,7 @@ no <rev> nor <glob> is given on the command line.
 OPTIONS
 -------
 <rev>::
-       Arbitrary extended SHA1 expression (see linkgit:gitrevisions[7])
+       Arbitrary extended SHA-1 expression (see linkgit:gitrevisions[7])
        that typically names a branch head or a tag.
 
 <glob>::
@@ -142,7 +142,7 @@ displayed, indented N places.  If a commit is on the I-th
 branch, the I-th indentation character shows a `+` sign;
 otherwise it shows a space.  Merge commits are denoted by
 a `-` sign.  Each commit shows a short name that
-can be used as an extended SHA1 to name that commit.
+can be used as an extended SHA-1 to name that commit.
 
 The following example shows three branches, "master", "fixes"
 and "mhf":
index 9cbbed944c9ab7511e5e27876174968624ded5ad..fbdc8adae5b10a8ed88883647d2f0ccc3636cddc 100644 (file)
@@ -19,7 +19,7 @@ Reads given idx file for packed Git archive created with
 
 The information it outputs is subset of what you can get from
 'git verify-pack -v'; this command only shows the packfile
-offset and SHA1 of each object.
+offset and SHA-1 of each object.
 
 GIT
 ---
index 5dbcd47fec3b605d0b4b3e6ed47c06cc57f1dd6d..de4d352da2e4835c107d5dc0121e70f132ffbd34 100644 (file)
@@ -50,8 +50,8 @@ OPTIONS
 -s::
 --hash[=<n>]::
 
-       Only show the SHA1 hash, not the reference name. When combined with
-       --dereference the dereferenced tag will still be shown after the SHA1.
+       Only show the SHA-1 hash, not the reference name. When combined with
+       --dereference the dereferenced tag will still be shown after the SHA-1.
 
 --verify::
 
index b21aa87fe87a26f738c971f8c3dffdcf44fb13cd..22894cbee6794fd738cf45aefefff0679dcb940d 100644 (file)
@@ -33,7 +33,7 @@ in the tag message.
 If `-m <msg>` or `-F <file>` is given and `-a`, `-s`, and `-u <key-id>`
 are absent, `-a` is implied.
 
-Otherwise just a tag reference for the SHA1 object name of the commit object is
+Otherwise just a tag reference for the SHA-1 object name of the commit object is
 created (i.e. a lightweight tag).
 
 A GnuPG signed tag object will be created when `-s` or `-u
index c92775829bd26d3d993600fd5bb104e527de59f4..670e9fb2c2baa1ce40415d273c08d5b137868432 100644 (file)
@@ -247,7 +247,7 @@ $ git update-index --index-info
 ------------
 
 The first line of the input feeds 0 as the mode to remove the
-path; the SHA1 does not matter as long as it is well formatted.
+path; the SHA-1 does not matter as long as it is well formatted.
 Then the second and third line feeds stage 1 and stage 2 entries
 for that path.  After the above, we would end up with this:
 
index 0eb9ffbdd2e691c24ed07eb8c97828bc3a81b427..526ba7be9ca08ff1925a387a4d98a9a3aaf867a8 100644 (file)
@@ -40,11 +40,11 @@ OUTPUT FORMAT
 -------------
 When specifying the -v option the format used is:
 
-       SHA1 type size size-in-pack-file offset-in-packfile
+       SHA-1 type size size-in-pack-file offset-in-packfile
 
 for objects that are not deltified in the pack, and
 
-       SHA1 type size size-in-packfile offset-in-packfile depth base-SHA1
+       SHA-1 type size size-in-packfile offset-in-packfile depth base-SHA-1
 
 for objects that are deltified.
 
index e996135be900067dc4054fc8eec20404d1b61380..f88ba96f023ac9f497f01ef699d0931a6d14e59a 100644 (file)
@@ -21,7 +21,7 @@ OPTIONS
        Print the contents of the tag object before validating it.
 
 <tag>...::
-       SHA1 identifiers of Git tag objects.
+       SHA-1 identifiers of Git tag objects.
 
 GIT
 ---
index 6a875f2adefe34e27bc0fc3b6fdb9d7bcfd23301..807a13c806f5e167ed52a83b7b7cd6ea5c12d5ef 100644 (file)
@@ -741,7 +741,7 @@ where:
 
        <old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the
                          contents of <old|new>,
-       <old|new>-hex:: are the 40-hexdigit SHA1 hashes,
+       <old|new>-hex:: are the 40-hexdigit SHA-1 hashes,
        <old|new>-mode:: are the octal representation of the file modes.
 +
 The file parameters can point at the user's working file
@@ -864,7 +864,7 @@ The commit, equivalent to what other systems call a "changeset" or
 represents an immediately preceding step.  Commits with more than one
 parent represent merges of independent lines of development.
 
-All objects are named by the SHA1 hash of their contents, normally
+All objects are named by the SHA-1 hash of their contents, normally
 written as a string of 40 hex digits.  Such names are globally unique.
 The entire history leading up to a commit can be vouched for by signing
 just that commit.  A fourth object type, the tag, is provided for this
@@ -874,9 +874,9 @@ When first created, objects are stored in individual files, but for
 efficiency may later be compressed together into "pack files".
 
 Named pointers called refs mark interesting points in history.  A ref
-may contain the SHA1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA1 name of the most
-recent commit (or "head") of a branch under development.  SHA1 names of
+may contain the SHA-1 name of an object or the name of another ref.  Refs
+with names beginning `ref/head/` contain the SHA-1 name of the most
+recent commit (or "head") of a branch under development.  SHA-1 names of
 tags of interest are stored under `ref/tags/`.  A special ref named
 `HEAD` contains the name of the currently checked-out branch.
 
index 59c1c17cca863d2b90c0ac3d7dabd37918473bdf..f538a870c72dec8a022c23d5023cf5252e9925cf 100644 (file)
@@ -106,9 +106,9 @@ branch. A number of the Git tools will assume that `.git/HEAD` is
 valid, though.
 
 [NOTE]
-An 'object' is identified by its 160-bit SHA1 hash, aka 'object name',
+An 'object' is identified by its 160-bit SHA-1 hash, aka 'object name',
 and a reference to an object is always the 40-byte hex
-representation of that SHA1 name. The files in the `refs`
+representation of that SHA-1 name. The files in the `refs`
 subdirectory are expected to contain these hex references
 (usually with a final `\n` at the end), and you should thus
 expect to see a number of 41-byte files containing these
@@ -763,7 +763,7 @@ already discussed, the `HEAD` branch is nothing but a symlink to one of
 these object pointers.
 
 You can at any time create a new branch by just picking an arbitrary
-point in the project history, and just writing the SHA1 name of that
+point in the project history, and just writing the SHA-1 name of that
 object into a file under `.git/refs/heads/`. You can use any filename you
 want (and indeed, subdirectories), but the convention is that the
 "normal" branch is called `master`. That's just a convention, though,
@@ -1233,7 +1233,7 @@ file (the first tree goes to stage 1, the second to stage 2,
 etc.).  After reading three trees into three stages, the paths
 that are the same in all three stages are 'collapsed' into stage
 0.  Also paths that are the same in two of three stages are
-collapsed into stage 0, taking the SHA1 from either stage 2 or
+collapsed into stage 0, taking the SHA-1 from either stage 2 or
 stage 3, whichever is different from stage 1 (i.e. only one side
 changed from the common ancestor).
 
index 4ed71c76cb4ee7855521b1a04c2bddf6d63d23a8..568d75783ae28576087e30e170aa6400a3017c44 100644 (file)
@@ -108,7 +108,7 @@ it changes it to:
 For the purpose of breaking a filepair, diffcore-break examines
 the extent of changes between the contents of the files before
 and after modification (i.e. the contents that have "bcd1234..."
-and "0123456..." as their SHA1 content ID, in the above
+and "0123456..." as their SHA-1 content ID, in the above
 example).  The amount of deletion of original contents and
 insertion of new material are added together, and if it exceeds
 the "break score", the filepair is broken into two.  The break
index dc6693fe482e2311a7d0ed5b5e60abec7c150c0c..d48bf4d6fae12a21232bc74ddeb230885c1bcbb9 100644 (file)
@@ -99,7 +99,7 @@ given); `template` (if a `-t` option was given or the
 configuration option `commit.template` is set); `merge` (if the
 commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
 (if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
-a commit SHA1 (if a `-c`, `-C` or `--amend` option was given).
+a commit SHA-1 (if a `-c`, `-C` or `--amend` option was given).
 
 If the exit status is non-zero, 'git commit' will abort.
 
@@ -196,11 +196,11 @@ hook would receive a line like the following:
 
   refs/heads/master 67890 refs/heads/foreign 12345
 
-although the full, 40-character SHA1s would be supplied.  If the foreign ref
-does not yet exist the `<remote SHA1>` will be 40 `0`.  If a ref is to be
+although the full, 40-character SHA-1s would be supplied.  If the foreign ref
+does not yet exist the `<remote SHA-1>` will be 40 `0`.  If a ref is to be
 deleted, the `<local ref>` will be supplied as `(delete)` and the `<local
-SHA1>` will be 40 `0`.  If the local commit was specified by something other
-than a name which could be expanded (such as `HEAD~`, or a SHA1) it will be
+SHA-1>` will be 40 `0`.  If the local commit was specified by something other
+than a name which could be expanded (such as `HEAD~`, or a SHA-1) it will be
 supplied as it was originally given.
 
 If this hook exits with a non-zero status, 'git push' will abort without
index f0eef765b96284fe42915bea18ea5fa6073d0dfe..d6f3393c5f5e4e8b564e702a06c632262847ee9d 100644 (file)
@@ -106,7 +106,7 @@ refs/remotes/`name`::
        from a remote repository.
 
 refs/replace/`<obj-sha1>`::
-       records the SHA1 of the object that replaces `<obj-sha1>`.
+       records the SHA-1 of the object that replaces `<obj-sha1>`.
        This is similar to info/grafts and is internally used and
        maintained by linkgit:git-replace[1]. Such refs can be exchanged
        between repositories while grafts are not.
@@ -184,6 +184,10 @@ info/exclude::
        'git clean' look at it but the core Git commands do not look
        at it.  See also: linkgit:gitignore[5].
 
+info/sparse-checkout::
+       This file stores sparse checkout patterns.
+       See also: linkgit:git-read-tree[1].
+
 remotes::
        Stores shorthands for URL and default refnames for use
        when interacting with remote repositories via 'git fetch',
index 94c906eda8d65c940252def28399e724967e24f8..3109ea8aade1ceb47de67823388d865a1505e616 100644 (file)
@@ -46,9 +46,9 @@ What are the 7 digits of hex that Git responded to the commit with?
 
 We saw in part one of the tutorial that commits have names like this.
 It turns out that every object in the Git history is stored under
-a 40-digit hex name.  That name is the SHA1 hash of the object's
+a 40-digit hex name.  That name is the SHA-1 hash of the object's
 contents; among other things, this ensures that Git will never store
-the same data twice (since identical data is given an identical SHA1
+the same data twice (since identical data is given an identical SHA-1
 name), and that the contents of a Git object will never change (since
 that would change the object's name as well). The 7 char hex strings
 here are simply the abbreviation of such 40 character long strings.
@@ -56,7 +56,7 @@ Abbreviations can be used everywhere where the 40 character strings
 can be used, so long as they are unambiguous.
 
 It is expected that the content of the commit object you created while
-following the example above generates a different SHA1 hash than
+following the example above generates a different SHA-1 hash than
 the one shown above because the commit object records the time when
 it was created and the name of the person performing the commit.
 
@@ -80,14 +80,14 @@ A tree can refer to one or more "blob" objects, each corresponding to
 a file.  In addition, a tree can also refer to other tree objects,
 thus creating a directory hierarchy.  You can examine the contents of
 any tree using ls-tree (remember that a long enough initial portion
-of the SHA1 will also work):
+of the SHA-1 will also work):
 
 ------------------------------------------------
 $ git ls-tree 92b8b694
 100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad    file.txt
 ------------------------------------------------
 
-Thus we see that this tree has one file in it.  The SHA1 hash is a
+Thus we see that this tree has one file in it.  The SHA-1 hash is a
 reference to that file's data:
 
 ------------------------------------------------
@@ -106,7 +106,7 @@ Note that this is the old file data; so the object that Git named in
 its response to the initial tree was a tree with a snapshot of the
 directory state that was recorded by the first commit.
 
-All of these objects are stored under their SHA1 names inside the Git
+All of these objects are stored under their SHA-1 names inside the Git
 directory:
 
 ------------------------------------------------
@@ -142,7 +142,7 @@ ref: refs/heads/master
 
 As you can see, this tells us which branch we're currently on, and it
 tells us this by naming a file under the .git directory, which itself
-contains a SHA1 name referring to a commit object, which we can
+contains a SHA-1 name referring to a commit object, which we can
 examine with cat-file:
 
 ------------------------------------------------
@@ -208,7 +208,7 @@ project's history:
 
 Note, by the way, that lots of commands take a tree as an argument.
 But as we can see above, a tree can be referred to in many different
-ways--by the SHA1 name for that tree, by the name of a commit that
+ways--by the SHA-1 name for that tree, by the name of a commit that
 refers to the tree, by the name of a branch whose head refers to that
 tree, etc.--and most such commands can accept any of these names.
 
index eb636317be501b6d448f0f7b861952c74b9ff2e0..ea0526ecc4019802b7088316cba9aed401fa6ee8 100644 (file)
@@ -857,6 +857,13 @@ adding the following lines to your gitweb configuration file:
        $known_snapshot_formats{'zip'}{'disabled'} = 1;
        $known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];
 
+BUGS
+----
+Debugging would be easier if the fallback configuration file
+(`/etc/gitweb.conf`) and environment variable to override its location
+('GITWEB_CONFIG_SYSTEM') had names reflecting their "fallback" role.
+The current names are kept to avoid breaking working setups.
+
 ENVIRONMENT
 -----------
 The location of per-instance and system-wide configuration files can be
index eb7ba84f1f65a316f3b1b3637983487b699a0a2c..ce3e4fae731b6c6c4e67034393309cd20f69b7dc 100644 (file)
@@ -100,12 +100,22 @@ to point at the new commit.
 
 [[def_detached_HEAD]]detached HEAD::
        Normally the <<def_HEAD,HEAD>> stores the name of a
-       <<def_branch,branch>>.  However, Git also allows you to <<def_checkout,check out>>
-       an arbitrary <<def_commit,commit>> that isn't necessarily the tip of any
-       particular branch.  In this case HEAD is said to be "detached".
-
-[[def_dircache]]dircache::
-       You are *waaaaay* behind. See <<def_index,index>>.
+       <<def_branch,branch>>, and commands that operate on the
+       history HEAD represents operate on the history leading to the
+       tip of the branch the HEAD points at.  However, Git also
+       allows you to <<def_checkout,check out>> an arbitrary
+       <<def_commit,commit>> that isn't necessarily the tip of any
+       particular branch.  The HEAD in such a state is called
+       "detached".
++
+Note that commands that operate on the history of the current branch
+(e.g. `git commit` to build a new history on top of it) still work
+while the HEAD is detached. They update the HEAD to point at the tip
+of the updated history without affecting any branch.  Commands that
+update or inquire information _about_ the current branch (e.g. `git
+branch --set-upstream-to` that sets what remote tracking branch the
+current branch integrates with) obviously do not work, as there is no
+(real) current branch to ask about in this state.
 
 [[def_directory]]directory::
        The list you get with "ls" :-)
@@ -115,11 +125,6 @@ to point at the new commit.
        it contains modifications which have not been <<def_commit,committed>> to the current
        <<def_branch,branch>>.
 
-[[def_ent]]ent::
-       Favorite synonym to "<<def_tree-ish,tree-ish>>" by some total geeks. See
-       http://en.wikipedia.org/wiki/Ent_(Middle-earth) for an in-depth
-       explanation. Avoid this term, not to confuse people.
-
 [[def_evil_merge]]evil merge::
        An evil merge is a <<def_merge,merge>> that introduces changes that
        do not appear in any <<def_parent,parent>>.
@@ -161,7 +166,7 @@ to point at the new commit.
        created. Configured via the `.git/info/grafts` file.
 
 [[def_hash]]hash::
-       In Git's context, synonym to <<def_object_name,object name>>.
+       In Git's context, synonym for <<def_object_name,object name>>.
 
 [[def_head]]head::
        A <<def_ref,named reference>> to the <<def_commit,commit>> at the tip of a
@@ -233,7 +238,7 @@ This commit is referred to as a "merge commit", or sometimes just a
 
 [[def_object]]object::
        The unit of storage in Git. It is uniquely identified by the
-       <<def_SHA1,SHA1>> of its contents. Consequently, an
+       <<def_SHA1,SHA-1>> of its contents. Consequently, an
        object can not be changed.
 
 [[def_object_database]]object database::
@@ -245,10 +250,9 @@ This commit is referred to as a "merge commit", or sometimes just a
        Synonym for <<def_object_name,object name>>.
 
 [[def_object_name]]object name::
-       The unique identifier of an <<def_object,object>>. The <<def_hash,hash>>
-       of the object's contents using the Secure Hash Algorithm
-       1 and usually represented by the 40 character hexadecimal encoding of
-       the <<def_hash,hash>> of the object.
+       The unique identifier of an <<def_object,object>>.  The
+       object name is usually represented by a 40 character
+       hexadecimal string.  Also colloquially called <<def_SHA1,SHA-1>>.
 
 [[def_object_type]]object type::
        One of the identifiers "<<def_commit_object,commit>>",
@@ -257,8 +261,7 @@ This commit is referred to as a "merge commit", or sometimes just a
        <<def_object,object>>.
 
 [[def_octopus]]octopus::
-       To <<def_merge,merge>> more than two <<def_branch,branches>>. Also denotes an
-       intelligent predator.
+       To <<def_merge,merge>> more than two <<def_branch,branches>>.
 
 [[def_origin]]origin::
        The default upstream <<def_repository,repository>>. Most projects have
@@ -278,7 +281,7 @@ This commit is referred to as a "merge commit", or sometimes just a
        pack.
 
 [[def_pathspec]]pathspec::
-       Pattern used to specify paths.
+       Pattern used to limit paths in Git commands.
 +
 Pathspecs are used on the command line of "git ls-files", "git
 ls-tree", "git add", "git grep", "git diff", "git checkout",
@@ -287,6 +290,8 @@ limit the scope of operations to some subset of the tree or
 worktree.  See the documentation of each command for whether
 paths are relative to the current directory or toplevel.  The
 pathspec syntax is as follows:
++
+--
 
 * any path matches itself
 * the pathspec up to the last slash represents a
@@ -296,11 +301,12 @@ pathspec syntax is as follows:
   of the pathname.  Paths relative to the directory
   prefix will be matched against that pattern using fnmatch(3);
   in particular, '*' and '?' _can_ match directory separators.
+
+--
 +
 For example, Documentation/*.jpg will match all .jpg files
 in the Documentation subtree,
 including Documentation/chapter_1/figure_1.jpg.
-
 +
 A pathspec that begins with a colon `:` has special meaning.  In the
 short form, the leading colon `:` is followed by zero or more "magic
@@ -316,18 +322,10 @@ and a close parentheses `)`, and the remainder is the pattern to match
 against the path.
 +
 The "magic signature" consists of an ASCII symbol that is not
-alphanumeric.
-+
---
-top `/`;;
-       The magic word `top` (mnemonic: `/`) makes the pattern match
-       from the root of the working tree, even when you are running
-       the command from inside a subdirectory.
---
-+
-Currently only the slash `/` is recognized as the "magic signature",
-but it is envisioned that we will support more types of magic in later
-versions of Git.
+alphanumeric. Currently only the slash `/` is recognized as a
+"magic signature": it makes the pattern match from the root of
+the working tree, even when you are running the command from
+inside a subdirectory.
 +
 A pathspec with only a colon means "there is no pathspec". This form
 should not be combined with other pathspec.
@@ -385,7 +383,7 @@ should not be combined with other pathspec.
        to the result.
 
 [[def_ref]]ref::
-       A 40-byte hex representation of a <<def_SHA1,SHA1>> or a name that
+       A 40-byte hex representation of a <<def_SHA1,SHA-1>> or a name that
        denotes a particular <<def_object,object>>. They may be stored in
        a file under `$GIT_DIR/refs/` directory, or
        in the `$GIT_DIR/packed-refs` file.
@@ -399,15 +397,7 @@ should not be combined with other pathspec.
 [[def_refspec]]refspec::
        A "refspec" is used by <<def_fetch,fetch>> and
        <<def_push,push>> to describe the mapping between remote
-       <<def_ref,ref>> and local ref. They are combined with a colon in
-       the format <src>:<dst>, preceded by an optional plus sign, +.
-       For example: `git fetch $URL
-       refs/heads/master:refs/heads/origin` means "grab the master
-       <<def_branch,branch>> <<def_head,head>> from the $URL and store
-       it as my origin branch head". And `git push
-       $URL refs/heads/master:refs/heads/to-upstream` means "publish my
-       master branch head as to-upstream branch at $URL". See also
-       linkgit:git-push[1].
+       <<def_ref,ref>> and local ref.
 
 [[def_remote_tracking_branch]]remote-tracking branch::
        A regular Git <<def_branch,branch>> that is used to follow changes from
@@ -441,8 +431,9 @@ should not be combined with other pathspec.
 [[def_SCM]]SCM::
        Source code management (tool).
 
-[[def_SHA1]]SHA1::
-       Synonym for <<def_object_name,object name>>.
+[[def_SHA1]]SHA-1::
+       "Secure Hash Algorithm 1"; a cryptographic hash function.
+       In the context of Git used as a synonym for <<def_object_name,object name>>.
 
 [[def_shallow_repository]]shallow repository::
        A shallow <<def_repository,repository>> has an incomplete
@@ -456,7 +447,7 @@ should not be combined with other pathspec.
        its history can be later deepened with linkgit:git-fetch[1].
 
 [[def_symref]]symref::
-       Symbolic reference: instead of containing the <<def_SHA1,SHA1>>
+       Symbolic reference: instead of containing the <<def_SHA1,SHA-1>>
        id itself, it is of the format 'ref: refs/some/thing' and when
        referenced, it recursively dereferences to this reference.
        '<<def_HEAD,HEAD>>' is a prime example of a symref. Symbolic
index 6d362ceb10c798600a89540548c48c406b6ca4a9..1b3b188d3c1579ac6cac7c4dcefcff1024249206 100644 (file)
@@ -15,7 +15,7 @@ On Fri, 9 Nov 2007, Yossi Leybovich wrote:
 > Any one know how can I track this object and understand which file is it
 -----------------------------------------------------------
 
-So exactly *because* the SHA1 hash is cryptographically secure, the hash
+So exactly *because* the SHA-1 hash is cryptographically secure, the hash
 itself doesn't actually tell you anything, in order to fix a corrupt
 object you basically have to find the "original source" for it.
 
@@ -44,7 +44,7 @@ So:
 -----------------------------------------------------------
 
 This is the right thing to do, although it's usually best to save it under
-it's full SHA1 name (you just dropped the "4b" from the result ;).
+it's full SHA-1 name (you just dropped the "4b" from the result ;).
 
 Let's see what that tells us:
 
@@ -89,7 +89,7 @@ working tree, in which case fixing this problem is really simple, just do
 
        git hash-object -w my-magic-file
 
-again, and if it outputs the missing SHA1 (4b945..) you're now all done!
+again, and if it outputs the missing SHA-1 (4b945..) you're now all done!
 
 But that's the really lucky case, so let's assume that it was some older
 version that was broken. How do you tell which version it was?
index 66db80296f505a9bd830c746f82bb54e3f49f313..49a9a7d53f5836ecf2c5bcadb30f0d314414afe0 100644 (file)
@@ -48,6 +48,12 @@ patience;;
        this when the branches to be merged have diverged wildly.
        See also linkgit:git-diff[1] `--patience`.
 
+diff-algorithm=[patience|minimal|histogram|myers];;
+       Tells 'merge-recursive' to use a different diff algorithm, which
+       can help avoid mismerges that occur due to unimportant matching
+       lines (such as braces from distinct functions).  See also
+       linkgit:git-diff[1] `--diff-algorithm`.
+
 ignore-space-change;;
 ignore-all-space;;
 ignore-space-at-eol;;
index afac703f21245b6fa34af90b1da4b3194372a81d..f5b50dcba2b97d9293cf2332346e778706bda589 100644 (file)
@@ -75,7 +75,7 @@ This is designed to be as compact as possible.
 * 'raw'
 +
 The 'raw' format shows the entire commit exactly as
-stored in the commit object.  Notably, the SHA1s are
+stored in the commit object.  Notably, the SHA-1s are
 displayed in full, regardless of whether --abbrev or
 --no-abbrev are used, and 'parents' information show the
 true parent commits, without taking grafts nor history
index 8855b1a0ac99012fcd98fcb3272b39e465d84626..a8ff691492927eef2f31d889f7bd20b4e60e7a91 100644 (file)
@@ -2,13 +2,13 @@ SPECIFYING REVISIONS
 --------------------
 
 A revision parameter '<rev>' typically, but not necessarily, names a
-commit object.  It uses what is called an 'extended SHA1'
+commit object.  It uses what is called an 'extended SHA-1'
 syntax.  Here are various ways to spell object names.  The
 ones listed near the end of this list name trees and
 blobs contained in a commit.
 
 '<sha1>', e.g. 'dae86e1950b1277e545cee180551750029cfe735', 'dae86e'::
-  The full SHA1 object name (40-byte hexadecimal string), or
+  The full SHA-1 object name (40-byte hexadecimal string), or
   a leading substring that is unique within the repository.
   E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
   name the same commit object if there is no other object in
index 45d1c517cd862878198db6023d5fdbd35f9fbb6c..3e75497a37d696d534c16ff0270a808b57ac9180 100644 (file)
@@ -1,7 +1,7 @@
 sha1-array API
 ==============
 
-The sha1-array API provides storage and manipulation of sets of SHA1
+The sha1-array API provides storage and manipulation of sets of SHA-1
 identifiers. The emphasis is on storage and processing efficiency,
 making them suitable for large lists. Note that the ordering of items is
 not preserved over some operations.
@@ -11,7 +11,7 @@ Data Structures
 
 `struct sha1_array`::
 
-       A single array of SHA1 hashes. This should be initialized by
+       A single array of SHA-1 hashes. This should be initialized by
        assignment from `SHA1_ARRAY_INIT`.  The `sha1` member contains
        the actual data. The `nr` member contains the number of items in
        the set.  The `alloc` and `sorted` members are used internally,
index 2c59cb2259d941232652241dc1cadcfc0c3ef812..3350d97dda2408f92dc44c1e3216facc50257a50 100644 (file)
@@ -230,6 +230,11 @@ which can be used by the programmer of the callback as she sees fit.
        destination. This is useful for literal data to be fed to either
        strbuf_expand or to the *printf family of functions.
 
+`strbuf_humanise_bytes`::
+
+       Append the given byte size as a human-readable string (i.e. 12.23 KiB,
+       3.50 MiB).
+
 `strbuf_addf`::
 
        Add a formatted string to the buffer.
index a37f1378d05d6def0ea3cac840acf62875536a70..8e5bf60be3f0689d61feb8ce43cb379b2417fd8f 100644 (file)
@@ -34,7 +34,7 @@ Git pack format
      Observation: length of each object is encoded in a variable
      length format and is not constrained to 32-bit or anything.
 
-  - The trailer records 20-byte SHA1 checksum of all of the above.
+  - The trailer records 20-byte SHA-1 checksum of all of the above.
 
 == Original (version 1) pack-*.idx files have the following format:
 
@@ -55,10 +55,10 @@ Git pack format
 
   - The file is concluded with a trailer:
 
-    A copy of the 20-byte SHA1 checksum at the end of
+    A copy of the 20-byte SHA-1 checksum at the end of
     corresponding packfile.
 
-    20-byte SHA1-checksum of all of the above.
+    20-byte SHA-1-checksum of all of the above.
 
 Pack Idx file:
 
@@ -106,7 +106,7 @@ Pack file entry: <+
         If it is not DELTA, then deflated bytes (the size above
                is the size before compression).
        If it is REF_DELTA, then
-         20-byte base object name SHA1 (the size above is the
+         20-byte base object name SHA-1 (the size above is the
                size of the delta data that follows).
           delta data, deflated.
        If it is OFS_DELTA, then
@@ -135,7 +135,7 @@ Pack file entry: <+
 
   - A 256-entry fan-out table just like v1.
 
-  - A table of sorted 20-byte SHA1 object names.  These are
+  - A table of sorted 20-byte SHA-1 object names.  These are
     packed together without offset values to reduce the cache
     footprint of the binary search for a specific object name.
 
@@ -156,7 +156,7 @@ Pack file entry: <+
 
   - The same trailer as a v1 pack file:
 
-    A copy of the 20-byte SHA1 checksum at the end of
+    A copy of the 20-byte SHA-1 checksum at the end of
     corresponding packfile.
 
-    20-byte SHA1-checksum of all of the above.
+    20-byte SHA-1-checksum of all of the above.
index dbdf7ba9c811837d70dde4e22fafec7a8f6b49d0..8b7ae1c140bc9d6d5fe01ea30dfbef0d6eb7ca8e 100644 (file)
@@ -89,7 +89,7 @@ Ah, grasshopper!  And thus the enlightenment begins anew.
 
     <linus> The "magic" is actually in theory totally arbitrary.
         ANY order will give you a working pack, but no, it's not
-        ordered by SHA1.
+       ordered by SHA-1.
 
         Before talking about the ordering for the sliding delta
         window, let's talk about the recency order. That's more
index ea2f69faf5cd1e87226eb2a8c281aa4d5f6ed204..5183b154229d7c25f0feab3d0afcd1d52ca652e0 100644 (file)
@@ -8,7 +8,7 @@ repo, and therefore grafts are introduced pretending that
 these commits have no parents.
 *********************************************************
 
-The basic idea is to write the SHA1s of shallow commits into
+The basic idea is to write the SHA-1s of shallow commits into
 $GIT_DIR/shallow, and handle its contents like the contents
 of $GIT_DIR/info/grafts (with the difference that shallow
 cannot contain parent information).
@@ -18,7 +18,7 @@ even the config, since the user should not touch that file
 at all (even throughout development of the shallow clone, it
 was never manually edited!).
 
-Each line contains exactly one SHA1. When read, a commit_graft
+Each line contains exactly one SHA-1. When read, a commit_graft
 will be constructed, which has nr_parent < 0 to make it easier
 to discern from user provided grafts.
 
diff --git a/attr.c b/attr.c
index 689bc2a8961fac72a01e615764af53f49d01c3ec..0e774c6f22f9fd6c7e27490e5bed5be1f9f10de5 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -381,46 +381,13 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
        return res;
 }
 
-static void *read_index_data(const char *path)
-{
-       int pos, len;
-       unsigned long sz;
-       enum object_type type;
-       void *data;
-       struct index_state *istate = use_index ? use_index : &the_index;
-
-       len = strlen(path);
-       pos = index_name_pos(istate, path, len);
-       if (pos < 0) {
-               /*
-                * We might be in the middle of a merge, in which
-                * case we would read stage #2 (ours).
-                */
-               int i;
-               for (i = -pos - 1;
-                    (pos < 0 && i < istate->cache_nr &&
-                     !strcmp(istate->cache[i]->name, path));
-                    i++)
-                       if (ce_stage(istate->cache[i]) == 2)
-                               pos = i;
-       }
-       if (pos < 0)
-               return NULL;
-       data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
-       if (!data || type != OBJ_BLOB) {
-               free(data);
-               return NULL;
-       }
-       return data;
-}
-
 static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
 {
        struct attr_stack *res;
        char *buf, *sp;
        int lineno = 0;
 
-       buf = read_index_data(path);
+       buf = read_blob_data_from_index(use_index ? use_index : &the_index, path, NULL);
        if (!buf)
                return NULL;
 
index 6ae6a4c321ab8866a3e21f15302b5549a95b4646..97c72bfe7043701132a2710bf03c5ce3ee109ba5 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -57,7 +57,7 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
        if (remote_is_branch
            && !strcmp(local, shortname)
            && !origin) {
-               warning("Not setting branch %s as its own upstream.",
+               warning(_("Not setting branch %s as its own upstream."),
                        local);
                return;
        }
@@ -78,25 +78,25 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
 
        if (flag & BRANCH_CONFIG_VERBOSE) {
                if (remote_is_branch && origin)
-                       printf(rebasing ?
-                              "Branch %s set up to track remote branch %s from %s by rebasing.\n" :
-                              "Branch %s set up to track remote branch %s from %s.\n",
-                              local, shortname, origin);
+                       printf_ln(rebasing ?
+                                 _("Branch %s set up to track remote branch %s from %s by rebasing.") :
+                                 _("Branch %s set up to track remote branch %s from %s."),
+                                 local, shortname, origin);
                else if (remote_is_branch && !origin)
-                       printf(rebasing ?
-                              "Branch %s set up to track local branch %s by rebasing.\n" :
-                              "Branch %s set up to track local branch %s.\n",
-                              local, shortname);
+                       printf_ln(rebasing ?
+                                 _("Branch %s set up to track local branch %s by rebasing.") :
+                                 _("Branch %s set up to track local branch %s."),
+                                 local, shortname);
                else if (!remote_is_branch && origin)
-                       printf(rebasing ?
-                              "Branch %s set up to track remote ref %s by rebasing.\n" :
-                              "Branch %s set up to track remote ref %s.\n",
-                              local, remote);
+                       printf_ln(rebasing ?
+                                 _("Branch %s set up to track remote ref %s by rebasing.") :
+                                 _("Branch %s set up to track remote ref %s."),
+                                 local, remote);
                else if (!remote_is_branch && !origin)
-                       printf(rebasing ?
-                              "Branch %s set up to track local ref %s by rebasing.\n" :
-                              "Branch %s set up to track local ref %s.\n",
-                              local, remote);
+                       printf_ln(rebasing ?
+                                 _("Branch %s set up to track local ref %s by rebasing.") :
+                                 _("Branch %s set up to track local ref %s."),
+                                 local, remote);
                else
                        die("BUG: impossible combination of %d and %p",
                            remote_is_branch, origin);
@@ -115,7 +115,7 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
        int config_flags = quiet ? 0 : BRANCH_CONFIG_VERBOSE;
 
        if (strlen(new_ref) > 1024 - 7 - 7 - 1)
-               return error("Tracking not set up: name too long: %s",
+               return error(_("Tracking not set up: name too long: %s"),
                                new_ref);
 
        memset(&tracking, 0, sizeof(tracking));
@@ -134,7 +134,7 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
                }
 
        if (tracking.matches > 1)
-               return error("Not tracking: ambiguous information for ref %s",
+               return error(_("Not tracking: ambiguous information for ref %s"),
                                orig_ref);
 
        install_branch_config(config_flags, new_ref, tracking.remote,
@@ -179,12 +179,12 @@ int validate_new_branchname(const char *name, struct strbuf *ref,
                            int force, int attr_only)
 {
        if (strbuf_check_branch_ref(ref, name))
-               die("'%s' is not a valid branch name.", name);
+               die(_("'%s' is not a valid branch name."), name);
 
        if (!ref_exists(ref->buf))
                return 0;
        else if (!force && !attr_only)
-               die("A branch named '%s' already exists.", ref->buf + strlen("refs/heads/"));
+               die(_("A branch named '%s' already exists."), ref->buf + strlen("refs/heads/"));
 
        if (!attr_only) {
                const char *head;
@@ -192,7 +192,7 @@ int validate_new_branchname(const char *name, struct strbuf *ref,
 
                head = resolve_ref_unsafe("HEAD", sha1, 0, NULL);
                if (!is_bare_repository() && head && !strcmp(head, ref->buf))
-                       die("Cannot force update the current branch.");
+                       die(_("Cannot force update the current branch."));
        }
        return 1;
 }
@@ -247,7 +247,7 @@ void create_branch(const char *head,
                        }
                        die(_(upstream_missing), start_name);
                }
-               die("Not a valid object name: '%s'.", start_name);
+               die(_("Not a valid object name: '%s'."), start_name);
        }
 
        switch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) {
@@ -267,18 +267,18 @@ void create_branch(const char *head,
                }
                break;
        default:
-               die("Ambiguous object name: '%s'.", start_name);
+               die(_("Ambiguous object name: '%s'."), start_name);
                break;
        }
 
        if ((commit = lookup_commit_reference(sha1)) == NULL)
-               die("Not a valid branch point: '%s'.", start_name);
+               die(_("Not a valid branch point: '%s'."), start_name);
        hashcpy(sha1, commit->object.sha1);
 
        if (!dont_change_ref) {
                lock = lock_any_ref_for_update(ref.buf, NULL, 0);
                if (!lock)
-                       die_errno("Failed to lock ref for update");
+                       die_errno(_("Failed to lock ref for update"));
        }
 
        if (reflog)
@@ -296,7 +296,7 @@ void create_branch(const char *head,
 
        if (!dont_change_ref)
                if (write_ref_sha1(lock, sha1, msg) < 0)
-                       die_errno("Failed to write ref");
+                       die_errno(_("Failed to write ref"));
 
        strbuf_release(&ref);
        free(real_ref);
index 06f365d12942f50e75c988ae744ac4fa63406cb8..d4b40f2b7a9dbdabcb0133d84b29d8ab281d1baf 100644 (file)
@@ -26,8 +26,55 @@ static int take_worktree_changes;
 struct update_callback_data {
        int flags;
        int add_errors;
+       const char *implicit_dot;
+       size_t implicit_dot_len;
+
+       /* only needed for 2.0 transition preparation */
+       int warn_add_would_remove;
 };
 
+static const char *option_with_implicit_dot;
+static const char *short_option_with_implicit_dot;
+
+static void warn_pathless_add(void)
+{
+       static int shown;
+       assert(option_with_implicit_dot && short_option_with_implicit_dot);
+
+       if (shown)
+               return;
+       shown = 1;
+
+       /*
+        * To be consistent with "git add -p" and most Git
+        * commands, we should default to being tree-wide, but
+        * this is not the original behavior and can't be
+        * changed until users trained themselves not to type
+        * "git add -u" or "git add -A". For now, we warn and
+        * keep the old behavior. Later, the behavior can be changed
+        * to tree-wide, keeping the warning for a while, and
+        * eventually we can drop the warning.
+        */
+       warning(_("The behavior of 'git add %s (or %s)' with no path argument from a\n"
+                 "subdirectory of the tree will change in Git 2.0 and should not be used anymore.\n"
+                 "To add content for the whole tree, run:\n"
+                 "\n"
+                 "  git add %s :/\n"
+                 "  (or git add %s :/)\n"
+                 "\n"
+                 "To restrict the command to the current directory, run:\n"
+                 "\n"
+                 "  git add %s .\n"
+                 "  (or git add %s .)\n"
+                 "\n"
+                 "With the current Git version, the command is restricted to "
+                 "the current directory.\n"
+                 ""),
+               option_with_implicit_dot, short_option_with_implicit_dot,
+               option_with_implicit_dot, short_option_with_implicit_dot,
+               option_with_implicit_dot, short_option_with_implicit_dot);
+}
+
 static int fix_unmerged_status(struct diff_filepair *p,
                               struct update_callback_data *data)
 {
@@ -49,15 +96,49 @@ static int fix_unmerged_status(struct diff_filepair *p,
                return DIFF_STATUS_MODIFIED;
 }
 
+static const char *add_would_remove_warning = N_(
+       "You ran 'git add' with neither '-A (--all)' or '--no-all', whose\n"
+"behaviour will change in Git 2.0 with respect to paths you removed from\n"
+"your working tree. Paths like '%s' that are\n"
+"removed are ignored with this version of Git.\n"
+"\n"
+"* 'git add --no-all <pathspec>', which is the current default, ignores\n"
+"  paths you removed from your working tree.\n"
+"\n"
+"* 'git add --all <pathspec>' will let you also record the removals.\n"
+"\n"
+"Run 'git status' to check the paths you removed from your working tree.\n");
+
+static void warn_add_would_remove(const char *path)
+{
+       warning(_(add_would_remove_warning), path);
+}
+
 static void update_callback(struct diff_queue_struct *q,
                            struct diff_options *opt, void *cbdata)
 {
        int i;
        struct update_callback_data *data = cbdata;
+       const char *implicit_dot = data->implicit_dot;
+       size_t implicit_dot_len = data->implicit_dot_len;
 
        for (i = 0; i < q->nr; i++) {
                struct diff_filepair *p = q->queue[i];
                const char *path = p->one->path;
+               /*
+                * Check if "git add -A" or "git add -u" was run from a
+                * subdirectory with a modified file outside that directory,
+                * and warn if so.
+                *
+                * "git add -u" will behave like "git add -u :/" instead of
+                * "git add -u ." in the future.  This warning prepares for
+                * that change.
+                */
+               if (implicit_dot &&
+                   strncmp_icase(path, implicit_dot, implicit_dot_len)) {
+                       warn_pathless_add();
+                       continue;
+               }
                switch (fix_unmerged_status(p, data)) {
                default:
                        die(_("unexpected diff status %c"), p->status);
@@ -70,6 +151,10 @@ static void update_callback(struct diff_queue_struct *q,
                        }
                        break;
                case DIFF_STATUS_DELETED:
+                       if (data->warn_add_would_remove) {
+                               warn_add_would_remove(path);
+                               data->warn_add_would_remove = 0;
+                       }
                        if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
                                break;
                        if (!(data->flags & ADD_CACHE_PRETEND))
@@ -81,24 +166,34 @@ static void update_callback(struct diff_queue_struct *q,
        }
 }
 
-int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
+static void update_files_in_cache(const char *prefix, const char **pathspec,
+                                 struct update_callback_data *data)
 {
-       struct update_callback_data data;
        struct rev_info rev;
+
        init_revisions(&rev, prefix);
        setup_revisions(0, NULL, &rev, NULL);
        init_pathspec(&rev.prune_data, pathspec);
        rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = update_callback;
-       data.flags = flags;
-       data.add_errors = 0;
-       rev.diffopt.format_callback_data = &data;
+       rev.diffopt.format_callback_data = data;
        rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
        run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
+}
+
+int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
+{
+       struct update_callback_data data;
+
+       memset(&data, 0, sizeof(data));
+       data.flags = flags;
+       update_files_in_cache(prefix, pathspec, &data);
        return !!data.add_errors;
 }
 
-static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
+#define WARN_IMPLICIT_DOT (1u << 0)
+static char *prune_directory(struct dir_struct *dir, const char **pathspec,
+                            int prefix, unsigned flag)
 {
        char *seen;
        int i, specs;
@@ -115,6 +210,16 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec, int
                if (match_pathspec(pathspec, entry->name, entry->len,
                                   prefix, seen))
                        *dst++ = entry;
+               else if (flag & WARN_IMPLICIT_DOT)
+                       /*
+                        * "git add -A" was run from a subdirectory with a
+                        * new file outside that directory.
+                        *
+                        * "git add -A" will behave like "git add -A :/"
+                        * instead of "git add -A ." in the future.
+                        * Warn about the coming behavior change.
+                        */
+                       warn_pathless_add();
        }
        dir->nr = dst - dir->entries;
        add_pathspec_matches_against_index(pathspec, seen, specs);
@@ -270,23 +375,27 @@ static struct lock_file lock_file;
 static const char ignore_error[] =
 N_("The following paths are ignored by one of your .gitignore files:\n");
 
-static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
-static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
+static int verbose, show_only, ignored_too, refresh_only;
+static int ignore_add_errors, intent_to_add, ignore_missing;
+
+#define ADDREMOVE_DEFAULT 0 /* Change to 1 in Git 2.0 */
+static int addremove = ADDREMOVE_DEFAULT;
+static int addremove_explicit = -1; /* unspecified */
 
 static struct option builtin_add_options[] = {
        OPT__DRY_RUN(&show_only, N_("dry run")),
        OPT__VERBOSE(&verbose, N_("be verbose")),
        OPT_GROUP(""),
-       OPT_BOOLEAN('i', "interactive", &add_interactive, N_("interactive picking")),
-       OPT_BOOLEAN('p', "patch", &patch_interactive, N_("select hunks interactively")),
-       OPT_BOOLEAN('e', "edit", &edit_interactive, N_("edit current diff and apply")),
+       OPT_BOOL('i', "interactive", &add_interactive, N_("interactive picking")),
+       OPT_BOOL('p', "patch", &patch_interactive, N_("select hunks interactively")),
+       OPT_BOOL('e', "edit", &edit_interactive, N_("edit current diff and apply")),
        OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
-       OPT_BOOLEAN('u', "update", &take_worktree_changes, N_("update tracked files")),
-       OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
-       OPT_BOOLEAN('A', "all", &addremove, N_("add changes from all tracked and untracked files")),
-       OPT_BOOLEAN( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
-       OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
-       OPT_BOOLEAN( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
+       OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
+       OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
+       OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
+       OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
+       OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
+       OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
        OPT_END(),
 };
 
@@ -321,35 +430,6 @@ static int add_files(struct dir_struct *dir, int flags)
        return exit_status;
 }
 
-static void warn_pathless_add(const char *option_name, const char *short_name) {
-       /*
-        * To be consistent with "git add -p" and most Git
-        * commands, we should default to being tree-wide, but
-        * this is not the original behavior and can't be
-        * changed until users trained themselves not to type
-        * "git add -u" or "git add -A". For now, we warn and
-        * keep the old behavior. Later, the behavior can be changed
-        * to tree-wide, keeping the warning for a while, and
-        * eventually we can drop the warning.
-        */
-       warning(_("The behavior of 'git add %s (or %s)' with no path argument from a\n"
-                 "subdirectory of the tree will change in Git 2.0 and should not be used anymore.\n"
-                 "To add content for the whole tree, run:\n"
-                 "\n"
-                 "  git add %s :/\n"
-                 "  (or git add %s :/)\n"
-                 "\n"
-                 "To restrict the command to the current directory, run:\n"
-                 "\n"
-                 "  git add %s .\n"
-                 "  (or git add %s .)\n"
-                 "\n"
-                 "With the current Git version, the command is restricted to the current directory."),
-               option_name, short_name,
-               option_name, short_name,
-               option_name, short_name);
-}
-
 int cmd_add(int argc, const char **argv, const char *prefix)
 {
        int exit_status = 0;
@@ -360,8 +440,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        int add_new_files;
        int require_pathspec;
        char *seen = NULL;
-       const char *option_with_implicit_dot = NULL;
-       const char *short_option_with_implicit_dot = NULL;
+       int implicit_dot = 0;
+       struct update_callback_data update_data;
 
        git_config(add_config, NULL);
 
@@ -377,8 +457,29 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        argc--;
        argv++;
 
+       if (0 <= addremove_explicit)
+               addremove = addremove_explicit;
+       else if (take_worktree_changes && ADDREMOVE_DEFAULT)
+               addremove = 0; /* "-u" was given but not "-A" */
+
        if (addremove && take_worktree_changes)
                die(_("-A and -u are mutually incompatible"));
+
+       /*
+        * Warn when "git add pathspec..." was given without "-u" or "-A"
+        * and pathspec... covers a removed path.
+        */
+       memset(&update_data, 0, sizeof(update_data));
+       if (!take_worktree_changes && addremove_explicit < 0)
+               update_data.warn_add_would_remove = 1;
+
+       if (!take_worktree_changes && addremove_explicit < 0 && argc)
+               /*
+                * Turn "git add pathspec..." to "git add -A pathspec..."
+                * in Git 2.0 but not yet
+                */
+               ; /* addremove = 1; */
+
        if (!show_only && ignore_missing)
                die(_("Option --ignore-missing can only be used together with --dry-run"));
        if (addremove) {
@@ -391,11 +492,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        }
        if (option_with_implicit_dot && !argc) {
                static const char *here[2] = { ".", NULL };
-               if (prefix)
-                       warn_pathless_add(option_with_implicit_dot,
-                                         short_option_with_implicit_dot);
                argc = 1;
                argv = here;
+               implicit_dot = 1;
        }
 
        add_new_files = !take_worktree_changes && !refresh_only;
@@ -408,7 +507,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                 (intent_to_add ? ADD_CACHE_INTENT : 0) |
                 (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
                 (!(addremove || take_worktree_changes)
-                 ? ADD_CACHE_IGNORE_REMOVAL : 0));
+                 ? ADD_CACHE_IGNORE_REMOVAL : 0)) |
+                (implicit_dot ? ADD_CACHE_IMPLICIT_DOT : 0);
 
        if (require_pathspec && argc == 0) {
                fprintf(stderr, _("Nothing specified, nothing added.\n"));
@@ -432,9 +532,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                }
 
                /* This picks up the paths that are not tracked */
-               baselen = fill_directory(&dir, pathspec);
+               baselen = fill_directory(&dir, implicit_dot ? NULL : pathspec);
                if (pathspec)
-                       seen = prune_directory(&dir, pathspec, baselen);
+                       seen = prune_directory(&dir, pathspec, baselen,
+                                       implicit_dot ? WARN_IMPLICIT_DOT : 0);
        }
 
        if (refresh_only) {
@@ -464,8 +565,20 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
        plug_bulk_checkin();
 
-       exit_status |= add_files_to_cache(prefix, pathspec, flags);
+       if ((flags & ADD_CACHE_IMPLICIT_DOT) && prefix) {
+               /*
+                * Check for modified files throughout the worktree so
+                * update_callback has a chance to warn about changes
+                * outside the cwd.
+                */
+               update_data.implicit_dot = prefix;
+               update_data.implicit_dot_len = strlen(prefix);
+               pathspec = NULL;
+       }
+       update_data.flags = flags & ~ADD_CACHE_IMPLICIT_DOT;
+       update_files_in_cache(prefix, pathspec, &update_data);
 
+       exit_status |= !!update_data.add_errors;
        if (add_new_files)
                exit_status |= add_files(&dir, flags);
 
index 86100e96627e4f839fb5b627bc09ed4264c36176..77707819afa03703b3ee110345a79eec3d3d9d6f 100644 (file)
@@ -1375,10 +1375,15 @@ static void get_ac_line(const char *inbuf, const char *what,
        maillen = ident.mail_end - ident.mail_begin;
        mailbuf = ident.mail_begin;
 
-       *time = strtoul(ident.date_begin, NULL, 10);
+       if (ident.date_begin && ident.date_end)
+               *time = strtoul(ident.date_begin, NULL, 10);
+       else
+               *time = 0;
 
-       len = ident.tz_end - ident.tz_begin;
-       strbuf_add(tz, ident.tz_begin, len);
+       if (ident.tz_begin && ident.tz_end)
+               strbuf_add(tz, ident.tz_begin, ident.tz_end - ident.tz_begin);
+       else
+               strbuf_addstr(tz, "(unknown)");
 
        /*
         * Now, convert both name and e-mail using mailmap
index 3f0fbc082aef95b3d02a8b677116264eea892369..083689063f66a614ad6f8ee4a84c79e214d1b6e0 100644 (file)
@@ -41,13 +41,15 @@ static char branch_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_RED,          /* REMOTE */
        GIT_COLOR_NORMAL,       /* LOCAL */
        GIT_COLOR_GREEN,        /* CURRENT */
+       GIT_COLOR_BLUE,         /* UPSTREAM */
 };
 enum color_branch {
        BRANCH_COLOR_RESET = 0,
        BRANCH_COLOR_PLAIN = 1,
        BRANCH_COLOR_REMOTE = 2,
        BRANCH_COLOR_LOCAL = 3,
-       BRANCH_COLOR_CURRENT = 4
+       BRANCH_COLOR_CURRENT = 4,
+       BRANCH_COLOR_UPSTREAM = 5
 };
 
 static enum merge_filter {
@@ -72,6 +74,8 @@ static int parse_branch_color_slot(const char *var, int ofs)
                return BRANCH_COLOR_LOCAL;
        if (!strcasecmp(var+ofs, "current"))
                return BRANCH_COLOR_CURRENT;
+       if (!strcasecmp(var+ofs, "upstream"))
+               return BRANCH_COLOR_UPSTREAM;
        return -1;
 }
 
@@ -418,36 +422,52 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
        int ours, theirs;
        char *ref = NULL;
        struct branch *branch = branch_get(branch_name);
+       struct strbuf fancy = STRBUF_INIT;
 
        if (!stat_tracking_info(branch, &ours, &theirs)) {
                if (branch && branch->merge && branch->merge[0]->dst &&
-                   show_upstream_ref)
-                       strbuf_addf(stat, "[%s] ",
-                           shorten_unambiguous_ref(branch->merge[0]->dst, 0));
+                   show_upstream_ref) {
+                       ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+                       if (want_color(branch_use_color))
+                               strbuf_addf(stat, "[%s%s%s] ",
+                                               branch_get_color(BRANCH_COLOR_UPSTREAM),
+                                               ref, branch_get_color(BRANCH_COLOR_RESET));
+                       else
+                               strbuf_addf(stat, "[%s] ", ref);
+               }
                return;
        }
 
-       if (show_upstream_ref)
+       if (show_upstream_ref) {
                ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+               if (want_color(branch_use_color))
+                       strbuf_addf(&fancy, "%s%s%s",
+                                       branch_get_color(BRANCH_COLOR_UPSTREAM),
+                                       ref, branch_get_color(BRANCH_COLOR_RESET));
+               else
+                       strbuf_addstr(&fancy, ref);
+       }
+
        if (!ours) {
                if (ref)
-                       strbuf_addf(stat, _("[%s: behind %d]"), ref, theirs);
+                       strbuf_addf(stat, _("[%s: behind %d]"), fancy.buf, theirs);
                else
                        strbuf_addf(stat, _("[behind %d]"), theirs);
 
        } else if (!theirs) {
                if (ref)
-                       strbuf_addf(stat, _("[%s: ahead %d]"), ref, ours);
+                       strbuf_addf(stat, _("[%s: ahead %d]"), fancy.buf, ours);
                else
                        strbuf_addf(stat, _("[ahead %d]"), ours);
        } else {
                if (ref)
                        strbuf_addf(stat, _("[%s: ahead %d, behind %d]"),
-                                   ref, ours, theirs);
+                                   fancy.buf, ours, theirs);
                else
                        strbuf_addf(stat, _("[ahead %d, behind %d]"),
                                    ours, theirs);
        }
+       strbuf_release(&fancy);
        strbuf_addch(stat, ' ');
        free(ref);
 }
index 40f87b4649aa97ca1f33a02f09f5938ce5f41f74..045cee7bce0cfc130d6964bab941a44558ec35a6 100644 (file)
 #define BATCH 1
 #define BATCH_CHECK 2
 
-static void pprint_tag(const unsigned char *sha1, const char *buf, unsigned long size)
-{
-       /* the parser in tag.c is useless here. */
-       const char *endp = buf + size;
-       const char *cp = buf;
-
-       while (cp < endp) {
-               char c = *cp++;
-               if (c != '\n')
-                       continue;
-               if (7 <= endp - cp && !memcmp("tagger ", cp, 7)) {
-                       const char *tagger = cp;
-
-                       /* Found the tagger line.  Copy out the contents
-                        * of the buffer so far.
-                        */
-                       write_or_die(1, buf, cp - buf);
-
-                       /*
-                        * Do something intelligent, like pretty-printing
-                        * the date.
-                        */
-                       while (cp < endp) {
-                               if (*cp++ == '\n') {
-                                       /* tagger to cp is a line
-                                        * that has ident and time.
-                                        */
-                                       const char *sp = tagger;
-                                       char *ep;
-                                       unsigned long date;
-                                       long tz;
-                                       while (sp < cp && *sp != '>')
-                                               sp++;
-                                       if (sp == cp) {
-                                               /* give up */
-                                               write_or_die(1, tagger,
-                                                            cp - tagger);
-                                               break;
-                                       }
-                                       while (sp < cp &&
-                                              !('0' <= *sp && *sp <= '9'))
-                                               sp++;
-                                       write_or_die(1, tagger, sp - tagger);
-                                       date = strtoul(sp, &ep, 10);
-                                       tz = strtol(ep, NULL, 10);
-                                       sp = show_date(date, tz, 0);
-                                       write_or_die(1, sp, strlen(sp));
-                                       xwrite(1, "\n", 1);
-                                       break;
-                               }
-                       }
-                       break;
-               }
-               if (cp < endp && *cp == '\n')
-                       /* end of header */
-                       break;
-       }
-       /* At this point, we have copied out the header up to the end of
-        * the tagger line and cp points at one past \n.  It could be the
-        * next header line after the tagger line, or it could be another
-        * \n that marks the end of the headers.  We need to copy out the
-        * remainder as is.
-        */
-       if (cp < endp)
-               write_or_die(1, cp, endp - cp);
-}
-
 static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 {
        unsigned char sha1[20];
@@ -133,10 +66,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                buf = read_sha1_file(sha1, &type, &size);
                if (!buf)
                        die("Cannot read object %s", obj_name);
-               if (type == OBJ_TAG) {
-                       pprint_tag(sha1, buf, size);
-                       return 0;
-               }
 
                /* otherwise just spit out the data */
                break;
index f8033f446e8f9ef1807aa28c2f9eca4e821c42c9..81b4419da51f3211129833a472048d897385bca4 100644 (file)
@@ -35,6 +35,7 @@ struct checkout_opts {
        int force_detach;
        int writeout_stage;
        int overwrite_ignore;
+       int ignore_skipworktree;
 
        const char *new_branch;
        const char *new_branch_force;
@@ -278,6 +279,8 @@ static int checkout_paths(const struct checkout_opts *opts,
        for (pos = 0; pos < active_nr; pos++) {
                struct cache_entry *ce = active_cache[pos];
                ce->ce_flags &= ~CE_MATCHED;
+               if (!opts->ignore_skipworktree && ce_skip_worktree(ce))
+                       continue;
                if (opts->source_tree && !(ce->ce_flags & CE_UPDATE))
                        /*
                         * "git checkout tree-ish -- path", but this entry
@@ -729,7 +732,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
                        "If you want to keep them by creating a new branch, "
                        "this may be a good time\nto do so with:\n\n"
                        " git branch new_branch_name %s\n\n"),
-                       sha1_to_hex(commit->object.sha1));
+                       find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
 }
 
 /*
@@ -1058,6 +1061,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                OPT_STRING(0, "conflict", &conflict_style, N_("style"),
                           N_("conflict style (merge or diff3)")),
                OPT_BOOLEAN('p', "patch", &opts.patch_mode, N_("select hunks interactively")),
+               OPT_BOOL(0, "ignore-skip-worktree-bits", &opts.ignore_skipworktree,
+                        N_("do not limit pathspecs to sparse entries only")),
                { OPTION_BOOLEAN, 0, "guess", &dwim_new_local_branch, NULL,
                  N_("second guess 'git checkout no-such-branch'"),
                  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
index f9c380eb6c536b657ddc65b88f6839ec761f7f25..58fee9874f0fea4ed52acf31f757268be5383267 100644 (file)
@@ -232,16 +232,26 @@ static void strip_trailing_slashes(char *dir)
 static int add_one_reference(struct string_list_item *item, void *cb_data)
 {
        char *ref_git;
+       const char *repo;
        struct strbuf alternate = STRBUF_INIT;
 
-       /* Beware: real_path() and mkpath() return static buffer */
+       /* Beware: read_gitfile(), real_path() and mkpath() return static buffer */
        ref_git = xstrdup(real_path(item->string));
-       if (is_directory(mkpath("%s/.git/objects", ref_git))) {
+
+       repo = read_gitfile(ref_git);
+       if (!repo)
+               repo = read_gitfile(mkpath("%s/.git", ref_git));
+       if (repo) {
+               free(ref_git);
+               ref_git = xstrdup(repo);
+       }
+
+       if (!repo && is_directory(mkpath("%s/.git/objects", ref_git))) {
                char *ref_git_git = mkpathdup("%s/.git", ref_git);
                free(ref_git);
                ref_git = ref_git_git;
        } else if (!is_directory(mkpath("%s/objects", ref_git)))
-               die(_("reference repository '%s' is not a local directory."),
+               die(_("reference repository '%s' is not a local repository."),
                    item->string);
 
        strbuf_addf(&alternate, "%s/objects", ref_git);
index 3a01a8d08591d93426d436ce2e1e17fccd3ebf78..a7f70cb858e6574562957b739b8a3d42f0353b40 100644 (file)
@@ -79,13 +79,13 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
 }
 
 static char const * const count_objects_usage[] = {
-       N_("git count-objects [-v]"),
+       N_("git count-objects [-v] [-H | --human-readable]"),
        NULL
 };
 
 int cmd_count_objects(int argc, const char **argv, const char *prefix)
 {
-       int i, verbose = 0;
+       int i, verbose = 0, human_readable = 0;
        const char *objdir = get_object_directory();
        int len = strlen(objdir);
        char *path = xmalloc(len + 50);
@@ -93,6 +93,8 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
        off_t loose_size = 0;
        struct option opts[] = {
                OPT__VERBOSE(&verbose, N_("be verbose")),
+               OPT_BOOL('H', "human-readable", &human_readable,
+                        N_("print sizes in human readable format")),
                OPT_END(),
        };
 
@@ -119,6 +121,9 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
                struct packed_git *p;
                unsigned long num_pack = 0;
                off_t size_pack = 0;
+               struct strbuf loose_buf = STRBUF_INIT;
+               struct strbuf pack_buf = STRBUF_INIT;
+               struct strbuf garbage_buf = STRBUF_INIT;
                if (!packed_git)
                        prepare_packed_git();
                for (p = packed_git; p; p = p->next) {
@@ -130,17 +135,40 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
                        size_pack += p->pack_size + p->index_size;
                        num_pack++;
                }
+
+               if (human_readable) {
+                       strbuf_humanise_bytes(&loose_buf, loose_size);
+                       strbuf_humanise_bytes(&pack_buf, size_pack);
+                       strbuf_humanise_bytes(&garbage_buf, size_garbage);
+               } else {
+                       strbuf_addf(&loose_buf, "%lu",
+                                   (unsigned long)(loose_size / 1024));
+                       strbuf_addf(&pack_buf, "%lu",
+                                   (unsigned long)(size_pack / 1024));
+                       strbuf_addf(&garbage_buf, "%lu",
+                                   (unsigned long)(size_garbage / 1024));
+               }
+
                printf("count: %lu\n", loose);
-               printf("size: %lu\n", (unsigned long) (loose_size / 1024));
+               printf("size: %s\n", loose_buf.buf);
                printf("in-pack: %lu\n", packed);
                printf("packs: %lu\n", num_pack);
-               printf("size-pack: %lu\n", (unsigned long) (size_pack / 1024));
+               printf("size-pack: %s\n", pack_buf.buf);
                printf("prune-packable: %lu\n", packed_loose);
                printf("garbage: %lu\n", garbage);
-               printf("size-garbage: %lu\n", (unsigned long) (size_garbage / 1024));
+               printf("size-garbage: %s\n", garbage_buf.buf);
+               strbuf_release(&loose_buf);
+               strbuf_release(&pack_buf);
+               strbuf_release(&garbage_buf);
+       } else {
+               struct strbuf buf = STRBUF_INIT;
+               if (human_readable)
+                       strbuf_humanise_bytes(&buf, loose_size);
+               else
+                       strbuf_addf(&buf, "%lu kilobytes",
+                                   (unsigned long)(loose_size / 1024));
+               printf("%lu objects, %s\n", loose, buf.buf);
+               strbuf_release(&buf);
        }
-       else
-               printf("%lu objects, %lu kilobytes\n",
-                      loose, (unsigned long) (loose_size / 1024));
        return 0;
 }
index 265a9253bfd7cacd730789212fdb5284fcd270ac..1c040708696c8d6e81023b3261966fa751f14ad4 100644 (file)
@@ -287,10 +287,10 @@ static void credit_people(struct strbuf *out,
        const char *me;
 
        if (kind == 'a') {
-               label = "\n# By ";
+               label = "By";
                me = git_author_info(IDENT_NO_DATE);
        } else {
-               label = "\n# Via ";
+               label = "Via";
                me = git_committer_info(IDENT_NO_DATE);
        }
 
@@ -300,7 +300,7 @@ static void credit_people(struct strbuf *out,
             (me = skip_prefix(me, them->items->string)) != NULL &&
             skip_prefix(me, " <")))
                return;
-       strbuf_addstr(out, label);
+       strbuf_addf(out, "\n%c %s ", comment_line_char, label);
        add_people_count(out, them);
 }
 
@@ -503,14 +503,18 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
                } else {
                        if (tag_number == 2) {
                                struct strbuf tagline = STRBUF_INIT;
-                               strbuf_addf(&tagline, "\n# %s\n",
-                                           origins.items[first_tag].string);
+                               strbuf_addch(&tagline, '\n');
+                               strbuf_add_commented_lines(&tagline,
+                                               origins.items[first_tag].string,
+                                               strlen(origins.items[first_tag].string));
                                strbuf_insert(&tagbuf, 0, tagline.buf,
                                              tagline.len);
                                strbuf_release(&tagline);
                        }
-                       strbuf_addf(&tagbuf, "\n# %s\n",
-                                   origins.items[i].string);
+                       strbuf_addch(&tagbuf, '\n');
+                       strbuf_add_commented_lines(&tagbuf,
+                                       origins.items[i].string,
+                                       strlen(origins.items[i].string));
                        fmt_tag_signature(&tagbuf, &sig, buf, len);
                }
                strbuf_release(&sig);
index 0f318107e5732a08bc6f979633829ea958d8f9b0..ad46f72950f3e4fda292da25f936e48c59705410 100644 (file)
@@ -100,9 +100,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
        int quiet = 0, source = 0, mailmap = 0;
 
        const struct option builtin_log_options[] = {
-               OPT_BOOLEAN(0, "quiet", &quiet, N_("suppress diff output")),
-               OPT_BOOLEAN(0, "source", &source, N_("show source")),
-               OPT_BOOLEAN(0, "use-mailmap", &mailmap, N_("Use mail map file")),
+               OPT_BOOL(0, "quiet", &quiet, N_("suppress diff output")),
+               OPT_BOOL(0, "source", &source, N_("show source")),
+               OPT_BOOL(0, "use-mailmap", &mailmap, N_("Use mail map file")),
                { OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),
                  PARSE_OPT_OPTARG, decorate_callback},
                OPT_END()
@@ -622,6 +622,14 @@ static void add_header(const char *value)
 static int thread;
 static int do_signoff;
 static const char *signature = git_version_string;
+static int config_cover_letter;
+
+enum {
+       COVER_UNSET,
+       COVER_OFF,
+       COVER_ON,
+       COVER_AUTO
+};
 
 static int git_format_config(const char *var, const char *value, void *cb)
 {
@@ -683,6 +691,14 @@ static int git_format_config(const char *var, const char *value, void *cb)
        }
        if (!strcmp(var, "format.signature"))
                return git_config_string(&signature, var, value);
+       if (!strcmp(var, "format.coverletter")) {
+               if (value && !strcasecmp(value, "auto")) {
+                       config_cover_letter = COVER_AUTO;
+                       return 0;
+               }
+               config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;
+               return 0;
+       }
 
        return git_log_config(var, value, cb);
 }
@@ -794,9 +810,37 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
        }
 }
 
+static char *find_branch_name(struct rev_info *rev)
+{
+       int i, positive = -1;
+       unsigned char branch_sha1[20];
+       const unsigned char *tip_sha1;
+       const char *ref;
+       char *full_ref, *branch = NULL;
+
+       for (i = 0; i < rev->cmdline.nr; i++) {
+               if (rev->cmdline.rev[i].flags & UNINTERESTING)
+                       continue;
+               if (positive < 0)
+                       positive = i;
+               else
+                       return NULL;
+       }
+       if (positive < 0)
+               return NULL;
+       ref = rev->cmdline.rev[positive].name;
+       tip_sha1 = rev->cmdline.rev[positive].item->sha1;
+       if (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&
+           !prefixcmp(full_ref, "refs/heads/") &&
+           !hashcmp(tip_sha1, branch_sha1))
+               branch = xstrdup(full_ref + strlen("refs/heads/"));
+       free(full_ref);
+       return branch;
+}
+
 static void make_cover_letter(struct rev_info *rev, int use_stdout,
                              struct commit *origin,
-                             int nr, struct commit **list, struct commit *head,
+                             int nr, struct commit **list,
                              const char *branch_name,
                              int quiet)
 {
@@ -810,6 +854,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        struct diff_options opts;
        int need_8bit_cte = 0;
        struct pretty_print_context pp = {0};
+       struct commit *head = list[0];
 
        if (rev->commit_format != CMIT_FMT_EMAIL)
                die(_("Cover letter needs email format"));
@@ -827,6 +872,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
                if (has_non_ascii(list[i]->buffer))
                        need_8bit_cte = 1;
 
+       if (!branch_name)
+               branch_name = find_branch_name(rev);
+
        msg = body;
        pp.fmt = CMIT_FMT_EMAIL;
        pp.date_mode = DATE_RFC2822;
@@ -1033,45 +1081,6 @@ static int cc_callback(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
-static char *find_branch_name(struct rev_info *rev)
-{
-       int i, positive = -1;
-       unsigned char branch_sha1[20];
-       const unsigned char *tip_sha1;
-       const char *ref;
-       char *full_ref, *branch = NULL;
-
-       for (i = 0; i < rev->cmdline.nr; i++) {
-               if (rev->cmdline.rev[i].flags & UNINTERESTING)
-                       continue;
-               if (positive < 0)
-                       positive = i;
-               else
-                       return NULL;
-       }
-       if (0 <= positive) {
-               ref = rev->cmdline.rev[positive].name;
-               tip_sha1 = rev->cmdline.rev[positive].item->sha1;
-       } else if (!rev->cmdline.nr && rev->pending.nr == 1 &&
-                  !strcmp(rev->pending.objects[0].name, "HEAD")) {
-               /*
-                * No actual ref from command line, but "HEAD" from
-                * rev->def was added in setup_revisions()
-                * e.g. format-patch --cover-letter -12
-                */
-               ref = "HEAD";
-               tip_sha1 = rev->pending.objects[0].item->sha1;
-       } else {
-               return NULL;
-       }
-       if (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&
-           !prefixcmp(full_ref, "refs/heads/") &&
-           !hashcmp(tip_sha1, branch_sha1))
-               branch = xstrdup(full_ref + strlen("refs/heads/"));
-       free(full_ref);
-       return branch;
-}
-
 int cmd_format_patch(int argc, const char **argv, const char *prefix)
 {
        struct commit *commit;
@@ -1083,10 +1092,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        int start_number = -1;
        int just_numbers = 0;
        int ignore_if_in_upstream = 0;
-       int cover_letter = 0;
+       int cover_letter = -1;
        int boundary_count = 0;
        int no_binary_diff = 0;
-       struct commit *origin = NULL, *head = NULL;
+       struct commit *origin = NULL;
        const char *in_reply_to = NULL;
        struct patch_ids ids;
        struct strbuf buf = STRBUF_INIT;
@@ -1101,12 +1110,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                { OPTION_CALLBACK, 'N', "no-numbered", &numbered, NULL,
                            N_("use [PATCH] even with multiple patches"),
                            PARSE_OPT_NOARG, no_numbered_callback },
-               OPT_BOOLEAN('s', "signoff", &do_signoff, N_("add Signed-off-by:")),
-               OPT_BOOLEAN(0, "stdout", &use_stdout,
+               OPT_BOOL('s', "signoff", &do_signoff, N_("add Signed-off-by:")),
+               OPT_BOOL(0, "stdout", &use_stdout,
                            N_("print patches to standard out")),
-               OPT_BOOLEAN(0, "cover-letter", &cover_letter,
+               OPT_BOOL(0, "cover-letter", &cover_letter,
                            N_("generate a cover letter")),
-               OPT_BOOLEAN(0, "numbered-files", &just_numbers,
+               OPT_BOOL(0, "numbered-files", &just_numbers,
                            N_("use simple number sequence for output file names")),
                OPT_STRING(0, "suffix", &fmt_patch_suffix, N_("sfx"),
                            N_("use <sfx> instead of '.patch'")),
@@ -1280,28 +1289,36 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        }
 
        if (rev.pending.nr == 1) {
+               int check_head = 0;
+
                if (rev.max_count < 0 && !rev.show_root_diff) {
                        /*
                         * This is traditional behaviour of "git format-patch
                         * origin" that prepares what the origin side still
                         * does not have.
                         */
-                       unsigned char sha1[20];
-                       const char *ref;
-
                        rev.pending.objects[0].item->flags |= UNINTERESTING;
                        add_head_to_pending(&rev);
-                       ref = resolve_ref_unsafe("HEAD", sha1, 1, NULL);
-                       if (ref && !prefixcmp(ref, "refs/heads/"))
-                               branch_name = xstrdup(ref + strlen("refs/heads/"));
-                       else
-                               branch_name = xstrdup(""); /* no branch */
+                       check_head = 1;
                }
                /*
                 * Otherwise, it is "format-patch -22 HEAD", and/or
                 * "format-patch --root HEAD".  The user wants
                 * get_revision() to do the usual traversal.
                 */
+
+               if (!strcmp(rev.pending.objects[0].name, "HEAD"))
+                       check_head = 1;
+
+               if (check_head) {
+                       unsigned char sha1[20];
+                       const char *ref;
+                       ref = resolve_ref_unsafe("HEAD", sha1, 1, NULL);
+                       if (ref && !prefixcmp(ref, "refs/heads/"))
+                               branch_name = xstrdup(ref + strlen("refs/heads/"));
+                       else
+                               branch_name = xstrdup(""); /* no branch */
+               }
        }
 
        /*
@@ -1310,29 +1327,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
         */
        rev.show_root_diff = 1;
 
-       if (cover_letter) {
-               /*
-                * NEEDSWORK:randomly pick one positive commit to show
-                * diffstat; this is often the tip and the command
-                * happens to do the right thing in most cases, but a
-                * complex command like "--cover-letter a b c ^bottom"
-                * picks "c" and shows diffstat between bottom..c
-                * which may not match what the series represents at
-                * all and totally broken.
-                */
-               int i;
-               for (i = 0; i < rev.pending.nr; i++) {
-                       struct object *o = rev.pending.objects[i].item;
-                       if (!(o->flags & UNINTERESTING))
-                               head = (struct commit *)o;
-               }
-               /* There is nothing to show; it is not an error, though. */
-               if (!head)
-                       return 0;
-               if (!branch_name)
-                       branch_name = find_branch_name(&rev);
-       }
-
        if (ignore_if_in_upstream) {
                /* Don't say anything if head and upstream are the same. */
                if (rev.pending.nr == 2) {
@@ -1364,11 +1358,21 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                list = xrealloc(list, nr * sizeof(list[0]));
                list[nr - 1] = commit;
        }
+       if (nr == 0)
+               /* nothing to do */
+               return 0;
        total = nr;
        if (!keep_subject && auto_number && total > 1)
                numbered = 1;
        if (numbered)
                rev.total = total + start_number - 1;
+       if (cover_letter == -1) {
+               if (config_cover_letter == COVER_AUTO)
+                       cover_letter = (total > 1);
+               else
+                       cover_letter = (config_cover_letter == COVER_ON);
+       }
+
        if (in_reply_to || thread || cover_letter)
                rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
        if (in_reply_to) {
@@ -1381,7 +1385,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                if (thread)
                        gen_message_id(&rev, "cover");
                make_cover_letter(&rev, use_stdout,
-                                 origin, nr, list, head, branch_name, quiet);
+                                 origin, nr, list, branch_name, quiet);
                total++;
                start_number--;
        }
index bc912e399efa295615e9bfaac0de03904edff367..ed25d81b880eb830481d4e729d7e9acc3266de65 100644 (file)
@@ -155,6 +155,11 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
                a->mode == b->mode;
 }
 
+static int both_empty(struct name_entry *a, struct name_entry *b)
+{
+       return !(a->sha1 || b->sha1);
+}
+
 static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)
 {
        struct merge_list *res = xcalloc(1, sizeof(*res));
@@ -297,13 +302,10 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
 static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
 {
        /* Same in both? */
-       if (same_entry(entry+1, entry+2)) {
-               if (entry[0].sha1) {
-                       /* Modified identically */
-                       resolve(info, NULL, entry+1);
-                       return mask;
-               }
-               /* "Both added the same" is left unresolved */
+       if (same_entry(entry+1, entry+2) || both_empty(entry+0, entry+2)) {
+               /* Modified, added or removed identically */
+               resolve(info, NULL, entry+1);
+               return mask;
        }
 
        if (same_entry(entry+0, entry+1)) {
@@ -319,12 +321,10 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s
                 */
        }
 
-       if (same_entry(entry+0, entry+2)) {
-               if (entry[1].sha1 && !S_ISDIR(entry[1].mode)) {
-                       /* We modified, they did not touch -- take ours */
-                       resolve(info, NULL, entry+1);
-                       return mask;
-               }
+       if (same_entry(entry+0, entry+2) || both_empty(entry+0, entry+2)) {
+               /* We added, modified or removed, they did not touch -- take ours */
+               resolve(info, NULL, entry+1);
+               return mask;
        }
 
        unresolved(info, entry);
index ccebd74f166f5d02e8e6a0bb6033d741f8580f7b..e3eb5fc0588a79b2b6c29bccdaf71ba49dc14c1f 100644 (file)
@@ -826,8 +826,11 @@ static const char *unpack(int err_fd)
                            : 0);
 
        hdr_err = parse_pack_header(&hdr);
-       if (hdr_err)
+       if (hdr_err) {
+               if (err_fd > 0)
+                       close(err_fd);
                return hdr_err;
+       }
        snprintf(hdr_arg, sizeof(hdr_arg),
                        "--pack_header=%"PRIu32",%"PRIu32,
                        ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));
index d208fd6c6821c729a713edb485a20bbe8d5e2692..90fc6b1b9d2a397ae43dfc4c0aba6bc192c9823c 100644 (file)
@@ -162,29 +162,28 @@ static void name_commits(struct commit_list *list,
                        nth = 0;
                        while (parents) {
                                struct commit *p = parents->item;
-                               char newname[1000], *en;
+                               struct strbuf newname = STRBUF_INIT;
                                parents = parents->next;
                                nth++;
                                if (p->util)
                                        continue;
-                               en = newname;
                                switch (n->generation) {
                                case 0:
-                                       en += sprintf(en, "%s", n->head_name);
+                                       strbuf_addstr(&newname, n->head_name);
                                        break;
                                case 1:
-                                       en += sprintf(en, "%s^", n->head_name);
+                                       strbuf_addf(&newname, "%s^", n->head_name);
                                        break;
                                default:
-                                       en += sprintf(en, "%s~%d",
-                                               n->head_name, n->generation);
+                                       strbuf_addf(&newname, "%s~%d",
+                                                   n->head_name, n->generation);
                                        break;
                                }
                                if (nth == 1)
-                                       en += sprintf(en, "^");
+                                       strbuf_addch(&newname, '^');
                                else
-                                       en += sprintf(en, "^%d", nth);
-                               name_commit(p, xstrdup(newname), 0);
+                                       strbuf_addf(&newname, "^%d", nth);
+                               name_commit(p, strbuf_detach(&newname, NULL), 0);
                                i++;
                                name_first_parent_chain(p);
                        }
index 505e07e93468b68454c7ec906f40eacea9746551..4b0e5cd51b82f916c26d3776f81f22cdb3045fa6 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -57,7 +57,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
                 * followed by SP and subject line.
                 */
                if (get_sha1_hex(buf.buf, sha1) ||
-                   (40 <= buf.len && !isspace(buf.buf[40])) ||
+                   (buf.len > 40 && !isspace(buf.buf[40])) ||
                    (!is_prereq && buf.len <= 40)) {
                        if (report_path)
                                error(_("unrecognized header: %s%s (%d)"),
diff --git a/cache.h b/cache.h
index e1e8ce80ed11efb9483fca3205f383a3f0825cd7..94ca1acf704bd2dfdc561b6b2d3d64740b975f61 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -311,6 +311,7 @@ extern void free_name_hash(struct index_state *istate);
 #define resolve_undo_clear() resolve_undo_clear_index(&the_index)
 #define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)
 #define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)
+#define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz))
 #endif
 
 enum object_type {
@@ -465,11 +466,13 @@ extern int remove_file_from_index(struct index_state *, const char *path);
 #define ADD_CACHE_IGNORE_ERRORS        4
 #define ADD_CACHE_IGNORE_REMOVAL 8
 #define ADD_CACHE_INTENT 16
+#define ADD_CACHE_IMPLICIT_DOT 32      /* internal to "git add -u/-A" */
 extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
 extern int add_file_to_index(struct index_state *, const char *path, int flags);
 extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);
 extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
 extern int index_name_is_other(const struct index_state *, const char *, int);
+extern void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
 
 /* do stat comparison even if CE_VALID is true */
 #define CE_MATCH_IGNORE_VALID          01
index 9080054f7617017a67ca0ae8414f829a01d3d546..d78fd3df5b211130ba8ff77197a3f852c32aab86 100644 (file)
@@ -507,6 +507,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
                compat/win32/dirent.o
        EXTLIBS += -lws2_32
        PTHREAD_LIBS =
+       NATIVE_CRLF = YesPlease
        X = .exe
        SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
 ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
index 2ba1461422c4e6c16e6c85ed3914536e1f4aa56e..6df62c217321b4f66fd230a1b95f2b3cfe2becd2 100644 (file)
@@ -53,19 +53,6 @@ __gitdir ()
        fi
 }
 
-__gitcomp_1 ()
-{
-       local c IFS=$' \t\n'
-       for c in $1; do
-               c="$c$2"
-               case $c in
-               --*=*|*.) ;;
-               *) c="$c " ;;
-               esac
-               printf '%s\n' "$c"
-       done
-}
-
 # The following function is based on code from:
 #
 #   bash_completion - programmable completion functions for bash 3.2+
@@ -195,8 +182,18 @@ _get_comp_words_by_ref ()
 }
 fi
 
-# Generates completion reply with compgen, appending a space to possible
-# completion words, if necessary.
+__gitcompadd ()
+{
+       local i=0
+       for x in $1; do
+               if [[ "$x" == "$3"* ]]; then
+                       COMPREPLY[i++]="$2$x$4"
+               fi
+       done
+}
+
+# Generates completion reply, appending a space to possible completion words,
+# if necessary.
 # It accepts 1 to 4 arguments:
 # 1: List of possible completion words.
 # 2: A prefix to be added to each possible completion word (optional).
@@ -208,19 +205,25 @@ __gitcomp ()
 
        case "$cur_" in
        --*=)
-               COMPREPLY=()
                ;;
        *)
-               local IFS=$'\n'
-               COMPREPLY=($(compgen -P "${2-}" \
-                       -W "$(__gitcomp_1 "${1-}" "${4-}")" \
-                       -- "$cur_"))
+               local c i=0 IFS=$' \t\n'
+               for c in $1; do
+                       c="$c${4-}"
+                       if [[ $c == "$cur_"* ]]; then
+                               case $c in
+                               --*=*|*.) ;;
+                               *) c="$c " ;;
+                               esac
+                               COMPREPLY[i++]="${2-}$c"
+                       fi
+               done
                ;;
        esac
 }
 
-# Generates completion reply with compgen from newline-separated possible
-# completion words by appending a space to all of them.
+# Generates completion reply from newline-separated possible completion words
+# by appending a space to all of them.
 # It accepts 1 to 4 arguments:
 # 1: List of possible completion words, separated by a single newline.
 # 2: A prefix to be added to each possible completion word (optional).
@@ -231,7 +234,7 @@ __gitcomp ()
 __gitcomp_nl ()
 {
        local IFS=$'\n'
-       COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
+       __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
 }
 
 # Generates completion reply with compgen from newline-separated possible
@@ -614,7 +617,6 @@ __git_complete_remote_or_refspec ()
                        case "$cmd" in
                        push) no_complete_refspec=1 ;;
                        fetch)
-                               COMPREPLY=()
                                return
                                ;;
                        *) ;;
@@ -630,7 +632,6 @@ __git_complete_remote_or_refspec ()
                return
        fi
        if [ $no_complete_refspec = 1 ]; then
-               COMPREPLY=()
                return
        fi
        [ "$remote" = "." ] && remote=
@@ -951,7 +952,6 @@ _git_am ()
                        "
                return
        esac
-       COMPREPLY=()
 }
 
 _git_apply ()
@@ -971,7 +971,6 @@ _git_apply ()
                        "
                return
        esac
-       COMPREPLY=()
 }
 
 _git_add ()
@@ -1031,7 +1030,6 @@ _git_bisect ()
                __gitcomp_nl "$(__git_refs)"
                ;;
        *)
-               COMPREPLY=()
                ;;
        esac
 }
@@ -1124,9 +1122,14 @@ _git_cherry ()
 
 _git_cherry_pick ()
 {
+       local dir="$(__gitdir)"
+       if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
+               __gitcomp "--continue --quit --abort"
+               return
+       fi
        case "$cur" in
        --*)
-               __gitcomp "--edit --no-commit"
+               __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
                ;;
        *)
                __gitcomp_nl "$(__git_refs)"
@@ -1170,7 +1173,6 @@ _git_clone ()
                return
                ;;
        esac
-       COMPREPLY=()
 }
 
 _git_commit ()
@@ -1354,7 +1356,6 @@ _git_fsck ()
                return
                ;;
        esac
-       COMPREPLY=()
 }
 
 _git_gc ()
@@ -1365,7 +1366,6 @@ _git_gc ()
                return
                ;;
        esac
-       COMPREPLY=()
 }
 
 _git_gitk ()
@@ -1442,7 +1442,6 @@ _git_init ()
                return
                ;;
        esac
-       COMPREPLY=()
 }
 
 _git_ls_files ()
@@ -1578,7 +1577,6 @@ _git_mergetool ()
                return
                ;;
        esac
-       COMPREPLY=()
 }
 
 _git_merge_base ()
@@ -1831,7 +1829,7 @@ _git_config ()
                local remote="${prev#remote.}"
                remote="${remote%.fetch}"
                if [ -z "$cur" ]; then
-                       COMPREPLY=("refs/heads/")
+                       __gitcompadd "refs/heads/" "" "" ""
                        return
                fi
                __gitcomp_nl "$(__git_refs_remotes "$remote")"
@@ -1891,7 +1889,6 @@ _git_config ()
                return
                ;;
        *.*)
-               COMPREPLY=()
                return
                ;;
        esac
@@ -2272,7 +2269,6 @@ _git_remote ()
                __gitcomp "$c"
                ;;
        *)
-               COMPREPLY=()
                ;;
        esac
 }
@@ -2388,8 +2384,6 @@ _git_stash ()
                *)
                        if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
                                __gitcomp "$subcommands"
-                       else
-                               COMPREPLY=()
                        fi
                        ;;
                esac
@@ -2402,14 +2396,12 @@ _git_stash ()
                        __gitcomp "--index --quiet"
                        ;;
                show,--*|drop,--*|branch,--*)
-                       COMPREPLY=()
                        ;;
                show,*|apply,*|drop,*|pop,*|branch,*)
                        __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
                                        | sed -n -e 's/:.*//p')"
                        ;;
                *)
-                       COMPREPLY=()
                        ;;
                esac
        fi
@@ -2526,7 +2518,6 @@ _git_svn ()
                        __gitcomp "--revision= --parent"
                        ;;
                *)
-                       COMPREPLY=()
                        ;;
                esac
        fi
@@ -2551,13 +2542,10 @@ _git_tag ()
 
        case "$prev" in
        -m|-F)
-               COMPREPLY=()
                ;;
        -*|tag)
                if [ $f = 1 ]; then
                        __gitcomp_nl "$(__git_tags)"
-               else
-                       COMPREPLY=()
                fi
                ;;
        *)
index 756a9514591c7664c82c93d3a6d50d91f46857d8..054c52e90aeabb9a9ab5d4f9ee38b0799126b338 100644 (file)
@@ -340,7 +340,7 @@ __git_ps1 ()
                           [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
                           [ -n "$(git ls-files --others --exclude-standard)" ]
                        then
-                               u="%"
+                               u="%${ZSH_VERSION+%}"
                        fi
 
                        if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
index bd25e082027f90e614f3f265b94b49979d96e49f..aa7bc97beecc6af7adca5b6886d8e7c61f9173b1 100755 (executable)
@@ -249,7 +249,7 @@ def export_files(tree, files):
     return final
 
 def export_branch(branch, name):
-    global prefix, dirname
+    global prefix
 
     ref = '%s/heads/%s' % (prefix, name)
     tip = marks.get_tip(name)
@@ -335,8 +335,10 @@ def export_branch(branch, name):
     marks.set_tip(name, revid)
 
 def export_tag(repo, name):
-    global tags
-    print "reset refs/tags/%s" % name
+    global tags, prefix
+
+    ref = '%s/tags/%s' % (prefix, name)
+    print "reset %s" % ref
     print "from :%u" % rev_to_mark(tags[name])
     print
 
@@ -649,6 +651,7 @@ def do_capabilities(parser):
     print "import"
     print "export"
     print "refspec refs/heads/*:%s/heads/*" % prefix
+    print "refspec refs/tags/*:%s/tags/*" % prefix
 
     path = os.path.join(dirname, 'marks-git')
 
index 328c2dc76dd33e47cfe69064757631e9717771e6..548133121d23a328d76d68d058fd4fb14b60fb16 100755 (executable)
@@ -8,8 +8,11 @@
 # Just copy to your ~/bin, or anywhere in your $PATH.
 # Then you can clone with:
 # git clone hg::/path/to/mercurial/repo/
+#
+# For remote repositories a local clone is stored in
+# "$GIT_DIR/hg/origin/clone/.hg/".
 
-from mercurial import hg, ui, bookmarks, context, util, encoding
+from mercurial import hg, ui, bookmarks, context, util, encoding, node, error
 
 import re
 import sys
@@ -18,11 +21,22 @@ import json
 import shutil
 import subprocess
 import urllib
+import atexit
 
 #
 # If you want to switch to hg-git compatibility mode:
 # git config --global remote-hg.hg-git-compat true
 #
+# If you are not in hg-git-compat mode and want to disable the tracking of
+# named branches:
+# git config --global remote-hg.track-branches false
+#
+# If you don't want to force pushes (and thus risk creating new remote heads):
+# git config --global remote-hg.force-push false
+#
+# If you want the equivalent of hg's clone/pull--insecure option:
+# git config remote-hg.insecure true
+#
 # git:
 # Sensible defaults for git.
 # hg bookmarks are exported as git branches, hg branches are prefixed
@@ -56,6 +70,9 @@ def hgmode(mode):
     m = { '100755': 'x', '120000': 'l' }
     return m.get(mode, '')
 
+def hghex(node):
+    return hg.node.hex(node)
+
 def get_config(config):
     cmd = ['git', 'config', '--get', config]
     process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
@@ -188,9 +205,15 @@ class Parser:
         tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
         return (user, int(date), -tz)
 
+def fix_file_path(path):
+    if not os.path.isabs(path):
+        return path
+    return os.path.relpath(path, '/')
+
 def export_file(fc):
     d = fc.data()
-    print "M %s inline %s" % (gitmode(fc.flags()), fc.path())
+    path = fix_file_path(fc.path())
+    print "M %s inline %s" % (gitmode(fc.flags()), path)
     print "data %d" % len(d)
     print d
 
@@ -267,17 +290,30 @@ def get_repo(url, alias):
 
     myui = ui.ui()
     myui.setconfig('ui', 'interactive', 'off')
+    myui.fout = sys.stderr
+
+    try:
+        if get_config('remote-hg.insecure') == 'true\n':
+            myui.setconfig('web', 'cacerts', '')
+    except subprocess.CalledProcessError:
+        pass
 
     if hg.islocal(url):
         repo = hg.repository(myui, url)
     else:
         local_path = os.path.join(dirname, 'clone')
         if not os.path.exists(local_path):
-            peer, dstpeer = hg.clone(myui, {}, url, local_path, update=False, pull=True)
+            try:
+                peer, dstpeer = hg.clone(myui, {}, url, local_path, update=True, pull=True)
+            except:
+                die('Repository error')
             repo = dstpeer.local()
         else:
             repo = hg.repository(myui, local_path)
-            peer = hg.peer(myui, {}, url)
+            try:
+                peer = hg.peer(myui, {}, url)
+            except:
+                die('Repository error')
             repo.pull(peer, heads=None, force=True)
 
     return repo
@@ -326,6 +362,8 @@ def export_ref(repo, name, kind, head):
         else:
             modified, removed = get_filechanges(repo, c, parents[0])
 
+        desc += '\n'
+
         if mode == 'hg':
             extra_msg = ''
 
@@ -349,7 +387,6 @@ def export_ref(repo, name, kind, head):
                 else:
                     extra_msg += "extra : %s : %s\n" % (key, urllib.quote(value))
 
-            desc += '\n'
             if extra_msg:
                 desc += '\n--HG--\n' + extra_msg
 
@@ -371,7 +408,7 @@ def export_ref(repo, name, kind, head):
         for f in modified:
             export_file(c.filectx(f))
         for f in removed:
-            print "D %s" % (f)
+            print "D %s" % (fix_file_path(f))
         print
 
         count += 1
@@ -531,7 +568,6 @@ def parse_blob(parser):
     data = parser.get_data()
     blob_marks[mark] = data
     parser.next()
-    return
 
 def get_merge_files(repo, p1, p2, files):
     for e in repo[p1].files():
@@ -542,7 +578,7 @@ def get_merge_files(repo, p1, p2, files):
             files[e] = f
 
 def parse_commit(parser):
-    global marks, blob_marks, bmarks, parsed_refs
+    global marks, blob_marks, parsed_refs
     global mode
 
     from_mark = merge_mark = None
@@ -575,7 +611,7 @@ def parse_commit(parser):
             mark = int(mark_ref[1:])
             f = { 'mode' : hgmode(m), 'data' : blob_marks[mark] }
         elif parser.check('D'):
-            t, path = line.split(' ')
+            t, path = line.split(' ', 1)
             f = { 'deleted' : True }
         else:
             die('Unknown file command: %s' % line)
@@ -618,11 +654,15 @@ def parse_commit(parser):
     if merge_mark:
         get_merge_files(repo, p1, p2, files)
 
+    # Check if the ref is supposed to be a named branch
+    if ref.startswith('refs/heads/branches/'):
+        extra['branch'] = ref[len('refs/heads/branches/'):]
+
     if mode == 'hg':
         i = data.find('\n--HG--\n')
         if i >= 0:
             tmp = data[i + len('\n--HG--\n'):].strip()
-            for k, v in [e.split(' : ') for e in tmp.split('\n')]:
+            for k, v in [e.split(' : ', 1) for e in tmp.split('\n')]:
                 if k == 'rename':
                     old, new = v.split(' => ', 1)
                     files[new]['rename'] = old
@@ -647,10 +687,11 @@ def parse_commit(parser):
     rev = repo[node].rev()
 
     parsed_refs[ref] = node
-
     marks.new_mark(rev, commit_mark)
 
 def parse_reset(parser):
+    global parsed_refs
+
     ref = parser[1]
     parser.next()
     # ugh
@@ -680,6 +721,8 @@ def parse_tag(parser):
 def do_export(parser):
     global parsed_refs, bmarks, peer
 
+    p_bmarks = []
+
     parser.next()
 
     for line in parser.each_block('done'):
@@ -698,28 +741,55 @@ def do_export(parser):
 
     for ref, node in parsed_refs.iteritems():
         if ref.startswith('refs/heads/branches'):
-            pass
+            print "ok %s" % ref
         elif ref.startswith('refs/heads/'):
             bmark = ref[len('refs/heads/'):]
-            if bmark in bmarks:
-                old = bmarks[bmark].hex()
-            else:
-                old = ''
-            if not bookmarks.pushbookmark(parser.repo, bmark, old, node):
-                continue
+            p_bmarks.append((bmark, node))
+            continue
         elif ref.startswith('refs/tags/'):
             tag = ref[len('refs/tags/'):]
-            parser.repo.tag([tag], node, None, True, None, {})
+            if mode == 'git':
+                msg = 'Added tag %s for changeset %s' % (tag, hghex(node[:6]));
+                parser.repo.tag([tag], node, msg, False, None, {})
+            else:
+                parser.repo.tag([tag], node, None, True, None, {})
+            print "ok %s" % ref
         else:
             # transport-helper/fast-export bugs
             continue
+
+    if peer:
+        parser.repo.push(peer, force=force_push)
+
+    # handle bookmarks
+    for bmark, node in p_bmarks:
+        ref = 'refs/heads/' + bmark
+        new = hghex(node)
+
+        if bmark in bmarks:
+            old = bmarks[bmark].hex()
+        else:
+            old = ''
+
+        if bmark == 'master' and 'master' not in parser.repo._bookmarks:
+            # fake bookmark
+            pass
+        elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
+            # updated locally
+            pass
+        else:
+            print "error %s" % ref
+            continue
+
+        if peer:
+            if not peer.pushkey('bookmarks', bmark, old, new):
+                print "error %s" % ref
+                continue
+
         print "ok %s" % ref
 
     print
 
-    if peer:
-        parser.repo.push(peer, force=False)
-
 def fix_path(alias, repo, orig_url):
     repo_url = util.url(repo.url())
     url = util.url(orig_url)
@@ -732,7 +802,7 @@ def main(args):
     global prefix, dirname, branches, bmarks
     global marks, blob_marks, parsed_refs
     global peer, mode, bad_mail, bad_name
-    global track_branches
+    global track_branches, force_push, is_tmp
 
     alias = args[1]
     url = args[2]
@@ -740,12 +810,16 @@ def main(args):
 
     hg_git_compat = False
     track_branches = True
+    force_push = True
+
     try:
         if get_config('remote-hg.hg-git-compat') == 'true\n':
             hg_git_compat = True
             track_branches = False
         if get_config('remote-hg.track-branches') == 'false\n':
             track_branches = False
+        if get_config('remote-hg.force-push') == 'false\n':
+            force_push = False
     except subprocess.CalledProcessError:
         pass
 
@@ -770,6 +844,7 @@ def main(args):
     bmarks = {}
     blob_marks = {}
     parsed_refs = {}
+    marks = None
 
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
@@ -797,9 +872,13 @@ def main(args):
             die('unhandled command: %s' % line)
         sys.stdout.flush()
 
+def bye():
+    if not marks:
+        return
     if not is_tmp:
         marks.store()
     else:
         shutil.rmtree(dirname)
 
+atexit.register(bye)
 sys.exit(main(sys.argv))
index 1d6198243667c655639781019d8d608e0791e00b..f36895311ea6b0dc8206498cad4aef94c822c83f 100755 (executable)
@@ -22,7 +22,6 @@ fi
 
 # clone to a git repo
 git_clone () {
-       hg -R $1 bookmark -f -r tip master &&
        git clone -q "hg::$PWD/$1" $2
 }
 
@@ -30,6 +29,7 @@ git_clone () {
 hg_clone () {
        (
        hg init $2 &&
+       hg -R $2 bookmark -i master &&
        cd $1 &&
        git push -q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
        ) &&
@@ -50,7 +50,8 @@ hg_push () {
 }
 
 hg_log () {
-       hg -R $1 log --graph --debug | grep -v 'tag: *default/'
+       hg -R $1 log --graph --debug >log &&
+       grep -v 'tag: *default/' log
 }
 
 setup () {
@@ -62,6 +63,8 @@ setup () {
        echo "commit = -d \"0 0\""
        echo "debugrawcommit = -d \"0 0\""
        echo "tag = -d \"0 0\""
+       echo "[extensions]"
+       echo "graphlog ="
        ) >> "$HOME"/.hgrc &&
        git config --global remote-hg.hg-git-compat true
 
@@ -200,8 +203,8 @@ test_expect_success 'hg branch' '
        hg_push hgrepo gitrepo &&
        hg_clone gitrepo hgrepo2 &&
 
-       : TODO, avoid "master" bookmark &&
-       (cd hgrepo2 && hg checkout gamma) &&
+       : Back to the common revision &&
+       (cd hgrepo && hg checkout default) &&
 
        hg_log hgrepo > expected &&
        hg_log hgrepo2 > actual &&
index 3f253b7de75a6fa44c4cff3b2e1f53f9feffcf5d..253e65aaa8881581b971eb51d518a4ad393f4b3d 100755 (executable)
@@ -27,7 +27,6 @@ fi
 
 # clone to a git repo with git
 git_clone_git () {
-       hg -R $1 bookmark -f -r tip master &&
        git clone -q "hg::$PWD/$1" $2
 }
 
@@ -35,6 +34,7 @@ git_clone_git () {
 hg_clone_git () {
        (
        hg init $2 &&
+       hg -R $2 bookmark -i master &&
        cd $1 &&
        git push -q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
        ) &&
@@ -47,7 +47,7 @@ git_clone_hg () {
        (
        git init -q $2 &&
        cd $1 &&
-       hg bookmark -f -r tip master &&
+       hg bookmark -i -f -r tip master &&
        hg -q push -r master ../$2 || true
        )
 }
@@ -78,7 +78,8 @@ hg_push_hg () {
 }
 
 hg_log () {
-       hg -R $1 log --graph --debug | grep -v 'tag: *default/'
+       hg -R $1 log --graph --debug >log &&
+       grep -v 'tag: *default/' log
 }
 
 git_log () {
@@ -97,6 +98,7 @@ setup () {
        echo "[extensions]"
        echo "hgext.bookmarks ="
        echo "hggit ="
+       echo "graphlog ="
        ) >> "$HOME"/.hgrc &&
        git config --global receive.denycurrentbranch warn
        git config --global remote-hg.hg-git-compat true
index 7bb81f2f8e0e288eb7e392075491fc1df0bd91d1..d5b873051f5d79e277fb8ed6cfcd0db85f0d429f 100755 (executable)
@@ -118,4 +118,40 @@ test_expect_success 'update bookmark' '
   hg -R hgrepo bookmarks | egrep "devel[        ]+3:"
 '
 
+author_test () {
+  echo $1 >> content &&
+  hg commit -u "$2" -m "add $1" &&
+  echo "$3" >> ../expected
+}
+
+test_expect_success 'authors' '
+  mkdir -p tmp && cd tmp &&
+  test_when_finished "cd .. && rm -rf tmp" &&
+
+  (
+  hg init hgrepo &&
+  cd hgrepo &&
+
+  touch content &&
+  hg add content &&
+
+  author_test alpha "" "H G Wells <wells@example.com>" &&
+  author_test beta "test" "test <unknown>" &&
+  author_test beta "test <test@example.com> (comment)" "test <unknown>" &&
+  author_test gamma "<test@example.com>" "Unknown <test@example.com>" &&
+  author_test delta "name<test@example.com>" "name <test@example.com>" &&
+  author_test epsilon "name <test@example.com" "name <unknown>" &&
+  author_test zeta " test " "test <unknown>" &&
+  author_test eta "test < test@example.com >" "test <test@example.com>" &&
+  author_test theta "test >test@example.com>" "test <unknown>" &&
+  author_test iota "test < test <at> example <dot> com>" "test <unknown>" &&
+  author_test kappa "test@example.com" "test@example.com <unknown>"
+  ) &&
+
+  git clone "hg::$PWD/hgrepo" gitrepo &&
+  git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
+
+  test_cmp expected actual
+'
+
 test_done
index 3520252d3abaf49d4b7682ad083da8b7ae6be4c6..2a2e46c2012de3af673b9d8d8647ec894f07b65a 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -153,36 +153,13 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,
 
 static int has_cr_in_index(const char *path)
 {
-       int pos, len;
        unsigned long sz;
-       enum object_type type;
        void *data;
        int has_cr;
-       struct index_state *istate = &the_index;
 
-       len = strlen(path);
-       pos = index_name_pos(istate, path, len);
-       if (pos < 0) {
-               /*
-                * We might be in the middle of a merge, in which
-                * case we would read stage #2 (ours).
-                */
-               int i;
-               for (i = -pos - 1;
-                    (pos < 0 && i < istate->cache_nr &&
-                     !strcmp(istate->cache[i]->name, path));
-                    i++)
-                       if (ce_stage(istate->cache[i]) == 2)
-                               pos = i;
-       }
-       if (pos < 0)
+       data = read_blob_data_from_cache(path, &sz);
+       if (!data)
                return 0;
-       data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
-       if (!data || type != OBJ_BLOB) {
-               free(data);
-               return 0;
-       }
-
        has_cr = memchr(data, '\r', sz) != NULL;
        free(data);
        return has_cr;
diff --git a/diff.c b/diff.c
index 0eb26535f52adf516961672628f2810e55a31a9d..f0b3e7cfe34a99c0e5fea85fcd00ec54e9b578d8 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -2255,6 +2255,7 @@ static void builtin_diff(const char *name_a,
                const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
                const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
                show_submodule_summary(o->file, one ? one->path : two->path,
+                               line_prefix,
                                one->sha1, two->sha1, two->dirty_submodule,
                                meta, del, add, reset);
                return;
@@ -3596,8 +3597,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
                options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
        else if (!strcmp(arg, "--histogram"))
                options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
-       else if (!prefixcmp(arg, "--diff-algorithm=")) {
-               long value = parse_algorithm_value(arg+17);
+       else if ((argcount = parse_long_opt("diff-algorithm", av, &optarg))) {
+               long value = parse_algorithm_value(optarg);
                if (value < 0)
                        return error("option diff-algorithm accepts \"myers\", "
                                     "\"minimal\", \"patience\" and \"histogram\"");
@@ -3605,6 +3606,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
                DIFF_XDL_CLR(options, NEED_MINIMAL);
                options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
                options->xdl_opts |= value;
+               return argcount;
        }
 
        /* flags options */
index 99efbe884528ffa730d6c0297e20d9de93d5ad9e..c58eea7cb6b34d69e812d2bac8f514272f679beb 100755 (executable)
@@ -311,7 +311,13 @@ bisect_next() {
        res=$?
 
        # Check if we should exit because bisection is finished
-       test $res -eq 10 && exit 0
+       if test $res -eq 10
+       then
+               bad_rev=$(git show-ref --hash --verify refs/bisect/bad)
+               bad_commit=$(git show-branch $bad_rev)
+               echo "# first bad commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
+               exit 0
+       fi
 
        # Check for an error in the bisection process
        test $res -ne 0 && exit $res
index cde442fb5f47cd13757e09ae435963bc061db083..e955bb5e8b3101cc8c753cf541beabf5cd037b39 100644 (file)
@@ -331,6 +331,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
 
 extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
 extern void set_error_routine(void (*routine)(const char *err, va_list params));
+extern void set_die_is_recursing_routine(int (*routine)(void));
 
 extern int prefixcmp(const char *str, const char *prefix);
 extern int suffixcmp(const char *str, const char *suffix);
index 97f31dc7af43bafe36d3222ba2f78da861a4e620..f84854f09a14b92790bad543cbe78c2662def9f7 100644 (file)
@@ -31,8 +31,8 @@ else
        rm -f "$GIT_DIR/rebased-patches"
 
        git format-patch -k --stdout --full-index --ignore-if-in-upstream \
-               --src-prefix=a/ --dst-prefix=b/ \
-               --no-renames $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
+               --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
+               $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
        ret=$?
 
        if test 0 != $ret
index 729747281864155bee7ef009de3ab92cc7643a89..bd13cc812d2a0115edcdd2c3ec146665ddfc5e29 100755 (executable)
@@ -54,7 +54,7 @@ sub usage {
     --[no-]bcc              <str>  * Email Bcc:
     --subject               <str>  * Email "Subject:"
     --in-reply-to           <str>  * Email "In-Reply-To:"
-    --annotate                     * Review each patch that will be sent in an editor.
+    --[no-]annotate                * Review each patch that will be sent in an editor.
     --compose                      * Open an editor for introduction.
     --compose-encoding      <str>  * Encoding to assume for introduction.
     --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared
@@ -212,7 +212,8 @@ sub do_edit {
     "signedoffbycc" => [\$signed_off_by_cc, undef],
     "signedoffcc" => [\$signed_off_by_cc, undef],      # Deprecated
     "validate" => [\$validate, 1],
-    "multiedit" => [\$multiedit, undef]
+    "multiedit" => [\$multiedit, undef],
+    "annotate" => [\$annotate, undef]
 );
 
 my %config_settings = (
@@ -304,7 +305,7 @@ sub signal_handler {
                    "smtp-debug:i" => \$debug_net_smtp,
                    "smtp-domain:s" => \$smtp_domain,
                    "identity=s" => \$identity,
-                   "annotate" => \$annotate,
+                   "annotate!" => \$annotate,
                    "compose" => \$compose,
                    "quiet" => \$quiet,
                    "cc-cmd=s" => \$cc_cmd,
index 08f3dda02d43f9b2e994ee2f7a8dccaecb82733e..408f2859d3c42becc333b8c0e4ee6366de7fdb14 100644 (file)
@@ -243,14 +243,11 @@ for gitweb (in gitweb/README), and gitweb.conf(5) manpage.
   GITWEB_CONFIG_SYSTEM build configuration variable, and override it
   through the GITWEB_CONFIG_SYSTEM environment variable.
 
-  Note that if per-instance configuration file exists, then system-wide
-  configuration is _not used at all_.  This is quite untypical and surprising
-  behavior.  On the other hand changing current behavior would break backwards
-  compatibility and can lead to unexpected changes in gitweb behavior.
-  Therefore gitweb also looks for common system-wide configuration file,
-  normally /etc/gitweb-common.conf (set during build time using build time
-  configuration variable GITWEB_CONFIG_COMMON, set it at runtime using
-  environment variable with the same name).  Settings from per-instance or
+  Note that the GITWEB_CONFIG_SYSTEM system-wide configuration file is
+  only used for instances that lack per-instance configuration file.
+  You can use GITWEB_CONFIG_COMMON common system-wide configuration
+  file (normally /etc/gitweb-common.conf) to keep common default
+  settings that apply to all instances.  Settings from per-instance or
   system-wide configuration file override those from common system-wide
   configuration file.
 
diff --git a/help.c b/help.c
index 1dfa0b05827e6e75dc463092b2838cd1c991623c..02ba043319932411e90121d4147f25395782dfb5 100644 (file)
--- a/help.c
+++ b/help.c
@@ -397,6 +397,10 @@ const char *help_unknown_cmd(const char *cmd)
 
 int cmd_version(int argc, const char **argv, const char *prefix)
 {
+       /*
+        * The format of this string should be kept stable for compatibility
+        * with external projects that rely on the output of "git version".
+        */
        printf("git version %s\n", git_version_string);
        return 0;
 }
index 8144f3ad5eb68c789fd031921e6e702170310d68..6b85ffac271596cf469984a06d27423af7df2b35 100644 (file)
@@ -361,17 +361,19 @@ static void run_service(const char **argv)
 static int show_text_ref(const char *name, const unsigned char *sha1,
        int flag, void *cb_data)
 {
+       const char *name_nons = strip_namespace(name);
        struct strbuf *buf = cb_data;
        struct object *o = parse_object(sha1);
        if (!o)
                return 0;
 
-       strbuf_addf(buf, "%s\t%s\n", sha1_to_hex(sha1), name);
+       strbuf_addf(buf, "%s\t%s\n", sha1_to_hex(sha1), name_nons);
        if (o->type == OBJ_TAG) {
                o = deref_tag(o, name, 0);
                if (!o)
                        return 0;
-               strbuf_addf(buf, "%s\t%s^{}\n", sha1_to_hex(o->sha1), name);
+               strbuf_addf(buf, "%s\t%s^{}\n", sha1_to_hex(o->sha1),
+                           name_nons);
        }
        return 0;
 }
@@ -402,12 +404,40 @@ static void get_info_refs(char *arg)
 
        } else {
                select_getanyfile();
-               for_each_ref(show_text_ref, &buf);
+               for_each_namespaced_ref(show_text_ref, &buf);
                send_strbuf("text/plain", &buf);
        }
        strbuf_release(&buf);
 }
 
+static int show_head_ref(const char *name, const unsigned char *sha1,
+       int flag, void *cb_data)
+{
+       struct strbuf *buf = cb_data;
+
+       if (flag & REF_ISSYMREF) {
+               unsigned char sha1[20];
+               const char *target = resolve_ref_unsafe(name, sha1, 1, NULL);
+               const char *target_nons = strip_namespace(target);
+
+               strbuf_addf(buf, "ref: %s\n", target_nons);
+       } else {
+               strbuf_addf(buf, "%s\n", sha1_to_hex(sha1));
+       }
+
+       return 0;
+}
+
+static void get_head(char *arg)
+{
+       struct strbuf buf = STRBUF_INIT;
+
+       select_getanyfile();
+       head_ref_namespaced(show_head_ref, &buf);
+       send_strbuf("text/plain", &buf);
+       strbuf_release(&buf);
+}
+
 static void get_info_packs(char *arg)
 {
        size_t objdirlen = strlen(get_object_directory());
@@ -520,7 +550,7 @@ static struct service_cmd {
        const char *pattern;
        void (*imp)(char *);
 } services[] = {
-       {"GET", "/HEAD$", get_text_file},
+       {"GET", "/HEAD$", get_head},
        {"GET", "/info/refs$", get_info_refs},
        {"GET", "/objects/info/alternates$", get_text_file},
        {"GET", "/objects/info/http-alternates$", get_text_file},
index bd66f6ab6edd24946d2bc84e117a2b97417b1503..395a8cfc1055fb6febc9cee559d8943bb4d9e829 100644 (file)
@@ -1551,7 +1551,7 @@ static int remote_exists(const char *path)
                ret = 0;
                break;
        case HTTP_ERROR:
-               http_error(url, HTTP_ERROR);
+               error("unable to access '%s': %s", url, curl_errorstr);
        default:
                ret = -1;
        }
diff --git a/http.c b/http.c
index 8803c70825ac8aefb619b6c56d6015573eb5d227..92aba59082a4ed9aa0c92d8522793abcd332e279 100644 (file)
--- a/http.c
+++ b/http.c
@@ -31,6 +31,7 @@ static CURL *curl_default;
 char curl_errorstr[CURL_ERROR_SIZE];
 
 static int curl_ssl_verify = -1;
+static int curl_ssl_try;
 static const char *ssl_cert;
 #if LIBCURL_VERSION_NUM >= 0x070903
 static const char *ssl_key;
@@ -163,6 +164,10 @@ static int http_options(const char *var, const char *value, void *cb)
                        ssl_cert_password_required = 1;
                return 0;
        }
+       if (!strcmp("http.ssltry", var)) {
+               curl_ssl_try = git_config_bool(var, value);
+               return 0;
+       }
        if (!strcmp("http.minsessions", var)) {
                min_curl_sessions = git_config_int(var, value);
 #ifndef USE_CURL_MULTI
@@ -282,7 +287,6 @@ static CURL *get_curl_handle(void)
 #endif
        if (ssl_cainfo != NULL)
                curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
-       curl_easy_setopt(result, CURLOPT_FAILONERROR, 1);
 
        if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {
                curl_easy_setopt(result, CURLOPT_LOW_SPEED_LIMIT,
@@ -307,6 +311,11 @@ static CURL *get_curl_handle(void)
        if (curl_ftp_no_epsv)
                curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
 
+#ifdef CURLOPT_USE_SSL
+       if (curl_ssl_try)
+               curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);
+#endif
+
        if (curl_http_proxy) {
                curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
                curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
@@ -506,6 +515,7 @@ struct active_request_slot *get_active_slot(void)
        curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
        curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
        curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
+       curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
        if (http_auth.password)
                init_curl_http_auth(slot->curl);
 
@@ -761,6 +771,25 @@ char *get_remote_object_url(const char *url, const char *hex,
 
 int handle_curl_result(struct slot_results *results)
 {
+       /*
+        * If we see a failing http code with CURLE_OK, we have turned off
+        * FAILONERROR (to keep the server's custom error response), and should
+        * translate the code into failure here.
+        */
+       if (results->curl_result == CURLE_OK &&
+           results->http_code >= 400) {
+               results->curl_result = CURLE_HTTP_RETURNED_ERROR;
+               /*
+                * Normally curl will already have put the "reason phrase"
+                * from the server into curl_errorstr; unfortunately without
+                * FAILONERROR it is lost, so we can give only the numeric
+                * status code.
+                */
+               snprintf(curl_errorstr, sizeof(curl_errorstr),
+                        "The requested URL returned error: %ld",
+                        results->http_code);
+       }
+
        if (results->curl_result == CURLE_OK) {
                credential_approve(&http_auth);
                return HTTP_OK;
@@ -825,6 +854,8 @@ static int http_request(const char *url, struct strbuf *type,
        strbuf_addstr(&buf, "Pragma:");
        if (options & HTTP_NO_CACHE)
                strbuf_addstr(&buf, " no-cache");
+       if (options & HTTP_KEEP_ERROR)
+               curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
 
        headers = curl_slist_append(headers, buf.buf);
 
@@ -836,7 +867,8 @@ static int http_request(const char *url, struct strbuf *type,
                run_active_slot(slot);
                ret = handle_curl_result(&results);
        } else {
-               error("Unable to start HTTP request for %s", url);
+               snprintf(curl_errorstr, sizeof(curl_errorstr),
+                        "failed to start HTTP request");
                ret = HTTP_START_FAILED;
        }
 
@@ -862,6 +894,22 @@ static int http_request_reauth(const char *url,
        int ret = http_request(url, type, result, target, options);
        if (ret != HTTP_REAUTH)
                return ret;
+
+       /*
+        * If we are using KEEP_ERROR, the previous request may have
+        * put cruft into our output stream; we should clear it out before
+        * making our next request. We only know how to do this for
+        * the strbuf case, but that is enough to satisfy current callers.
+        */
+       if (options & HTTP_KEEP_ERROR) {
+               switch (target) {
+               case HTTP_REQUEST_STRBUF:
+                       strbuf_reset(result);
+                       break;
+               default:
+                       die("BUG: HTTP_KEEP_ERROR is only supported with strbufs");
+               }
+       }
        return http_request(url, type, result, target, options);
 }
 
@@ -903,15 +951,6 @@ static int http_get_file(const char *url, const char *filename, int options)
        return ret;
 }
 
-int http_error(const char *url, int ret)
-{
-       /* http_request has already handled HTTP_START_FAILED. */
-       if (ret != HTTP_START_FAILED)
-               error("%s while accessing %s", curl_errorstr, url);
-
-       return ret;
-}
-
 int http_fetch_ref(const char *base, struct ref *ref)
 {
        char *url;
diff --git a/http.h b/http.h
index 25d19313983f0d0a11ab50dffbb623b105c8960a..d77c1b54f24d142461b9e1a0d11cf6de041bc59f 100644 (file)
--- a/http.h
+++ b/http.h
 #define NO_CURL_IOCTL
 #endif
 
+/*
+ * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4,
+ * and the constants were known as CURLFTPSSL_*
+*/
+#if !defined(CURLOPT_USE_SSL) && defined(CURLOPT_FTP_SSL)
+#define CURLOPT_USE_SSL CURLOPT_FTP_SSL
+#define CURLUSESSL_TRY CURLFTPSSL_TRY
+#endif
+
 struct slot_results {
        CURLcode curl_result;
        long http_code;
@@ -118,6 +127,7 @@ extern char *get_remote_object_url(const char *url, const char *hex,
 
 /* Options for http_request_*() */
 #define HTTP_NO_CACHE          1
+#define HTTP_KEEP_ERROR                2
 
 /* Return values for http_request_*() */
 #define HTTP_OK                        0
@@ -134,12 +144,6 @@ extern char *get_remote_object_url(const char *url, const char *hex,
  */
 int http_get_strbuf(const char *url, struct strbuf *content_type, struct strbuf *result, int options);
 
-/*
- * Prints an error message using error() containing url and curl_errorstr,
- * and returns ret.
- */
-int http_error(const char *url, int ret);
-
 extern int http_fetch_ref(const char *base, struct ref *ref);
 
 /* Helpers for fetching packs */
index 650db90853c6ff2a769e981afd2954ffbb97469c..dc48159ccab1cf2f888a6169460c5fc60d0d1bab 100644 (file)
@@ -1489,12 +1489,12 @@ sub _command_common_pipe {
                if (not defined $pid) {
                        throw Error::Simple("open failed: $!");
                } elsif ($pid == 0) {
-                       if (defined $opts{STDERR}) {
-                               close STDERR;
-                       }
                        if ($opts{STDERR}) {
                                open (STDERR, '>&', $opts{STDERR})
                                        or die "dup failed: $!";
+                       } elsif (defined $opts{STDERR}) {
+                               open (STDERR, '>', '/dev/null')
+                                       or die "opening /dev/null failed: $!";
                        }
                        _cmd_exec($self, $cmd, @args);
                }
index d3a82d22d398ae7234f8917f4d8b0770ba4d0c47..c11624832bf09d9b4630d8a9b5e213fe2de69c7f 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -393,6 +393,19 @@ static void add_rfc2047(struct strbuf *sb, const char *line, size_t len,
        strbuf_addstr(sb, "?=");
 }
 
+static const char *show_ident_date(const struct ident_split *ident,
+                                  enum date_mode mode)
+{
+       unsigned long date = 0;
+       int tz = 0;
+
+       if (ident->date_begin && ident->date_end)
+               date = strtoul(ident->date_begin, NULL, 10);
+       if (ident->tz_begin && ident->tz_end)
+               tz = strtol(ident->tz_begin, NULL, 10);
+       return show_date(date, tz, mode);
+}
+
 void pp_user_info(const struct pretty_print_context *pp,
                  const char *what, struct strbuf *sb,
                  const char *line, const char *encoding)
@@ -401,12 +414,10 @@ void pp_user_info(const struct pretty_print_context *pp,
        struct strbuf mail;
        struct ident_split ident;
        int linelen;
-       char *line_end, *date;
+       char *line_end;
        const char *mailbuf, *namebuf;
        size_t namelen, maillen;
        int max_length = 78; /* per rfc2822 */
-       unsigned long time;
-       int tz;
 
        if (pp->fmt == CMIT_FMT_ONELINE)
                return;
@@ -438,8 +449,6 @@ void pp_user_info(const struct pretty_print_context *pp,
        strbuf_add(&name, namebuf, namelen);
 
        namelen = name.len + mail.len + 3; /* ' ' + '<' + '>' */
-       time = strtoul(ident.date_begin, &date, 10);
-       tz = strtol(date, NULL, 10);
 
        if (pp->fmt == CMIT_FMT_EMAIL) {
                strbuf_addstr(sb, "From: ");
@@ -472,13 +481,16 @@ void pp_user_info(const struct pretty_print_context *pp,
 
        switch (pp->fmt) {
        case CMIT_FMT_MEDIUM:
-               strbuf_addf(sb, "Date:   %s\n", show_date(time, tz, pp->date_mode));
+               strbuf_addf(sb, "Date:   %s\n",
+                           show_ident_date(&ident, pp->date_mode));
                break;
        case CMIT_FMT_EMAIL:
-               strbuf_addf(sb, "Date: %s\n", show_date(time, tz, DATE_RFC2822));
+               strbuf_addf(sb, "Date: %s\n",
+                           show_ident_date(&ident, DATE_RFC2822));
                break;
        case CMIT_FMT_FULLER:
-               strbuf_addf(sb, "%sDate: %s\n", what, show_date(time, tz, pp->date_mode));
+               strbuf_addf(sb, "%sDate: %s\n", what,
+                           show_ident_date(&ident, pp->date_mode));
                break;
        default:
                /* notin' */
@@ -688,8 +700,6 @@ static size_t format_person_part(struct strbuf *sb, char part,
 {
        /* currently all placeholders have same length */
        const int placeholder_len = 2;
-       int tz;
-       unsigned long date = 0;
        struct ident_split s;
        const char *name, *mail;
        size_t maillen, namelen;
@@ -716,30 +726,23 @@ static size_t format_person_part(struct strbuf *sb, char part,
        if (!s.date_begin)
                goto skip;
 
-       date = strtoul(s.date_begin, NULL, 10);
-
        if (part == 't') {      /* date, UNIX timestamp */
                strbuf_add(sb, s.date_begin, s.date_end - s.date_begin);
                return placeholder_len;
        }
 
-       /* parse tz */
-       tz = strtoul(s.tz_begin + 1, NULL, 10);
-       if (*s.tz_begin == '-')
-               tz = -tz;
-
        switch (part) {
        case 'd':       /* date */
-               strbuf_addstr(sb, show_date(date, tz, dmode));
+               strbuf_addstr(sb, show_ident_date(&s, dmode));
                return placeholder_len;
        case 'D':       /* date, RFC2822 style */
-               strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
+               strbuf_addstr(sb, show_ident_date(&s, DATE_RFC2822));
                return placeholder_len;
        case 'r':       /* date, relative */
-               strbuf_addstr(sb, show_date(date, tz, DATE_RELATIVE));
+               strbuf_addstr(sb, show_ident_date(&s, DATE_RELATIVE));
                return placeholder_len;
        case 'i':       /* date, ISO 8601 */
-               strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
+               strbuf_addstr(sb, show_ident_date(&s, DATE_ISO8601));
                return placeholder_len;
        }
 
index 3971f49f4ddaa774806bd1717379a1edd22ba17c..10652b174d1ccfb941b3d4122a882f1af3323084 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "git-compat-util.h"
 #include "progress.h"
+#include "strbuf.h"
 
 #define TP_IDX_MAX      8
 
@@ -112,34 +113,14 @@ static int display(struct progress *progress, unsigned n, const char *done)
        return 0;
 }
 
-static void throughput_string(struct throughput *tp, off_t total,
+static void throughput_string(struct strbuf *buf, off_t total,
                              unsigned int rate)
 {
-       int l = sizeof(tp->display);
-       if (total > 1 << 30) {
-               l -= snprintf(tp->display, l, ", %u.%2.2u GiB",
-                             (int)(total >> 30),
-                             (int)(total & ((1 << 30) - 1)) / 10737419);
-       } else if (total > 1 << 20) {
-               int x = total + 5243;  /* for rounding */
-               l -= snprintf(tp->display, l, ", %u.%2.2u MiB",
-                             x >> 20, ((x & ((1 << 20) - 1)) * 100) >> 20);
-       } else if (total > 1 << 10) {
-               int x = total + 5;  /* for rounding */
-               l -= snprintf(tp->display, l, ", %u.%2.2u KiB",
-                             x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);
-       } else {
-               l -= snprintf(tp->display, l, ", %u bytes", (int)total);
-       }
-
-       if (rate > 1 << 10) {
-               int x = rate + 5;  /* for rounding */
-               snprintf(tp->display + sizeof(tp->display) - l, l,
-                        " | %u.%2.2u MiB/s",
-                        x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);
-       } else if (rate)
-               snprintf(tp->display + sizeof(tp->display) - l, l,
-                        " | %u KiB/s", rate);
+       strbuf_addstr(buf, ", ");
+       strbuf_humanise_bytes(buf, total);
+       strbuf_addstr(buf, " | ");
+       strbuf_humanise_bytes(buf, rate * 1024);
+       strbuf_addstr(buf, "/s");
 }
 
 void display_throughput(struct progress *progress, off_t total)
@@ -183,6 +164,7 @@ void display_throughput(struct progress *progress, off_t total)
        misecs += (int)(tv.tv_usec - tp->prev_tv.tv_usec) / 977;
 
        if (misecs > 512) {
+               struct strbuf buf = STRBUF_INIT;
                unsigned int count, rate;
 
                count = total - tp->prev_total;
@@ -197,7 +179,9 @@ void display_throughput(struct progress *progress, off_t total)
                tp->last_misecs[tp->idx] = misecs;
                tp->idx = (tp->idx + 1) % TP_IDX_MAX;
 
-               throughput_string(tp, total, rate);
+               throughput_string(&buf, total, rate);
+               strncpy(tp->display, buf.buf, sizeof(tp->display));
+               strbuf_release(&buf);
                if (progress->last_value != -1 && progress_update)
                        display(progress, progress->last_value, NULL);
        }
@@ -253,9 +237,12 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
 
                bufp = (len < sizeof(buf)) ? buf : xmalloc(len + 1);
                if (tp) {
+                       struct strbuf strbuf = STRBUF_INIT;
                        unsigned int rate = !tp->avg_misecs ? 0 :
                                        tp->avg_bytes / tp->avg_misecs;
-                       throughput_string(tp, tp->curr_total, rate);
+                       throughput_string(&strbuf, tp->curr_total, rate);
+                       strncpy(tp->display, strbuf.buf, sizeof(tp->display));
+                       strbuf_release(&strbuf);
                }
                progress_update = 1;
                sprintf(bufp, ", %s.\n", msg);
index 5a9704f4e5b974a46bc5486373a26816c5b3b4bd..04ed561bfe7dd8fbf1988190f95eb1cc3530ff58 100644 (file)
@@ -1899,3 +1899,37 @@ int index_name_is_other(const struct index_state *istate, const char *name,
        }
        return 1;
 }
+
+void *read_blob_data_from_index(struct index_state *istate, const char *path, unsigned long *size)
+{
+       int pos, len;
+       unsigned long sz;
+       enum object_type type;
+       void *data;
+
+       len = strlen(path);
+       pos = index_name_pos(istate, path, len);
+       if (pos < 0) {
+               /*
+                * We might be in the middle of a merge, in which
+                * case we would read stage #2 (ours).
+                */
+               int i;
+               for (i = -pos - 1;
+                    (pos < 0 && i < istate->cache_nr &&
+                     !strcmp(istate->cache[i]->name, path));
+                    i++)
+                       if (ce_stage(istate->cache[i]) == 2)
+                               pos = i;
+       }
+       if (pos < 0)
+               return NULL;
+       data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
+       if (!data || type != OBJ_BLOB) {
+               free(data);
+               return NULL;
+       }
+       if (size)
+               *size = sz;
+       return data;
+}
index 93a09a64c3b1689b0f29a26c6cdd601ef298b975..60eda6308197ad3d0b5957b9ae34e2dc15dfe5cc 100644 (file)
@@ -151,6 +151,33 @@ static void free_discovery(struct discovery *d)
        }
 }
 
+static int show_http_message(struct strbuf *type, struct strbuf *msg)
+{
+       const char *p, *eol;
+
+       /*
+        * We only show text/plain parts, as other types are likely
+        * to be ugly to look at on the user's terminal.
+        *
+        * TODO should handle "; charset=XXX", and re-encode into
+        * logoutputencoding
+        */
+       if (strcasecmp(type->buf, "text/plain"))
+               return -1;
+
+       strbuf_trim(msg);
+       if (!msg->len)
+               return -1;
+
+       p = msg->buf;
+       do {
+               eol = strchrnul(p, '\n');
+               fprintf(stderr, "remote: %.*s\n", (int)(eol - p), p);
+               p = eol + 1;
+       } while(*eol);
+       return 0;
+}
+
 static struct discovery* discover_refs(const char *service, int for_push)
 {
        struct strbuf exp = STRBUF_INIT;
@@ -176,18 +203,20 @@ static struct discovery* discover_refs(const char *service, int for_push)
        }
        refs_url = strbuf_detach(&buffer, NULL);
 
-       http_ret = http_get_strbuf(refs_url, &type, &buffer, HTTP_NO_CACHE);
+       http_ret = http_get_strbuf(refs_url, &type, &buffer,
+                                  HTTP_NO_CACHE | HTTP_KEEP_ERROR);
        switch (http_ret) {
        case HTTP_OK:
                break;
        case HTTP_MISSING_TARGET:
-               die("%s not found: did you run git update-server-info on the"
-                   " server?", refs_url);
+               show_http_message(&type, &buffer);
+               die("repository '%s' not found", url);
        case HTTP_NOAUTH:
-               die("Authentication failed");
+               show_http_message(&type, &buffer);
+               die("Authentication failed for '%s'", url);
        default:
-               http_error(refs_url, http_ret);
-               die("HTTP request failed");
+               show_http_message(&type, &buffer);
+               die("unable to access '%s': %s", url, curl_errorstr);
        }
 
        last= xcalloc(1, sizeof(*last_discovery));
index eb981288686a2c7cd8c854e3f414b606ed4f8c69..56d666d69a8a961d33651c0658f7009967e0b7ab 100644 (file)
@@ -1276,7 +1276,8 @@ static void read_revisions_from_stdin(struct rev_info *revs,
                        }
                        die("options not supported in --stdin mode");
                }
-               if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
+               if (handle_revision_arg(xstrdup(sb.buf), revs, 0,
+                                       REVARG_CANNOT_BE_FILENAME))
                        die("bad revision '%s'", sb.buf);
        }
        if (seen_dashdash)
index 765c2ce0567ad0d75270283397d63eac3674c01a..1b32a12a29b64fcc7d8b2401b00fb8a70ff81bad 100644 (file)
@@ -588,6 +588,7 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
 static pthread_t main_thread;
 static int main_thread_set;
 static pthread_key_t async_key;
+static pthread_key_t async_die_counter;
 
 static void *run_thread(void *data)
 {
@@ -614,6 +615,14 @@ static NORETURN void die_async(const char *err, va_list params)
 
        exit(128);
 }
+
+static int async_die_is_recursing(void)
+{
+       void *ret = pthread_getspecific(async_die_counter);
+       pthread_setspecific(async_die_counter, (void *)1);
+       return ret != NULL;
+}
+
 #endif
 
 int start_async(struct async *async)
@@ -695,7 +704,9 @@ int start_async(struct async *async)
                main_thread_set = 1;
                main_thread = pthread_self();
                pthread_key_create(&async_key, NULL);
+               pthread_key_create(&async_die_counter, NULL);
                set_die_routine(die_async);
+               set_die_is_recursing_routine(async_die_is_recursing);
        }
 
        if (proc_in >= 0)
index ee4f8c6ed4f040072b4d706c26d04a07f665c9f6..cf8fbeb8d5ac2b6ca3b498f2115c02eeea22910a 100644 (file)
@@ -1047,6 +1047,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 {
        struct commit_list *todo_list = NULL;
        unsigned char sha1[20];
+       int i;
 
        if (opts->subcommand == REPLAY_NONE)
                assert(opts->revs);
@@ -1067,6 +1068,23 @@ int sequencer_pick_revisions(struct replay_opts *opts)
        if (opts->subcommand == REPLAY_CONTINUE)
                return sequencer_continue(opts);
 
+       for (i = 0; i < opts->revs->pending.nr; i++) {
+               unsigned char sha1[20];
+               const char *name = opts->revs->pending.objects[i].name;
+
+               /* This happens when using --stdin. */
+               if (!strlen(name))
+                       continue;
+
+               if (!get_sha1(name, sha1)) {
+                       enum object_type type = sha1_object_info(sha1, NULL);
+
+                       if (type > 0 && type != OBJ_COMMIT)
+                               die(_("%s: can't cherry-pick a %s"), name, typename(type));
+               } else
+                       die(_("%s: bad revision"), name);
+       }
+
        /*
         * If we were called as "git cherry-pick <commit>", just
         * cherry-pick/revert it, set CHERRY_PICK_HEAD /
index 0ed23981b363a07c6f4c5b930b1a5991d5c8a622..64228a26d0be873040ebde37e95e62d20f5ba957 100644 (file)
@@ -1648,50 +1648,6 @@ static off_t get_delta_base(struct packed_git *p,
        return base_offset;
 }
 
-/* forward declaration for a mutually recursive function */
-static int packed_object_info(struct packed_git *p, off_t offset,
-                             unsigned long *sizep, int *rtype);
-
-static int packed_delta_info(struct packed_git *p,
-                            struct pack_window **w_curs,
-                            off_t curpos,
-                            enum object_type type,
-                            off_t obj_offset,
-                            unsigned long *sizep)
-{
-       off_t base_offset;
-
-       base_offset = get_delta_base(p, w_curs, &curpos, type, obj_offset);
-       if (!base_offset)
-               return OBJ_BAD;
-       type = packed_object_info(p, base_offset, NULL, NULL);
-       if (type <= OBJ_NONE) {
-               struct revindex_entry *revidx;
-               const unsigned char *base_sha1;
-               revidx = find_pack_revindex(p, base_offset);
-               if (!revidx)
-                       return OBJ_BAD;
-               base_sha1 = nth_packed_object_sha1(p, revidx->nr);
-               mark_bad_packed_object(p, base_sha1);
-               type = sha1_object_info(base_sha1, NULL);
-               if (type <= OBJ_NONE)
-                       return OBJ_BAD;
-       }
-
-       /* We choose to only get the type of the base object and
-        * ignore potentially corrupt pack file that expects the delta
-        * based on a base with a wrong size.  This saves tons of
-        * inflate() calls.
-        */
-       if (sizep) {
-               *sizep = get_size_from_delta(p, w_curs, curpos);
-               if (*sizep == 0)
-                       type = OBJ_BAD;
-       }
-
-       return type;
-}
-
 int unpack_object_header(struct packed_git *p,
                         struct pack_window **w_curs,
                         off_t *curpos,
@@ -1718,6 +1674,25 @@ int unpack_object_header(struct packed_git *p,
        return type;
 }
 
+static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)
+{
+       int type;
+       struct revindex_entry *revidx;
+       const unsigned char *sha1;
+       revidx = find_pack_revindex(p, obj_offset);
+       if (!revidx)
+               return OBJ_BAD;
+       sha1 = nth_packed_object_sha1(p, revidx->nr);
+       mark_bad_packed_object(p, sha1);
+       type = sha1_object_info(sha1, NULL);
+       if (type <= OBJ_NONE)
+               return OBJ_BAD;
+       return type;
+}
+
+
+#define POI_STACK_PREALLOC 64
+
 static int packed_object_info(struct packed_git *p, off_t obj_offset,
                              unsigned long *sizep, int *rtype)
 {
@@ -1725,31 +1700,89 @@ static int packed_object_info(struct packed_git *p, off_t obj_offset,
        unsigned long size;
        off_t curpos = obj_offset;
        enum object_type type;
+       off_t small_poi_stack[POI_STACK_PREALLOC];
+       off_t *poi_stack = small_poi_stack;
+       int poi_stack_nr = 0, poi_stack_alloc = POI_STACK_PREALLOC;
 
        type = unpack_object_header(p, &w_curs, &curpos, &size);
+
        if (rtype)
                *rtype = type; /* representation type */
 
+       if (sizep) {
+               if (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {
+                       off_t tmp_pos = curpos;
+                       off_t base_offset = get_delta_base(p, &w_curs, &tmp_pos,
+                                                          type, obj_offset);
+                       if (!base_offset) {
+                               type = OBJ_BAD;
+                               goto out;
+                       }
+                       *sizep = get_size_from_delta(p, &w_curs, tmp_pos);
+                       if (*sizep == 0) {
+                               type = OBJ_BAD;
+                               goto out;
+                       }
+               } else {
+                       *sizep = size;
+               }
+       }
+
+       while (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {
+               off_t base_offset;
+               /* Push the object we're going to leave behind */
+               if (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {
+                       poi_stack_alloc = alloc_nr(poi_stack_nr);
+                       poi_stack = xmalloc(sizeof(off_t)*poi_stack_alloc);
+                       memcpy(poi_stack, small_poi_stack, sizeof(off_t)*poi_stack_nr);
+               } else {
+                       ALLOC_GROW(poi_stack, poi_stack_nr+1, poi_stack_alloc);
+               }
+               poi_stack[poi_stack_nr++] = obj_offset;
+               /* If parsing the base offset fails, just unwind */
+               base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
+               if (!base_offset)
+                       goto unwind;
+               curpos = obj_offset = base_offset;
+               type = unpack_object_header(p, &w_curs, &curpos, &size);
+               if (type <= OBJ_NONE) {
+                       /* If getting the base itself fails, we first
+                        * retry the base, otherwise unwind */
+                       type = retry_bad_packed_offset(p, base_offset);
+                       if (type > OBJ_NONE)
+                               goto out;
+                       goto unwind;
+               }
+       }
+
        switch (type) {
-       case OBJ_OFS_DELTA:
-       case OBJ_REF_DELTA:
-               type = packed_delta_info(p, &w_curs, curpos,
-                                        type, obj_offset, sizep);
-               break;
+       case OBJ_BAD:
        case OBJ_COMMIT:
        case OBJ_TREE:
        case OBJ_BLOB:
        case OBJ_TAG:
-               if (sizep)
-                       *sizep = size;
                break;
        default:
                error("unknown object type %i at offset %"PRIuMAX" in %s",
                      type, (uintmax_t)obj_offset, p->pack_name);
                type = OBJ_BAD;
        }
+
+out:
+       if (poi_stack != small_poi_stack)
+               free(poi_stack);
        unuse_pack(&w_curs);
        return type;
+
+unwind:
+       while (poi_stack_nr) {
+               obj_offset = poi_stack[--poi_stack_nr];
+               type = retry_bad_packed_offset(p, obj_offset);
+               if (type > OBJ_NONE)
+                       goto out;
+       }
+       type = OBJ_BAD;
+       goto out;
 }
 
 static void *unpack_compressed_entry(struct packed_git *p,
@@ -1811,32 +1844,51 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset)
        return hash % MAX_DELTA_CACHE;
 }
 
-static int in_delta_base_cache(struct packed_git *p, off_t base_offset)
+static struct delta_base_cache_entry *
+get_delta_base_cache_entry(struct packed_git *p, off_t base_offset)
 {
        unsigned long hash = pack_entry_hash(p, base_offset);
-       struct delta_base_cache_entry *ent = delta_base_cache + hash;
+       return delta_base_cache + hash;
+}
+
+static int eq_delta_base_cache_entry(struct delta_base_cache_entry *ent,
+                                    struct packed_git *p, off_t base_offset)
+{
        return (ent->data && ent->p == p && ent->base_offset == base_offset);
 }
 
+static int in_delta_base_cache(struct packed_git *p, off_t base_offset)
+{
+       struct delta_base_cache_entry *ent;
+       ent = get_delta_base_cache_entry(p, base_offset);
+       return eq_delta_base_cache_entry(ent, p, base_offset);
+}
+
+static void clear_delta_base_cache_entry(struct delta_base_cache_entry *ent)
+{
+       ent->data = NULL;
+       ent->lru.next->prev = ent->lru.prev;
+       ent->lru.prev->next = ent->lru.next;
+       delta_base_cached -= ent->size;
+}
+
 static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
        unsigned long *base_size, enum object_type *type, int keep_cache)
 {
+       struct delta_base_cache_entry *ent;
        void *ret;
-       unsigned long hash = pack_entry_hash(p, base_offset);
-       struct delta_base_cache_entry *ent = delta_base_cache + hash;
 
-       ret = ent->data;
-       if (!ret || ent->p != p || ent->base_offset != base_offset)
+       ent = get_delta_base_cache_entry(p, base_offset);
+
+       if (!eq_delta_base_cache_entry(ent, p, base_offset))
                return unpack_entry(p, base_offset, type, base_size);
 
-       if (!keep_cache) {
-               ent->data = NULL;
-               ent->lru.next->prev = ent->lru.prev;
-               ent->lru.prev->next = ent->lru.next;
-               delta_base_cached -= ent->size;
-       } else {
+       ret = ent->data;
+
+       if (!keep_cache)
+               clear_delta_base_cache_entry(ent);
+       else
                ret = xmemdupz(ent->data, ent->size);
-       }
        *type = ent->type;
        *base_size = ent->size;
        return ret;
@@ -1900,68 +1952,6 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
 static void *read_object(const unsigned char *sha1, enum object_type *type,
                         unsigned long *size);
 
-static void *unpack_delta_entry(struct packed_git *p,
-                               struct pack_window **w_curs,
-                               off_t curpos,
-                               unsigned long delta_size,
-                               off_t obj_offset,
-                               enum object_type *type,
-                               unsigned long *sizep)
-{
-       void *delta_data, *result, *base;
-       unsigned long base_size;
-       off_t base_offset;
-
-       base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset);
-       if (!base_offset) {
-               error("failed to validate delta base reference "
-                     "at offset %"PRIuMAX" from %s",
-                     (uintmax_t)curpos, p->pack_name);
-               return NULL;
-       }
-       unuse_pack(w_curs);
-       base = cache_or_unpack_entry(p, base_offset, &base_size, type, 0);
-       if (!base) {
-               /*
-                * We're probably in deep shit, but let's try to fetch
-                * the required base anyway from another pack or loose.
-                * This is costly but should happen only in the presence
-                * of a corrupted pack, and is better than failing outright.
-                */
-               struct revindex_entry *revidx;
-               const unsigned char *base_sha1;
-               revidx = find_pack_revindex(p, base_offset);
-               if (!revidx)
-                       return NULL;
-               base_sha1 = nth_packed_object_sha1(p, revidx->nr);
-               error("failed to read delta base object %s"
-                     " at offset %"PRIuMAX" from %s",
-                     sha1_to_hex(base_sha1), (uintmax_t)base_offset,
-                     p->pack_name);
-               mark_bad_packed_object(p, base_sha1);
-               base = read_object(base_sha1, type, &base_size);
-               if (!base)
-                       return NULL;
-       }
-
-       delta_data = unpack_compressed_entry(p, w_curs, curpos, delta_size);
-       if (!delta_data) {
-               error("failed to unpack compressed delta "
-                     "at offset %"PRIuMAX" from %s",
-                     (uintmax_t)curpos, p->pack_name);
-               free(base);
-               return NULL;
-       }
-       result = patch_delta(base, base_size,
-                            delta_data, delta_size,
-                            sizep);
-       if (!result)
-               die("failed to apply delta");
-       free(delta_data);
-       add_delta_base_cache(p, base_offset, base, base_size, *type);
-       return result;
-}
-
 static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
 {
        static FILE *log_file;
@@ -1982,48 +1972,179 @@ static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
 
 int do_check_packed_object_crc;
 
+#define UNPACK_ENTRY_STACK_PREALLOC 64
+struct unpack_entry_stack_ent {
+       off_t obj_offset;
+       off_t curpos;
+       unsigned long size;
+};
+
 void *unpack_entry(struct packed_git *p, off_t obj_offset,
-                  enum object_type *type, unsigned long *sizep)
+                  enum object_type *final_type, unsigned long *final_size)
 {
        struct pack_window *w_curs = NULL;
        off_t curpos = obj_offset;
-       void *data;
+       void *data = NULL;
+       unsigned long size;
+       enum object_type type;
+       struct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];
+       struct unpack_entry_stack_ent *delta_stack = small_delta_stack;
+       int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
+       int base_from_cache = 0;
 
        if (log_pack_access)
                write_pack_access_log(p, obj_offset);
 
-       if (do_check_packed_object_crc && p->index_version > 1) {
-               struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
-               unsigned long len = revidx[1].offset - obj_offset;
-               if (check_pack_crc(p, &w_curs, obj_offset, len, revidx->nr)) {
-                       const unsigned char *sha1 =
-                               nth_packed_object_sha1(p, revidx->nr);
-                       error("bad packed object CRC for %s",
-                             sha1_to_hex(sha1));
-                       mark_bad_packed_object(p, sha1);
-                       unuse_pack(&w_curs);
-                       return NULL;
+       /* PHASE 1: drill down to the innermost base object */
+       for (;;) {
+               off_t base_offset;
+               int i;
+               struct delta_base_cache_entry *ent;
+
+               if (do_check_packed_object_crc && p->index_version > 1) {
+                       struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
+                       unsigned long len = revidx[1].offset - obj_offset;
+                       if (check_pack_crc(p, &w_curs, obj_offset, len, revidx->nr)) {
+                               const unsigned char *sha1 =
+                                       nth_packed_object_sha1(p, revidx->nr);
+                               error("bad packed object CRC for %s",
+                                     sha1_to_hex(sha1));
+                               mark_bad_packed_object(p, sha1);
+                               unuse_pack(&w_curs);
+                               return NULL;
+                       }
+               }
+
+               ent = get_delta_base_cache_entry(p, curpos);
+               if (eq_delta_base_cache_entry(ent, p, curpos)) {
+                       type = ent->type;
+                       data = ent->data;
+                       size = ent->size;
+                       clear_delta_base_cache_entry(ent);
+                       base_from_cache = 1;
+                       break;
                }
+
+               type = unpack_object_header(p, &w_curs, &curpos, &size);
+               if (type != OBJ_OFS_DELTA && type != OBJ_REF_DELTA)
+                       break;
+
+               base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
+               if (!base_offset) {
+                       error("failed to validate delta base reference "
+                             "at offset %"PRIuMAX" from %s",
+                             (uintmax_t)curpos, p->pack_name);
+                       /* bail to phase 2, in hopes of recovery */
+                       data = NULL;
+                       break;
+               }
+
+               /* push object, proceed to base */
+               if (delta_stack_nr >= delta_stack_alloc
+                   && delta_stack == small_delta_stack) {
+                       delta_stack_alloc = alloc_nr(delta_stack_nr);
+                       delta_stack = xmalloc(sizeof(*delta_stack)*delta_stack_alloc);
+                       memcpy(delta_stack, small_delta_stack,
+                              sizeof(*delta_stack)*delta_stack_nr);
+               } else {
+                       ALLOC_GROW(delta_stack, delta_stack_nr+1, delta_stack_alloc);
+               }
+               i = delta_stack_nr++;
+               delta_stack[i].obj_offset = obj_offset;
+               delta_stack[i].curpos = curpos;
+               delta_stack[i].size = size;
+
+               curpos = obj_offset = base_offset;
        }
 
-       *type = unpack_object_header(p, &w_curs, &curpos, sizep);
-       switch (*type) {
+       /* PHASE 2: handle the base */
+       switch (type) {
        case OBJ_OFS_DELTA:
        case OBJ_REF_DELTA:
-               data = unpack_delta_entry(p, &w_curs, curpos, *sizep,
-                                         obj_offset, type, sizep);
+               if (data)
+                       die("BUG in unpack_entry: left loop at a valid delta");
                break;
        case OBJ_COMMIT:
        case OBJ_TREE:
        case OBJ_BLOB:
        case OBJ_TAG:
-               data = unpack_compressed_entry(p, &w_curs, curpos, *sizep);
+               if (!base_from_cache)
+                       data = unpack_compressed_entry(p, &w_curs, curpos, size);
                break;
        default:
                data = NULL;
                error("unknown object type %i at offset %"PRIuMAX" in %s",
-                     *type, (uintmax_t)obj_offset, p->pack_name);
+                     type, (uintmax_t)obj_offset, p->pack_name);
+       }
+
+       /* PHASE 3: apply deltas in order */
+
+       /* invariants:
+        *   'data' holds the base data, or NULL if there was corruption
+        */
+       while (delta_stack_nr) {
+               void *delta_data;
+               void *base = data;
+               unsigned long delta_size, base_size = size;
+               int i;
+
+               data = NULL;
+
+               if (base)
+                       add_delta_base_cache(p, obj_offset, base, base_size, type);
+
+               if (!base) {
+                       /*
+                        * We're probably in deep shit, but let's try to fetch
+                        * the required base anyway from another pack or loose.
+                        * This is costly but should happen only in the presence
+                        * of a corrupted pack, and is better than failing outright.
+                        */
+                       struct revindex_entry *revidx;
+                       const unsigned char *base_sha1;
+                       revidx = find_pack_revindex(p, obj_offset);
+                       if (revidx) {
+                               base_sha1 = nth_packed_object_sha1(p, revidx->nr);
+                               error("failed to read delta base object %s"
+                                     " at offset %"PRIuMAX" from %s",
+                                     sha1_to_hex(base_sha1), (uintmax_t)obj_offset,
+                                     p->pack_name);
+                               mark_bad_packed_object(p, base_sha1);
+                               base = read_object(base_sha1, &type, &base_size);
+                       }
+               }
+
+               i = --delta_stack_nr;
+               obj_offset = delta_stack[i].obj_offset;
+               curpos = delta_stack[i].curpos;
+               delta_size = delta_stack[i].size;
+
+               if (!base)
+                       continue;
+
+               delta_data = unpack_compressed_entry(p, &w_curs, curpos, delta_size);
+
+               if (!delta_data) {
+                       error("failed to unpack compressed delta "
+                             "at offset %"PRIuMAX" from %s",
+                             (uintmax_t)curpos, p->pack_name);
+                       free(base);
+                       data = NULL;
+                       continue;
+               }
+
+               data = patch_delta(base, base_size,
+                                  delta_data, delta_size,
+                                  &size);
+               if (!data)
+                       die("failed to apply delta");
+
+               free (delta_data);
        }
+
+       *final_type = type;
+       *final_size = size;
+
        unuse_pack(&w_curs);
        return data;
 }
index 48e9abb5c2069bfc02a32747004bf51799dda0f1..1170d01c4322b494cd900853279766edd030de32 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -528,6 +528,25 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
        strbuf_add_urlencode(sb, s, strlen(s), reserved);
 }
 
+void strbuf_humanise_bytes(struct strbuf *buf, off_t bytes)
+{
+       if (bytes > 1 << 30) {
+               strbuf_addf(buf, "%u.%2.2u GiB",
+                           (int)(bytes >> 30),
+                           (int)(bytes & ((1 << 30) - 1)) / 10737419);
+       } else if (bytes > 1 << 20) {
+               int x = bytes + 5243;  /* for rounding */
+               strbuf_addf(buf, "%u.%2.2u MiB",
+                           x >> 20, ((x & ((1 << 20) - 1)) * 100) >> 20);
+       } else if (bytes > 1 << 10) {
+               int x = bytes + 5;  /* for rounding */
+               strbuf_addf(buf, "%u.%2.2u KiB",
+                           x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);
+       } else {
+               strbuf_addf(buf, "%u bytes", (int)bytes);
+       }
+}
+
 int printf_ln(const char *fmt, ...)
 {
        int ret;
index 958822c2dd4ebf2275f294258c265884cfbf3ee8..73e80cea69b5e2965cf4ce8c36444f45aae8e19c 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -170,6 +170,7 @@ extern int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
 
 extern void strbuf_addstr_urlencode(struct strbuf *, const char *,
                                    int reserved);
+extern void strbuf_humanise_bytes(struct strbuf *buf, off_t bytes);
 
 __attribute__((format (printf,1,2)))
 extern int printf_ln(const char *fmt, ...);
index 975bc87e48b33e70bd7c38e82b7f59e34bb81ca3..e728025f60dbf7f3df87b7104af6410832ddb653 100644 (file)
@@ -216,6 +216,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,
 }
 
 static void print_submodule_summary(struct rev_info *rev, FILE *f,
+               const char *line_prefix,
                const char *del, const char *add, const char *reset)
 {
        static const char format[] = "  %m %s";
@@ -226,6 +227,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
                struct pretty_print_context ctx = {0};
                ctx.date_mode = rev->date_mode;
                strbuf_setlen(&sb, 0);
+               strbuf_addstr(&sb, line_prefix);
                if (commit->object.flags & SYMMETRIC_LEFT) {
                        if (del)
                                strbuf_addstr(&sb, del);
@@ -256,6 +258,7 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
 }
 
 void show_submodule_summary(FILE *f, const char *path,
+               const char *line_prefix,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule, const char *meta,
                const char *del, const char *add, const char *reset)
@@ -280,16 +283,18 @@ void show_submodule_summary(FILE *f, const char *path,
                message = "(revision walker failed)";
 
        if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
-               fprintf(f, "Submodule %s contains untracked content\n", path);
+               fprintf(f, "%sSubmodule %s contains untracked content\n",
+                       line_prefix, path);
        if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
-               fprintf(f, "Submodule %s contains modified content\n", path);
+               fprintf(f, "%sSubmodule %s contains modified content\n",
+                       line_prefix, path);
 
        if (!hashcmp(one, two)) {
                strbuf_release(&sb);
                return;
        }
 
-       strbuf_addf(&sb, "%sSubmodule %s %s..", meta, path,
+       strbuf_addf(&sb, "%s%sSubmodule %s %s..", line_prefix, meta, path,
                        find_unique_abbrev(one, DEFAULT_ABBREV));
        if (!fast_backward && !fast_forward)
                strbuf_addch(&sb, '.');
@@ -301,7 +306,7 @@ void show_submodule_summary(FILE *f, const char *path,
        fwrite(sb.buf, sb.len, 1, f);
 
        if (!message) /* only NULL if we succeeded in setting up the walk */
-               print_submodule_summary(&rev, f, del, add, reset);
+               print_submodule_summary(&rev, f, line_prefix, del, add, reset);
        if (left)
                clear_commit_marks(left, ~0);
        if (right)
index 3dc1b3fe891eaf5c758ee0a668f9f385ea99d5ba..c7ffc7c399d23781d823954d74bab4620debb628 100644 (file)
@@ -19,6 +19,7 @@ int parse_submodule_config_option(const char *var, const char *value);
 void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
 int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
 void show_submodule_summary(FILE *f, const char *path,
+               const char *line_prefix,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule, const char *meta,
                const char *del, const char *add, const char *reset);
index 938b4cf803b3b4ea07be20338425f784b80cdf0c..b5bce459b61160653fcf45023f1e3c65e91f89be 100644 (file)
@@ -40,6 +40,9 @@ ErrorLog error.log
 <IfModule !mod_authz_user.c>
        LoadModule authz_user_module modules/mod_authz_user.so
 </IfModule>
+<IfModule !mod_authz_host.c>
+       LoadModule authz_host_module modules/mod_authz_host.so
+</IfModule>
 </IfVersion>
 
 PassEnv GIT_VALGRIND
@@ -61,6 +64,11 @@ Alias /auth/dumb/ www/auth/dumb/
        SetEnv GIT_COMMITTER_NAME "Custom User"
        SetEnv GIT_COMMITTER_EMAIL custom@example.com
 </LocationMatch>
+<LocationMatch /smart_namespace/>
+       SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
+       SetEnv GIT_HTTP_EXPORT_ALL
+       SetEnv GIT_NAMESPACE ns
+</LocationMatch>
 ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
 ScriptAlias /broken_smart/ broken-smart-http.sh/
 <Directory ${GIT_EXEC_PATH}>
@@ -110,6 +118,21 @@ SSLEngine On
        Require valid-user
 </LocationMatch>
 
+RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
+RewriteCond %{REQUEST_URI} /git-receive-pack$
+RewriteRule ^/half-auth-complete/ - [E=AUTHREQUIRED:yes]
+
+<Location /half-auth-complete/>
+  Order Deny,Allow
+  Deny from env=AUTHREQUIRED
+
+  AuthType Basic
+  AuthName "Git Access"
+  AuthUserFile passwd
+  Require valid-user
+  Satisfy Any
+</Location>
+
 <IfDefine DAV>
        LoadModule dav_module modules/mod_dav.so
        LoadModule dav_fs_module modules/mod_dav_fs.so
index 9820f70c84d93b9461ae6663e6ab5b3cd735e3d5..9cc5c6bf4dda488428f6b4389e4e494c6c63983c 100755 (executable)
@@ -134,15 +134,12 @@ tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
 tag_description="This is a tag"
 tag_content="$tag_header_without_timestamp 0000000000 +0000
 
-$tag_description"
-tag_pretty_content="$tag_header_without_timestamp Thu Jan 1 00:00:00 1970 +0000
-
 $tag_description"
 
 tag_sha1=$(echo_without_newline "$tag_content" | git mktag)
 tag_size=$(strlen "$tag_content")
 
-run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_pretty_content" 1
+run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content" 1
 
 test_expect_success \
     "Reach a blob from a tag pointing to it" \
index 5c0053a20bf2fbf1dd466ace5dc933e38ce3544d..0c74beedd22600e8dfe852393a5a9a36350cfeb5 100755 (executable)
@@ -250,4 +250,28 @@ EOF
        test_cmp expected actual
 '
 
+test_expect_success 'checkout without --ignore-skip-worktree-bits' '
+       echo "*" >.git/info/sparse-checkout &&
+       git checkout -f top &&
+       test_path_is_file init.t &&
+       echo sub >.git/info/sparse-checkout &&
+       git checkout &&
+       echo modified >> sub/added &&
+       git checkout . &&
+       test_path_is_missing init.t &&
+       git diff --exit-code HEAD
+'
+
+test_expect_success 'checkout with --ignore-skip-worktree-bits' '
+       echo "*" >.git/info/sparse-checkout &&
+       git checkout -f top &&
+       test_path_is_file init.t &&
+       echo sub >.git/info/sparse-checkout &&
+       git checkout &&
+       echo modified >> sub/added &&
+       git checkout --ignore-skip-worktree-bits . &&
+       test_path_is_file init.t &&
+       git diff --exit-code HEAD
+'
+
 test_done
index c317254b9a82befd3400d300f85ecfd661d1a948..b2bd41918ee7f8b19e3ef906f27796f331ed9ea5 100755 (executable)
@@ -166,9 +166,9 @@ test_expect_success 'add -u resolves unmerged paths' '
        echo 2 >path3 &&
        echo 2 >path5 &&
 
-       # Explicit resolving by adding removed paths should fail
-       test_must_fail git add path4 &&
-       test_must_fail git add path6 &&
+       # Fail to explicitly resolve removed paths with "git add"
+       test_must_fail git add --no-all path4 &&
+       test_must_fail git add --no-all path6 &&
 
        # "add -u" should notice removals no matter what stages
        # the index entries are in.
index ec4fae2f3978d5a1127dfb7f20690b60a61bd013..4e3735f0cb28d2b545f59a2464ea74bea4b626a1 100755 (executable)
@@ -103,7 +103,7 @@ test_expect_success \
      test_cmp expect output'
 
 test_expect_success 'restore gitignore' '
-       git checkout $allignores &&
+       git checkout --ignore-skip-worktree-bits $allignores &&
        rm .git/index
 '
 
index 4e7136b83775946a07678119c7c9897bb0f2b709..19c99d7ef1bc02e67a7b995206b9f66c04c1b31c 100755 (executable)
@@ -55,6 +55,12 @@ one
 two"
 '
 
+test_expect_success 'cherry-pick three one two: fails' '
+       git checkout -f master &&
+       git reset --hard first &&
+       test_must_fail git cherry-pick three one two:
+'
+
 test_expect_success 'output to keep user entertained during multi-pick' '
        cat <<-\EOF >expected &&
        [master OBJID] second
index 86ee0771077a9da0404a276873c81dd17600ceb4..58d418098d793b284bb4a7222cf9709c45b26c90 100755 (executable)
@@ -1284,4 +1284,37 @@ test_expect_success 'cover letter using branch description (6)' '
        grep hello actual >/dev/null
 '
 
+test_expect_success 'cover letter with nothing' '
+       git format-patch --stdout --cover-letter >actual &&
+       test_line_count = 0 actual
+'
+
+test_expect_success 'cover letter auto' '
+       mkdir -p tmp &&
+       test_when_finished "rm -rf tmp;
+               git config --unset format.coverletter" &&
+
+       git config format.coverletter auto &&
+       git format-patch -o tmp -1 >list &&
+       test_line_count = 1 list &&
+       git format-patch -o tmp -2 >list &&
+       test_line_count = 3 list
+'
+
+test_expect_success 'cover letter auto user override' '
+       mkdir -p tmp &&
+       test_when_finished "rm -rf tmp;
+               git config --unset format.coverletter" &&
+
+       git config format.coverletter auto &&
+       git format-patch -o tmp --cover-letter -1 >list &&
+       test_line_count = 2 list &&
+       git format-patch -o tmp --cover-letter -2 >list &&
+       test_line_count = 3 list &&
+       git format-patch -o tmp --no-cover-letter -1 >list &&
+       test_line_count = 1 list &&
+       git format-patch -o tmp --no-cover-letter -2 >list &&
+       test_line_count = 2 list
+'
+
 test_done
diff --git a/t/t4212-log-corrupt.sh b/t/t4212-log-corrupt.sh
new file mode 100755 (executable)
index 0000000..ec5099b
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='git log with invalid commit headers'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       test_commit foo &&
+
+       git cat-file commit HEAD |
+       sed "/^author /s/>/>-<>/" >broken_email.commit &&
+       git hash-object -w -t commit broken_email.commit >broken_email.hash &&
+       git update-ref refs/heads/broken_email $(cat broken_email.hash)
+'
+
+test_expect_success 'git log with broken author email' '
+       {
+               echo commit $(cat broken_email.hash)
+               echo "Author: A U Thor <author@example.com>"
+               echo "Date:   Thu Jan 1 00:00:00 1970 +0000"
+               echo
+               echo "    foo"
+       } >expect.out &&
+       : >expect.err &&
+
+       git log broken_email >actual.out 2>actual.err &&
+
+       test_cmp expect.out actual.out &&
+       test_cmp expect.err actual.err
+'
+
+test_expect_success 'git log --format with broken author email' '
+       echo "A U Thor+author@example.com+" >expect.out &&
+       : >expect.err &&
+
+       git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err &&
+
+       test_cmp expect.out actual.out &&
+       test_cmp expect.err actual.err
+'
+
+test_done
index d0b2a457b8bf30fc7ab472ff6b2576ff319432f7..bd43b3d8ef8b3e71f6985cfa96a940dccb4a0a54 100755 (executable)
@@ -26,8 +26,6 @@ EXPECTED
 
 test_expect_success 'file add !A, B' '
        cat >expected <<\EXPECTED &&
-added in local
-  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 EXPECTED
 
        git reset --hard initial &&
@@ -38,9 +36,6 @@ EXPECTED
 
 test_expect_success 'file add A, B (same)' '
        cat >expected <<\EXPECTED &&
-added in both
-  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
-  their  100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 EXPECTED
 
        git reset --hard initial &&
@@ -181,9 +176,6 @@ AAA" &&
 
 test_expect_success 'file remove A, !B' '
        cat >expected <<\EXPECTED &&
-removed in local
-  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
-  their  100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 EXPECTED
 
        git reset --hard initial &&
@@ -283,8 +275,6 @@ test_expect_success 'turn tree to file' '
        test_commit "make-file" "dir" "CCC" &&
        git merge-tree add-tree add-another-tree make-file >actual &&
        cat >expect <<-\EOF &&
-       added in local
-         our    100644 ba629238ca89489f2b350e196ca445e09d8bb834 dir/another
        removed in remote
          base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
          our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
index cdb7d7a7f9b59678e4079c61ae5104db51dc05a2..bfdb56a0694db0c6ed07aaa568c648909ac62660 100755 (executable)
@@ -28,7 +28,7 @@ check_dir() {
 }
 
 test_expect_success 'tar archive of empty tree is empty' '
-       git archive --format=tar HEAD >empty.tar &&
+       git archive --format=tar HEAD: >empty.tar &&
        make_dir extract &&
        "$TAR" xf empty.tar -C extract &&
        check_dir extract
index c24003565d635722f07333bb662c8e102d577c9e..2b8c0bac7db47ef7b37024ecea95ed0e37d5364f 100755 (executable)
@@ -36,7 +36,7 @@ test_expect_success 'prepare pushable branches' '
 '
 
 test_expect_success 'mixed-success push returns error' '
-       test_must_fail git push
+       test_must_fail git push origin :
 '
 
 test_expect_success 'check tracking branches updated correctly after push' '
index ccc55ebf4bf10d4782bf2ff32910ed6eeec040f6..6579a86724cec01b8c731ead2d4083dfe44293dd 100755 (executable)
@@ -345,7 +345,7 @@ test_expect_success 'fetch mirrors do not act as mirrors during push' '
        ) &&
        (cd mirror-fetch/child &&
         git branch -m renamed renamed2 &&
-        git push parent
+        git push parent :
        ) &&
        (cd mirror-fetch/parent &&
         git rev-parse --verify renamed &&
index 838e71dafea8388cbe18c82b26f58f074f56abbd..4691d51b8cde48dbb97ac5dfc1e3b75fe90f8da3 100755 (executable)
@@ -252,7 +252,7 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf
 test_expect_success 'push with matching heads' '
 
        mk_test testrepo heads/master &&
-       git push testrepo &&
+       git push testrepo &&
        check_push_result testrepo $the_commit heads/master
 
 '
@@ -281,7 +281,7 @@ test_expect_success 'push --force with matching heads' '
        mk_test testrepo heads/master &&
        git push testrepo : &&
        git commit --amend -massaged &&
-       git push --force testrepo &&
+       git push --force testrepo &&
        ! check_push_result testrepo $the_commit heads/master &&
        git reset --hard $the_commit
 
@@ -504,6 +504,7 @@ test_expect_success 'push with remote.pushdefault' '
        test_config remote.down.url down_repo &&
        test_config branch.master.remote up &&
        test_config remote.pushdefault down &&
+       test_config push.default matching &&
        git push &&
        check_push_result up_repo $the_first_commit heads/master &&
        check_push_result down_repo $the_commit heads/master
@@ -515,7 +516,7 @@ test_expect_success 'push with config remote.*.pushurl' '
        git checkout master &&
        test_config remote.there.url test2repo &&
        test_config remote.there.pushurl testrepo &&
-       git push there &&
+       git push there &&
        check_push_result testrepo $the_commit heads/master
 '
 
@@ -528,6 +529,7 @@ test_expect_success 'push with config branch.*.pushremote' '
        test_config remote.down.url down_repo &&
        test_config branch.master.remote up &&
        test_config branch.master.pushremote down &&
+       test_config push.default matching &&
        git push &&
        check_push_result up_repo $the_first_commit heads/master &&
        check_push_result side_repo $the_first_commit heads/master &&
@@ -541,7 +543,7 @@ test_expect_success 'push with dry-run' '
                cd testrepo &&
                old_commit=$(git show-ref -s --verify refs/heads/master)
        ) &&
-       git push --dry-run testrepo &&
+       git push --dry-run testrepo &&
        check_push_result testrepo $old_commit heads/master
 '
 
@@ -1022,7 +1024,7 @@ test_expect_success 'push --porcelain --dry-run rejected' '
 
 test_expect_success 'push --prune' '
        mk_test testrepo heads/master heads/second heads/foo heads/bar &&
-       git push --prune testrepo &&
+       git push --prune testrepo &&
        check_push_result testrepo $the_commit heads/master &&
        check_push_result testrepo $the_first_commit heads/second &&
        ! check_push_result testrepo $the_first_commit heads/foo heads/bar
index e2ad2605084194868fc23e23fec1636af622b47f..12a5dfb17e0a0bd4d0d9636ff13bf44999f78e36 100755 (executable)
@@ -256,7 +256,7 @@ test_expect_success 'remote.foo.mirror=no has no effect' '
                git branch keep master &&
                git push --mirror up &&
                git branch -D keep &&
-               git push up
+               git push up :
        ) &&
        (
                cd mirror &&
index c00c9b071d696038f63e8d613e11beab68eb547e..11fcd37700f372117145258f209e6c56ae04a1fc 100755 (executable)
@@ -40,7 +40,7 @@ test_expect_success 'alice works and pushes' '
                cd alice-work &&
                echo more >file &&
                git commit -a -m second &&
-               git push ../alice-pub
+               git push ../alice-pub :
        )
 '
 
@@ -57,7 +57,7 @@ test_expect_success 'bob fetches from alice, works and pushes' '
                git pull ../alice-pub master &&
                echo more bob >file &&
                git commit -a -m third &&
-               git push ../bob-pub
+               git push ../bob-pub :
        ) &&
 
        # Check that the second commit by Alice is not sent
@@ -86,7 +86,7 @@ test_expect_success 'alice works and pushes again' '
                cd alice-work &&
                echo more alice >file &&
                git commit -a -m fourth &&
-               git push ../alice-pub
+               git push ../alice-pub :
        )
 '
 
@@ -99,7 +99,7 @@ test_expect_success 'bob works and pushes' '
                cd bob-work &&
                echo yet more bob >file &&
                git commit -a -m fifth &&
-               git push ../bob-pub
+               git push ../bob-pub :
        )
 '
 
@@ -115,7 +115,7 @@ test_expect_success 'alice works and pushes yet again' '
                git commit -a -m sixth.2 &&
                echo more and more alice >>file &&
                git commit -a -m sixth.3 &&
-               git push ../alice-pub
+               git push ../alice-pub :
        )
 '
 
@@ -136,7 +136,7 @@ test_expect_success 'bob works and pushes again' '
                git hash-object -t commit -w commit &&
                echo even more bob >file &&
                git commit -a -m seventh &&
-               git push ../bob-pub
+               git push ../bob-pub :
        )
 '
 
index 1947c28c6466d46c79c7b1b093488c1620324172..8c16e045a0c585957a0be4e31b5628d1d5b6cb23 100755 (executable)
@@ -16,6 +16,7 @@ test_expect_success setup '
                (
                        cd gar/bage &&
                        git init &&
+                       git config push.default matching &&
                        >junk &&
                        git add junk &&
                        git commit -m "Initial junk"
index 4086f02bc129b3628c724c7037fe60509fbef46c..beb00be4b1593a058308d8897fed81a7cf1556d7 100755 (executable)
@@ -294,5 +294,35 @@ test_expect_success 'push to auth-only-for-push repo' '
        test_cmp expect actual
 '
 
+test_expect_success 'create repo without http.receivepack set' '
+       cd "$ROOT_PATH" &&
+       git init half-auth &&
+       (
+               cd half-auth &&
+               test_commit one
+       ) &&
+       git clone --bare half-auth "$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git"
+'
+
+test_expect_success 'clone via half-auth-complete does not need password' '
+       cd "$ROOT_PATH" &&
+       set_askpass wrong &&
+       git clone "$HTTPD_URL"/half-auth-complete/smart/half-auth.git \
+               half-auth-clone &&
+       expect_askpass none
+'
+
+test_expect_success 'push into half-auth-complete requires password' '
+       cd "$ROOT_PATH/half-auth-clone" &&
+       echo two >expect &&
+       test_commit two &&
+       set_askpass user@host &&
+       git push "$HTTPD_URL/half-auth-complete/smart/half-auth.git" &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git" \
+               log -1 --format=%s >actual &&
+       expect_askpass both user@host &&
+       test_cmp expect actual
+'
+
 stop_httpd
 test_done
index 80d20c876bbac0b00d388d511da555a29e827dbc..f7d0f146f0f69775dd3fa3ea06895e2bb1a74d55 100755 (executable)
@@ -13,6 +13,7 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5550'}
 start_httpd
 
 test_expect_success 'setup repository' '
+       git config push.default matching &&
        echo content1 >file &&
        git add file &&
        git commit -m one
index 47eb76921ddd53acb63573f9af75e41ab5067f5c..b23efbbfd9586670f1eeee114a1335b9dad4d97f 100755 (executable)
@@ -13,6 +13,7 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5551'}
 start_httpd
 
 test_expect_success 'setup repository' '
+       git config push.default matching &&
        echo content >file &&
        git add file &&
        git commit -m one
@@ -162,6 +163,30 @@ test_expect_success 'invalid Content-Type rejected' '
        grep "not valid:" actual
 '
 
+test_expect_success 'create namespaced refs' '
+       test_commit namespaced &&
+       git push public HEAD:refs/namespaces/ns/refs/heads/master &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+               symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master
+'
+
+test_expect_success 'smart clone respects namespace' '
+       git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart &&
+       echo namespaced >expect &&
+       git --git-dir=ns-smart/.git log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'dumb clone via http-backend respects namespace' '
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+               config http.getanyfile true &&
+       GIT_SMART_HTTP=0 git clone \
+               "$HTTPD_URL/smart_namespace/repo.git" ns-dumb &&
+       echo namespaced >expect &&
+       git --git-dir=ns-dumb/.git log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
 test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
 
 test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
index a3a4e47e1d25379e981373e67124c9efe5c76213..f01edffa3c0babf76593fbd211f6606ff2036c74 100755 (executable)
@@ -8,6 +8,7 @@ LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-5570}
 start_git_daemon
 
 test_expect_success 'setup repository' '
+       git config push.default matching &&
        echo content >file &&
        git add file &&
        git commit -m one
index 60f1552adef417b8d37ca4215be1e66627c37258..6537911a4300656706c995226b2f0444a760bae0 100755 (executable)
@@ -185,4 +185,17 @@ test_expect_success 'fetch with incomplete alternates' '
        ! grep " want $tag_object" "$U.K"
 '
 
+test_expect_success 'clone using repo with gitfile as a reference' '
+       git clone --separate-git-dir=L A M &&
+       git clone --reference=M A N &&
+       echo "$base_dir/L/objects" >expected &&
+       test_cmp expected "$base_dir/N/.git/objects/info/alternates"
+'
+
+test_expect_success 'clone using repo pointed at by gitfile as reference' '
+       git clone --reference=M/.git A O &&
+       echo "$base_dir/L/objects" >expected &&
+       test_cmp expected "$base_dir/O/.git/objects/info/alternates"
+'
+
 test_done
index 9e43731fe504c46737c5294e4d508b5c20bbb663..a45c31692e17218988e6619742c366043e426039 100755 (executable)
@@ -58,4 +58,14 @@ test_expect_success 'ridiculously long subject in boundary' '
        grep "^-[0-9a-f]\\{40\\} " boundary
 '
 
+test_expect_success 'prerequisites with an empty commit message' '
+       : >file1 &&
+       git add file1 &&
+       test_tick &&
+       git commit --allow-empty-message -m "" &&
+       test_commit file2 &&
+       git bundle create bundle HEAD^.. &&
+       git bundle verify bundle
+'
+
 test_done
index 8bf53de3ef6bc7cc5de14b70e93ffe42b9b3f094..4d3074a45cdaf768ea9d46049f5b8eb6da095056 100755 (executable)
@@ -741,4 +741,22 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
        git bisect reset
 "
 
+cat > expected.bisect-log <<EOF
+# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
+# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.
+git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'
+# good: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
+git bisect good 3de952f2416b6084f557ec417709eac740c6818c
+# first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
+EOF
+
+test_expect_success 'bisect log: successfull result' '
+       git bisect reset &&
+       git bisect start $HASH4 $HASH2 &&
+       git bisect good &&
+       git bisect log >bisect-log.txt &&
+       test_cmp expected.bisect-log bisect-log.txt &&
+       git bisect reset
+'
+
 test_done
index f73eceabfbcd0a763b8908a8d829894a5e36055b..54b5744cc526e172acb79bb204af1800fdceb315 100755 (executable)
@@ -175,6 +175,24 @@ test_expect_success 'merge.log=5 shows all 5 commits' '
        test_cmp expected actual
 '
 
+test_expect_success '--log=5 with custom comment character' '
+       cat >expected <<-EOF &&
+       Merge branch ${apos}left${apos}
+
+       x By Another Author (3) and A U Thor (2)
+       x Via Another Committer
+       * left:
+         Left #5
+         Left #4
+         Left #3
+         Common #2
+         Common #1
+       EOF
+
+       git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'merge.log=0 disables shortlog' '
        echo "Merge branch ${apos}left${apos}" >expected
        git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
index 2a0cfaac329c6c0974f205c81c45a0304a04897d..a4ffea0dbe743a1bbe4c5512037a6b1ffde1c313 100755 (executable)
@@ -596,14 +596,14 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
           git log > ../../../expected
          ) &&
          git commit -m "added subsubmodule" &&
-         git push
+         git push origin :
         ) &&
         (cd .git/modules/deeper/submodule/modules/subsubmodule &&
          git log > ../../../../../actual
         ) &&
         git add deeper/submodule &&
         git commit -m "update submodule" &&
-        git push &&
+        git push origin : &&
         test_cmp actual expected
        )
 '
index 9502f2438aeeb47c0881b80326a4152002fc23ad..043138631b8ba7fa21899e634383925feb6737e8 100755 (executable)
@@ -36,6 +36,7 @@ export CVSROOT CVS_SERVER
 
 rm -rf "$CVSWORK" "$SERVERDIR"
 test_expect_success 'setup' '
+  git config push.default matching &&
   echo >empty &&
   git add empty &&
   git commit -q -m "First Commit" &&
index 1c5bc84fa72492a820638e4e197b89ba13bc27f1..8c3db763013ff736e173a405de70f68cbdddaf9f 100755 (executable)
@@ -84,6 +84,7 @@ export CVSROOT CVS_SERVER
 
 rm -rf "$CVSWORK" "$SERVERDIR"
 test_expect_success 'setup' '
+    git config push.default matching &&
     echo "Simple text file" >textfile.c &&
     echo "File with embedded NUL: Q <- there" | q_to_nul > binfile.bin &&
     mkdir subdir &&
index 0d4e366232c29bdde0e1059d431ae96afc259112..1140767b50706f03b0da5b2c8befdae6898e4136 100755 (executable)
@@ -45,7 +45,8 @@ BEGIN
 # Failure cases for config:
 # Save and restore STDERR; we will probably extract this into a
 # "dies_ok" method and possibly move the STDERR handling to Git.pm.
-open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR;
+open our $tmpstderr, ">&STDERR" or die "cannot save STDERR";
+open STDERR, ">", "/dev/null" or die "cannot redirect STDERR to /dev/null";
 is($r->config("test.dupstring"), "value2", "config: multivar");
 eval { $r->config_bool("test.boolother") };
 ok($@, "config_bool: non-boolean values fail");
index adc1372b3c334b4305761f6c3922493c85a0822a..6d9d1418a041bd8b3dddb598ac5479c999047a06 100755 (executable)
@@ -69,6 +69,7 @@ run_completion ()
        local -a COMPREPLY _words
        local _cword
        _words=( $1 )
+       test "${1: -1}" == ' ' && _words+=('')
        (( _cword = ${#_words[@]} - 1 ))
        __git_wrap__git_main && print_comp
 }
@@ -104,6 +105,23 @@ test_gitcomp ()
        test_cmp expected out
 }
 
+# Test __gitcomp_nl
+# Arguments are:
+# 1: current word (cur)
+# -: the rest are passed to __gitcomp_nl
+test_gitcomp_nl ()
+{
+       local -a COMPREPLY &&
+       sed -e 's/Z$//' >expected &&
+       cur="$1" &&
+       shift &&
+       __gitcomp_nl "$@" &&
+       print_comp &&
+       test_cmp expected out
+}
+
+invalid_variable_name='${foo.bar}'
+
 test_expect_success '__gitcomp - trailing space - options' '
        test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
                --reset-author" <<-EOF
@@ -147,8 +165,51 @@ test_expect_success '__gitcomp - suffix' '
        EOF
 '
 
+test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
+       __gitcomp "$invalid_variable_name"
+'
+
+read -r -d "" refs <<-\EOF
+maint
+master
+next
+pu
+EOF
+
+test_expect_success '__gitcomp_nl - trailing space' '
+       test_gitcomp_nl "m" "$refs" <<-EOF
+       maint Z
+       master Z
+       EOF
+'
+
+test_expect_success '__gitcomp_nl - prefix' '
+       test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF
+       --fixup=maint Z
+       --fixup=master Z
+       EOF
+'
+
+test_expect_success '__gitcomp_nl - suffix' '
+       test_gitcomp_nl "branch.ma" "$refs" "branch." "ma" "." <<-\EOF
+       branch.maint.Z
+       branch.master.Z
+       EOF
+'
+
+test_expect_success '__gitcomp_nl - no suffix' '
+       test_gitcomp_nl "ma" "$refs" "" "ma" "" <<-\EOF
+       maintZ
+       masterZ
+       EOF
+'
+
+test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' '
+       __gitcomp_nl "$invalid_variable_name"
+'
+
 test_expect_success 'basic' '
-       run_completion "git \"\"" &&
+       run_completion "git " &&
        # built-in
        grep -q "^add \$" out &&
        # script
@@ -271,7 +332,7 @@ test_expect_success 'complete tree filename with spaces' '
        EOF
 '
 
-test_expect_failure 'complete tree filename with metacharacters' '
+test_expect_success 'complete tree filename with metacharacters' '
        echo content >"name with \${meta}" &&
        git add . &&
        git commit -m meta &&
index 2101d914f2d34d28b05ce17982a24c0b008809af..e147a8d277af7948cf165ea93899e9020a961d7a 100755 (executable)
@@ -59,7 +59,7 @@ test_expect_success 'gitdir - .git directory in cwd' '
 '
 
 test_expect_success 'gitdir - .git directory in parent' '
-       echo "$TRASH_DIRECTORY/.git" > expected &&
+       echo "$(pwd -P)/.git" > expected &&
        (
                cd subdir/subsubdir &&
                __gitdir > "$actual"
@@ -77,7 +77,7 @@ test_expect_success 'gitdir - cwd is a .git directory' '
 '
 
 test_expect_success 'gitdir - parent is a .git directory' '
-       echo "$TRASH_DIRECTORY/.git" > expected &&
+       echo "$(pwd -P)/.git" > expected &&
        (
                cd .git/refs/heads &&
                __gitdir > "$actual"
@@ -115,7 +115,7 @@ test_expect_success 'gitdir - non-existing $GIT_DIR' '
 '
 
 test_expect_success 'gitdir - gitfile in cwd' '
-       echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+       echo "$(pwd -P)/otherrepo/.git" > expected &&
        echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
        test_when_finished "rm -f subdir/.git" &&
        (
@@ -126,7 +126,7 @@ test_expect_success 'gitdir - gitfile in cwd' '
 '
 
 test_expect_success 'gitdir - gitfile in parent' '
-       echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+       echo "$(pwd -P)/otherrepo/.git" > expected &&
        echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
        test_when_finished "rm -f subdir/.git" &&
        (
@@ -137,7 +137,7 @@ test_expect_success 'gitdir - gitfile in parent' '
 '
 
 test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '
-       echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+       echo "$(pwd -P)/otherrepo/.git" > expected &&
        mkdir otherrepo/dir &&
        test_when_finished "rm -rf otherrepo/dir" &&
        ln -s otherrepo/dir link &&
index debd8b475186591ec1d1ef38848fef1a213889f4..ca6bdef63d2ee9389729e5118f22461c887dc5ed 100644 (file)
@@ -600,14 +600,14 @@ then
 fi
 
 # Test repository
-test="trash directory.$(basename "$0" .sh)"
-test -n "$root" && test="$root/$test"
-case "$test" in
-/*) TRASH_DIRECTORY="$test" ;;
- *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$test" ;;
+TRASH_DIRECTORY="trash directory.$(basename "$0" .sh)"
+test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY"
+case "$TRASH_DIRECTORY" in
+/*) ;; # absolute path is good
+ *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
 esac
 test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
-rm -fr "$test" || {
+rm -fr "$TRASH_DIRECTORY" || {
        GIT_EXIT_OK=t
        echo >&5 "FATAL: Cannot prepare test area"
        exit 1
@@ -618,13 +618,13 @@ export HOME
 
 if test -z "$TEST_NO_CREATE_REPO"
 then
-       test_create_repo "$test"
+       test_create_repo "$TRASH_DIRECTORY"
 else
-       mkdir -p "$test"
+       mkdir -p "$TRASH_DIRECTORY"
 fi
 # Use -P to resolve symlinks in our working directory so that the cwd
 # in subprocesses like git equals our $PWD (for pathname comparisons).
-cd -P "$test" || exit 1
+cd -P "$TRASH_DIRECTORY" || exit 1
 
 this_test=${0##*/}
 this_test=${this_test%%-*}
diff --git a/usage.c b/usage.c
index 40b3de51c7dfa3fdaaeb44e1c64a2208560414c5..ed146453cabeb9e82bef0c5610cda47d1b2a0b1c 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -6,8 +6,6 @@
 #include "git-compat-util.h"
 #include "cache.h"
 
-static int dying;
-
 void vreportf(const char *prefix, const char *err, va_list params)
 {
        char msg[4096];
@@ -49,12 +47,19 @@ static void warn_builtin(const char *warn, va_list params)
        vreportf("warning: ", warn, params);
 }
 
+static int die_is_recursing_builtin(void)
+{
+       static int dying;
+       return dying++;
+}
+
 /* If we are in a dlopen()ed .so write to a global variable would segfault
  * (ugh), so keep things static. */
 static NORETURN_PTR void (*usage_routine)(const char *err, va_list params) = usage_builtin;
 static NORETURN_PTR void (*die_routine)(const char *err, va_list params) = die_builtin;
 static void (*error_routine)(const char *err, va_list params) = error_builtin;
 static void (*warn_routine)(const char *err, va_list params) = warn_builtin;
+static int (*die_is_recursing)(void) = die_is_recursing_builtin;
 
 void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params))
 {
@@ -66,6 +71,11 @@ void set_error_routine(void (*routine)(const char *err, va_list params))
        error_routine = routine;
 }
 
+void set_die_is_recursing_routine(int (*routine)(void))
+{
+       die_is_recursing = routine;
+}
+
 void NORETURN usagef(const char *err, ...)
 {
        va_list params;
@@ -84,11 +94,10 @@ void NORETURN die(const char *err, ...)
 {
        va_list params;
 
-       if (dying) {
+       if (die_is_recursing()) {
                fputs("fatal: recursion detected in die handler\n", stderr);
                exit(128);
        }
-       dying = 1;
 
        va_start(params, err);
        die_routine(err, params);
@@ -102,12 +111,11 @@ void NORETURN die_errno(const char *fmt, ...)
        char str_error[256], *err;
        int i, j;
 
-       if (dying) {
+       if (die_is_recursing()) {
                fputs("fatal: recursion detected in die_errno handler\n",
                        stderr);
                exit(128);
        }
-       dying = 1;
 
        err = strerror(errno);
        for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
diff --git a/zlib.c b/zlib.c
index bbaa0815ed55a425e458773a58a0eb9aca8453eb..61e6df0fdce6dfaf38da7af996d7fe801db8f00c 100644 (file)
--- a/zlib.c
+++ b/zlib.c
@@ -189,7 +189,7 @@ void git_deflate_init_gzip(git_zstream *strm, int level)
         * Use default 15 bits, +16 is to generate gzip header/trailer
         * instead of the zlib wrapper.
         */
-       return do_git_deflate_init(strm, level, 15 + 16);
+       do_git_deflate_init(strm, level, 15 + 16);
 }
 
 void git_deflate_init_raw(git_zstream *strm, int level)
@@ -198,7 +198,7 @@ void git_deflate_init_raw(git_zstream *strm, int level)
         * Use default 15 bits, negate the value to get raw compressed
         * data without zlib header and trailer.
         */
-       return do_git_deflate_init(strm, level, -15);
+       do_git_deflate_init(strm, level, -15);
 }
 
 int git_deflate_abort(git_zstream *strm)