gitweb.git
Third batch after 2.12Junio C Hamano Mon, 13 Mar 2017 06:24:14 +0000 (23:24 -0700)

Third batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'ah/doc-ls-files-quotepath'Junio C Hamano Mon, 13 Mar 2017 06:21:36 +0000 (23:21 -0700)

Merge branch 'ah/doc-ls-files-quotepath'

Documentation for "git ls-files" did not refer to core.quotePath

* ah/doc-ls-files-quotepath:
Documentation: improve description for core.quotePath

Merge branch 'jc/diff-populate-filespec-size-only-fix'Junio C Hamano Mon, 13 Mar 2017 06:21:36 +0000 (23:21 -0700)

Merge branch 'jc/diff-populate-filespec-size-only-fix'

"git diff --quiet" relies on the size field in diff_filespec to be
correctly populated, but diff_populate_filespec() helper function
made an incorrect short-cut when asked only to populate the size
field for paths that need to go through convert_to_git() (e.g. CRLF
conversion).

* jc/diff-populate-filespec-size-only-fix:
diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

Merge branch 'vn/line-log-memcpy-size-fix'Junio C Hamano Mon, 13 Mar 2017 06:21:35 +0000 (23:21 -0700)

Merge branch 'vn/line-log-memcpy-size-fix'

The command-line parsing of "git log -L" copied internal data
structures using incorrect size on ILP32 systems.

* vn/line-log-memcpy-size-fix:
line-log: use COPY_ARRAY to fix mis-sized memcpy

Merge branch 'jk/ewah-use-right-type-in-sizeof'Junio C Hamano Mon, 13 Mar 2017 06:21:35 +0000 (23:21 -0700)

Merge branch 'jk/ewah-use-right-type-in-sizeof'

Code clean-up.

* jk/ewah-use-right-type-in-sizeof:
ewah: fix eword_t/uint64_t confusion

Merge branch 'ax/line-log-range-merge-fix'Junio C Hamano Mon, 13 Mar 2017 06:21:34 +0000 (23:21 -0700)

Merge branch 'ax/line-log-range-merge-fix'

The code to parse "git log -L..." command line was buggy when there
are many ranges specified with -L; overrun of the allocated buffer
has been fixed.

* ax/line-log-range-merge-fix:
line-log.c: prevent crash during union of too many ranges

Merge branch 'ss/remote-bzr-hg-placeholder-wo-python'Junio C Hamano Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)

Merge branch 'ss/remote-bzr-hg-placeholder-wo-python'

There is no need for Python only to give a few messages to the
standard error stream, but we somehow did.

* ss/remote-bzr-hg-placeholder-wo-python:
contrib: git-remote-{bzr,hg} placeholders don't need Python

Merge branch 'js/realpath-pathdup-fix'Junio C Hamano Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)

Merge branch 'js/realpath-pathdup-fix'

Git v2.12 was shipped with an embarrassing breakage where various
operations that verify paths given from the user stopped dying when
seeing an issue, and instead later triggering segfault.

* js/realpath-pathdup-fix:
real_pathdup(): fix callsites that wanted it to die on error
t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

Merge branch 'jk/add-i-patch-do-prompt'Junio C Hamano Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)

Merge branch 'jk/add-i-patch-do-prompt'

The patch subcommand of "git add -i" was meant to have paths
selection prompt just like other subcommand, unlike "git add -p"
directly jumps to hunk selection. Recently, this was broken and
"add -i" lost the paths selection dialog, but it now has been
fixed.

* jk/add-i-patch-do-prompt:
add--interactive: fix missing file prompt for patch mode with "-i"

Merge branch 'jh/mingw-openssl-sha1'Junio C Hamano Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)

Merge branch 'jh/mingw-openssl-sha1'

Windows port wants to use OpenSSL's implementation of SHA-1
routines, so let them.

* jh/mingw-openssl-sha1:
mingw: use OpenSSL's SHA-1 routines

Second batch after 2.12Junio C Hamano Fri, 10 Mar 2017 21:24:59 +0000 (13:24 -0800)

Second batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'rs/log-email-subject'Junio C Hamano Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)

Merge branch 'rs/log-email-subject'

Code clean-up.

* rs/log-email-subject:
pretty: use fmt_output_email_subject()
log-tree: factor out fmt_output_email_subject()

Merge branch 'tg/stash-push'Junio C Hamano Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)

Merge branch 'tg/stash-push'

"git stash save" takes a pathspec so that the local changes can be
stashed away only partially.

* tg/stash-push:
stash: allow pathspecs in the no verb form
stash: use stash_push for no verb form
stash: teach 'push' (and 'create_stash') to honor pathspec
stash: refactor stash_create
stash: add test for the create command line arguments
stash: introduce push verb

Merge branch 'sb/submodule-init-url-selection'Junio C Hamano Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)

Merge branch 'sb/submodule-init-url-selection'

When "git submodule init" decides that the submodule in the working
tree is its upstream, it now gives a warning as it is not a very
common setup.

* sb/submodule-init-url-selection:
submodule init: warn about falling back to a local path

Merge branch 'rj/remove-unused-mktemp'Junio C Hamano Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)

Merge branch 'rj/remove-unused-mktemp'

Code cleanup.

* rj/remove-unused-mktemp:
wrapper.c: remove unused gitmkstemps() function
wrapper.c: remove unused git_mkstemp() function

Merge branch 'ew/markdown-url-in-readme'Junio C Hamano Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)

Merge branch 'ew/markdown-url-in-readme'

Doc update.

* ew/markdown-url-in-readme:
README: create HTTP/HTTPS links from URLs in Markdown

Merge branch 'ps/docs-diffcore'Junio C Hamano Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)

Merge branch 'ps/docs-diffcore'

Doc update.

* ps/docs-diffcore:
docs/diffcore: unquote "Complete Rewrites" in headers
docs/diffcore: fix grammar in diffcore-rename header

Merge branch 'jt/http-base-url-update-upon-redirect'Junio C Hamano Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)

Merge branch 'jt/http-base-url-update-upon-redirect'

When a redirected http transport gets an error during the
redirected request, we ignored the error we got from the server,
and ended up giving a not-so-useful error message.

* jt/http-base-url-update-upon-redirect:
http: attempt updating base URL only if no error

Merge branch 'jk/http-auth'Junio C Hamano Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)

Merge branch 'jk/http-auth'

Reduce authentication round-trip over HTTP when the server supports
just a single authentication method.

* jk/http-auth:
http: add an "auto" mode for http.emptyauth
http: restrict auth methods to what the server advertises

Merge branch 'jh/send-email-one-cc'Junio C Hamano Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)

Merge branch 'jh/send-email-one-cc'

"Cc:" on the trailer part does not have to conform to RFC strictly,
unlike in the e-mail header. "git send-email" has been updated to
ignore anything after '>' when picking addresses, to allow non-address
cruft like " # stable 4.4" after the address.

* jh/send-email-one-cc:
send-email: only allow one address per body tag

Merge branch 'rs/strbuf-add-real-path'Junio C Hamano Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)

Merge branch 'rs/strbuf-add-real-path'

An helper function to make it easier to append the result from
real_path() to a strbuf has been added.

* rs/strbuf-add-real-path:
strbuf: add strbuf_add_real_path()
cocci: use ALLOC_ARRAY

Merge branch 'rs/sha1-file-plug-fallback-base-leak'Junio C Hamano Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)

Merge branch 'rs/sha1-file-plug-fallback-base-leak'

A leak in a codepath to read from a packed object in (rare) cases
has been plugged.

* rs/sha1-file-plug-fallback-base-leak:
sha1_file: release fallback base's memory in unpack_entry()

Merge branch 'rs/commit-parsing-optim'Junio C Hamano Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)

Merge branch 'rs/commit-parsing-optim'

The code that parses header fields in the commit object has been
updated for (micro)performance and code hygiene.

* rs/commit-parsing-optim:
commit: don't check for space twice when looking for header
commit: be more precise when searching for headers

Merge branch 'jk/t6300-cleanup'Junio C Hamano Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)

Merge branch 'jk/t6300-cleanup'

A test that creates a confusing branch whose name is HEAD has been
corrected not to do so.

* jk/t6300-cleanup:
t6300: avoid creating refs/heads/HEAD

Merge branch 'jk/parse-config-key-cleanup'Junio C Hamano Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)

Merge branch 'jk/parse-config-key-cleanup'

The "parse_config_key()" API function has been cleaned up.

* jk/parse-config-key-cleanup:
parse_hide_refs_config: tell parse_config_key we don't want a subsection
parse_config_key: allow matching single-level config
parse_config_key: use skip_prefix instead of starts_with

Merge branch 'sb/parse-hide-refs-config-cleanup'Junio C Hamano Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)

Merge branch 'sb/parse-hide-refs-config-cleanup'

Code clean-up.

* sb/parse-hide-refs-config-cleanup:
refs: parse_hide_refs_config to use parse_config_key

Merge branch 'jt/upload-pack-error-report'Junio C Hamano Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)

Merge branch 'jt/upload-pack-error-report'

"git upload-pack", which is a counter-part of "git fetch", did not
report a request for a ref that was not advertised as invalid.
This is generally not a problem (because "git fetch" will stop
before making such a request), but is the right thing to do.

* jt/upload-pack-error-report:
upload-pack: report "not our ref" to client

Merge branch 'jk/ident-empty'Junio C Hamano Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)

Merge branch 'jk/ident-empty'

user.email that consists of only cruft chars should consistently
error out, but didn't.

* jk/ident-empty:
ident: do not ignore empty config name/email
ident: reject all-crud ident name
ident: handle NULL email when complaining of empty name
ident: mark error messages for translation

Merge branch 'jc/config-case-cmdline-take-2'Junio C Hamano Fri, 10 Mar 2017 21:24:20 +0000 (13:24 -0800)

Merge branch 'jc/config-case-cmdline-take-2'

The code to parse "git -c VAR=VAL cmd" and set configuration
variable for the duration of cmd had two small bugs, which have
been fixed.

* jc/config-case-cmdline-take-2:
config: use git_config_parse_key() in git_config_parse_parameter()
config: move a few helper functions up

real_pathdup(): fix callsites that wanted it to die... Johannes Schindelin Wed, 8 Mar 2017 15:43:40 +0000 (16:43 +0100)

real_pathdup(): fix callsites that wanted it to die on error

In 4ac9006f832 (real_path: have callers use real_pathdup and
strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path())
pattern to use real_pathdup() directly.

The problem with this change is that real_path() calls
strbuf_realpath() with die_on_error = 1 while real_pathdup() calls
it with die_on_error = 0. Meaning that in cases where real_path()
causes Git to die() with an error message, real_pathdup() is silent
and returns NULL instead.

The callers, however, are ill-prepared for that change, as they expect
the return value to be non-NULL (and otherwise the function died
with an appropriate error message).

Fix this by extending real_pathdup()'s signature to accept the
die_on_error flag and simply pass it through to strbuf_realpath(),
and then adjust all callers after a careful audit whether they would
handle NULLs well.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1501: demonstrate NULL pointer access with invalid... Johannes Schindelin Wed, 8 Mar 2017 15:43:34 +0000 (16:43 +0100)

t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

When GIT_WORK_TREE does not specify a valid path, we should error
out, instead of crashing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git svn: fix authentication with 'branch'Hiroshi Shirosaki Mon, 6 Mar 2017 05:59:07 +0000 (14:59 +0900)

git svn: fix authentication with 'branch'

Authentication fails with svn branch while svn rebase and
svn dcommit work fine without authentication failures.

$ git svn branch v7_3
Copying https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at r27519
to https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/v7_3...
Can't create session: Unable to connect to a repository at URL
'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': No more
credentials or we tried too many times.
Authentication failed at
C:\Program Files\Git\mingw64/libexec/git-core\git-svn line 1200.

We add auth configuration to SVN::Client->new() to fix the issue.

Signed-off-by: Hiroshi Shirosaki <h.shirosaki@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>

ewah: fix eword_t/uint64_t confusionJeff King Sun, 5 Mar 2017 11:46:38 +0000 (06:46 -0500)

ewah: fix eword_t/uint64_t confusion

The ewah subsystem typedefs eword_t to be uint64_t, but some
code uses a bare uint64_t. This isn't a bug now, but it's a
potential maintenance problem if the definition of eword_t
ever changes. Let's use the correct type.

Note that we can't use COPY_ARRAY() here because the source
and destination point to objects of different sizes. For
that reason we'll also skip the usual "sizeof(*dst)" and use
the real type, which should make it more clear that there's
something tricky going on.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

line-log: use COPY_ARRAY to fix mis-sized memcpyVegard Nossum Sun, 5 Mar 2017 11:44:46 +0000 (06:44 -0500)

line-log: use COPY_ARRAY to fix mis-sized memcpy

This memcpy meant to get the sizeof a "struct range", not a
"range_set", as the former is what our array holds. Rather
than swap out the types, let's convert this site to
COPY_ARRAY, which avoids the problem entirely (and confirms
that the src and dst types match).

Note for curiosity's sake that this bug doesn't trigger on
I32LP64 systems, but does on ILP32 systems. The mistaken
"struct range_set" has two ints and a pointer. That's 16
bytes on LP64, or 12 on ILP32. The correct "struct range"
type has two longs, which is also 16 on LP64, but only 8 on
ILP32.

Likewise an IL32P64 system would experience the bug.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

line-log.c: prevent crash during union of too many... Allan Xavier Thu, 2 Mar 2017 17:29:02 +0000 (17:29 +0000)

line-log.c: prevent crash during union of too many ranges

The existing implementation of range_set_union does not correctly
reallocate memory, leading to a heap overflow when it attempts to union
more than 24 separate line ranges.

For struct range_set *out to grow correctly it must have out->nr set to
the current size of the buffer when it is passed to range_set_grow.
However, the existing implementation of range_set_union only updates
out->nr at the end of the function, meaning that it is always zero
before this. This results in range_set_grow never growing the buffer, as
well as some of the union logic itself being incorrect as !out->nr is
always true.

The reason why 24 is the limit is that the first allocation of size 1
ends up allocating a buffer of size 24 (due to the call to alloc_nr in
ALLOC_GROW). This goes some way to explain why this hasn't been
caught before.

Fix the problem by correctly updating out->nr after reallocating the
range_set. As this results in out->nr containing the same value as the
variable o, replace o with out->nr as well.

Finally, add a new test to help prevent the problem reoccurring in the
future. Thanks to Vegard Nossum for writing the test.

Signed-off-by: Allan Xavier <allan.x.xavier@oracle.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

contrib: git-remote-{bzr,hg} placeholders don't need... Sebastian Schuberth Fri, 3 Mar 2017 10:57:46 +0000 (10:57 +0000)

contrib: git-remote-{bzr,hg} placeholders don't need Python

It does not make sense for these placeholder scripts to depend on Python
just because the real scripts do. At the example of Git for Windows, we
would not even be able to see those warnings as it does not ship with
Python. So just use plain shell scripts instead.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: improve description for core.quotePathAndreas Heiduk Thu, 2 Mar 2017 19:03:52 +0000 (20:03 +0100)

Documentation: improve description for core.quotePath

Linking the description for pathname quoting to the configuration
variable "core.quotePath" removes inconstistent and incomplete
sections while also giving two hints how to deal with it: Either with
"-c core.quotePath=false" or with "-z".

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: do not short-cut CHECK_SIZE_ONLY check in diff_po... Junio C Hamano Wed, 1 Mar 2017 17:04:44 +0000 (18:04 +0100)

diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

Callers of diff_populate_filespec() can choose to ask only for the
size of the blob without grabbing the blob data, and the function,
after running lstat() when the filespec points at a working tree
file, returns by copying the value in size field of the stat
structure into the size field of the filespec when this is the case.

However, this short-cut cannot be taken if the contents from the
path needs to go through convert_to_git(), whose resulting real blob
data may be different from what is in the working tree file.

As "git diff --quiet" compares the .size fields of filespec
structures to skip content comparison, this bug manifests as a
false "there are differences" for a file that needs eol conversion,
for example.

Reported-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

add--interactive: fix missing file prompt for patch... Jeff King Thu, 2 Mar 2017 09:48:22 +0000 (04:48 -0500)

add--interactive: fix missing file prompt for patch mode with "-i"

When invoked as "git add -i", each menu interactive menu
option prompts the user to select a list of files. This
includes the "patch" option, which gets the list before
starting the hunk-selection loop.

As "git add -p", it behaves differently, and jumps straight
to the hunk selection loop.

Since 0539d5e6d (i18n: add--interactive: mark patch prompt
for translation, 2016-12-14), the "add -i" case mistakenly
jumps to straight to the hunk-selection loop. Prior to that
commit the distinction between the two cases was managed by
the $patch_mode variable. That commit used $patch_mode for
something else, and moved the old meaning to the "$cmd"
variable. But it forgot to update the $patch_mode check
inside patch_update_cmd() which controls the file-list
behavior.

The simplest fix would be to change that line to check $cmd.
But while we're here, let's use a less obscure name for this
flag: $patch_mode_only, a boolean which tells whether we are
in full-interactive mode or only in patch-mode.

Reported-by: Henrik Grubbström <grubba@grubba.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pretty: use fmt_output_email_subject()René Scharfe Wed, 1 Mar 2017 11:37:07 +0000 (12:37 +0100)

pretty: use fmt_output_email_subject()

Add the email-style subject prefix (e.g. "Subject: [PATCH] ") directly
when it's needed instead of letting log_write_email_headers() prepare
it in a static buffer in advance. This simplifies storage ownership and
code flow.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

README: create HTTP/HTTPS links from URLs in MarkdownEric Wong Wed, 1 Mar 2017 22:22:04 +0000 (22:22 +0000)

README: create HTTP/HTTPS links from URLs in Markdown

Markdown supports automatic links by surrounding URLs with
angle brackets, as documented in
<https://daringfireball.net/projects/markdown/syntax#autolink>

While we're at it, update URLs to avoid redirecting clients for
git-scm.com (by using HTTPS) and public-inbox.org (by adding a
trailing slash).

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

log-tree: factor out fmt_output_email_subject()René Scharfe Wed, 1 Mar 2017 11:36:38 +0000 (12:36 +0100)

log-tree: factor out fmt_output_email_subject()

Use a strbuf to store the subject prefix string and move its
construction into its own function. This gets rid of two arbitrary
length limits and allows the string to be added by callers directly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: allow pathspecs in the no verb formThomas Gummerer Tue, 28 Feb 2017 20:33:40 +0000 (20:33 +0000)

stash: allow pathspecs in the no verb form

Now that stash_push is used in the no verb form of stash, allow
specifying the command line for this form as well. Always use -- to
disambiguate pathspecs from other non-option arguments.

Also make git stash -p an alias for git stash push -p. This allows
users to use git stash -p <pathspec>.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: use stash_push for no verb formThomas Gummerer Tue, 28 Feb 2017 20:33:39 +0000 (20:33 +0000)

stash: use stash_push for no verb form

Now that we have stash_push, which accepts pathspec arguments, use
it instead of stash_save in git stash without any additional verbs.

Previously we allowed git stash -- -message, which is no longer allowed
after this patch. Messages starting with a hyphen was allowed since
3c2eb80f, ("stash: simplify defaulting to "save" and reject unknown
options"). However it was never the intent to allow that, but rather it
was allowed accidentally.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: teach 'push' (and 'create_stash') to honor pathspecThomas Gummerer Tue, 28 Feb 2017 20:33:38 +0000 (20:33 +0000)

stash: teach 'push' (and 'create_stash') to honor pathspec

While working on a repository, it's often helpful to stash the changes
of a single or multiple files, and leave others alone. Unfortunately
git currently offers no such option. git stash -p can be used to work
around this, but it's often impractical when there are a lot of changes
over multiple files.

Allow 'git stash push' to take pathspec to specify which paths to stash.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule init: warn about falling back to a local... Stefan Beller Sat, 25 Feb 2017 01:31:47 +0000 (17:31 -0800)

submodule init: warn about falling back to a local path

When a submodule is initialized, the config variable 'submodule.<name>.url'
is set depending on the value of the same variable in the .gitmodules
file. When the URL indicates to be relative, then the url is computed
relative to its default remote. The default remote cannot be determined
accurately in all cases, such that it falls back to 'origin'.

The 'origin' remote may not exist, though. In that case we give up looking
for a suitable remote and we'll just assume it to be a local relative path.

This can be confusing to users as there is a lot of guessing involved,
which is not obvious to the user.

So in the corner case of assuming a local autoritative truth, warn the
user to lessen the confusion.

This behavior was introduced in 4d6893200 (submodule add: allow relative
repository path even when no url is set, 2011-06-06), which shared the
code with submodule-init and then ported to C in 3604242f080a (submodule:
port init from shell to C, 2016-04-15).

In case of submodule-add, this behavior makes sense in some use cases[1],
however for submodule-init there does not seem to be an immediate obvious
use case to fall back to a local submodule. However there might be, so
warn instead of die here.

While adding the warning, also clarify the behavior of relative URLs in
the documentation.

[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"

Reported-by: Shawn Pearce <spearce@spearce.org>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wrapper.c: remove unused gitmkstemps() functionRamsay Jones Tue, 28 Feb 2017 01:26:06 +0000 (01:26 +0000)

wrapper.c: remove unused gitmkstemps() function

The last call to the mkstemps() function was removed in commit 659488326
("wrapper.c: delete dead function git_mkstemps()", 22-04-2016). In order
to support platforms without mkstemps(), this functionality was provided,
along with a Makefile build variable (NO_MKSTEMPS), by the gitmkstemps()
function. Remove the dead code, along with the defunct build machinery.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wrapper.c: remove unused git_mkstemp() functionRamsay Jones Tue, 28 Feb 2017 01:24:10 +0000 (01:24 +0000)

wrapper.c: remove unused git_mkstemp() function

The last caller of git_mkstemp() was removed in commit 6fec0a89
("verify_signed_buffer: use tempfile object", 16-06-2016). Since
the introduction of the 'tempfile' APIs, along with git_mkstemp_mode,
it is unlikely that new callers will materialize. Remove the dead
code.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http: attempt updating base URL only if no errorJonathan Tan Tue, 28 Feb 2017 02:53:11 +0000 (18:53 -0800)

http: attempt updating base URL only if no error

http.c supports HTTP redirects of the form

http://foo/info/refs?service=git-upload-pack
-> http://anything
-> http://bar/info/refs?service=git-upload-pack

(that is to say, as long as the Git part of the path and the query
string is preserved in the final redirect destination, the intermediate
steps can have any URL). However, if one of the intermediate steps
results in an HTTP exception, a confusing "unable to update url base
from redirection" message is printed instead of a Curl error message
with the HTTP exception code.

This was introduced by 2 commits. Commit c93c92f ("http: update base
URLs when we see redirects", 2013-09-28) introduced a best-effort
optimization that required checking if only the "base" part of the URL
differed between the initial request and the final redirect destination,
but it performed the check before any HTTP status checking was done. If
something went wrong, the normal code path was still followed, so this
did not cause any confusing error messages until commit 6628eb4 ("http:
always update the base URL for redirects", 2016-12-06), which taught
http to die if the non-"base" part of the URL differed.

Therefore, teach http to check the HTTP status before attempting to
check if only the "base" part of the URL differed. This commit teaches
http_request_reauth to return early without updating options->base_url
upon an error; the only invoker of this function that passes a non-NULL
"options" is remote-curl.c (through "http_get_strbuf"), which only uses
options->base_url for an informational message in the situations that
this commit cares about (that is, when the return value is not HTTP_OK).

The included test checks that the redirect scheme at the beginning of
this commit message works, and that returning a 502 in the middle of the
redirect scheme produces the correct result. Note that this is different
from the test in commit 6628eb4 ("http: always update the base URL for
redirects", 2016-12-06) in that this commit tests that a Git-shaped URL
(http://.../info/refs?service=git-upload-pack) works, whereas commit
6628eb4 tests that a non-Git-shaped URL
(http://.../info/refs/foo?service=git-upload-pack) does not work (even
though Git is processing that URL) and is an error that is fatal, not
silently swallowed.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/diffcore: unquote "Complete Rewrites" in headersPatrick Steinhardt Tue, 28 Feb 2017 08:59:05 +0000 (09:59 +0100)

docs/diffcore: unquote "Complete Rewrites" in headers

The gitdiffcore documentation quotes the term "Complete Rewrites" in
headers for no real gain. This would make sense if the term could be
easily confused if not properly grouped together. But actually, the term
is quite obvious and thus does not really need any quoting, especially
regarding that it is not used anywhere else.

But more importanly, this brings up a bug when rendering man pages: when
trying to render quotes inside of a section header, we end up with
quotes which have been misaligned to the end of line. E.g.

diffcore-break: For Splitting Up Complete Rewrites
--------------------------------------------------

renders as

DIFFCORE-BREAK: FOR SPLITTING UP COMPLETE REWRITES""

, which is obviously wrong. While this is fixable for the man pages by
using double-quotes (e.g. ""COMPLETE REWRITES""), this again breaks it
for our generated HTML pages.

So fix the issue by simply dropping quotes inside of section headers,
which is currently only done for the term "Complete Rewrites".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/diffcore: fix grammar in diffcore-rename headerPatrick Steinhardt Tue, 28 Feb 2017 08:59:04 +0000 (09:59 +0100)

docs/diffcore: fix grammar in diffcore-rename header

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

First batch after 2.12Junio C Hamano Mon, 27 Feb 2017 22:04:24 +0000 (14:04 -0800)

First batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'rl/remote-allow-missing-branch-name-merge'Junio C Hamano Mon, 27 Feb 2017 21:57:18 +0000 (13:57 -0800)

Merge branch 'rl/remote-allow-missing-branch-name-merge'

"git remote rm X", when a branch has remote X configured as the
value of its branch.*.remote, tried to remove branch.*.remote and
branch.*.merge and failed if either is unset.

* rl/remote-allow-missing-branch-name-merge:
remote: ignore failure to remove missing branch.<name>.merge

Merge branch 'km/delete-ref-reflog-message'Junio C Hamano Mon, 27 Feb 2017 21:57:18 +0000 (13:57 -0800)

Merge branch 'km/delete-ref-reflog-message'

"git update-ref -d" and other operations to delete references did
not leave any entry in HEAD's reflog when the reference being
deleted was the current branch. This is not a problem in practice
because you do not want to delete the branch you are currently on,
but caused renaming of the current branch to something else not to
be logged in a useful way.

* km/delete-ref-reflog-message:
branch: record creation of renamed branch in HEAD's log
rename_ref: replace empty message in HEAD's log
update-ref: pass reflog message to delete_ref()
delete_ref: accept a reflog message argument

Merge branch 'jk/tempfile-ferror-fclose-confusion'Junio C Hamano Mon, 27 Feb 2017 21:57:18 +0000 (13:57 -0800)

Merge branch 'jk/tempfile-ferror-fclose-confusion'

A caller of tempfile API that uses stdio interface to write to
files may ignore errors while writing, which is detected when
tempfile is closed (with a call to ferror()). By that time, the
original errno that may have told us what went wrong is likely to
be long gone and was overwritten by an irrelevant value.
close_tempfile() now resets errno to EIO to make errno at least
predictable.

* jk/tempfile-ferror-fclose-confusion:
tempfile: set errno to a known value before calling ferror()

Merge branch 'vn/xdiff-func-context'Junio C Hamano Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)

Merge branch 'vn/xdiff-func-context'

"git diff -W" has been taught to handle the case where a new
function is added at the end of the file better.

* vn/xdiff-func-context:
xdiff -W: relax end-of-file function detection

Merge branch 'js/git-path-in-subdir'Junio C Hamano Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)

Merge branch 'js/git-path-in-subdir'

The "--git-path", "--git-common-dir", and "--shared-index-path"
options of "git rev-parse" did not produce usable output. They are
now updated to show the path to the correct file, relative to where
the caller is.

* js/git-path-in-subdir:
rev-parse: fix several options when running in a subdirectory
rev-parse tests: add tests executed from a subdirectory

Merge branch 'mm/two-more-xstrfmt'Junio C Hamano Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)

Merge branch 'mm/two-more-xstrfmt'

Code clean-up and a string truncation fix.

* mm/two-more-xstrfmt:
bisect_next_all: convert xsnprintf to xstrfmt
stop_progress_msg: convert xsnprintf to xstrfmt

Merge branch 'nd/clean-preserve-errno-in-warning'Junio C Hamano Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)

Merge branch 'nd/clean-preserve-errno-in-warning'

Some warning() messages from "git clean" were updated to show the
errno from failed system calls.

* nd/clean-preserve-errno-in-warning:
clean: use warning_errno() when appropriate

Merge branch 'jk/show-branch-lift-name-len-limit'Junio C Hamano Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)

Merge branch 'jk/show-branch-lift-name-len-limit'

"git show-branch" expected there were only very short branch names
in the repository and used a fixed-length buffer to hold them
without checking for overflow.

* jk/show-branch-lift-name-len-limit:
show-branch: use skip_prefix to drop magic numbers
show-branch: store resolved head in heap buffer
show-branch: drop head_len variable

Merge branch 'jn/remote-helpers-with-git-dir'Junio C Hamano Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)

Merge branch 'jn/remote-helpers-with-git-dir'

"git ls-remote" and "git archive --remote" are designed to work
without being in a directory under Git's control. However, recent
updates revealed that we randomly look into a directory called
.git/ without actually doing necessary set-up when working in a
repository. Stop doing so.

* jn/remote-helpers-with-git-dir:
remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
remote: avoid reading $GIT_DIR config in non-repo

Merge branch 'jk/grep-no-index-fix'Junio C Hamano Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)

Merge branch 'jk/grep-no-index-fix'

The code to parse the command line "git grep <patterns>... <rev>
[[--] <pathspec>...]" has been cleaned up, and a handful of bugs
have been fixed (e.g. we used to check "--" if it is a rev).

* jk/grep-no-index-fix:
grep: treat revs the same for --untracked as for --no-index
grep: do not diagnose misspelt revs with --no-index
grep: avoid resolving revision names in --no-index case
grep: fix "--" rev/pathspec disambiguation
grep: re-order rev-parsing loop
grep: do not unnecessarily query repo for "--"
grep: move thread initialization a little lower

Merge branch 'dt/gc-ignore-old-gc-logs'Junio C Hamano Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)

Merge branch 'dt/gc-ignore-old-gc-logs'

A "gc.log" file left by a backgrounded "gc --auto" disables further
automatic gc; it has been taught to run at least once a day (by
default) by ignoring a stale "gc.log" file that is too old.

* dt/gc-ignore-old-gc-logs:
gc: ignore old gc.log files

Merge branch 'jh/preload-index-skip-skip'Junio C Hamano Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)

Merge branch 'jh/preload-index-skip-skip'

The preload-index code has been taught not to bother with the index
entries that are paths that are not checked out by "sparse checkout".

* jh/preload-index-skip-skip:
preload-index: avoid lstat for skip-worktree items

Merge branch 'mh/submodule-hash'Junio C Hamano Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)

Merge branch 'mh/submodule-hash'

Code and design clean-up for the refs API.

* mh/submodule-hash:
read_loose_refs(): read refs using resolve_ref_recursively()
files_ref_store::submodule: use NULL for the main repository
base_ref_store_init(): remove submodule argument
refs: push the submodule attribute down
refs: store submodule ref stores in a hashmap
register_ref_store(): new function
refs: remove some unnecessary handling of submodule == ""
refs: make some ref_store lookup functions private
refs: reorder some function definitions

Merge branch 'sf/putty-w-args'Junio C Hamano Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)

Merge branch 'sf/putty-w-args'

The command line options for ssh invocation needs to be tweaked for
some implementations of SSH (e.g. PuTTY plink wants "-P <port>"
while OpenSSH wants "-p <port>" to specify port to connect to), and
the variant was guessed when GIT_SSH environment variable is used
to specify it. The logic to guess now applies to the command
specified by the newer GIT_SSH_COMMAND and also core.sshcommand
configuration variable, and comes with an escape hatch for users to
deal with misdetected cases.

* sf/putty-w-args:
connect.c: stop conflating ssh command names and overrides
connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
git_connect(): factor out SSH variant handling
connect: rename tortoiseplink and putty variables
connect: handle putty/plink also in GIT_SSH_COMMAND

Merge branch 'js/rebase-helper'Junio C Hamano Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)

Merge branch 'js/rebase-helper'

"git rebase -i" starts using the recently updated "sequencer" code.

* js/rebase-helper:
rebase -i: use the rebase--helper builtin
rebase--helper: add a builtin helper for interactive rebases

Merge branch 'bw/attr'Junio C Hamano Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)

Merge branch 'bw/attr'

The gitattributes machinery is being taught to work better in a
multi-threaded environment.

* bw/attr: (27 commits)
attr: reformat git_attr_set_direction() function
attr: push the bare repo check into read_attr()
attr: store attribute stack in attr_check structure
attr: tighten const correctness with git_attr and match_attr
attr: remove maybe-real, maybe-macro from git_attr
attr: eliminate global check_all_attr array
attr: use hashmap for attribute dictionary
attr: change validity check for attribute names to use positive logic
attr: pass struct attr_check to collect_some_attrs
attr: retire git_check_attrs() API
attr: convert git_check_attrs() callers to use the new API
attr: convert git_all_attrs() to use "struct attr_check"
attr: (re)introduce git_check_attr() and struct attr_check
attr: rename function and struct related to checking attributes
attr.c: outline the future plans by heavily commenting
Documentation: fix a typo
attr.c: add push_stack() helper
attr: support quoting pathname patterns in C style
attr.c: plug small leak in parse_attr_line()
attr.c: tighten constness around "git_attr" structure
...

Merge branch 'sg/completion'Junio C Hamano Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)

Merge branch 'sg/completion'

Clean-up and updates to command line completion (in contrib/).

* sg/completion: (22 commits)
completion: restore removed line continuating backslash
completion: cache the path to the repository
completion: extract repository discovery from __gitdir()
completion: don't guard git executions with __gitdir()
completion: consolidate silencing errors from git commands
completion: don't use __gitdir() for git commands
completion: respect 'git -C <path>'
rev-parse: add '--absolute-git-dir' option
completion: fix completion after 'git -C <path>'
completion: don't offer commands when 'git --opt' needs an argument
completion: list short refs from a remote given as a URL
completion: don't list 'HEAD' when trying refs completion outside of a repo
completion: list refs from remote when remote's name matches a directory
completion: respect 'git --git-dir=<path>' when listing remote refs
completion: fix most spots not respecting 'git --git-dir=<path>'
completion: ensure that the repository path given on the command line exists
completion tests: add tests for the __git_refs() helper function
completion tests: check __gitdir()'s output in the error cases
completion tests: consolidate getting path of current working directory
completion tests: make the $cur variable local to the test helper functions
...

Merge branch 'lt/pathspec-negative'Junio C Hamano Mon, 27 Feb 2017 21:57:13 +0000 (13:57 -0800)

Merge branch 'lt/pathspec-negative'

The "negative" pathspec feature was somewhat more cumbersome to use
than necessary in that its short-hand used "!" which needed to be
escaped from shells, and it required "exclude from what?" specified.

* lt/pathspec-negative:
pathspec: don't error out on all-exclusionary pathspec patterns
pathspec magic: add '^' as alias for '!'

Merge branch 'cw/tag-reflog-message'Junio C Hamano Mon, 27 Feb 2017 21:57:13 +0000 (13:57 -0800)

Merge branch 'cw/tag-reflog-message'

"git tag" did not leave useful message when adding a new entry to
reflog; this was left unnoticed for a long time because refs/tags/*
doesn't keep reflog by default.

* cw/tag-reflog-message:
tag: generate useful reflog message

Merge branch 'jk/alternate-ref-optim'Junio C Hamano Mon, 27 Feb 2017 21:57:13 +0000 (13:57 -0800)

Merge branch 'jk/alternate-ref-optim'

Optimizes resource usage while enumerating refs from alternate
object store, to help receiving end of "push" that hosts a
repository with many "forks".

* jk/alternate-ref-optim:
receive-pack: avoid duplicates between our refs and alternates
receive-pack: treat namespace .have lines like alternates
receive-pack: fix misleading namespace/.have comment
receive-pack: use oidset to de-duplicate .have lines
add oidset API
fetch-pack: cache results of for_each_alternate_ref
for_each_alternate_ref: replace transport code with for-each-ref
for_each_alternate_ref: pass name/oid instead of ref struct
for_each_alternate_ref: use strbuf for path allocation
for_each_alternate_ref: stop trimming trailing slashes
for_each_alternate_ref: handle failure from real_pathdup()

Merge branch 'kn/ref-filter-branch-list'Junio C Hamano Mon, 27 Feb 2017 21:57:13 +0000 (13:57 -0800)

Merge branch 'kn/ref-filter-branch-list'

The code to list branches in "git branch" has been consolidated
with the more generic ref-filter API.

* kn/ref-filter-branch-list: (21 commits)
ref-filter: resurrect "strip" as a synonym to "lstrip"
branch: implement '--format' option
branch: use ref-filter printing APIs
branch, tag: use porcelain output
ref-filter: allow porcelain to translate messages in the output
ref-filter: add an 'rstrip=<N>' option to atoms which deal with refnames
ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>'
ref-filter: Do not abruptly die when using the 'lstrip=<N>' option
ref-filter: rename the 'strip' option to 'lstrip'
ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
ref-filter: introduce refname_atom_parser()
ref-filter: introduce refname_atom_parser_internal()
ref-filter: make "%(symref)" atom work with the ':short' modifier
ref-filter: add support for %(upstream:track,nobracket)
ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams
ref-filter: introduce format_ref_array_item()
ref-filter: move get_head_description() from branch.c
ref-filter: modify "%(objectname:short)" to take length
ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>)
ref-filter: include reference to 'used_atom' within 'atom_value'
...

Merge branch 'ps/urlmatch-wildcard'Junio C Hamano Mon, 27 Feb 2017 21:57:12 +0000 (13:57 -0800)

Merge branch 'ps/urlmatch-wildcard'

The <url> part in "http.<url>.<variable>" configuration variable
can now be spelled with '*' that serves as wildcard.
E.g. "http.https://*.example.com.proxy" can be used to specify the
proxy used for https://a.example.com, https://b.example.com, etc.,
i.e. any host in the example.com domain.

* ps/urlmatch-wildcard:
urlmatch: allow globbing for the URL host part
urlmatch: include host in urlmatch ranking
urlmatch: split host and port fields in `struct url_info`
urlmatch: enable normalization of URLs with globs
mailmap: add Patrick Steinhardt's work address

Merge branch 'mm/merge-rename-delete-message'Junio C Hamano Mon, 27 Feb 2017 21:57:12 +0000 (13:57 -0800)

Merge branch 'mm/merge-rename-delete-message'

When "git merge" detects a path that is renamed in one history
while the other history deleted (or modified) it, it now reports
both paths to help the user understand what is going on in the two
histories being merged.

* mm/merge-rename-delete-message:
merge-recursive: make "CONFLICT (rename/delete)" message show both paths

Merge branch 'mh/ref-remove-empty-directory'Junio C Hamano Mon, 27 Feb 2017 21:57:12 +0000 (13:57 -0800)

Merge branch 'mh/ref-remove-empty-directory'

Deletion of a branch "foo/bar" could remove .git/refs/heads/foo
once there no longer is any other branch whose name begins with
"foo/", but we didn't do so so far. Now we do.

* mh/ref-remove-empty-directory: (23 commits)
files_transaction_commit(): clean up empty directories
try_remove_empty_parents(): teach to remove parents of reflogs, too
try_remove_empty_parents(): don't trash argument contents
try_remove_empty_parents(): rename parameter "name" -> "refname"
delete_ref_loose(): inline function
delete_ref_loose(): derive loose reference path from lock
log_ref_write_1(): inline function
log_ref_setup(): manage the name of the reflog file internally
log_ref_write_1(): don't depend on logfile argument
log_ref_setup(): pass the open file descriptor back to the caller
log_ref_setup(): improve robustness against races
log_ref_setup(): separate code for create vs non-create
log_ref_write(): inline function
rename_tmp_log(): improve error reporting
rename_tmp_log(): use raceproof_create_file()
lock_ref_sha1_basic(): use raceproof_create_file()
lock_ref_sha1_basic(): inline constant
raceproof_create_file(): new function
safe_create_leading_directories(): set errno on SCLD_EXISTS
safe_create_leading_directories_const(): preserve errno
...

Merge branch 'jk/delta-chain-limit'Junio C Hamano Mon, 27 Feb 2017 21:57:11 +0000 (13:57 -0800)

Merge branch 'jk/delta-chain-limit'

"git repack --depth=<n>" for a long time busted the specified depth
when reusing delta from existing packs. This has been corrected.

* jk/delta-chain-limit:
pack-objects: convert recursion to iteration in break_delta_chain()
pack-objects: enforce --depth limit in reused deltas

Merge branch 'jk/describe-omit-some-refs'Junio C Hamano Mon, 27 Feb 2017 21:57:11 +0000 (13:57 -0800)

Merge branch 'jk/describe-omit-some-refs'

"git describe" and "git name-rev" have been taught to take more
than one refname patterns to restrict the set of refs to base their
naming output on, and also learned to take negative patterns to
name refs not to be used for naming via their "--exclude" option.

* jk/describe-omit-some-refs:
describe: teach describe negative pattern matches
describe: teach --match to accept multiple patterns
name-rev: add support to exclude refs by pattern match
name-rev: extend --refs to accept multiple patterns
doc: add documentation for OPT_STRING_LIST

t6300: avoid creating refs/heads/HEADJeff King Mon, 27 Feb 2017 09:29:31 +0000 (04:29 -0500)

t6300: avoid creating refs/heads/HEAD

In one test, we use "git checkout --orphan HEAD" to create
an unborn branch. Confusingly, the resulting branch is named
"refs/heads/HEAD". The original probably meant something
like:

git checkout --orphan orphaned-branch HEAD

Let's just use "orphaned-branch" here to make this less
confusing. Putting HEAD in the second argument is already
implied.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: don't check for space twice when looking for... René Scharfe Sat, 25 Feb 2017 19:27:40 +0000 (20:27 +0100)

commit: don't check for space twice when looking for header

Both standard_header_field() and excluded_header_field() check if
there's a space after the buffer that's handed to them. We already
check in the caller if that space is present. Don't bother calling
the functions if it's missing, as they are guaranteed to return 0 in
that case, and remove the now redundant checks from them.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: be more precise when searching for headersRené Scharfe Sat, 25 Feb 2017 19:21:52 +0000 (20:21 +0100)

commit: be more precise when searching for headers

Search for a space character only within the current line in
read_commit_extra_header_lines() instead of searching in the whole
buffer (and possibly beyond, if it's not NUL-terminated) and then
discarding any results after the end of the current line.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf: add strbuf_add_real_path()René Scharfe Sat, 25 Feb 2017 16:00:33 +0000 (17:00 +0100)

strbuf: add strbuf_add_real_path()

Add a function for appending the canonized absolute pathname of a given
path to a strbuf. It keeps the existing contents intact, as expected of
a function of the strbuf_add() family, while avoiding copying the result
if the given strbuf is empty. It's more consistent with the rest of the
strbuf API than strbuf_realpath(), which it's wrapping.

Also add a semantic patch demonstrating its intended usage and apply it
to the current tree. Using strbuf_add_real_path() instead of calling
strbuf_addstr() and real_path() avoids an extra copy to a static buffer.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cocci: use ALLOC_ARRAYRené Scharfe Sat, 25 Feb 2017 10:30:03 +0000 (11:30 +0100)

cocci: use ALLOC_ARRAY

Add a semantic patch for using ALLOC_ARRAY to allocate arrays and apply
the transformation on the current source tree. The macro checks for
multiplication overflow and infers the element size automatically; the
result is shorter and safer code.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: release fallback base's memory in unpack_entry()René Scharfe Sat, 25 Feb 2017 10:02:28 +0000 (11:02 +0100)

sha1_file: release fallback base's memory in unpack_entry()

If a pack entry that's used as a delta base is corrupt, unpack_entry()
marks it as unusable and then searches the object again in the hope that
it can be found in another pack or in a loose file. The memory for this
external base object is never released. Free it after use.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http: add an "auto" mode for http.emptyauthJeff King Sat, 25 Feb 2017 19:18:31 +0000 (14:18 -0500)

http: add an "auto" mode for http.emptyauth

This variable needs to be specified to make some types of
non-basic authentication work, but ideally this would just
work out of the box for everyone.

However, simply setting it to "1" by default introduces an
extra round-trip for cases where it _isn't_ useful. We end
up sending a bogus empty credential that the server rejects.

Instead, let's introduce an automatic mode, that works like
this:

1. We won't try to send the bogus credential on the first
request. We'll wait to get an HTTP 401, as usual.

2. After seeing an HTTP 401, the empty-auth hack will kick
in only when we know there is an auth method available
that might make use of it (i.e., something besides
"Basic" or "Digest").

That should make it work out of the box, without incurring
any extra round-trips for people hitting Basic-only servers.

This _does_ incur an extra round-trip if you really want to
use "Basic" but your server advertises other methods (the
emptyauth hack will kick in but fail, and then Git will
actually ask for a password).

The auto mode may incur an extra round-trip over setting
http.emptyauth=true, because part of the emptyauth hack is
to feed this blank password to curl even before we've made a
single request.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: only allow one address per body tagJohan Hovold Mon, 20 Feb 2017 11:44:06 +0000 (12:44 +0100)

send-email: only allow one address per body tag

Adding comments after a tag in the body is a common practise (e.g. in
the Linux kernel) and git-send-email has been supporting this for years
by removing any trailing cruft after the address.

After some recent changes, any trailing comment is now instead appended
to the recipient name (with some random white space inserted) resulting
in undesirable noise in the headers, for example:

CC: "# 3 . 3 . x : 1b9508f : sched : Rate-limit newidle" <stable@vger.kernel.org>
Revert to the earlier behaviour of discarding anything after the (first)
address in a tag while parsing the body.

Note that multiple addresses after are still allowed after a command
line switch (and in a CC header field).

Also note that --suppress-cc=self was never honoured when using multiple
addresses in a tag.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse_hide_refs_config: tell parse_config_key we don... Jeff King Fri, 24 Feb 2017 21:08:16 +0000 (16:08 -0500)

parse_hide_refs_config: tell parse_config_key we don't want a subsection

This lets us avoid declaring some otherwise useless
variables.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse_config_key: allow matching single-level configJeff King Fri, 24 Feb 2017 21:08:02 +0000 (16:08 -0500)

parse_config_key: allow matching single-level config

The parse_config_key() function was introduced to make it
easier to match "section.subsection.key" variables. It also
handles the simpler "section.key", and the caller is
responsible for distinguishing the two from its
out-parameters.

Most callers who _only_ want "section.key" would just use a
strcmp(var, "section.key"), since there is no parsing
required. However, they may still use parse_config_key() if
their "section" variable isn't a constant (an example of
this is in parse_hide_refs_config).

Using the parse_config_key is a bit clunky, though:

const char *subsection;
int subsection_len;
const char *key;

if (!parse_config_key(var, section, &subsection, &subsection_len, &key) &&
!subsection) {
/* matched! */
}

Instead, let's treat a NULL subsection as an indication that
the caller does not expect one. That lets us write:

const char *key;

if (!parse_config_key(var, section, NULL, NULL, &key)) {
/* matched! */
}

Existing callers should be unaffected, as passing a NULL
subsection would currently segfault.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse_config_key: use skip_prefix instead of starts_withJeff King Fri, 24 Feb 2017 21:07:19 +0000 (16:07 -0500)

parse_config_key: use skip_prefix instead of starts_with

This saves us having to repeatedly add in "section_len" (and
also avoids walking over the first part of the string
multiple times for a strlen() and strrchr()).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: parse_hide_refs_config to use parse_config_keyStefan Beller Fri, 24 Feb 2017 20:43:35 +0000 (12:43 -0800)

refs: parse_hide_refs_config to use parse_config_key

parse_config_key was introduced in 1b86bbb0ade (config: add helper
function for parsing key names, 2013-01-22), the NEEDSWORK that is removed
in this patch was introduced at daebaa7813 (upload/receive-pack: allow
hiding ref hierarchies, 2013-01-18), which is only a couple days apart,
so presumably the code replaced in this patch was only introduced due
to not wanting to wait on the proper helper function being available.

Make the condition easier to read by using parse_config_key.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.12 v2.12.0Junio C Hamano Fri, 24 Feb 2017 18:49:58 +0000 (10:49 -0800)

Git 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'ps/doc-gc-aggressive-depth-update'Junio C Hamano Fri, 24 Feb 2017 18:48:10 +0000 (10:48 -0800)

Merge branch 'ps/doc-gc-aggressive-depth-update'

Doc update.

* ps/doc-gc-aggressive-depth-update:
docs/git-gc: fix default value for `--aggressiveDepth`

Merge branch 'bc/worktree-doc-fix-detached'Junio C Hamano Fri, 24 Feb 2017 18:48:10 +0000 (10:48 -0800)

Merge branch 'bc/worktree-doc-fix-detached'

Doc update.

* bc/worktree-doc-fix-detached:
Documentation: correctly spell git worktree --detach

Merge branch 'dr/doc-check-ref-format-normalize'Junio C Hamano Fri, 24 Feb 2017 18:48:09 +0000 (10:48 -0800)

Merge branch 'dr/doc-check-ref-format-normalize'

Doc update.

* dr/doc-check-ref-format-normalize:
git-check-ref-format: clarify documentation for --normalize

Merge branch 'gp/document-dotfiles-in-templates-are... Junio C Hamano Fri, 24 Feb 2017 18:48:09 +0000 (10:48 -0800)

Merge branch 'gp/document-dotfiles-in-templates-are-not-copied'

Doc update.

* gp/document-dotfiles-in-templates-are-not-copied:
init: document dotfiles exclusion on template copy

Merge branch 'rt/align-add-i-help-text'Junio C Hamano Fri, 24 Feb 2017 18:48:08 +0000 (10:48 -0800)

Merge branch 'rt/align-add-i-help-text'

Doc update.

* rt/align-add-i-help-text:
git add -i: replace \t with blanks in the help message

Merge branch 'bc/blame-doc-fix'Junio C Hamano Fri, 24 Feb 2017 18:48:07 +0000 (10:48 -0800)

Merge branch 'bc/blame-doc-fix'

Doc update.

* bc/blame-doc-fix:
Documentation: use brackets for optional arguments

docs/git-gc: fix default value for `--aggressiveDepth`Patrick Steinhardt Fri, 24 Feb 2017 08:46:45 +0000 (09:46 +0100)

docs/git-gc: fix default value for `--aggressiveDepth`

In commit 07e7dbf0d (gc: default aggressive depth to 50, 2016-08-11),
the default aggressive depth of git-gc has been changed to 50. While
git-config(1) has been updated to represent the new default value,
git-gc(1) still mentions the old value. This patch fixes it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge tag 'l10n-2.12.0-rnd2' of git://github.com/git... Junio C Hamano Fri, 24 Feb 2017 17:55:41 +0000 (09:55 -0800)

Merge tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po

l10n-2.12.0-rnd2

* tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po: (22 commits)
l10n: zh_CN: for git v2.12.0 l10n round 2
l10n: Update Catalan translation
l10n: pt_PT: update Portuguese tranlation
l10n: sv.po: Update Swedish translation (3139t0f0u)
l10n: de.po: translate 241 messages
l10n: ko.po: Update Korean translation
l10n: vi.po (3139t): Updated 2 new messages for rc1
l10n: fr.po: v2.12.0 round 2 3139t
l10n: git.pot: v2.12.0 round 2 (2 new)
l10n: vi.po: Updated Vietnamese translation (3137t)
l10n: update Catalan translation
l10n: sv.po: Update Swedish translation (3137t0f0u)
l10n: fr.po: v2.11-rc0 first round
l10n: ko.po: Update Korean translation
l10n: fr.po: Fix a typo in the French translation
l10n: fr.po: Remove gender specific adjectives
l10n: fr.po: Fix typos
l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
l10n: fixes to Catalan translation
...

l10n: zh_CN: for git v2.12.0 l10n round 2Jiang Xin Fri, 27 Jan 2017 14:50:57 +0000 (22:50 +0800)

l10n: zh_CN: for git v2.12.0 l10n round 2

Translate 241 messages (3139t0f0u) for git v2.12.0-rc1.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>