summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/RelNotes/1.8.3.txt79
-rw-r--r--Documentation/config.txt19
-rw-r--r--Documentation/git-cat-file.txt6
-rw-r--r--Documentation/git-count-objects.txt14
-rw-r--r--Documentation/git-daemon.txt7
-rw-r--r--Documentation/git-describe.txt2
-rw-r--r--Documentation/git-format-patch.txt5
-rw-r--r--Documentation/git-fsck.txt4
-rw-r--r--Documentation/git-http-backend.txt82
-rw-r--r--Documentation/git-index-pack.txt2
-rw-r--r--Documentation/git-ls-files.txt2
-rw-r--r--Documentation/git-merge-index.txt2
-rw-r--r--Documentation/git-pack-objects.txt2
-rw-r--r--Documentation/git-patch-id.txt2
-rw-r--r--Documentation/git-replace.txt4
-rw-r--r--Documentation/git-rev-parse.txt4
-rw-r--r--Documentation/git-send-email.txt5
-rw-r--r--Documentation/git-show-branch.txt4
-rw-r--r--Documentation/git-show-index.txt2
-rw-r--r--Documentation/git-show-ref.txt4
-rw-r--r--Documentation/git-tag.txt2
-rw-r--r--Documentation/git-update-index.txt2
-rw-r--r--Documentation/git-verify-pack.txt4
-rw-r--r--Documentation/git-verify-tag.txt2
-rw-r--r--Documentation/git.txt10
-rw-r--r--Documentation/gitcore-tutorial.txt8
-rw-r--r--Documentation/gitdiffcore.txt2
-rw-r--r--Documentation/githooks.txt10
-rw-r--r--Documentation/gitrepository-layout.txt2
-rw-r--r--Documentation/gittutorial-2.txt16
-rw-r--r--Documentation/glossary-content.txt83
-rw-r--r--Documentation/howto/recover-corrupted-blob-object.txt6
-rw-r--r--Documentation/merge-strategies.txt6
-rw-r--r--Documentation/pretty-formats.txt2
-rw-r--r--Documentation/revisions.txt4
-rw-r--r--Documentation/technical/api-sha1-array.txt4
-rw-r--r--Documentation/technical/api-strbuf.txt5
-rw-r--r--Documentation/technical/pack-format.txt14
-rw-r--r--Documentation/technical/pack-heuristics.txt2
-rw-r--r--Documentation/technical/shallow.txt4
-rw-r--r--attr.c35
-rw-r--r--branch.c54
-rw-r--r--builtin/add.c134
-rw-r--r--builtin/blame.c11
-rw-r--r--builtin/branch.c36
-rw-r--r--builtin/cat-file.c71
-rw-r--r--builtin/checkout.c2
-rw-r--r--builtin/count-objects.c44
-rw-r--r--builtin/fmt-merge-msg.c18
-rw-r--r--builtin/log.c166
-rw-r--r--builtin/merge-tree.c26
-rw-r--r--builtin/show-branch.c17
-rw-r--r--bundle.c2
-rw-r--r--cache.h3
-rw-r--r--config.mak.uname1
-rw-r--r--contrib/completion/git-completion.bash78
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr9
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg125
-rwxr-xr-xcontrib/remote-helpers/test-hg-bidi.sh11
-rwxr-xr-xcontrib/remote-helpers/test-hg-hg-git.sh8
-rwxr-xr-xcontrib/remote-helpers/test-hg.sh36
-rw-r--r--convert.c27
-rw-r--r--diff.c6
-rwxr-xr-xgit-bisect.sh8
-rw-r--r--git-compat-util.h1
-rw-r--r--git-rebase--am.sh4
-rwxr-xr-xgit-send-email.perl7
-rw-r--r--help.c4
-rw-r--r--http-backend.c38
-rw-r--r--http-push.c2
-rw-r--r--http.c61
-rw-r--r--http.h16
-rw-r--r--perl/Git.pm6
-rw-r--r--pretty.c45
-rw-r--r--progress.c43
-rw-r--r--read-cache.c34
-rw-r--r--remote-curl.c41
-rw-r--r--revision.c3
-rw-r--r--run-command.c11
-rw-r--r--sequencer.c18
-rw-r--r--sha1_file.c411
-rw-r--r--strbuf.c19
-rw-r--r--strbuf.h1
-rw-r--r--submodule.c13
-rw-r--r--submodule.h1
-rw-r--r--t/lib-httpd/apache.conf23
-rwxr-xr-xt/t1006-cat-file.sh5
-rwxr-xr-xt/t3508-cherry-pick-many-commits.sh6
-rwxr-xr-xt/t4014-format-patch.sh33
-rwxr-xr-xt/t4212-log-corrupt.sh42
-rwxr-xr-xt/t4300-merge-tree.sh10
-rwxr-xr-xt/t5004-archive-corner-cases.sh2
-rwxr-xr-xt/t5404-tracking-branches.sh2
-rwxr-xr-xt/t5505-remote.sh2
-rwxr-xr-xt/t5516-fetch-push.sh12
-rwxr-xr-xt/t5517-push-mirror.sh2
-rwxr-xr-xt/t5519-push-alternates.sh12
-rwxr-xr-xt/t5531-deep-submodule-push.sh1
-rwxr-xr-xt/t5541-http-push.sh30
-rwxr-xr-xt/t5550-http-fetch.sh1
-rwxr-xr-xt/t5551-http-fetch.sh25
-rwxr-xr-xt/t5570-git-daemon.sh1
-rwxr-xr-xt/t5704-bundle.sh10
-rwxr-xr-xt/t6030-bisect-porcelain.sh18
-rwxr-xr-xt/t6200-fmt-merge-msg.sh18
-rwxr-xr-xt/t7406-submodule-update.sh4
-rwxr-xr-xt/t9400-git-cvsserver-server.sh1
-rwxr-xr-xt/t9401-git-cvsserver-crlf.sh1
-rwxr-xr-xt/t9700/test.pl3
-rwxr-xr-xt/t9902-completion.sh65
-rwxr-xr-xt/t9903-bash-prompt.sh10
-rw-r--r--t/test-lib.sh18
-rw-r--r--usage.c20
-rw-r--r--zlib.c4
114 files changed, 1701 insertions, 826 deletions
diff --git a/Documentation/RelNotes/1.8.3.txt b/Documentation/RelNotes/1.8.3.txt
index bcbcf15..7799cec 100644
--- a/Documentation/RelNotes/1.8.3.txt
+++ b/Documentation/RelNotes/1.8.3.txt
@@ -24,7 +24,10 @@ 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
@@ -32,6 +35,29 @@ Updates since v1.8.2
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).
+
+ * "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 +93,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 +145,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 +182,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 +192,49 @@ 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).
+ * 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.
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 3d750e0..c67038b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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::
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index 2fb95bb..30d585a 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -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
diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt
index da6e72e..b300e84 100644
--- a/Documentation/git-count-objects.txt
+++ b/Documentation/git-count-objects.txt
@@ -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
---
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
index 77da564..bfb106c 100644
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -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>::
diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index 3c81e85..28e5ec0 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -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
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 3a62f50..3911877 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -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
------------
diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt
index eff9188..e5878bd 100644
--- a/Documentation/git-fsck.txt
+++ b/Documentation/git-fsck.txt
@@ -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
diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt
index 7b1e85c..e3bcdb5 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -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
-----------
diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt
index 36adc5f..bde8eec 100644
--- a/Documentation/git-index-pack.txt
+++ b/Documentation/git-index-pack.txt
@@ -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'
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 0bdebff..c0856a6 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -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
diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt
index 0c80cec..02676fb 100644
--- a/Documentation/git-merge-index.txt
+++ b/Documentation/git-merge-index.txt
@@ -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.
diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt
index 69c9313..d94edcd 100644
--- a/Documentation/git-pack-objects.txt
+++ b/Documentation/git-pack-objects.txt
@@ -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.
diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt
index 90268f0..312c3b1 100644
--- a/Documentation/git-patch-id.txt
+++ b/Documentation/git-patch-id.txt
@@ -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.
diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt
index 0142cd1..e0b4057 100644
--- a/Documentation/git-replace.txt
+++ b/Documentation/git-replace.txt
@@ -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.
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 1f9ed6c..947d62f 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -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.
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 0cffef8..40a9a9a 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -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
diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt
index a8e77b5..a515648 100644
--- a/Documentation/git-show-branch.txt
+++ b/Documentation/git-show-branch.txt
@@ -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":
diff --git a/Documentation/git-show-index.txt b/Documentation/git-show-index.txt
index 9cbbed9..fbdc8ad 100644
--- a/Documentation/git-show-index.txt
+++ b/Documentation/git-show-index.txt
@@ -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
---
diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index 5dbcd47..de4d352 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -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::
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index b21aa87..22894cb 100644
--- a/Documentation/git-tag.txt
+++ b/Documentation/git-tag.txt
@@ -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
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index c927758..670e9fb 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -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:
diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt
index 0eb9ffb..526ba7b 100644
--- a/Documentation/git-verify-pack.txt
+++ b/Documentation/git-verify-pack.txt
@@ -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.
diff --git a/Documentation/git-verify-tag.txt b/Documentation/git-verify-tag.txt
index e996135..f88ba96 100644
--- a/Documentation/git-verify-tag.txt
+++ b/Documentation/git-verify-tag.txt
@@ -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
---
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 6a875f2..807a13c 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -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.
diff --git a/Documentation/gitcore-tutorial.txt b/Documentation/gitcore-tutorial.txt
index 59c1c17..f538a87 100644
--- a/Documentation/gitcore-tutorial.txt
+++ b/Documentation/gitcore-tutorial.txt
@@ -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).
diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt
index 4ed71c7..568d757 100644
--- a/Documentation/gitdiffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -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
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index dc6693f..d48bf4d 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -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
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index 817337f..d6f3393 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -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.
diff --git a/Documentation/gittutorial-2.txt b/Documentation/gittutorial-2.txt
index 94c906e..3109ea8 100644
--- a/Documentation/gittutorial-2.txt
+++ b/Documentation/gittutorial-2.txt
@@ -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.
diff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt
index eb7ba84..ce3e4fa 100644
--- a/Documentation/glossary-content.txt
+++ b/Documentation/glossary-content.txt
@@ -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
diff --git a/Documentation/howto/recover-corrupted-blob-object.txt b/Documentation/howto/recover-corrupted-blob-object.txt
index 6d362ce..1b3b188 100644
--- a/Documentation/howto/recover-corrupted-blob-object.txt
+++ b/Documentation/howto/recover-corrupted-blob-object.txt
@@ -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?
diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 66db802..49a9a7d 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -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;;
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index afac703..f5b50dc 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -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
diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index 8855b1a..a8ff691 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -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
diff --git a/Documentation/technical/api-sha1-array.txt b/Documentation/technical/api-sha1-array.txt
index 45d1c51..3e75497 100644
--- a/Documentation/technical/api-sha1-array.txt
+++ b/Documentation/technical/api-sha1-array.txt
@@ -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,
diff --git a/Documentation/technical/api-strbuf.txt b/Documentation/technical/api-strbuf.txt
index 2c59cb2..3350d97 100644
--- a/Documentation/technical/api-strbuf.txt
+++ b/Documentation/technical/api-strbuf.txt
@@ -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.
diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt
index a37f137..8e5bf60 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -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.
diff --git a/Documentation/technical/pack-heuristics.txt b/Documentation/technical/pack-heuristics.txt
index dbdf7ba..8b7ae1c 100644
--- a/Documentation/technical/pack-heuristics.txt
+++ b/Documentation/technical/pack-heuristics.txt
@@ -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
diff --git a/Documentation/technical/shallow.txt b/Documentation/technical/shallow.txt
index ea2f69f..5183b15 100644
--- a/Documentation/technical/shallow.txt
+++ b/Documentation/technical/shallow.txt
@@ -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 689bc2a..0e774c6 100644
--- 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;
diff --git a/branch.c b/branch.c
index 6ae6a4c..97c72bf 100644
--- 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);
diff --git a/builtin/add.c b/builtin/add.c
index ab1c9e8..daf02c6 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -26,8 +26,52 @@ static int take_worktree_changes;
struct update_callback_data {
int flags;
int add_errors;
+ const char *implicit_dot;
+ size_t implicit_dot_len;
};
+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)
{
@@ -54,10 +98,26 @@ static void update_callback(struct diff_queue_struct *q,
{
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);
@@ -85,20 +145,34 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
{
struct update_callback_data data;
struct rev_info rev;
+
+ memset(&data, 0, sizeof(data));
+ data.flags = flags & ~ADD_CACHE_IMPLICIT_DOT;
+ 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.
+ */
+ data.implicit_dot = prefix;
+ data.implicit_dot_len = strlen(prefix);
+ pathspec = NULL;
+ }
+
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.max_count = 0; /* do not compare unmerged paths with stage #2 */
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
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 +189,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);
@@ -321,35 +405,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 +415,7 @@ 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;
git_config(add_config, NULL);
@@ -391,11 +445,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 +460,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 +485,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) {
diff --git a/builtin/blame.c b/builtin/blame.c
index 86100e9..7770781 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -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
diff --git a/builtin/branch.c b/builtin/branch.c
index 3f0fbc0..0836890 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -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);
}
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 40f87b4..045cee7 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -16,73 +16,6 @@
#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;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 4ed1ee7..81b4419 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -732,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));
}
/*
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 3a01a8d..a7f70cb 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -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;
}
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 265a925..1c04070 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -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);
diff --git a/builtin/log.c b/builtin/log.c
index 0f31810..ad46f72 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -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--;
}
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index bc912e3..ed25d81 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -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);
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index d208fd6..90fc6b1 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -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);
}
diff --git a/bundle.c b/bundle.c
index 505e07e..4b0e5cd 100644
--- 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 e1e8ce8..94ca1ac 100644
--- 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
diff --git a/config.mak.uname b/config.mak.uname
index 9080054..d78fd3d 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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))
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2ba1461..6df62c2 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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
;;
*)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index bd25e08..aa7bc97 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -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')
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 328c2dc..5481331 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -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))
diff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh
index 1d61982..f368953 100755
--- a/contrib/remote-helpers/test-hg-bidi.sh
+++ b/contrib/remote-helpers/test-hg-bidi.sh
@@ -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 &&
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 3f253b7..253e65a 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -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
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 7bb81f2..d5b8730 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -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
diff --git a/convert.c b/convert.c
index 3520252..2a2e46c 100644
--- 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 0eb2653..f0b3e7c 100644
--- 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 */
diff --git a/git-bisect.sh b/git-bisect.sh
index 99efbe8..c58eea7 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -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
diff --git a/git-compat-util.h b/git-compat-util.h
index cde442f..e955bb5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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);
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 97f31dc..f84854f 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -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
diff --git a/git-send-email.perl b/git-send-email.perl
index 7297472..bd13cc8 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -54,7 +54,7 @@ git send-email [options] <file | directory | rev-list options >
--[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 @@ my %config_bool_settings = (
"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 @@ my $rc = GetOptions("h" => \$help,
"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,
diff --git a/help.c b/help.c
index 1dfa0b0..02ba043 100644
--- 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;
}
diff --git a/http-backend.c b/http-backend.c
index 8144f3a..6b85ffa 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -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},
diff --git a/http-push.c b/http-push.c
index bd66f6a..395a8cf 100644
--- a/http-push.c
+++ b/http-push.c
@@ -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 8803c70..92aba59 100644
--- 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 @@ cleanup:
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 25d1931..d77c1b5 100644
--- a/http.h
+++ b/http.h
@@ -42,6 +42,15 @@
#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 */
diff --git a/perl/Git.pm b/perl/Git.pm
index 650db90..dc48159 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -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);
}
diff --git a/pretty.c b/pretty.c
index d3a82d2..c116248 100644
--- 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;
}
diff --git a/progress.c b/progress.c
index 3971f49..10652b1 100644
--- a/progress.c
+++ b/progress.c
@@ -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);
diff --git a/read-cache.c b/read-cache.c
index 5a9704f..04ed561 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -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;
+}
diff --git a/remote-curl.c b/remote-curl.c
index 93a09a6..60eda63 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -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));
diff --git a/revision.c b/revision.c
index eb98128..56d666d 100644
--- a/revision.c
+++ b/revision.c
@@ -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)
diff --git a/run-command.c b/run-command.c
index 765c2ce..1b32a12 100644
--- a/run-command.c
+++ b/run-command.c
@@ -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)
diff --git a/sequencer.c b/sequencer.c
index ee4f8c6..cf8fbeb 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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 /
diff --git a/sha1_file.c b/sha1_file.c
index 0ed2398..64228a2 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -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;
}
diff --git a/strbuf.c b/strbuf.c
index 48e9abb..1170d01 100644
--- 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;
diff --git a/strbuf.h b/strbuf.h
index 958822c..73e80ce 100644
--- 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, ...);
diff --git a/submodule.c b/submodule.c
index 975bc87..e728025 100644
--- a/submodule.c
+++ b/submodule.c
@@ -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)
diff --git a/submodule.h b/submodule.h
index 3dc1b3f..c7ffc7c 100644
--- a/submodule.h
+++ b/submodule.h
@@ -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);
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 938b4cf..b5bce45 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -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
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 9820f70..9cc5c6b 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -135,14 +135,11 @@ 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" \
diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
index 4e7136b..19c99d7 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -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
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 86ee077..58d4180 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -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
index 0000000..ec5099b
--- /dev/null
+++ b/t/t4212-log-corrupt.sh
@@ -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
diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh
index d0b2a45..bd43b3d 100755
--- a/t/t4300-merge-tree.sh
+++ b/t/t4300-merge-tree.sh
@@ -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
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index cdb7d7a..bfdb56a 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -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
diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh
index c240035..2b8c0ba 100755
--- a/t/t5404-tracking-branches.sh
+++ b/t/t5404-tracking-branches.sh
@@ -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' '
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index ccc55eb..6579a86 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -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 &&
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 838e71d..4691d51 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -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
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
index e2ad260..12a5dfb 100755
--- a/t/t5517-push-mirror.sh
+++ b/t/t5517-push-mirror.sh
@@ -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 &&
diff --git a/t/t5519-push-alternates.sh b/t/t5519-push-alternates.sh
index c00c9b0..11fcd37 100755
--- a/t/t5519-push-alternates.sh
+++ b/t/t5519-push-alternates.sh
@@ -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 :
)
'
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index 1947c28..8c16e04 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -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"
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 4086f02..beb00be 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -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
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index 80d20c8..f7d0f14 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -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
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
index 47eb769..b23efbb 100755
--- a/t/t5551-http-fetch.sh
+++ b/t/t5551-http-fetch.sh
@@ -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' '
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index a3a4e47..f01edff 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -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
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index 9e43731..a45c316 100755
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
@@ -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
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 8bf53de..4d3074a 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -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
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index f73ecea..54b5744 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -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 &&
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 2a0cfaa..a4ffea0 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -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
)
'
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 9502f24..0431386 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -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" &&
diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh
index 1c5bc84..8c3db76 100755
--- a/t/t9401-git-cvsserver-crlf.sh
+++ b/t/t9401-git-cvsserver-crlf.sh
@@ -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 &&
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 0d4e366..1140767 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -45,7 +45,8 @@ is($r->get_color("color.test.slot1", "red"), $ansi_green, "get_color");
# 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");
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index adc1372..6d9d141 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -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 &&
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 2101d91..e147a8d 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -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 &&
diff --git a/t/test-lib.sh b/t/test-lib.sh
index debd8b4..ca6bdef 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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 40b3de5..ed14645 100644
--- 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 bbaa081..61e6df0 100644
--- 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)