gitweb.git
Merge branch 'ml/userdiff-rust'Junio C Hamano Fri, 21 Jun 2019 18:24:08 +0000 (11:24 -0700)

Merge branch 'ml/userdiff-rust'

The pattern "git diff/grep" use to extract funcname and words
boundary for Rust has been added.

* ml/userdiff-rust:
userdiff: two simplifications of patterns for rust
userdiff: add built-in pattern for rust

pull: add --[no-]show-forced-updates passthroughDerrick Stolee Tue, 18 Jun 2019 20:25:28 +0000 (13:25 -0700)

pull: add --[no-]show-forced-updates passthrough

The 'git fetch' command can avoid calculating forced updates, so
allow users of 'git pull' to provide that option. This is particularly
necessary when the advice to use '--no-show-forced-updates' is given
at the end of the command.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: warn about forced updates in branch listingDerrick Stolee Tue, 18 Jun 2019 20:25:27 +0000 (13:25 -0700)

fetch: warn about forced updates in branch listing

The --[no-]show-forced-updates option in 'git fetch' can be confusing
for some users, especially if it is enabled via config setting and not
by argument. Add advice to warn the user that the (forced update)
messages were not listed.

Additionally, warn users when the forced update check takes longer
than ten seconds, and recommend that they disable the check. These
messages can be disabled by the advice.fetchShowForcedUpdates config
setting.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: add --[no-]show-forced-updates argumentDerrick Stolee Tue, 18 Jun 2019 20:25:26 +0000 (13:25 -0700)

fetch: add --[no-]show-forced-updates argument

After updating a set of remove refs during a 'git fetch', we walk the
commits in the new ref value and not in the old ref value to discover
if the update was a forced update. This results in two things happening
during the command:

1. The line including the ref update has an additional "(forced-update)"
marker at the end.

2. The ref log for that remote branch includes a bit saying that update
is a forced update.

For many situations, this forced-update message happens infrequently, or
is a small bit of information among many ref updates. Many users ignore
these messages, but the calculation required here slows down their fetches
significantly. Keep in mind that they do not have the opportunity to
calculate a commit-graph file containing the newly-fetched commits, so
these comparisons can be very slow.

Add a '--[no-]show-forced-updates' option that allows a user to skip this
calculation. The only permanent result is dropping the forced-update bit
in the reflog.

Include a new fetch.showForcedUpdates config setting that allows this
behavior without including the argument in every command. The config
setting is overridden by the command-line arguments.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

status: ignore status.aheadbehind in porcelain formatsJeff Hostetler Tue, 18 Jun 2019 20:21:28 +0000 (13:21 -0700)

status: ignore status.aheadbehind in porcelain formats

Teach porcelain V[12] formats to ignore the status.aheadbehind
config setting. They only respect the --[no-]ahead-behind
command line argument. This is for backwards compatibility
with existing scripts.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

status: warn when a/b calculation takes too longJeff Hostetler Tue, 18 Jun 2019 20:21:27 +0000 (13:21 -0700)

status: warn when a/b calculation takes too long

The ahead/behind calculation in 'git status' can be slow in some
cases. Users may not realize that there are ways to avoid this
computation, especially if they are not using the information.

Add a warning that appears if this calculation takes more than
two seconds. The warning can be disabled through the new config
setting advice.statusAheadBehind.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

status: add status.aheadbehind settingJeff Hostetler Tue, 18 Jun 2019 20:21:25 +0000 (13:21 -0700)

status: add status.aheadbehind setting

The --[no-]ahead-behind option was introduced in fd9b544a
(status: add --[no-]ahead-behind to status and commit for V2
format, 2018-01-09). This is a necessary change of behavior
in repos where the remote tracking branches can move very
quickly ahead of the local branches. However, users need to
remember to provide the command-line argument every time.

Add a new "status.aheadBehind" config setting to change the
default behavior of all git status formats.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

msvc: update Makefile to allow for spaces in the compil... Jeff Hostetler Wed, 19 Jun 2019 21:06:06 +0000 (14:06 -0700)

msvc: update Makefile to allow for spaces in the compiler path

It is quite common that MS Visual C++ is installed into a location whose
path contains spaces, therefore we need to quote it.

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

msvc: fix detect_msys_tty()Jeff Hostetler Wed, 19 Jun 2019 21:06:05 +0000 (14:06 -0700)

msvc: fix detect_msys_tty()

The ntstatus.h header is only available in MINGW.

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

msvc: define ftello()Jeff Hostetler Wed, 19 Jun 2019 21:06:04 +0000 (14:06 -0700)

msvc: define ftello()

It is just called differently in MSVC's headers.

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

msvc: do not re-declare the timespec structJeff Hostetler Wed, 19 Jun 2019 21:06:03 +0000 (14:06 -0700)

msvc: do not re-declare the timespec struct

VS2015's headers already declare that struct.

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

msvc: mark a variable as non-constJeff Hostetler Wed, 19 Jun 2019 21:06:02 +0000 (14:06 -0700)

msvc: mark a variable as non-const

VS2015 complains when using a const pointer in memcpy()/free().

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

msvc: define O_ACCMODEPhilip Oakley Wed, 19 Jun 2019 21:06:02 +0000 (14:06 -0700)

msvc: define O_ACCMODE

This constant is not defined in MSVC's headers.

In UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1
and 2, respectively. Yes, that means that UCRT breaks with the tradition
that O_RDWR == O_RDONLY | O_WRONLY.

It is a perfectly legal way to define those constants, though, therefore
we need to take care of defining O_ACCMODE accordingly.

This is particularly important in order to keep our "open() can set
errno to EISDIR" emulation working: it tests that (flags & O_ACCMODE) is
not identical to O_RDONLY before going on to test specifically whether
the file for which open() reported EACCES is, in fact, a directory.

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

msvc: include sigset_t definitionPhilip Oakley Wed, 19 Jun 2019 21:06:01 +0000 (14:06 -0700)

msvc: include sigset_t definition

On MSVC (VS2008) sigset_t is not defined.

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

msvc: fix dependencies of compat/msvc.cJohannes Schindelin Wed, 19 Jun 2019 21:06:00 +0000 (14:06 -0700)

msvc: fix dependencies of compat/msvc.c

The file compat/msvc.c includes compat/mingw.c, which means that we have
to recompile compat/msvc.o if compat/mingw.c changes.

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

mingw: replace mingw_startup() hackJohannes Schindelin Wed, 19 Jun 2019 21:05:59 +0000 (14:05 -0700)

mingw: replace mingw_startup() hack

Git for Windows has special code to retrieve the command-line parameters
(and even the environment) in UTF-16 encoding, so that they can be
converted to UTF-8. This is necessary because Git for Windows wants to
use UTF-8 encoded strings throughout its code, and the main() function
does not get the parameters in that encoding.

To do that, we used the __wgetmainargs() function, which is not even a
Win32 API function, but provided by the MINGW "runtime" instead.

Obviously, this method would not work with any compiler other than GCC,
and in preparation for compiling with Visual C++, we would like to avoid
precisely that.

Lucky us, there is a much more elegant way: we can simply implement the
UTF-16 variant of `main()`: `wmain()`.

To make that work, we need to link with -municode. The command-line
parameters are passed to `wmain()` encoded in UTF-16, as desired, and
this method also works with GCC, and also with Visual C++ after
adjusting the MSVC linker flags to force it to use `wmain()`.

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

obstack: fix compiler warningJohannes Schindelin Wed, 19 Jun 2019 21:05:59 +0000 (14:05 -0700)

obstack: fix compiler warning

MS Visual C suggests that the construct

condition ? (int) i : (ptrdiff_t) d

is incorrect. Let's fix this by casting to ptrdiff_t also for the
positive arm of the conditional.

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

cache-tree/blame: avoid reusing the DEBUG constantJeff Hostetler Wed, 19 Jun 2019 21:05:58 +0000 (14:05 -0700)

cache-tree/blame: avoid reusing the DEBUG constant

In MS Visual C, the `DEBUG` constant is set automatically whenever
compiling with debug information.

This is clearly not what was intended in `cache-tree.c` nor in
`builtin/blame.c`, so let's use a less ambiguous name there.

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

t0001 (mingw): do not expect a specific order of stdout... Johannes Schindelin Wed, 19 Jun 2019 21:05:57 +0000 (14:05 -0700)

t0001 (mingw): do not expect a specific order of stdout/stderr

When redirecting stdout/stderr to the same file, we cannot guarantee
that stdout will come first.

In fact, in this test case, it seems that an MSVC build always prints
stderr first.

In any case, this test case does not want to verify the *order* but
the *presence* of both outputs, so let's test exactly that.

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

Mark .bat files as requiring CR/LF endingsJohannes Schindelin Wed, 19 Jun 2019 21:05:57 +0000 (14:05 -0700)

Mark .bat files as requiring CR/LF endings

Just like the natural line ending for Unix shell scripts consist of a
single Line Feed, the natural line ending for (DOS) Batch scripts
consists of a Carriage Return followed by a Line Feed.

It seems that both Unix shell script interpreters and the interpreter
for Batch scripts (`cmd.exe`) are keen on seeing the "right" line
endings.

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

mingw: fix a typo in the msysGit-specific sectionJohannes Schindelin Wed, 19 Jun 2019 21:05:56 +0000 (14:05 -0700)

mingw: fix a typo in the msysGit-specific section

The msysGit project (i.e. Git for Windows 1.x' SDK) is safely dead for
*years* already. This is probably the reason why nobody caught this typo
until Carlo Arenas spotted a copy-edited version of it nearby.

It is probably about time to rip out the remainders of msysGit/MSys1
support, but that can safely wait a bit longer, and we can at least fix
the typo for now.

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

fetch-pack: print server version at the top in -v -vNguyễn Thái Ngọc Duy Thu, 20 Jun 2019 11:59:51 +0000 (18:59 +0700)

fetch-pack: print server version at the top in -v -v

Before the previous patch, the server version is printed after all the
"Server supports" lines. The previous one puts the version in the middle
of "Server supports" group.

Instead of moving it to the bottom, I move it to the top. Version may
stand out more at the top as we will have even more debug out after
capabilities.

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

fetch-pack: print all relevant supported capabilities... Nguyễn Thái Ngọc Duy Thu, 20 Jun 2019 11:59:50 +0000 (18:59 +0700)

fetch-pack: print all relevant supported capabilities with -v -v

When we check if some capability is supported, we do print something in
verbose mode. Some capabilities are not printed though (and it made me
think it's not supported; I was more used to GIT_TRACE_PACKET) so let's
print them all.

It's a bit more code. And one could argue for printing all supported
capabilities the server sends us. But I think it's still valuable this
way because we see the capabilities that the client cares about.

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

fetch-pack: move capability names out of i18n stringsNguyễn Thái Ngọc Duy Thu, 20 Jun 2019 11:59:49 +0000 (18:59 +0700)

fetch-pack: move capability names out of i18n strings

This reduces the work on translators since they only have one string to
translate (and I think it's still enough context to translate). It also
makes sure no capability name is translated by accident.

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

completion: disable dwim on "git switch -d"Nguyễn Thái Ngọc Duy Thu, 20 Jun 2019 09:55:22 +0000 (16:55 +0700)

completion: disable dwim on "git switch -d"

Even though dwim is enabled by default, it will never be done when
--detached is specified. If you force "-d --guess" you will get an error
because --guess then implies -c which cannot be used with -d. So we can
disable dwim in "switch -d". It makes the completion list in this case a
bit shorter.

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

switch: allow to switch in the middle of bisectNguyễn Thái Ngọc Duy Thu, 20 Jun 2019 09:55:21 +0000 (16:55 +0700)

switch: allow to switch in the middle of bisect

In c45f0f525d (switch: reject if some operation is in progress,
2019-03-29), a check is added to prevent switching when some operation
is in progress. The reason is it's often not safe to do so.

This is true for merge, am, rebase, cherry-pick and revert, but not so
much for bisect because bisecting is basically jumping/switching between
a bunch of commits to pin point the first bad one. git-bisect suggests
the next commit to test, but it's not wrong for the user to test a
different commit because git-bisect cannot have the knowledge to know
better.

For this reason, allow to switch when bisecting (*). I considered if we
should still prevent switching by default and allow it with
--ignore-in-progress. But I don't think the prevention really adds
anything much.

If the user switches away by mistake, since we print the previous HEAD
value, even if they don't know about the "-" shortcut, switching back is
still possible.

The warning will be printed on every switch while bisect is still
ongoing, not the first time you switch away from bisect's suggested
commit, so it could become a bit annoying.

(*) of course when it's safe to do so, i.e. no loss of local changes and
stuff.

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

t2027: use test_must_be_emptyNguyễn Thái Ngọc Duy Thu, 20 Jun 2019 09:55:20 +0000 (16:55 +0700)

t2027: use test_must_be_empty

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

delta-islands: respect progress flagJeff King Thu, 20 Jun 2019 08:58:32 +0000 (04:58 -0400)

delta-islands: respect progress flag

The delta island code always prints "Marked %d islands", even if
progress has been suppressed with --no-progress or by sending stderr to
a non-tty.

Let's pass a progress boolean to load_delta_islands(). We already do
the same thing for the progress meter in resolve_tree_islands().

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

rev-list: teach --no-object-names to enable pipingEmily Shaffer Wed, 19 Jun 2019 20:56:56 +0000 (13:56 -0700)

rev-list: teach --no-object-names to enable piping

Allow easier parsing by cat-file by giving rev-list an option to print
only the OID of a non-commit object without any additional information.
This is a short-term shim; later on, rev-list should be taught how to
print the types of objects it finds in a format similar to cat-file's.

Before this commit, the output from rev-list needed to be massaged
before being piped to cat-file, like so:

git rev-list --objects HEAD | cut -f 1 -d ' ' |
git cat-file --batch-check

This was especially unexpected when dealing with root trees, as an
invisible whitespace exists at the end of the OID:

git rev-list --objects --filter=tree:1 --max-count=1 HEAD |
xargs -I% echo "AA%AA"

Now, it can be piped directly, as in the added test case:

git rev-list --objects --no-object-names HEAD | git cat-file --batch-check

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Change-Id: I489bdf0a8215532e540175188883ff7541d70e1b
Signed-off-by: Junio C Hamano <gitster@pobox.com>

hashmap: convert sha1hash() to oidhash()Jeff King Thu, 20 Jun 2019 07:41:49 +0000 (03:41 -0400)

hashmap: convert sha1hash() to oidhash()

There are no callers left of sha1hash() that do not simply pass the
"hash" member of a "struct object_id". Let's get rid of the outdated
sha1-specific function and provide one that operates on the whole struct
(even though the technique, taking the first few bytes of the hash, will
remain the same).

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

hash.h: move object_id definition from cache.hJeff King Thu, 20 Jun 2019 07:41:45 +0000 (03:41 -0400)

hash.h: move object_id definition from cache.h

Our hashmap.h helpfully defines a sha1hash() function. But it cannot
define a similar oidhash() without including all of cache.h, which
itself wants to include hashmap.h! Let's break this circular dependency
by moving the definition to hash.h, along with the remaining RAWSZ
macros, etc. That will put them with the existing git_hash_algo
definition.

One alternative would be to move oidhash() into cache.h, but it's
already quite bloated. We're better off moving things out than in.

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

khash: rename oid helper functionsJeff King Thu, 20 Jun 2019 07:41:42 +0000 (03:41 -0400)

khash: rename oid helper functions

For use in object_id hash tables, we have oid_hash() and oid_equal().
But these are confusingly similar to the existing oideq() and the
oidhash() we plan to add to replace sha1hash().

The big difference from those functions is that rather than accepting a
const pointer to the "struct object_id", we take the arguments by value
(which is a khash internal convention). So let's make that obvious by
calling them oidhash_by_value() and oideq_by_value().

Those names are fairly horrendous to type, but we rarely need to do so;
they are passed to the khash implementation macro and then only used
internally. Callers get to use the nice kh_put_oid_map(), etc.

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

khash: drop sha1-specific map typesJeff King Thu, 20 Jun 2019 07:41:38 +0000 (03:41 -0400)

khash: drop sha1-specific map types

All of the callers of khash_sha1 and khash_sha1_pos have been removed,
in favor of using maps that use "struct object_id" as their keys. Let's
drop these now-obsolete types.

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

pack-bitmap: convert khash_sha1 maps into kh_oid_mapJeff King Thu, 20 Jun 2019 07:41:35 +0000 (03:41 -0400)

pack-bitmap: convert khash_sha1 maps into kh_oid_map

All of the users of our khash_sha1 maps actually have a "struct
object_id". Let's use the more descriptive type.

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

delta-islands: convert island_marks khash to use oidsJeff King Thu, 20 Jun 2019 07:41:32 +0000 (03:41 -0400)

delta-islands: convert island_marks khash to use oids

All of the users of this map have an actual "struct object_id" rather
than a bare sha1. Let's use the more descriptive type (and get one step
closer to dropping khash_sha1 entirely).

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

khash: rename kh_oid_t to kh_oid_setJeff King Thu, 20 Jun 2019 07:41:28 +0000 (03:41 -0400)

khash: rename kh_oid_t to kh_oid_set

khash lets us define a hash as either a map or a set (i.e., with no
"value" type). For the oid maps we define, "oid" is the set and
"oid_map" is the map. As the bug in the previous commit shows, it's easy
to pick the wrong one.

So let's make the names more distinct: "oid_set" and "oid_map".

An alternative naming scheme would be to actually name the type after
the key/value types. So e.g., "oid" _would_ be the set, since it has no
value type. And "oid_map" would become "oid_void" or similar (and
"oid_pos" becomes "oid_int"). That's better in some ways: it's more
regular, and a given map type can be more reasily reused in multiple
contexts (e.g., something storing an "int" that isn't a "pos"). But it's
also slightly less descriptive.

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

khash: drop broken oid_map typedefJeff King Thu, 20 Jun 2019 07:41:25 +0000 (03:41 -0400)

khash: drop broken oid_map typedef

Commit 5a8643eff1 (khash: move oid hash table definition, 2019-02-19)
added a khash "oid_map" type to match the existing "oid" type, which is
a simple set (i.e., just keys, no values). But in setting up the
khash_oid_map typedef, it accidentally referred to "kh_oid_t", which is
the set type.

Nobody noticed the breakage because there are not yet any callers; the
type was added just as a match to the existing sha1 types (whose map
type confusingly _is_ called khash_sha1, and it has no matching set
type).

We could easily fix this with s/oid/oid_map/ in the typedef. But let's
take this a step further, and just drop the typedef entirely. These
typedefs were added by 5a8643eff1 to match the khash_sha1 typedefs. But
the actual khash-derived type names are descriptive enough; this is just
adding an extra layer of indirection. The khash names do not quite
follow our usual style (e.g., they end in "_t"), but since we end up
using other khash names (e.g., khiter_t, kh_get_oid()) anyway, just
typedef-ing the struct name is not really helping much.

And there are already many cases where we use the raw khash type names
anyway (e.g., the "set" variant defined just above us does not have such
a typedef!).

So let's drop this typedef, and the matching oid_pos one (which actually
_does_ have a user, but we can easily convert it).

We'll leave the khash_sha1 typedef around. The ultimate fate of its
callers should be conversion to kh_oid_map_t, so there's no point in
going through the noise of changing the names now.

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

object: convert create_object() to use object_idJeff King Thu, 20 Jun 2019 07:41:21 +0000 (03:41 -0400)

object: convert create_object() to use object_id

There are no callers left of create_object() that aren't just passing us
the "hash" member of a "struct object_id". Let's take the whole struct,
which gets us closer to removing all raw sha1 variables.

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

object: convert internal hash_obj() to object_idJeff King Thu, 20 Jun 2019 07:41:17 +0000 (03:41 -0400)

object: convert internal hash_obj() to object_id

Now that lookup_object() has an object_id, we can consistently pass that
around instead of a raw sha1. We still convert to a hash to pass to
sha1hash(), but the goal is for that to go away shortly.

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

object: convert lookup_object() to use object_idJeff King Thu, 20 Jun 2019 07:41:14 +0000 (03:41 -0400)

object: convert lookup_object() to use object_id

There are no callers left of lookup_object() that aren't just passing us
the "hash" member of a "struct object_id". Let's take the whole struct,
which gets us closer to removing all raw sha1 variables. It also
matches the existing conversions of lookup_blob(), etc.

The conversions of callers were done by hand, but they're all mechanical
one-liners.

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

object: convert lookup_unknown_object() to use object_idJeff King Thu, 20 Jun 2019 07:41:10 +0000 (03:41 -0400)

object: convert lookup_unknown_object() to use object_id

There are no callers left of lookup_unknown_object() that aren't just
passing us the "hash" member of a "struct object_id". Let's take the
whole struct, which gets us closer to removing all raw sha1 variables.
It also matches the existing conversions of lookup_blob(), etc.

The conversions of callers were done by hand, but they're all mechanical
one-liners.

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

pack-objects: convert locate_object_entry_hash() to... Jeff King Thu, 20 Jun 2019 07:41:07 +0000 (03:41 -0400)

pack-objects: convert locate_object_entry_hash() to object_id

There are no callers of locate_object_entry_hash() that aren't just
passing us the "hash" member of a "struct object_id". Let's take the
whole struct, which gets us closer to removing all raw sha1 variables.

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

pack-objects: convert packlist_find() to use object_idJeff King Thu, 20 Jun 2019 07:41:03 +0000 (03:41 -0400)

pack-objects: convert packlist_find() to use object_id

We take a raw hash pointer, but most of our callers have a "struct
object_id" already. Let's switch to taking the full struct, which will
let us continue removing uses of raw sha1 buffers.

There are two callers that do need special attention:

- in rebuild_existing_bitmaps(), we need to switch to
nth_packed_object_oid(). This incurs an extra hash copy over
pointing straight to the mmap'd sha1, but it shouldn't be measurable
compared to the rest of the operation.

- in can_reuse_delta() we already spent the effort to copy the sha1
into a "struct object_id", but now we just have to do so a little
earlier in the function (we can't easily convert that function's
callers because they may be pointing at mmap'd REF_DELTA blocks).

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

pack-bitmap-write: convert some helpers to use object_idJeff King Thu, 20 Jun 2019 07:40:59 +0000 (03:40 -0400)

pack-bitmap-write: convert some helpers to use object_id

A few functions take raw hash pointers, but all of their callers
actually have a "struct object_id". Let's retain that extra type as long
as possible (which will let future patches extend that further, and so
on).

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

upload-pack: rename a "sha1" variable to "oid"Jeff King Thu, 20 Jun 2019 07:40:54 +0000 (03:40 -0400)

upload-pack: rename a "sha1" variable to "oid"

This variable is a "struct object_id", but uses the old-style name
"sha1". Let's call it oid to match more modern code (and make it clear
that it can handle any algorithm, since it uses parse_oid_hex()
properly).

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

describe: fix accidental oid/hash type-punningJeff King Thu, 20 Jun 2019 07:40:50 +0000 (03:40 -0400)

describe: fix accidental oid/hash type-punning

The find_commit_name() function passes an object_id.hash as the key of a
hashmap. That ends up in commit_name_neq(), which then feeds it to
oideq(). Which means we should actually be the whole "struct object_id".

It works anyway because pointers to the two are interchangeable. And
because we're going through a layer of void pointers, the compiler
doesn't notice the type mismatch.

But it's worth cleaning up (especially since once we switch away from
sha1hash() on the same line, accessing the hash member will look doubly
out of place).

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

fetch: only run 'gc' once when fetching multiple remotesNguyễn Thái Ngọc Duy Wed, 19 Jun 2019 09:46:30 +0000 (16:46 +0700)

fetch: only run 'gc' once when fetching multiple remotes

In multiple remotes mode, git-fetch is launched for n-1 remotes and the
last remote is handled by the current process. Each of these processes
will in turn run 'gc' at the end.

This is not really a problem because even if multiple 'gc --auto' is run
at the same time we still handle it correctly. It does show multiple
"auto packing in the background" messages though. And we may waste some
resources when gc actually runs because we still do some stuff before
checking the lock and moving it to background.

So let's try to avoid that. We should only need one 'gc' run after all
objects and references are added anyway. Add a new option --no-auto-gc
that will be used by those n-1 processes. 'gc --auto' will always run on
the main fetch process (*).

(*) even if we fetch remotes in parallel at some point in future, this
should still be fine because we should "join" all those processes
before this step.

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

stash: fix show referencing stash indexThomas Gummerer Sat, 15 Jun 2019 11:26:18 +0000 (12:26 +0100)

stash: fix show referencing stash index

In the conversion of 'stash show' to C in dc7bd382b1 ("stash: convert
show to builtin", 2019-02-25), 'git stash show <n>', where n is the
index of a stash got broken, if n is not a file or a valid revision by
itself.

'stash show' accepts any flag 'git diff' accepts for changing the
output format. Internally we use 'setup_revisions()' to parse these
command line flags. Currently we pass the whole argv through to
'setup_revisions()', which includes the stash index.

As the stash index is not a valid revision or a file in the working
tree in most cases however, this 'setup_revisions()' call (and thus
the whole command) ends up failing if we use this form of 'git stash
show'.

Instead of passing the whole argv to 'setup_revisions()', only pass
the flags (and the command name) through, while excluding the stash
reference. The stash reference is parsed (and validated) in
'get_stash_info()' already.

This separate parsing also means that we currently do produce the
correct output if the command succeeds.

Reported-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ref-filter: sort detached HEAD lines firstlyMatthew DeVore Tue, 18 Jun 2019 22:29:15 +0000 (15:29 -0700)

ref-filter: sort detached HEAD lines firstly

Before this patch, "git branch" would put "(HEAD detached...)" and "(no
branch, rebasing...)" lines before all the other branches *in most
cases* except for when using Chinese-language messages. zh_CN generally
uses a full-width "(" symbol (codepoint FF08) to match the full-width
proportions of Chinese characters, and the translated strings we had did
use them. This meant that the detached HEAD line would appear after all
local refs and even after the remote refs if there were any.

AFAIK, it is sometimes not jarring to see the half-width parenthesis in
"full-width" text as in the CJK languages, for instance when there are
no characters preceding or following the parenthesized text fragment. By
removing the parenthesis from the localizable text, we can share strings
with wt-status.c and remove a cautionary comment to translators.

Remove the ( from the localizable portion of messages so the sorting
happens properly regardless of locale.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Matthew DeVore <matvore@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wrapper: avoid undefined behaviour in macOSCarlo Marcelo Arenas Belón Sun, 16 Jun 2019 18:40:03 +0000 (11:40 -0700)

wrapper: avoid undefined behaviour in macOS

0620b39b3b ("compat: add a mkstemps() compatibility function", 2009-05-31)
included a function based on code from libiberty which would result in
undefined behaviour in platforms where timeval's tv_usec is a 32-bit signed
type as shown by:

wrapper.c:505:31: runtime error: left shift of 594546 by 16 places cannot be represented in type '__darwin_suseconds_t' (aka 'int')

interestingly the version of this code from gcc never had this bug and the
code had a cast that would had prevented the issue (at least in 64-bit
platforms) but was misapplied.

change the cast to uint64_t so it also works in 32-bit platforms.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

interpret-trailers: load default configJeff King Wed, 19 Jun 2019 03:37:28 +0000 (23:37 -0400)

interpret-trailers: load default config

The interpret-trailers program does not do the usual loading of config
via git_default_config(), and thus does not respect many of the usual
options. In particular, we will not load core.commentChar, even though
the underlying trailer code uses its value.

This can be seen in the accompanying test, where setting
core.commentChar to anything besides "#" results in a failure to treat
the comments correctly.

Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

show --continue/skip etc. consistently in synopsisPhillip Wood Mon, 17 Jun 2019 09:17:09 +0000 (10:17 +0100)

show --continue/skip etc. consistently in synopsis

Command mode options that the user can choose one among many are
listed like this in the documentation:

git am (--continue | --skip | --abort | --quit)

They are listed on a single line and in parenthesis, because they
are not optional.

But documentation pages for some commands deviate from this norm.
Fix the merge and rebase docs to match this style.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use COPY_ARRAY for copying arraysRené Scharfe Sat, 15 Jun 2019 18:36:35 +0000 (20:36 +0200)

use COPY_ARRAY for copying arrays

Convert calls of memcpy(3) to use COPY_ARRAY, which shortens and
simplifies the code a bit.

Patch generated by Coccinelle and contrib/coccinelle/array.cocci.

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

coccinelle: use COPY_ARRAY for copying arraysRené Scharfe Sat, 15 Jun 2019 18:32:58 +0000 (20:32 +0200)

coccinelle: use COPY_ARRAY for copying arrays

The current semantic patch for COPY_ARRAY transforms memcpy(3) calls on
pointers, but Coccinelle distinguishes them from arrays. It already
contains three rules to handle the options for sizeof (i.e. source,
destination and type), and handling arrays as source and destination
would require four times as many rules if we enumerated all cases.

We also don't handle array subscripts, and supporting that would
increase the number of rules by another factor of four. (An isomorphism
telling Coccinelle that "sizeof x[...]" is equivalent to "sizeof *x"
would be nice..)

Support arrays and array subscripts, but keep the number of rules down
by adding normalization steps: First turn array subscripts into
derefences, then determine the types of expressions used with sizeof and
replace them with these types, and then convert the different possible
combinations of arrays and pointers with memcpy(3) to COPY_ARRAY.

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

fsmonitor: avoid signed integer overflow / infinite... Carlo Marcelo Arenas Belón Sat, 15 Jun 2019 16:11:35 +0000 (09:11 -0700)

fsmonitor: avoid signed integer overflow / infinite loop

883e248b8a ("fsmonitor: teach git to optionally utilize a file system
monitor to speed up detecting new or changed files.", 2017-09-22) uses
an int in a loop that would wrap if index_state->cache_nr (unsigned)
is bigger than INT_MAX

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

The second batchJunio C Hamano Mon, 17 Jun 2019 17:16:10 +0000 (10:16 -0700)

The second batch

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

Merge branch 'xl/record-partial-clone-origin'Junio C Hamano Mon, 17 Jun 2019 17:15:20 +0000 (10:15 -0700)

Merge branch 'xl/record-partial-clone-origin'

When creating a partial clone, the object filtering criteria is
recorded for the origin of the clone, but this incorrectly used a
hardcoded name "origin" to name that remote; it has been corrected
to honor the "--origin <name>" option.

* xl/record-partial-clone-origin:
clone: respect user supplied origin name when setting up partial clone

Merge branch 'pb/request-pull-verify-remote-ref'Junio C Hamano Mon, 17 Jun 2019 17:15:20 +0000 (10:15 -0700)

Merge branch 'pb/request-pull-verify-remote-ref'

"git request-pull" learned to warn when the ref we ask them to pull
from in the local repository and in the published repository are
different.

* pb/request-pull-verify-remote-ref:
request-pull: warn if the remote object is not the same as the local one
request-pull: quote regex metacharacters in local ref

Merge branch 'mm/p4-unshelve-windows-fix'Junio C Hamano Mon, 17 Jun 2019 17:15:19 +0000 (10:15 -0700)

Merge branch 'mm/p4-unshelve-windows-fix'

The command line to invoke a "git cat-file" command from inside
"git p4" was not properly quoted to protect a caret and running a
broken command on Windows, which has been corrected.

* mm/p4-unshelve-windows-fix:
p4 unshelve: fix "Not a valid object name HEAD0" on Windows

Merge branch 'po/git-help-on-git-itself'Junio C Hamano Mon, 17 Jun 2019 17:15:19 +0000 (10:15 -0700)

Merge branch 'po/git-help-on-git-itself'

"git help git" was hard to discover (well, at least for some
people).

* po/git-help-on-git-itself:
Doc: git.txt: remove backticks from link and add git-scm.com/docs
git.c: show usage for accessing the git(1) help page

Merge branch 'es/first-contrib-tutorial'Junio C Hamano Mon, 17 Jun 2019 17:15:18 +0000 (10:15 -0700)

Merge branch 'es/first-contrib-tutorial'

A new tutorial targetting specifically aspiring git-core
developers.

* es/first-contrib-tutorial:
doc: add some nit fixes to MyFirstContribution
documentation: add anchors to MyFirstContribution
documentation: add tutorial for first contribution

Merge branch 'bb/unicode-12.1-reiwa'Junio C Hamano Mon, 17 Jun 2019 17:15:18 +0000 (10:15 -0700)

Merge branch 'bb/unicode-12.1-reiwa'

Update to Unicode 12.1 width table.

* bb/unicode-12.1-reiwa:
unicode: update the width tables to Unicode 12.1

Merge branch 'sw/git-p4-unshelve-branched-files'Junio C Hamano Mon, 17 Jun 2019 17:15:18 +0000 (10:15 -0700)

Merge branch 'sw/git-p4-unshelve-branched-files'

"git p4" update.

* sw/git-p4-unshelve-branched-files:
git-p4: allow unshelving of branched files

Merge branch 'js/fsmonitor-unflake'Junio C Hamano Mon, 17 Jun 2019 17:15:17 +0000 (10:15 -0700)

Merge branch 'js/fsmonitor-unflake'

The data collected by fsmonitor was not properly written back to
the on-disk index file, breaking t7519 tests occasionally, which
has been corrected.

* js/fsmonitor-unflake:
mark_fsmonitor_valid(): mark the index as changed if needed
fill_stat_cache_info(): prepare for an fsmonitor fix

Merge branch 'ds/topo-traversal-using-commit-graph'Junio C Hamano Mon, 17 Jun 2019 17:15:17 +0000 (10:15 -0700)

Merge branch 'ds/topo-traversal-using-commit-graph'

Prepare use of reachability index in topological walker that works
on a range (A..B).

* ds/topo-traversal-using-commit-graph:
revision: keep topo-walk free of unintersting commits
revision: use generation for A..B --topo-order queries

Merge branch 'bl/userdiff-octave'Junio C Hamano Mon, 17 Jun 2019 17:15:17 +0000 (10:15 -0700)

Merge branch 'bl/userdiff-octave'

The pattern "git diff/grep" use to extract funcname and words
boundary for Matlab has been extend to cover Octave, which is more
or less equivalent.

* bl/userdiff-octave:
userdiff: fix grammar and style issues
userdiff: add Octave

Merge branch 'ba/clone-remote-submodules'Junio C Hamano Mon, 17 Jun 2019 17:15:17 +0000 (10:15 -0700)

Merge branch 'ba/clone-remote-submodules'

"git clone --recurse-submodules" learned to set up the submodules
to ignore commit object names recorded in the superproject gitlink
and instead use the commits that happen to be at the tip of the
remote-tracking branches from the get-go, by passing the new
"--remote-submodules" option.

* ba/clone-remote-submodules:
clone: add `--remote-submodules` flag

Merge branch 'vv/merge-squash-with-explicit-commit'Junio C Hamano Mon, 17 Jun 2019 17:15:17 +0000 (10:15 -0700)

Merge branch 'vv/merge-squash-with-explicit-commit'

"git merge --squash" is designed to update the working tree and the
index without creating the commit, and this cannot be countermanded
by adding the "--commit" option; the command now refuses to work
when both options are given.

* vv/merge-squash-with-explicit-commit:
merge: refuse --commit with --squash

Merge branch 'js/bundle-verify-require-object-store'Junio C Hamano Mon, 17 Jun 2019 17:15:16 +0000 (10:15 -0700)

Merge branch 'js/bundle-verify-require-object-store'

"git bundle verify" needs to see if prerequisite objects exist in
the receiving repository, but the command did not check if we are
in a repository upfront, which has been corrected.

* js/bundle-verify-require-object-store:
bundle verify: error out if called without an object database

Merge branch 'js/bisect-helper-check-get-oid-return... Junio C Hamano Mon, 17 Jun 2019 17:15:16 +0000 (10:15 -0700)

Merge branch 'js/bisect-helper-check-get-oid-return-value'

Code cleanup.

* js/bisect-helper-check-get-oid-return-value:
bisect--helper: verify HEAD could be parsed before continuing

Merge branch 'jk/am-i-resolved-fix'Junio C Hamano Mon, 17 Jun 2019 17:15:15 +0000 (10:15 -0700)

Merge branch 'jk/am-i-resolved-fix'

"git am -i --resolved" segfaulted after trying to see a commit as
if it were a tree, which has been corrected.

* jk/am-i-resolved-fix:
am: fix --interactive HEAD tree resolution
am: drop tty requirement for --interactive
am: read interactive input from stdin
am: simplify prompt response handling

Merge branch 'jk/HEAD-symref-in-xfer-namespaces'Junio C Hamano Mon, 17 Jun 2019 17:15:15 +0000 (10:15 -0700)

Merge branch 'jk/HEAD-symref-in-xfer-namespaces'

The server side support for "git fetch" used to show incorrect
value for the HEAD symbolic ref when the namespace feature is in
use, which has been corrected.

* jk/HEAD-symref-in-xfer-namespaces:
upload-pack: strip namespace from symref data

Merge branch 'ew/server-info-remove-crufts'Junio C Hamano Mon, 17 Jun 2019 17:15:15 +0000 (10:15 -0700)

Merge branch 'ew/server-info-remove-crufts'

"git update-server-info" used to leave stale packfiles in its
output, which has been corrected.

* ew/server-info-remove-crufts:
server-info: do not list unlinked packs

Merge branch 'es/grep-require-name-when-needed'Junio C Hamano Mon, 17 Jun 2019 17:15:14 +0000 (10:15 -0700)

Merge branch 'es/grep-require-name-when-needed'

More parameter validation.

* es/grep-require-name-when-needed:
grep: fail if call could output and name is null

Merge branch 'es/git-debugger-doc'Junio C Hamano Mon, 17 Jun 2019 17:15:14 +0000 (10:15 -0700)

Merge branch 'es/git-debugger-doc'

Doc update.

* es/git-debugger-doc:
doc: hint about GIT_DEBUGGER in CodingGuidelines

Merge branch 'ds/object-info-for-prefetch-fix'Junio C Hamano Mon, 17 Jun 2019 17:15:14 +0000 (10:15 -0700)

Merge branch 'ds/object-info-for-prefetch-fix'

Code cleanup and futureproof.

* ds/object-info-for-prefetch-fix:
sha1-file: split OBJECT_INFO_FOR_PREFETCH

t3404: fix a typoJohannes Schindelin Fri, 14 Jun 2019 12:16:08 +0000 (05:16 -0700)

t3404: fix a typo

This one slipped through the review of a9279c678588 (sequencer: do not
squash 'reword' commits when we hit conflicts, 2018-06-19).

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

The first batch after 2.22Junio C Hamano Thu, 13 Jun 2019 20:23:03 +0000 (13:23 -0700)

The first batch after 2.22

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

Merge branch 'pw/rebase-edit-message-for-replayed-merge'Junio C Hamano Thu, 13 Jun 2019 20:19:43 +0000 (13:19 -0700)

Merge branch 'pw/rebase-edit-message-for-replayed-merge'

A "merge -c" instruction during "git rebase --rebase-merges" should
give the user a chance to edit the log message, even when there is
otherwise no need to create a new merge and replace the existing
one (i.e. fast-forward instead), but did not. Which has been
corrected.

* pw/rebase-edit-message-for-replayed-merge:
rebase -r: always reword merge -c

Merge branch 'ab/deprecate-R-for-dynpath'Junio C Hamano Thu, 13 Jun 2019 20:19:43 +0000 (13:19 -0700)

Merge branch 'ab/deprecate-R-for-dynpath'

The way of specifying the path to find dynamic libraries at runtime
has been simplified. The old default to pass -R/path/to/dir has been
replaced with the new default to pass -Wl,-rpath,/path/to/dir,
which is the more recent GCC uses. Those who need to build with an
old GCC can still use "CC_LD_DYNPATH=-R"

* ab/deprecate-R-for-dynpath:
Makefile: remove the NO_R_TO_GCC_LINKER flag

Merge branch 'mh/import-transport-fd-fix'Junio C Hamano Thu, 13 Jun 2019 20:19:43 +0000 (13:19 -0700)

Merge branch 'mh/import-transport-fd-fix'

The ownership rule for the file descriptor to fast-import remote
backend was mixed up, leading to unrelated file descriptor getting
closed, which has been fixed.

* mh/import-transport-fd-fix:
Use xmmap_gently instead of xmmap in use_pack
dup() the input fd for fast-import used for remote helpers

Merge branch 'ew/update-server-info'Junio C Hamano Thu, 13 Jun 2019 20:19:42 +0000 (13:19 -0700)

Merge branch 'ew/update-server-info'

"git update-server-info" learned not to rewrite the file with the
same contents.

* ew/update-server-info:
update-server-info: avoid needless overwrites

Merge branch 'jk/help-unknown-ref-fix'Junio C Hamano Thu, 13 Jun 2019 20:19:42 +0000 (13:19 -0700)

Merge branch 'jk/help-unknown-ref-fix'

Improve the code to show args with potential typo that cannot be
interpreted as a commit-ish.

* jk/help-unknown-ref-fix:
help_unknown_ref(): check for refname ambiguity
help_unknown_ref(): duplicate collected refnames

Merge branch 'dl/format-patch-notes-config'Junio C Hamano Thu, 13 Jun 2019 20:19:42 +0000 (13:19 -0700)

Merge branch 'dl/format-patch-notes-config'

"git format-patch" learns a configuration to set the default for
its --notes=<ref> option.

* dl/format-patch-notes-config:
format-patch: teach format.notes config option
git-format-patch.txt: document --no-notes option

Merge branch 'nd/merge-quit'Junio C Hamano Thu, 13 Jun 2019 20:19:41 +0000 (13:19 -0700)

Merge branch 'nd/merge-quit'

"git merge" learned "--quit" option that cleans up the in-progress
merge while leaving the working tree and the index still in a mess.

* nd/merge-quit:
merge: add --quit
merge: remove drop_save() in favor of remove_merge_branch_state()

Merge branch 'ab/fail-prereqs-in-test'Junio C Hamano Thu, 13 Jun 2019 20:19:41 +0000 (13:19 -0700)

Merge branch 'ab/fail-prereqs-in-test'

Developer support to emulate unsatisfied prerequisites in tests to
ensure that the remainer of the tests still succeeds when tests
with prerequisites are skipped.

* ab/fail-prereqs-in-test:
tests: add a special setup where prerequisites fail

Merge branch 'nd/corrupt-worktrees'Junio C Hamano Thu, 13 Jun 2019 20:19:41 +0000 (13:19 -0700)

Merge branch 'nd/corrupt-worktrees'

"git worktree add" used to fail when another worktree connected to
the same repository was corrupt, which has been corrected.

* nd/corrupt-worktrees:
worktree add: be tolerant of corrupt worktrees

Merge branch 'js/rebase-cleanup'Junio C Hamano Thu, 13 Jun 2019 20:19:40 +0000 (13:19 -0700)

Merge branch 'js/rebase-cleanup'

Update supporting parts of "git rebase" to remove code that should
no longer be used.

* js/rebase-cleanup:
rebase: fold git-rebase--common into the -p backend
sequencer: the `am` and `rebase--interactive` scripts are gone
.gitignore: there is no longer a built-in `git-rebase--interactive`
t3400: stop referring to the scripted rebase
Drop unused git-rebase--am.sh

Merge branch 'nd/worktree-name-sanitization'Junio C Hamano Thu, 13 Jun 2019 20:19:40 +0000 (13:19 -0700)

Merge branch 'nd/worktree-name-sanitization'

In recent versions of Git, per-worktree refs are exposed in
refs/worktrees/<wtname>/ hierarchy, which means that worktree names
must be a valid refname component. The code now sanitizes the names
given to worktrees, to make sure these refs are well-formed.

* nd/worktree-name-sanitization:
worktree add: sanitize worktree names

Merge branch 'en/fast-export-encoding'Junio C Hamano Thu, 13 Jun 2019 20:19:39 +0000 (13:19 -0700)

Merge branch 'en/fast-export-encoding'

The "git fast-export/import" pair has been taught to handle commits
with log messages in encoding other than UTF-8 better.

* en/fast-export-encoding:
fast-export: do automatic reencoding of commit messages only if requested
fast-export: differentiate between explicitly UTF-8 and implicitly UTF-8
fast-export: avoid stripping encoding header if we cannot reencode
fast-import: support 'encoding' commit header
t9350: fix encoding test to actually test reencoding

Merge branch 'jk/unused-params-final-batch'Junio C Hamano Thu, 13 Jun 2019 20:19:34 +0000 (13:19 -0700)

Merge branch 'jk/unused-params-final-batch'

* jk/unused-params-final-batch:
verify-commit: simplify parameters to run_gpg_verify()
show-branch: drop unused parameter from show_independent()
rev-list: drop unused void pointer from finish_commit()
remove_all_fetch_refspecs(): drop unused "remote" parameter
receive-pack: drop unused "commands" from prepare_shallow_update()
pack-objects: drop unused rev_info parameters
name-rev: drop unused parameters from is_better_name()
mktree: drop unused length parameter
wt-status: drop unused status parameter
read-cache: drop unused parameter from threaded load
clone: drop dest parameter from copy_alternates()
submodule: drop unused prefix parameter from some functions
builtin: consistently pass cmd_* prefix to parse_options
cmd_{read,write}_tree: rename "unused" variable that is used

Merge branch 'sb/format-patch-base-patch-id-fix'Junio C Hamano Thu, 13 Jun 2019 20:18:46 +0000 (13:18 -0700)

Merge branch 'sb/format-patch-base-patch-id-fix'

The "--base" option of "format-patch" computed the patch-ids for
prerequisite patches in an unstable way, which has been updated to
compute in a way that is compatible with "git patch-id --stable".

* sb/format-patch-base-patch-id-fix:
format-patch: make --base patch-id output stable
format-patch: inform user that patch-id generation is unstable

Merge branch 'nd/init-relative-template-fix'Junio C Hamano Thu, 13 Jun 2019 20:18:46 +0000 (13:18 -0700)

Merge branch 'nd/init-relative-template-fix'

A relative pathname given to "git init --template=<path> <repo>"
ought to be relative to the directory "git init" gets invoked in,
but it instead was made relative to the repository, which has been
corrected.

* nd/init-relative-template-fix:
init: make --template path relative to $CWD

Merge branch 'ab/send-email-transferencoding-fix'Junio C Hamano Thu, 13 Jun 2019 20:18:46 +0000 (13:18 -0700)

Merge branch 'ab/send-email-transferencoding-fix'

Since "git send-email" learned to take 'auto' as the value for the
transfer-encoding, it by mistake stopped honoring the values given
to the configuration variables sendemail.transferencoding and/or
sendemail.<ident>.transferencoding. This has been corrected to
(finally) redoing the order of setting the default, reading the
configuration and command line options.

* ab/send-email-transferencoding-fix:
send-email: fix regression in sendemail.identity parsing
send-email: document --no-[to|cc|bcc]
send-email: fix broken transferEncoding tests
send-email: remove cargo-culted multi-patch pattern in tests
send-email: do defaults -> config -> getopt in that order
send-email: rename the @bcclist variable for consistency
send-email: move the read_config() function above getopts

cleanup: fix possible overflow errors in binary search... René Scharfe Thu, 13 Jun 2019 17:51:56 +0000 (19:51 +0200)

cleanup: fix possible overflow errors in binary search, part 2

Calculating the sum of two array indexes to find the midpoint between
them can overflow, i.e. code like this is unsafe for big arrays:

mid = (first + last) >> 1;

Make sure the intermediate value stays within the boundaries instead,
like this:

mid = first + ((last - first) >> 1);

The loop condition of the binary search makes sure that 'last' is
always greater than 'first', so this is safe as long as 'first' is
not negative. And that can be verified easily using the pre-context
of each change, except for name-hash.c, so add an assertion to that
effect there.

The unsafe calculations were found with:

git grep '(.*+.*) *>> *1'

This is a continuation of 19716b21a4 (cleanup: fix possible overflow
errors in binary search, 2017-10-08).

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

add -p: fix checkout -p with pathological contextPhillip Wood Wed, 12 Jun 2019 09:25:27 +0000 (02:25 -0700)

add -p: fix checkout -p with pathological context

Commit fecc6f3a68 ("add -p: adjust offsets of subsequent hunks when one is
skipped", 2018-03-01) fixed adding hunks in the correct place when a
previous hunk has been skipped. However it did not address patches that
are applied in reverse. In that case we need to adjust the pre-image
offset so that when apply reverses the patch the post-image offset is
adjusted correctly. We subtract rather than add the delta as the patch
is reversed (the easiest way to think about it is to consider a hunk of
deletions that is skipped - in that case we want to reduce offset so we
need to subtract).

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: avoid calling `labs()` on too-large data typeJohannes Schindelin Thu, 13 Jun 2019 11:49:47 +0000 (04:49 -0700)

config: avoid calling `labs()` on too-large data type

The `labs()` function operates, as the initial `l` suggests, on `long`
parameters. However, in `config.c` we tried to use it on values of type
`intmax_t`.

This problem was found by GCC v9.x.

To fix it, let's just "unroll" the function (i.e. negate the value if it
is negative).

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

winansi: simplify loading the GetCurrentConsoleFontEx... Johannes Schindelin Thu, 13 Jun 2019 11:49:46 +0000 (04:49 -0700)

winansi: simplify loading the GetCurrentConsoleFontEx() function

We introduced helper macros to simplify loading functions dynamically.
Might just as well use them.

This also side-steps a compiler warning when building with GCC v8.x: it
would complain about casting between incompatible function pointers.

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

kwset: allow building with GCC 8Johannes Schindelin Thu, 13 Jun 2019 11:49:45 +0000 (04:49 -0700)

kwset: allow building with GCC 8

The kwset functionality makes use of the obstack code, which expects to
be handed a function that can allocate large chunks of data. It expects
that function to accept a `size` parameter of type `long`.

This upsets GCC 8 on Windows, because `long` does not have the same
bit size as `size_t` there.

Now, the proper thing to do would be to switch to `size_t`. But this
would make us deviate from the "upstream" code even further, making it
hard to synchronize with newer versions, and also it would be quite
involved because that `long` type is so invasive in that code.

Let's punt, and instead provide a super small wrapper around
`xmalloc()`.

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

poll (mingw): allow compiling with GCC 8 and DEVELOPER=1Johannes Schindelin Thu, 13 Jun 2019 11:49:44 +0000 (04:49 -0700)

poll (mingw): allow compiling with GCC 8 and DEVELOPER=1

The return type of the `GetProcAddress()` function is `FARPROC` which
evaluates to `long long int (*)()`, i.e. it cannot be cast to the
correct function signature by GCC 8.

To work around that, we first cast to `void *` and go on with our merry
lives.

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