gitweb.git
transport_anonymize_url: use xstrfmtJeff King Mon, 22 Feb 2016 22:45:05 +0000 (17:45 -0500)

transport_anonymize_url: use xstrfmt

This function uses xcalloc and two memcpy calls to
concatenate two strings. We can do this as an xstrfmt
one-liner, and then it is more clear that we are allocating
the correct amount of memory.

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

git-compat-util: drop mempcpy compat codeJeff King Mon, 22 Feb 2016 22:45:01 +0000 (17:45 -0500)

git-compat-util: drop mempcpy compat code

There are no callers of this left, as the last one was
dropped in the previous patch. And there are not likely to
be new ones, as the function has been around since 2010
without gaining any new callers.

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

sequencer: simplify memory allocation of get_messageJeff King Mon, 22 Feb 2016 22:44:57 +0000 (17:44 -0500)

sequencer: simplify memory allocation of get_message

For a commit with sha1 "1234abcd" and subject "foo", this
function produces a struct with three strings:

1. "foo"

2. "1234abcd... foo"

3. "parent of 1234abcd... foo"

It takes advantage of the fact that these strings are
subsets of each other, and allocates only _one_ string, with
pointers into the various parts. Unfortunately, this makes
the string allocation complicated and hard to follow.

Since we keep only one of these in memory at a time, we can
afford to simply allocate three strings. This lets us build
on tools like xstrfmt and avoid manual computation.

While we're here, we can also drop the ad-hoc
reimplementation of get_git_commit_encoding(), and simply
call that function.

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

test-path-utils: fix normalize_path_copy output buffer... Jeff King Mon, 22 Feb 2016 22:44:54 +0000 (17:44 -0500)

test-path-utils: fix normalize_path_copy output buffer size

The normalize_path_copy function needs an output buffer that
is at least as long as its input (it may shrink the path,
but never expand it). However, this test program feeds it
static PATH_MAX-sized buffers, which have no relation to the
input size.

In the normalize_ceiling_entry case, we do at least check
the size against PATH_MAX and die(), but that case is even
more convoluted. We normalize into a fixed-size buffer, free
the original, and then replace it with a strdup'd copy of
the result. But normalize_path_copy explicitly allows
normalizing in-place, so we can simply do that.

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

fetch-pack: simplify add_sought_entryJeff King Mon, 22 Feb 2016 22:44:50 +0000 (17:44 -0500)

fetch-pack: simplify add_sought_entry

We have two variants of this function, one that takes a
string and one that takes a ptr/len combo. But we only call
the latter with the length of a NUL-terminated string, so
our first simplification is to drop it in favor of the
string variant.

Since we know we have a string, we can also replace the
manual memory computation with a call to alloc_ref().

Furthermore, we can rely on get_oid_hex() to complain if it
hits the end of the string. That means we can simplify the
check for "<sha1> <ref>" versus just "<ref>". Rather than
manage the ptr/len pair, we can just bump the start of our
string forward. The original code over-allocated based on
the original "namelen" (which wasn't _wrong_, but was simply
wasteful and confusing).

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

fast-import: simplify allocation in start_packfileJeff King Mon, 22 Feb 2016 22:44:46 +0000 (17:44 -0500)

fast-import: simplify allocation in start_packfile

This function allocate a packed_git flex-array, and adds a
mysterious 2 bytes to the length of the pack_name field. One
is for the trailing NUL, but the other has no purpose. This
is probably cargo-culted from add_packed_git, which gets the
".idx" path and needed to allocate enough space to hold the
matching ".pack" (though since 48bcc1c, we calculate the
size there differently).

This site, however, is using the raw path of a tempfile, and
does not need the extra byte. We can just replace the
allocation with FLEX_ALLOC_STR, which handles the allocation
and the NUL for us.

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

write_untracked_extension: use FLEX_ALLOC helperJeff King Mon, 22 Feb 2016 22:44:42 +0000 (17:44 -0500)

write_untracked_extension: use FLEX_ALLOC helper

We perform unchecked additions when computing the size of a
"struct ondisk_untracked_cache". This is unlikely to have an
integer overflow in practice, but we'd like to avoid this
dangerous pattern to make further audits easier.

Note that there's one subtlety here, though. We protect
ourselves against a NULL exclude_per_dir entry in our
source, and avoid calling strlen() on it, keeping "len" at
0. But later, we unconditionally memcpy "len + 1" bytes to
get the trailing NUL byte. If we did have a NULL
exclude_per_dir, we would read from bogus memory.

As it turns out, though, we always create this field
pointing to a string literal, so there's no bug. We can just
get rid of the pointless extra conditional.

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

prepare_{git,shell}_cmd: use argv_arrayJeff King Mon, 22 Feb 2016 22:44:39 +0000 (17:44 -0500)

prepare_{git,shell}_cmd: use argv_array

These functions transform an existing argv into one suitable
for exec-ing or spawning via git or a shell. We can use an
argv_array in each to avoid dealing with manual counting and
allocation.

This also makes the memory allocation more clear and fixes
some leaks. In prepare_shell_cmd, we would sometimes
allocate a new string with "$@" in it and sometimes not,
meaning the caller could not correctly free it. On the
non-Windows side, we are in a child process which will
exec() or exit() immediately, so the leak isn't a big deal.
On Windows, though, we use spawn() from the parent process,
and leak a string for each shell command we run. On top of
that, the Windows code did not free the allocated argv array
at all (but does for the prepare_git_cmd case!).

By switching both of these functions to write into an
argv_array, we can consistently free the result as
appropriate.

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

use st_add and st_mult for allocation size computationJeff King Mon, 22 Feb 2016 22:44:35 +0000 (17:44 -0500)

use st_add and st_mult for allocation size computation

If our size computation overflows size_t, we may allocate a
much smaller buffer than we expected and overflow it. It's
probably impossible to trigger an overflow in most of these
sites in practice, but it is easy enough convert their
additions and multiplications into overflow-checking
variants. This may be fixing real bugs, and it makes
auditing the code easier.

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

convert trivial cases to FLEX_ARRAY macrosJeff King Mon, 22 Feb 2016 22:44:32 +0000 (17:44 -0500)

convert trivial cases to FLEX_ARRAY macros

Using FLEX_ARRAY macros reduces the amount of manual
computation size we have to do. It also ensures we don't
overflow size_t, and it makes sure we write the same number
of bytes that we allocated.

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

use xmallocz to avoid size arithmeticJeff King Mon, 22 Feb 2016 22:44:28 +0000 (17:44 -0500)

use xmallocz to avoid size arithmetic

We frequently allocate strings as xmalloc(len + 1), where
the extra 1 is for the NUL terminator. This can be done more
simply with xmallocz, which also checks for integer
overflow.

There's no case where switching xmalloc(n+1) to xmallocz(n)
is wrong; the result is the same length, and malloc made no
guarantees about what was in the buffer anyway. But in some
cases, we can stop manually placing NUL at the end of the
allocated buffer. But that's only safe if it's clear that
the contents will always fill the buffer.

In each case where this patch does so, I manually examined
the control flow, and I tried to err on the side of caution.

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

convert trivial cases to ALLOC_ARRAYJeff King Mon, 22 Feb 2016 22:44:25 +0000 (17:44 -0500)

convert trivial cases to ALLOC_ARRAY

Each of these cases can be converted to use ALLOC_ARRAY or
REALLOC_ARRAY, which has two advantages:

1. It automatically checks the array-size multiplication
for overflow.

2. It always uses sizeof(*array) for the element-size,
so that it can never go out of sync with the declared
type of the array.

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

convert manual allocations to argv_arrayJeff King Mon, 22 Feb 2016 22:44:21 +0000 (17:44 -0500)

convert manual allocations to argv_array

There are many manual argv allocations that predate the
argv_array API. Switching to that API brings a few
advantages:

1. We no longer have to manually compute the correct final
array size (so it's one less thing we can screw up).

2. In many cases we had to make a separate pass to count,
then allocate, then fill in the array. Now we can do it
in one pass, making the code shorter and easier to
follow.

3. argv_array handles memory ownership for us, making it
more obvious when things should be free()d and and when
not.

Most of these cases are pretty straightforward. In some, we
switch from "run_command_v" to "run_command" which lets us
directly use the argv_array embedded in "struct
child_process".

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

argv-array: add detach functionJeff King Mon, 22 Feb 2016 22:44:15 +0000 (17:44 -0500)

argv-array: add detach function

The usual pattern for an argv array is to initialize it,
push in some strings, and then clear it when done. Very
occasionally, though, we must do other exotic things with
the memory, like freeing the list but keeping the strings.
Let's provide a detach function so that callers can make use
of our API to build up the array, and then take ownership of
it.

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

add helpers for allocating flex-array structsJeff King Mon, 22 Feb 2016 22:43:25 +0000 (17:43 -0500)

add helpers for allocating flex-array structs

Allocating a struct with a flex array is pretty simple in
practice: you over-allocate the struct, then copy some data
into the over-allocation. But it can be a slight pain to
make sure you're allocating and copying the right amounts.

This patch adds a few helpers to turn simple cases of
flex-array struct allocation into a one-liner that properly
checks for overflow. See the embedded documentation for
details.

Ideally we could provide a more flexible version that could
handle multiple strings, like:

FLEX_ALLOC_FMT(ref, name, "%s%s", prefix, name);

But we have to implement this as a macro (because of the
offset calculation of the flex member), which means we would
need all compilers to support variadic macros.

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

harden REALLOC_ARRAY and xcalloc against size_t overflowJeff King Mon, 22 Feb 2016 22:43:18 +0000 (17:43 -0500)

harden REALLOC_ARRAY and xcalloc against size_t overflow

REALLOC_ARRAY inherently involves a multiplication which can
overflow size_t, resulting in a much smaller buffer than we
think we've allocated. We can easily harden it by using
st_mult() to check for overflow. Likewise, we can add
ALLOC_ARRAY to do the same thing for xmalloc calls.

xcalloc() should already be fine, because it takes the two
factors separately, assuming the system calloc actually
checks for overflow. However, before we even hit the system
calloc(), we do our memory_limit_check, which involves a
multiplication. Let's check for overflow ourselves so that
this limit cannot be bypassed.

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

Sync with 2.7.2Junio C Hamano Mon, 22 Feb 2016 21:16:12 +0000 (13:16 -0800)

Sync with 2.7.2

Merge branch 'js/git-remote-add-url-insteadof-test'Junio C Hamano Mon, 22 Feb 2016 21:15:01 +0000 (13:15 -0800)

Merge branch 'js/git-remote-add-url-insteadof-test'

* js/git-remote-add-url-insteadof-test:
t5505: 'remote add x y' should work when url.y.insteadOf = x

Merge branch 'jk/config-include'Junio C Hamano Mon, 22 Feb 2016 21:14:48 +0000 (13:14 -0800)

Merge branch 'jk/config-include'

* jk/config-include:
git-config: better document default behavior for `--include`

Merge branch 'ew/connect-verbose'Junio C Hamano Mon, 22 Feb 2016 21:14:33 +0000 (13:14 -0800)

Merge branch 'ew/connect-verbose'

* ew/connect-verbose:
t5570: add tests for "git {clone,fetch,pull} -v"

Git 2.7.2 v2.7.2Junio C Hamano Mon, 22 Feb 2016 21:12:56 +0000 (13:12 -0800)

Git 2.7.2

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

Merge branch 'nd/ita-cleanup' into maintJunio C Hamano Mon, 22 Feb 2016 21:10:21 +0000 (13:10 -0800)

Merge branch 'nd/ita-cleanup' into maint

Paths that have been told the index about with "add -N" are not
quite yet in the index, but a few commands behaved as if they
already are in a harmful way.

* nd/ita-cleanup:
grep: make it clear i-t-a entries are ignored
add and use a convenience macro ce_intent_to_add()
blame: remove obsolete comment

Merge branch 'pw/completion-stash' into maintJunio C Hamano Mon, 22 Feb 2016 21:10:20 +0000 (13:10 -0800)

Merge branch 'pw/completion-stash' into maint

* pw/completion-stash:
completion: fix mis-indentation in _git_stash()

Merge branch 'mm/clean-doc-fix' into maintJunio C Hamano Mon, 22 Feb 2016 21:10:20 +0000 (13:10 -0800)

Merge branch 'mm/clean-doc-fix' into maint

The documentation for "git clean" has been corrected; it mentioned
that .git/modules/* are removed by giving two "-f", which has never
been the case.

* mm/clean-doc-fix:
Documentation/git-clean.txt: don't mention deletion of .git/modules/*

Merge branch 'dw/mergetool-vim-window-shuffle' into... Junio C Hamano Mon, 22 Feb 2016 21:10:19 +0000 (13:10 -0800)

Merge branch 'dw/mergetool-vim-window-shuffle' into maint

The vimdiff backend for "git mergetool" has been tweaked to arrange
and number buffers in the order that would match the expectation of
majority of people who read left to right, then top down and assign
buffers 1 2 3 4 "mentally" to local base remote merge windows based
on that order.

* dw/mergetool-vim-window-shuffle:
mergetool: reorder vim/gvim buffers in three-way diffs

Merge branch 'ah/stripspace-optstring' into maintJunio C Hamano Mon, 22 Feb 2016 21:10:19 +0000 (13:10 -0800)

Merge branch 'ah/stripspace-optstring' into maint

* ah/stripspace-optstring:
stripspace: call U+0020 a "space" instead of a "blank"

merge-strategies.txt: fix typoFelipe Gonçalves Assis Sun, 21 Feb 2016 22:59:01 +0000 (19:59 -0300)

merge-strategies.txt: fix typo

Signed-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: clarify textconv interfaceJeff King Mon, 22 Feb 2016 18:28:54 +0000 (13:28 -0500)

diff: clarify textconv interface

The memory allocation scheme for the textconv interface is a
bit tricky, and not well documented. It was originally
designed as an internal part of diff.c (matching
fill_mmfile), but gradually was made public.

Refactoring it is difficult, but we can at least improve the
situation by documenting the intended flow and enforcing it
with an in-code assertion.

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

Merge branch 'ks/svn-pathnameencoding-4' of git://git... Junio C Hamano Mon, 22 Feb 2016 18:29:46 +0000 (10:29 -0800)

Merge branch 'ks/svn-pathnameencoding-4' of git://git.bogomips.org/git-svn

* 'ks/svn-pathnameencoding-4' of git://git.bogomips.org/git-svn:
git-svn: apply "svn.pathnameencoding" before URL encoding
git-svn: enable "svn.pathnameencoding" on dcommit
git-svn: hoist out utf8 prep from t9129 to lib-git-svn

Merge branch 'pw/completion-stash'Junio C Hamano Mon, 22 Feb 2016 18:27:24 +0000 (10:27 -0800)

Merge branch 'pw/completion-stash'

* pw/completion-stash:
completion: fix mis-indentation in _git_stash()

completion: fix mis-indentation in _git_stash()SZEDER Gábor Mon, 22 Feb 2016 13:02:50 +0000 (14:02 +0100)

completion: fix mis-indentation in _git_stash()

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: rename git_config_set_or_die to git_config_setPatrick Steinhardt Mon, 22 Feb 2016 11:23:36 +0000 (12:23 +0100)

config: rename git_config_set_or_die to git_config_set

Rename git_config_set_or_die functions to git_config_set, leading
to the new default behavior of dying whenever a configuration
error occurs.

By now all callers that shall die on error have been transitioned
to the _or_die variants, thus making this patch a simple rename
of the functions.

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

config: rename git_config_set to git_config_set_gentlyPatrick Steinhardt Mon, 22 Feb 2016 11:23:35 +0000 (12:23 +0100)

config: rename git_config_set to git_config_set_gently

The desired default behavior for `git_config_set` is to die
whenever an error occurs. Dying is the default for a lot of
internal functions when failures occur and is in this case the
right thing to do for most callers as otherwise we might run into
inconsistent repositories without noticing.

As some code may rely on the actual return values for
`git_config_set` we still require the ability to invoke these
functions without aborting. Rename the existing `git_config_set`
functions to `git_config_set_gently` to keep them available for
those callers.

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

compat: die when unable to set core.precomposeunicodePatrick Steinhardt Mon, 22 Feb 2016 11:23:34 +0000 (12:23 +0100)

compat: die when unable to set core.precomposeunicode

When calling `git_config_set` to set 'core.precomposeunicode' we
ignore the return value of the function, which may indicate that
we were unable to write the value back to disk. As the function
is only called by init-db we can and should die when an error
occurs.

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

sequencer: die on config error when saving replay optsPatrick Steinhardt Mon, 22 Feb 2016 11:23:33 +0000 (12:23 +0100)

sequencer: die on config error when saving replay opts

When we start picking a range of revisions we save the replay
options that are required to restore state when interrupting and
later continuing picking the revisions. However, we do not check
the return values of the `git_config_set` functions, which may
lead us to store incomplete information. As this may lead us to
fail when trying to continue the sequence the error can be fatal.

Fix this by dying immediately when we are unable to write back
any replay option.

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

init-db: die on config errors when initializing empty... Patrick Steinhardt Mon, 22 Feb 2016 11:23:32 +0000 (12:23 +0100)

init-db: die on config errors when initializing empty repo

When creating an empty repository with `git init-db` we do not
check for error codes returned by `git_config_set` functions.
This may cause the user to end up with an inconsistent repository
without any indication for the user.

Fix this problem by dying early with an error message when we are
unable to write the configuration files to disk.

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

clone: die on config error in cmd_clonePatrick Steinhardt Mon, 22 Feb 2016 11:23:31 +0000 (12:23 +0100)

clone: die on config error in cmd_clone

The clone command does not check for error codes returned by
`git_config_set` functions. This may cause the user to end up
with an inconsistent repository without any indication with what
went wrong.

Fix this problem by dying with an error message when we are
unable to write the configuration files to disk.

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

remote: die on config error when manipulating remotesPatrick Steinhardt Mon, 22 Feb 2016 11:23:30 +0000 (12:23 +0100)

remote: die on config error when manipulating remotes

When manipulating remotes we try to set various configuration
values without checking if the values were persisted correctly,
possibly leaving the remote in an inconsistent state.

Fix this issue by dying early and notifying the user about the
error.

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

remote: die on config error when setting/adding branchesPatrick Steinhardt Mon, 22 Feb 2016 11:23:29 +0000 (12:23 +0100)

remote: die on config error when setting/adding branches

When we add or set new branches (e.g. by `git remote add -f` or
`git remote set-branches`) we do not check for error codes when
writing the branches to the configuration file. When persisting
the configuration failed we are left with a remote that has none
or not all of the branches that should have been set without
notifying the user.

Fix this issue by dying early on configuration error.

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

remote: die on config error when setting URLPatrick Steinhardt Mon, 22 Feb 2016 11:23:28 +0000 (12:23 +0100)

remote: die on config error when setting URL

When invoking `git-remote --set-url` we do not check the return
value when writing the actual new URL to the configuration file,
pretending to the user that the configuration has been set while
it was in fact not persisted.

Fix this problem by dying early when setting the config fails.

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

submodule--helper: die on config error when cloning... Patrick Steinhardt Mon, 22 Feb 2016 11:23:27 +0000 (12:23 +0100)

submodule--helper: die on config error when cloning module

When setting the 'core.worktree' option for a newly cloned
submodule we ignore the return value of `git_config_set_in_file`.
As this leaves the submodule in an inconsistent state, we instead
want to inform the user that something has gone wrong by printing
an error and aborting the program.

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

submodule: die on config error when linking modulesPatrick Steinhardt Mon, 22 Feb 2016 11:23:26 +0000 (12:23 +0100)

submodule: die on config error when linking modules

When trying to connect a submodule with its corresponding
repository in '.git/modules' we try to set the core.worktree
setting in the submodule, which may fail due to an error
encountered in `git_config_set_in_file`.

The function is used in the git-mv command when trying to move a
submodule to another location. We already die when renaming a
file fails but do not pay attention to the case where updating
the connection between submodule and its repository fails. As
this leaves the repository in an inconsistent state, as well,
abort the program by dying early and presenting the failure to
the user.

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

branch: die on config error when editing branch descriptionPatrick Steinhardt Mon, 22 Feb 2016 11:23:25 +0000 (12:23 +0100)

branch: die on config error when editing branch description

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

branch: die on config error when unsetting upstreamPatrick Steinhardt Mon, 22 Feb 2016 11:23:24 +0000 (12:23 +0100)

branch: die on config error when unsetting upstream

When we try to unset upstream configurations we do not check
return codes for the `git_config_set` functions. As those may
indicate that we were unable to unset the respective
configuration we may exit successfully without any error message
while in fact the upstream configuration was not unset.

Fix this by dying with an error message when we cannot unset the
configuration.

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

branch: report errors in tracking branch setupPatrick Steinhardt Mon, 22 Feb 2016 11:23:23 +0000 (12:23 +0100)

branch: report errors in tracking branch setup

When setting up a new tracking branch fails due to issues with
the configuration file we do not report any errors to the user
and pretend setting the tracking branch succeeded.

Setting up the tracking branch is handled by the
`install_branch_config` function. We do not want to simply die
there as the function is not only invoked when explicitly setting
upstream information with `git branch --set-upstream-to=`, but
also by `git push --set-upstream` and `git clone`. While it is
reasonable to die in the explict first case, we would lose
information in the latter two cases, so we only print the error
message but continue the program as usual.

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

config: add '--show-origin' option to print the origin... Lars Schneider Fri, 19 Feb 2016 09:16:02 +0000 (10:16 +0100)

config: add '--show-origin' option to print the origin of a config value

If config values are queried using 'git config' (e.g. via --get,
--get-all, --get-regexp, or --list flag) then it is sometimes hard to
find the configuration file where the values were defined.

Teach 'git config' the '--show-origin' option to print the source
configuration file for every printed value.

Based-on-patch-by: Jeff King <peff@peff.net>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: add 'origin_type' to config_source structLars Schneider Fri, 19 Feb 2016 09:16:01 +0000 (10:16 +0100)

config: add 'origin_type' to config_source struct

Use the config origin_type to print more detailed error messages that
inform the user about the origin of a config error (file, stdin, blob).

Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git.c: simplify stripping extension of a file in handle... Alexander Kuleshov Mon, 22 Feb 2016 07:18:29 +0000 (13:18 +0600)

git.c: simplify stripping extension of a file in handle_builtin()

The handle_builtin() starts from stripping of command extension if
STRIP_EXTENSION is enabled. Actually STRIP_EXTENSION does not used
anywhere else.

This patch introduces strip_extension() helper to strip STRIP_EXTENSION
extension from argv[0] with the strip_suffix() instead of manually
stripping.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-svn: apply "svn.pathnameencoding" before URL encodingKazutoshi Satoda Mon, 8 Feb 2016 15:21:02 +0000 (00:21 +0900)

git-svn: apply "svn.pathnameencoding" before URL encoding

The conversion from "svn.pathnameencoding" to UTF-8 should be applied
first, and then URL encoding should be applied on the resulting UTF-8
path. The reversed order of these transforms (used before this fix)
makes non-UTF-8 URL which causes error from Subversion such as
"Filesystem has no item: '...' path not found" when sending a rename (or
a copy) from non-ASCII path.

[ew: t9115 test case added (requires SVN_HTTPD_PORT set to test),
squash LC_ALL=$a_utf8_locale export from Kazutoshi for Cygwin]

Signed-off-by: Kazutoshi SATODA <k_satoda@f2.dion.ne.jp>
Signed-off-by: Eric Wong <normalperson@yhbt.net>

git-svn: enable "svn.pathnameencoding" on dcommitKazutoshi Satoda Mon, 8 Feb 2016 15:20:31 +0000 (00:20 +0900)

git-svn: enable "svn.pathnameencoding" on dcommit

Without the initialization of $self->{pathnameencoding}, conversion in
repo_path() is always skipped as $self->{pathnameencoding} is undefined
even if "svn.pathnameencoding" is configured.

The lack of conversion results in mysterious failure of dcommit (e.g.
"Malformed XML") which happen only when a commit involves a change on
non-ASCII path.

[ew: add test case to t9115,
squash LC_ALL=$a_utf8_locale export from Kazutoshi for Cygwin]

Signed-off-by: Kazutoshi SATODA <k_satoda@f2.dion.ne.jp>
Signed-off-by: Eric Wong <normalperson@yhbt.net>

git-svn: hoist out utf8 prep from t9129 to lib-git-svnEric Wong Mon, 22 Feb 2016 02:17:51 +0000 (02:17 +0000)

git-svn: hoist out utf8 prep from t9129 to lib-git-svn

We will be reusing this in t9115.

Suggested-by: Kazutoshi Satoda <k_satoda@f2.dion.ne.jp>
Signed-off-by: Eric Wong <normalperson@yhbt.net>

tests: rename work-tree tests to *work-tree*Michael J Gruber Sat, 20 Feb 2016 16:18:41 +0000 (17:18 +0100)

tests: rename work-tree tests to *work-tree*

"Work tree" or "working tree" is the name of a checked out tree,
"worktree" the name of the command which manages several working trees.
The naming of tests mixes these two, currently:

$ls t/*worktree*
t/t1501-worktree.sh
t/t1509-root-worktree.sh
t/t2025-worktree-add.sh
t/t2026-worktree-prune.sh
t/t2027-worktree-list.sh
t/t2104-update-index-skip-worktree.sh
t/t3320-notes-merge-worktrees.sh
t/t7011-skip-worktree-reading.sh
t/t7012-skip-worktree-writing.sh
t/t7409-submodule-detached-worktree.sh

$grep -l "git worktree" t/*.sh
t/t0002-gitfile.sh
t/t1400-update-ref.sh
t/t2025-worktree-add.sh
t/t2026-worktree-prune.sh
t/t2027-worktree-list.sh
t/t3320-notes-merge-worktrees.sh
t/t7410-submodule-checkout-to.sh

Rename t1501, t1509 and t7409 to make it clear on first glance that they
test work tree related behavior, rather than the worktree command.

t2104, t7011 and t7012 are about the "skip-worktree" flag so that their
name should remain unchanged.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

exec_cmd.c: use find_last_dir_sep() for code simplificationAlexander Kuleshov Fri, 19 Feb 2016 08:44:48 +0000 (14:44 +0600)

exec_cmd.c: use find_last_dir_sep() for code simplification

We are trying to extract dirname from argv0 in the git_extract_argv0_path().
But in the same time, the <git-compat-util.h> provides find_last_dir_sep()
to get dirname from a given path. Let's use it instead of loop for the code
simplification.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rename git_config_from_buf to git_config_from_memLars Schneider Fri, 19 Feb 2016 09:16:00 +0000 (10:16 +0100)

rename git_config_from_buf to git_config_from_mem

This matches the naming used in the index_{fd,mem,...} functions.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-diff: catch integer overflow in combine_diff_path... Jeff King Fri, 19 Feb 2016 11:21:30 +0000 (06:21 -0500)

tree-diff: catch integer overflow in combine_diff_path allocation

A combine_diff_path struct has two "flex" members allocated
alongside the struct: a string to hold the pathname, and an
array of parent pointers. We use an "int" to compute this,
meaning we may easily overflow it if the pathname is
extremely long.

We can fix this by using size_t, and checking for overflow
with the st_add helper.

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

add helpers for detecting size_t overflowJeff King Fri, 19 Feb 2016 11:21:19 +0000 (06:21 -0500)

add helpers for detecting size_t overflow

Performing computations on size_t variables that we feed to
xmalloc and friends can be dangerous, as an integer overflow
can cause us to allocate a much smaller chunk than we
realized.

We already have unsigned_add_overflows(), but let's add
unsigned_mult_overflows() to that. Furthermore, rather than
have each site manually check and die on overflow, we can
provide some helpers that will:

- promote the arguments to size_t, so that we know we are
doing our computation in the same size of integer that
will ultimately be fed to xmalloc

- check and die on overflow

- return the result so that computations can be done in
the parameter list of xmalloc.

These functions are a lot uglier to use than normal
arithmetic operators (you have to do "st_add(foo, bar)"
instead of "foo + bar"). To at least limit the damage, we
also provide multi-valued versions. So rather than:

st_add(st_add(a, b), st_add(c, d));

you can write:

st_add4(a, b, c, d);

This isn't nearly as elegant as a varargs function, but it's
a lot harder to get it wrong. You don't have to remember to
add a sentinel value at the end, and the compiler will
complain if you get the number of arguments wrong. This
patch adds only the numbered variants required to convert
the current code base; we can easily add more later if
needed.

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

reflog_expire_cfg: NUL-terminate pattern fieldJeff King Fri, 19 Feb 2016 11:21:08 +0000 (06:21 -0500)

reflog_expire_cfg: NUL-terminate pattern field

You can tweak the reflog expiration for a particular subset
of refs by configuring gc.foo.reflogexpire. We keep a linked
list of reflog_expire_cfg structs, each of which holds the
pattern and a "len" field for the length of the pattern. The
pattern itself is _not_ NUL-terminated.

However, we feed the pattern directly to wildmatch(), which
expects a NUL-terminated string, meaning it may keep reading
random junk after our struct.

We can fix this by allocating an extra byte for the NUL
(which is already zero because we use xcalloc). Let's also
drop the misleading "len" field, which is no longer
necessary. The existing use of "len" can be converted to use
strncmp().

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

ref-filter: introduce objectname_atom_parser()Karthik Nayak Wed, 17 Feb 2016 18:06:19 +0000 (23:36 +0530)

ref-filter: introduce objectname_atom_parser()

Introduce objectname_atom_parser() which will parse the
'%(objectname)' atom and store information into the 'used_atom'
structure based on the modifiers used along with the atom.

Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce contents_atom_parser()Karthik Nayak Wed, 17 Feb 2016 18:06:18 +0000 (23:36 +0530)

ref-filter: introduce contents_atom_parser()

Introduce contents_atom_parser() which will parse the '%(contents)'
atom and store information into the 'used_atom' structure based on the
modifiers used along with the atom. Also introduce body_atom_parser()
and subject_atom_parser() for parsing atoms '%(body)' and '%(subject)'
respectively.

Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce remote_ref_atom_parser()Karthik Nayak Wed, 17 Feb 2016 18:06:17 +0000 (23:36 +0530)

ref-filter: introduce remote_ref_atom_parser()

Introduce remote_ref_atom_parser() which will parse the '%(upstream)'
and '%(push)' atoms and store information into the 'used_atom'
structure based on the modifiers used along with the corresponding
atom.

Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: align: introduce long-form syntaxKarthik Nayak Wed, 17 Feb 2016 18:06:16 +0000 (23:36 +0530)

ref-filter: align: introduce long-form syntax

Introduce optional prefixes "width=" and "position=" for the align atom
so that the atom can be used as "%(align:width=<width>,position=<position>)".

Add Documentation and tests for the same.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce align_atom_parser()Karthik Nayak Wed, 17 Feb 2016 18:06:15 +0000 (23:36 +0530)

ref-filter: introduce align_atom_parser()

Introduce align_atom_parser() which will parse an 'align' atom and
store the required alignment position and width in the 'used_atom'
structure for further usage in populate_value().

Since this patch removes the last usage of match_atom_name(), remove
the function from ref-filter.c.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce parse_align_position()Karthik Nayak Wed, 17 Feb 2016 18:06:14 +0000 (23:36 +0530)

ref-filter: introduce parse_align_position()

Extract parse_align_position() from populate_value(), which, given a
string, would give us the alignment position. This is a preparatory
patch as to introduce prefixes for the %(align) atom and avoid
redundancy in the code.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce color_atom_parser()Karthik Nayak Wed, 17 Feb 2016 18:06:13 +0000 (23:36 +0530)

ref-filter: introduce color_atom_parser()

Introduce color_atom_parser() which will parse a "color" atom and
store its color in the "used_atom" structure for further usage in
populate_value().

Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce parsing functions for each valid... Karthik Nayak Wed, 17 Feb 2016 18:06:12 +0000 (23:36 +0530)

ref-filter: introduce parsing functions for each valid atom

Parsing atoms is done in populate_value(), this is repetitive and
hence expensive. Introduce a parsing function which would let us parse
atoms beforehand and store the required details into the 'used_atom'
structure for further usage.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: introduce struct used_atomKarthik Nayak Wed, 17 Feb 2016 18:06:11 +0000 (23:36 +0530)

ref-filter: introduce struct used_atom

Introduce the 'used_atom' structure to replace the existing
implementation of 'used_atom' (which is a list of atoms). This helps
us parse atoms beforehand and store required details into the
'used_atom' for future usage.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: bump 'used_atom' and related code to the topKarthik Nayak Wed, 17 Feb 2016 18:06:10 +0000 (23:36 +0530)

ref-filter: bump 'used_atom' and related code to the top

Bump code to the top for usage in further patches.

Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: use string_list_split over strbuf_splitJeff King Wed, 17 Feb 2016 18:06:09 +0000 (23:36 +0530)

ref-filter: use string_list_split over strbuf_split

We don't do any post-processing on the resulting strbufs, so it is
simpler to just use string_list_split, which takes care of removing
the delimiter for us.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t: do not hide Git's exit code in tests using 'nul_to_q'Lars Schneider Wed, 17 Feb 2016 08:57:46 +0000 (09:57 +0100)

t: do not hide Git's exit code in tests using 'nul_to_q'

Git should not be on the left-hand side of a pipe, because it hides the exit
code, and we want to make sure git does not fail.

Fix all invocations of 'nul_to_q' (defined in /t/test-lib-functions.sh) using
this pattern. There is one more occurrence of the pattern in t9010-svn-fe.sh
which is too evolved to change it easily.

All remaining test code that does not adhere to the pattern can be found with
the following command:
git grep -E 'git.*[^|]\|($|[^|])'

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: more consistent interfaceFelipe Gonçalves Assis Wed, 17 Feb 2016 03:15:26 +0000 (01:15 -0200)

merge-recursive: more consistent interface

Add strategy option find-renames, following git-diff interface. This
makes the option rename-threshold redundant.

Signed-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: option to disable renamesFelipe Gonçalves Assis Wed, 17 Feb 2016 03:15:25 +0000 (01:15 -0200)

merge-recursive: option to disable renames

The recursive strategy turns on rename detection by default. Add a
strategy option to disable rename detection even for exact renames.

Signed-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint'Junio C Hamano Wed, 17 Feb 2016 18:14:39 +0000 (10:14 -0800)

Merge branch 'maint'

* maint:
Start preparing for 2.7.2
git-cvsserver.perl: fix typo

Seventh batch for the 2.8 cycleJunio C Hamano Wed, 17 Feb 2016 18:13:57 +0000 (10:13 -0800)

Seventh batch for the 2.8 cycle

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

Merge branch 'dw/mergetool-vim-window-shuffle'Junio C Hamano Wed, 17 Feb 2016 18:13:34 +0000 (10:13 -0800)

Merge branch 'dw/mergetool-vim-window-shuffle'

The vimdiff backend for "git mergetool" has been tweaked to arrange
and number buffers in the order that would match the expectation of
majority of people who read left to right, then top down and assign
buffers 1 2 3 4 "mentally" to local base remote merge windows based
on that order.

* dw/mergetool-vim-window-shuffle:
mergetool: reorder vim/gvim buffers in three-way diffs

Merge branch 'ah/stripspace-optstring'Junio C Hamano Wed, 17 Feb 2016 18:13:33 +0000 (10:13 -0800)

Merge branch 'ah/stripspace-optstring'

* ah/stripspace-optstring:
stripspace: call U+0020 a "space" instead of a "blank"

Merge branch 'mm/clean-doc-fix'Junio C Hamano Wed, 17 Feb 2016 18:13:33 +0000 (10:13 -0800)

Merge branch 'mm/clean-doc-fix'

The documentation for "git clean" has been corrected; it mentioned
that .git/modules/* are removed by giving two "-f", which has never
been the case.

* mm/clean-doc-fix:
Documentation/git-clean.txt: don't mention deletion of .git/modules/*

Merge branch 'jk/rerere-xsnprintf'Junio C Hamano Wed, 17 Feb 2016 18:13:33 +0000 (10:13 -0800)

Merge branch 'jk/rerere-xsnprintf'

Some calls to strcpy(3) triggers a false warning from static
analysers that are less intelligent than humans, and reducing the
number of these false hits helps us notice real issues. A few
calls to strcpy(3) in "git rerere" that are already safe has been
rewritten to avoid false wanings.

* jk/rerere-xsnprintf:
rerere: replace strcpy with xsnprintf

Merge branch 'jk/test-path-utils-xsnprintf'Junio C Hamano Wed, 17 Feb 2016 18:13:32 +0000 (10:13 -0800)

Merge branch 'jk/test-path-utils-xsnprintf'

Some calls to strcpy(3) triggers a false warning from static
analysers that are less intelligent than humans, and reducing the
number of these false hits helps us notice real issues. A few
calls to strcpy(3) in test-path-utils that are already safe has
been rewritten to avoid false wanings.

* jk/test-path-utils-xsnprintf:
test-path-utils: use xsnprintf in favor of strcpy

Merge branch 'da/user-useconfigonly'Junio C Hamano Wed, 17 Feb 2016 18:13:31 +0000 (10:13 -0800)

Merge branch 'da/user-useconfigonly'

The "user.useConfigOnly" configuration variable can be used to
force the user to always set user.email & user.name configuration
variables, serving as a reminder for those who work on multiple
projects and do not want to put these in their $HOME/.gitconfig.

* da/user-useconfigonly:
ident: add user.useConfigOnly boolean for when ident shouldn't be guessed
fmt_ident: refactor strictness checks

Merge branch 'nd/clear-gitenv-upon-use-of-alias'Junio C Hamano Wed, 17 Feb 2016 18:13:31 +0000 (10:13 -0800)

Merge branch 'nd/clear-gitenv-upon-use-of-alias'

The automatic typo correction applied to an alias was broken
with a recent change already in 'master'.

* nd/clear-gitenv-upon-use-of-alias:
restore_env(): free the saved environment variable once we are done
git: simplify environment save/restore logic
git: protect against unbalanced calls to {save,restore}_env()
git: remove an early return from save_env_before_alias()

Merge branch 'mg/mingw-test-fix'Junio C Hamano Wed, 17 Feb 2016 18:13:29 +0000 (10:13 -0800)

Merge branch 'mg/mingw-test-fix'

An earlier adjustment of test mistakenly used write_script
to prepare a file whose exact content matters for the test;
reverting that part fixes the breakage for those who use
SHELL_PATH that is different from /bin/sh.

* mg/mingw-test-fix:
t9100: fix breakage when SHELL_PATH is not /bin/sh

Merge branch 'js/mingw-tests'Junio C Hamano Wed, 17 Feb 2016 18:13:28 +0000 (10:13 -0800)

Merge branch 'js/mingw-tests'

Test scripts have been updated to remove assumptions that are not
portable between Git for POSIX and Git for Windows, or to skip ones
with expectations that are not satisfiable on Git for Windows.

* js/mingw-tests: (21 commits)
gitignore: ignore generated test-fake-ssh executable
mingw: do not bother to test funny file names
mingw: skip a test in t9130 that cannot pass on Windows
mingw: handle the missing POSIXPERM prereq in t9124
mingw: avoid illegal filename in t9118
mingw: mark t9100's test cases with appropriate prereqs
t0008: avoid absolute path
mingw: work around pwd issues in the tests
mingw: fix t9700's assumption about directory separators
mingw: skip test in t1508 that fails due to path conversion
tests: turn off git-daemon tests if FIFOs are not available
mingw: disable mkfifo-based tests
mingw: accomodate t0060-path-utils for MSYS2
mingw: fix t5601-clone.sh
mingw: let lstat() fail with errno == ENOTDIR when appropriate
mingw: try to delete target directory before renaming
mingw: prepare the TMPDIR environment variable for shell scripts
mingw: factor out Windows specific environment setup
Git.pm: stop assuming that absolute paths start with a slash
mingw: do not trust MSYS2's MinGW gettext.sh
...

Merge branch 'jk/drop-rsync-transport'Junio C Hamano Wed, 17 Feb 2016 18:13:28 +0000 (10:13 -0800)

Merge branch 'jk/drop-rsync-transport'

It turns out "git clone" over rsync transport has been broken when
the source repository has packed references for a long time, and
nobody noticed nor complained about it.

* jk/drop-rsync-transport:
transport: drop support for git-over-rsync

Start preparing for 2.7.2Junio C Hamano Wed, 17 Feb 2016 18:05:44 +0000 (10:05 -0800)

Start preparing for 2.7.2

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

Merge branch 'js/test-lib-windows-emulated-yes' into... Junio C Hamano Wed, 17 Feb 2016 18:03:41 +0000 (10:03 -0800)

Merge branch 'js/test-lib-windows-emulated-yes' into maint

The emulated "yes" command used in our test scripts has been
tweaked not to spend too much time generating unnecessary output
that is not used, to help those who test on Windows where it would
not stop until it fills the pipe buffer due to lack of SIGPIPE.

* js/test-lib-windows-emulated-yes:
test-lib: limit the output of the yes utility

Merge branch 'aw/push-force-with-lease-reporting' into... Junio C Hamano Wed, 17 Feb 2016 18:03:40 +0000 (10:03 -0800)

Merge branch 'aw/push-force-with-lease-reporting' into maint

"git push --force-with-lease" has been taught to report if the push
needed to force (or fast-forwarded).

* aw/push-force-with-lease-reporting:
push: fix ref status reporting for --force-with-lease

Merge branch 'nd/do-not-move-worktree-manually' into... Junio C Hamano Wed, 17 Feb 2016 18:03:40 +0000 (10:03 -0800)

Merge branch 'nd/do-not-move-worktree-manually' into maint

"git worktree" had a broken code that attempted to auto-fix
possible inconsistency that results from end-users moving a
worktree to different places without telling Git (the original
repository needs to maintain backpointers to its worktrees, but
"mv" run by end-users who are not familiar with that fact will
obviously not adjust them), which actually made things worse
when triggered.

* nd/do-not-move-worktree-manually:
worktree: stop supporting moving worktrees manually
worktree.c: fix indentation

Merge branch 'js/xmerge-marker-eol' into maintJunio C Hamano Wed, 17 Feb 2016 18:03:39 +0000 (10:03 -0800)

Merge branch 'js/xmerge-marker-eol' into maint

The low-level merge machinery has been taught to use CRLF line
termination when inserting conflict markers to merged contents that
are themselves CRLF line-terminated.

* js/xmerge-marker-eol:
merge-file: ensure that conflict sections match eol style
merge-file: let conflict markers match end-of-line style of the context

git-cvsserver.perl: fix typoGyuYong Jung Wed, 17 Feb 2016 02:14:58 +0000 (11:14 +0900)

git-cvsserver.perl: fix typo

Signed-off-by: GyuYong Jung <obliviscence@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5505: 'remote add x y' should work when url.y.insteadO... Johannes Schindelin Wed, 17 Feb 2016 16:20:47 +0000 (17:20 +0100)

t5505: 'remote add x y' should work when url.y.insteadOf = x

This is the test missing from fb86e32 (git remote: allow adding
remotes agreeing with url.<...>.insteadOf, 2014-12-23): we should
allow adding a remote with the URL when it agrees with the
url.<...>.insteadOf setting.

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

am -i: fix "v"iewJunio C Hamano Tue, 16 Feb 2016 22:46:39 +0000 (14:46 -0800)

am -i: fix "v"iew

The 'v'iew subcommand of the interactive mode of "git am -i" was
broken by the rewrite to C we did at around 2.6.0 timeframe at
7ff26832 (builtin-am: implement -i/--interactive, 2015-08-04); we
used to spawn the pager via the shell, accepting things like

PAGER='less -S'

in the environment, but the rewrite forgot and tried to directly
spawn a command whose name is the entire string.

The previous refactoring of the new helper function makes it easier
for us to do the right thing.

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

pager: factor out a helper to prepare a child process... Junio C Hamano Tue, 16 Feb 2016 22:34:44 +0000 (14:34 -0800)

pager: factor out a helper to prepare a child process to run the pager

When running a pager, we need to run the program git_pager() gave
us, but we need to make sure we spawn it via the shell (i.e. it is
valid to say PAGER='less -S', for example) and give default values
to $LESS and $LV environment variables. Factor out these details
to a separate helper function.

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

pager: lose a separate argv[]Junio C Hamano Tue, 16 Feb 2016 22:26:40 +0000 (14:26 -0800)

pager: lose a separate argv[]

These days, using the embedded args array in the child_process
structure is the norm. Follow that practice.

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

config: introduce set_or_die wrappersPatrick Steinhardt Tue, 16 Feb 2016 12:56:28 +0000 (13:56 +0100)

config: introduce set_or_die wrappers

A lot of call-sites for the existing family of `git_config_set`
functions do not check for errors that may occur, e.g. when the
configuration file is locked. In many cases we simply want to die
when such a situation arises.

Introduce wrappers that will cause the program to die in those
cases. These wrappers are temporary only to ease the transition
to let `git_config_set` die by default. They will be removed
later on when `git_config_set` itself has been replaced by
`git_config_set_gently`.

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

remote: use remote_is_configured() for add and renameThomas Gummerer Tue, 16 Feb 2016 09:47:52 +0000 (10:47 +0100)

remote: use remote_is_configured() for add and rename

Both remote add and remote rename use a slightly different hand-rolled
check if the remote exits. The hand-rolled check may have some subtle
cases in which it might fail to detect when a remote already exists.
One such case was fixed in fb86e32 ("git remote: allow adding remotes
agreeing with url.<...>.insteadOf"). Another case is when a remote is
configured as follows:

[remote "foo"]
vcs = bar

If we try to run `git remote add foo bar` with the above remote
configuration, git segfaults. This change fixes it.

In addition, git remote rename $existing foo with the configuration for
foo as above silently succeeds, even though foo already exists,
modifying its configuration. With this patch it fails with "remote foo
already exists".

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

remote: actually check if remote exitsThomas Gummerer Tue, 16 Feb 2016 09:47:51 +0000 (10:47 +0100)

remote: actually check if remote exits

When converting the git remote command to a builtin in 211c89 ("Make
git-remote a builtin"), a few calls to check if a remote exists were
converted from:
if (!exists $remote->{$name}) {
[...]
to:
remote = remote_get(argv[1]);
if (!remote)
[...]

The new check is not quite correct, because remote_get() never returns
NULL if a name is given. This leaves us with the somewhat cryptic error
message "error: Could not remove config section 'remote.test'", if we
are trying to remove a remote that does not exist, or a similar error if
we try to rename a remote.

Use the remote_is_configured() function to check whether the remote
actually exists, and die with a more sensible error message ("No such
remote: $remotename") instead if it doesn't.

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

remote: simplify remote_is_configured()Thomas Gummerer Tue, 16 Feb 2016 09:47:50 +0000 (10:47 +0100)

remote: simplify remote_is_configured()

The remote_is_configured() function allows checking whether a remote
exists or not. The function however only works if remote_get() wasn't
called before calling it. In addition, it only checks the configuration
for remotes, but not remotes or branches files.

Make use of the origin member of struct remote instead, which indicates
where the remote comes from. It will be set to some value if the remote
is configured in any file in the repository, but is initialized to 0 if
the remote is only created in make_remote().

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

remote: use parse_config_keyThomas Gummerer Tue, 16 Feb 2016 09:47:49 +0000 (10:47 +0100)

remote: use parse_config_key

95b567c7 ("use skip_prefix to avoid repeating strings") transformed
calls using starts_with() and then skipping the length of the prefix to
skip_prefix() calls. In remote.c there are a few calls like:

if (starts_with(foo, "bar"))
foo += 3

These calls weren't touched by the aformentioned commit, but can be
replaced by calls to parse_config_key(), to simplify the code and
clarify the intentions. Do that.

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

http: implement public key pinningChristoph Egger Mon, 15 Feb 2016 14:04:22 +0000 (15:04 +0100)

http: implement public key pinning

Add the http.pinnedpubkey configuration option for public key
pinning. It allows any string supported by libcurl --
base64(sha256(pubkey)) or filename of the full public key.

If cURL does not support pinning (is too old) output a warning to the
user.

Signed-off-by: Christoph Egger <christoph@christoph-egger.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktree add -B: do the checkout test before update... Nguyễn Thái Ngọc Duy Mon, 15 Feb 2016 13:35:33 +0000 (20:35 +0700)

worktree add -B: do the checkout test before update branch

If --force is not given but -B is, we should not proceed if the given
branch is already checked out elsewhere. add_worktree() has this test,
but it kicks in too late when "git branch --force" is already
executed. As a result, even though we correctly refuse to create a new
worktree, we have already updated the branch and mess up the other
checkout.

Repeat the die_if_checked_out() test again for this specific case before
"git branch" runs.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>