gitweb.git
remote-curl.c: xcurl_off_t is not portable (on 32 bit... Torsten Bögershausen Fri, 9 Nov 2018 17:41:10 +0000 (18:41 +0100)

remote-curl.c: xcurl_off_t is not portable (on 32 bit platfoms)

When setting
DEVELOPER = 1
DEVOPTS = extra-all

"gcc (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516" errors out with
"comparison is always false due to limited range of data type"
"[-Werror=type-limits]"

It turns out that the function xcurl_off_t() has 2 flavours:

- It gives a warning 32 bit systems, like Linux
- It takes the signed ssize_t as a paramter, but the only caller is using
a size_t (which is typically unsigned these days)

The original motivation of this function is to make sure that sizes > 2GiB
are handled correctly. The curl documentation says:
"For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
wide signed integral data type"
On a 32 bit system "size_t" can be promoted into a 64 bit signed value
without loss of data, and therefore we may see the
"comparison is always false" warning.
On a 64 bit system it may happen, at least in theory, that size_t is > 2^63,
and then the promotion from an unsigned "size_t" into a signed "curl_off_t"
may be a problem.

One solution to suppress a possible compiler warning could be to remove
the function xcurl_off_t().

However, to be on the very safe side, we keep it and improve it:

- The len parameter is changed from ssize_t to size_t
- A temporally variable "size" is used, promoted int uintmax_t and the compared
with "maximum_signed_value_of_type(curl_off_t)".
Thanks to Junio C Hamano for this hint.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Upcast size_t variables to uintmax_t when printingTorsten Bögershausen Sun, 11 Nov 2018 07:05:04 +0000 (08:05 +0100)

Upcast size_t variables to uintmax_t when printing

When printing variables which contain a size, today "unsigned long"
is used at many places.
In order to be able to change the type from "unsigned long" into size_t
some day in the future, we need to have a way to print 64 bit variables
on a system that has "unsigned long" defined to be 32 bit, like Win64.

Upcast all those variables into uintmax_t before they are printed.
This is to prepare for a bigger change, when "unsigned long"
will be converted into size_t for variables which may be > 4Gib.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

p3400: replace calls to `git checkout -b' by `git check... Alban Gruin Fri, 9 Nov 2018 21:19:23 +0000 (22:19 +0100)

p3400: replace calls to `git checkout -b' by `git checkout -B'

p3400 makes a copy of the current repository to test git-rebase
performance, and creates new branches in the copy with `git checkout
-b'. If the original repository has branches with the same name as the
script is trying to create, this operation will fail.

This replaces these calls by `git checkout -B' to force the creation and
update of these branches.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

build: fix broken command-list.h generation with core... Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 18:23:23 +0000 (19:23 +0100)

build: fix broken command-list.h generation with core.autocrlf

The script generate-cmdlist.sh needs input text files in UNIX line
ending to work correctly. It's been fine even with core.autocrlf set
because Documentation/git-*.txt is forced LF conversion.

But this leaves out gitk.txt and also Documentation/*config.txt that
recently becomes new input for this script. Update the attribute file
to force LF on all *.txt files to be on the safe side.

For more details, please see 00ddc9d13c (Fix build with
core.autocrlf=true - 2017-05-09)

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

rebase-interactive.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:10 +0000 (06:49 +0100)

rebase-interactive.c: remove the_repository references

While at there add a forward declaration for struct strbuf.

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

rerere.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:09 +0000 (06:49 +0100)

rerere.c: remove the_repository references

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

pack-*.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:08 +0000 (06:49 +0100)

pack-*.c: remove the_repository references

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

pack-check.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:07 +0000 (06:49 +0100)

pack-check.c: remove the_repository references

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

notes-cache.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:06 +0000 (06:49 +0100)

notes-cache.c: remove the_repository references

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

line-log.c: remove the_repository referenceNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:05 +0000 (06:49 +0100)

line-log.c: remove the_repository reference

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

diff-lib.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:04 +0000 (06:49 +0100)

diff-lib.c: remove the_repository references

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

delta-islands.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:03 +0000 (06:49 +0100)

delta-islands.c: remove the_repository references

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

cache-tree.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:02 +0000 (06:49 +0100)

cache-tree.c: remove the_repository references

This case is more interesting than other boring "remove the_repo"
commits because while we need access to the object database, we cannot
simply use r->index because unpack-trees.c can operate on a temporary
index, not $GIT_DIR/index. Ideally we should be able to pass an object
database to lookup_tree() but that ship has sailed.

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

bundle.c: remove the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:01 +0000 (06:49 +0100)

bundle.c: remove the_repository references

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

branch.c: remove the_repository referenceNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:49:00 +0000 (06:49 +0100)

branch.c: remove the_repository reference

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

bisect.c: remove the_repository referenceNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:59 +0000 (06:48 +0100)

bisect.c: remove the_repository reference

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

blame.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:58 +0000 (06:48 +0100)

blame.c: remove implicit dependency the_repository

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

sequencer.c: remove implicit dependency on the_repositoryNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:57 +0000 (06:48 +0100)

sequencer.c: remove implicit dependency on the_repository

Note that the_hash_algo stays, even if we can easily replace it with
repo->hash_algo. My reason is I still believe tying hash_algo to a
struct repository is a wrong move. But if I'm wrong, we can always go
for another round of conversion.

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

sequencer.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:56 +0000 (06:48 +0100)

sequencer.c: remove implicit dependency on the_index

Since we're going to pass 'struct repository *' around most of the
time instead of 'struct index_state *' because most sequencer.c
operations need more than just the index, the_repository is replaced
as well in the functions that now take 'struct repository
*'. the_repository is still present in this file, but total clean up
will be done later. It's not the main focus of this patch.

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

transport.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:55 +0000 (06:48 +0100)

transport.c: remove implicit dependency on the_index

note, there's still another hidden dependency related to this: even
though we pass a repo to transport_push() we still use
is_bare_repository() which pretty much assumes the_repository (and
some other global state).

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

notes-merge.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:54 +0000 (06:48 +0100)

notes-merge.c: remove implicit dependency the_repository

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

notes-merge.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:53 +0000 (06:48 +0100)

notes-merge.c: remove implicit dependency on the_index

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

list-objects.c: reduce the_repository referencesNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:52 +0000 (06:48 +0100)

list-objects.c: reduce the_repository references

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

list-objects-filter.c: remove implicit dependency on... Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:51 +0000 (06:48 +0100)

list-objects-filter.c: remove implicit dependency on the_index

While at there, since we have access to struct repository now,
eliminate the only the_repository reference in this file.

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

wt-status.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:50 +0000 (06:48 +0100)

wt-status.c: remove implicit dependency the_repository

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

wt-status.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:48:49 +0000 (06:48 +0100)

wt-status.c: remove implicit dependency on the_index

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

fsck: mark strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:15 +0000 (06:16 +0100)

fsck: mark strings for translation

Two die() are updated to start with lowercase to be consistent with
the rest.

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

fsck: reduce word legos to help i18nNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:14 +0000 (06:16 +0100)

fsck: reduce word legos to help i18n

These messages will be marked for translation later. Reduce word legos
and give translators almost full phrases. describe_object() is updated
so that it can be called from printf() twice.

While at there, remove \n from the strings to reduce a bit of work
from translators.

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

parse-options.c: mark more strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:13 +0000 (06:16 +0100)

parse-options.c: mark more strings for translation

One error is updated to start with lowercase to be consistent with the
rest.

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

parse-options.c: turn some die() to BUG()Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:12 +0000 (06:16 +0100)

parse-options.c: turn some die() to BUG()

These two strings are clearly not for the user to see. Reduce the
violence in one string while at there.

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

parse-options: replace opterror() with optname()Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:11 +0000 (06:16 +0100)

parse-options: replace opterror() with optname()

Introduce optname() that does the early half of original opterror() to
come up with the name of the option reported back to the user, and use
it to kill opterror(). The callers of opterror() now directly call
error() using the string returned by opterror() instead.

There are a few issues with opterror()

- it tries to assemble an English sentence from pieces. This is not
great for translators because we give them pieces instead of a full
sentence.

- It's a wrapper around error() and needs some hack to let the
compiler know it always returns -1.

- Since it takes a string instead of printf format, one call site has
to assemble the string manually before passing to it.

Using error() directly solves the second and third problems.

It kind helps the first problem as well because "%s does foo" does
give a translator a full sentence in a sense and let them reorder if
needed. But it has limitations, if the subject part has to change
based on the rest of the sentence, that language is screwed. This is
also why I try to avoid calling optname() when 'flags' is known in
advance.

Mark of these strings for translation as well while at there.

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

repack: mark more strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:10 +0000 (06:16 +0100)

repack: mark more strings for translation

Two strings are slightly updated to be consistent with the rest: die()
starts with lowercase.

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

remote.c: mark messages for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:09 +0000 (06:16 +0100)

remote.c: mark messages for translation

The two strings are slightly modified to be consistent with the rest:
die() and error() start with a lowercase.

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

remote.c: turn some error() or die() to BUG()Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:08 +0000 (06:16 +0100)

remote.c: turn some error() or die() to BUG()

The first error, "internal error", is clearly a BUG(). The second two
are meant to catch calls with invalid parameters and should never
happen outside the test suite.

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

reflog: mark strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:07 +0000 (06:16 +0100)

reflog: mark strings for translation

One string "nothing to delete?" is rephrased to be more helpful.

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

read-cache.c: add missing colon separatorsNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:06 +0000 (06:16 +0100)

read-cache.c: add missing colon separators

typechange_fmt and added_fmt should have a colon before "needs
update". Align the statements to make it easier to read and see. Also
drop the unnecessary ().

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

read-cache.c: mark more strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:05 +0000 (06:16 +0100)

read-cache.c: mark more strings for translation

There are a couple other improvements on these strings as well:

- add missing colon (as separator)
- quote paths
- provide more information on error messages
- keep first word in lowercase

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

read-cache.c: turn die("internal error") to BUG()Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:04 +0000 (06:16 +0100)

read-cache.c: turn die("internal error") to BUG()

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

attr.c: mark more string for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:03 +0000 (06:16 +0100)

attr.c: mark more string for translation

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

archive.c: mark more strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:02 +0000 (06:16 +0100)

archive.c: mark more strings for translation

Two messages also print extra information to be more useful

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

alias.c: mark split_cmdline_strerror() strings for... Nguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:01 +0000 (06:16 +0100)

alias.c: mark split_cmdline_strerror() strings for translation

This function can be part of translated messages. To make sure we
don't have a sentence with mixed languages, mark the strings for
translation, but only use translated strings in places we know we will
output translated strings.

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

git.c: mark more strings for translationNguyễn Thái Ngọc Duy Sat, 10 Nov 2018 05:16:00 +0000 (06:16 +0100)

git.c: mark more strings for translation

One string is slightly updated to keep consistency with the rest:
die() should begin with lowercase.

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

Update .mailmapJohannes Schindelin Fri, 9 Nov 2018 11:31:14 +0000 (03:31 -0800)

Update .mailmap

This patch makes the output of `git shortlog -nse v2.10.0..master`
duplicate-free by taking/guessing the current and preferred
addresses for authors that appear with more than one address.

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

range-diff: fix regression in passing along diff optionsÆvar Arnfjörð Bjarmason Fri, 9 Nov 2018 10:18:02 +0000 (10:18 +0000)

range-diff: fix regression in passing along diff options

In 73a834e9e2 ("range-diff: relieve callers of low-level configuration
burden", 2018-07-22) we broke passing down options like --no-patch,
--stat etc.

Fix that regression, and add a test asserting the pre-73a834e9e2
behavior for some of these diff options.

As noted in a change leading up to this ("range-diff doc: add a
section about output stability", 2018-11-07) the output is not meant
to be stable. So this regression test will likely need to be tweaked
once we get a "proper" --stat option.

See
https://public-inbox.org/git/nycvar.QRO.7.76.6.1811071202480.39@tvgsbejvaqbjf.bet/
for a further explanation of the regression. The fix here is not the
same as in Johannes's on-list patch, for reasons that'll be explained
in a follow-up commit.

The quoting of "EOF" here mirrors that of an earlier test. Perhaps
that should be fixed, but let's leave that up to a later cleanup
change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

range-diff doc: add a section about output stabilityÆvar Arnfjörð Bjarmason Fri, 9 Nov 2018 10:18:01 +0000 (10:18 +0000)

range-diff doc: add a section about output stability

The range-diff command is already advertised as porcelain, but let's
make it really clear that the output is completely subject to change,
particularly when it comes to diff options such as --stat. Right now
that option doesn't work, but fixing that is the subject of a later
change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: Update Catalan translationJordi Mas Sun, 11 Nov 2018 15:35:19 +0000 (16:35 +0100)

l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>

http: add support selecting http versionForce Charlie Fri, 9 Nov 2018 03:44:14 +0000 (19:44 -0800)

http: add support selecting http version

Usually we don't need to set libcurl to choose which version of the
HTTP protocol to use to communicate with a server.
But different versions of libcurl, the default value is not the same.

CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS
CURL < 7.62: CURL_HTTP_VERSION_1_1

In order to give users the freedom to control the HTTP version,
we need to add a setting to choose which HTTP version to use.

Signed-off-by: Force Charlie <charlieio@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: ease dynamic-gettext-poison transitionJunio C Hamano Thu, 8 Nov 2018 21:15:30 +0000 (21:15 +0000)

Makefile: ease dynamic-gettext-poison transition

Earlier we made the entire build to fail when GETTEXT_POISON=Yes is
given to make, to notify those who did not notice that text poisoning
is now a runtime behaviour.

It turns out that this is too irritating for those who need to build
and test different versions of Git that cross the boundary between
history with and without this topic to switch between two
environment variables. Demote the error to a warning, so that you
can say something like

make GETTEXT_POISON=Yes GIT_TEST_GETTEXT_POISON=Yes test

during the transition period, without having to worry about whether
exact version you are testing has or does not have this topic.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: make GETTEXT_POISON a runtime optionÆvar Arnfjörð Bjarmason Thu, 8 Nov 2018 21:15:29 +0000 (21:15 +0000)

i18n: make GETTEXT_POISON a runtime option

Change the GETTEXT_POISON compile-time + runtime GIT_GETTEXT_POISON
test parameter to only be a GIT_TEST_GETTEXT_POISON=<non-empty?>
runtime parameter, to be consistent with other parameters documented
in "Running tests with special setups" in t/README.

When I added GETTEXT_POISON in bb946bba76 ("i18n: add GETTEXT_POISON
to simulate unfriendly translator", 2011-02-22) I was concerned with
ensuring that the _() function would get constant folded if NO_GETTEXT
was defined, and likewise that GETTEXT_POISON would be compiled out
unless it was defined.

But as the benchmark in my [1] shows doing a one-off runtime
getenv("GIT_TEST_[...]") is trivial, and since GETTEXT_POISON was
originally added the GIT_TEST_* env variables have become the common
idiom for turning on special test setups.

So change GETTEXT_POISON to work the same way. Now the
GETTEXT_POISON=YesPlease compile-time option is gone, and running the
tests with GIT_TEST_GETTEXT_POISON=[YesPlease|] can be toggled on/off
without recompiling.

This allows for conditionally amending tests to test with/without
poison, similar to what 859fdc0c3c ("commit-graph: define
GIT_TEST_COMMIT_GRAPH", 2018-08-29) did for GIT_TEST_COMMIT_GRAPH. Do
some of that, now we e.g. always run the t0205-gettext-poison.sh test.

I did enough there to remove the GETTEXT_POISON prerequisite, but its
inverse C_LOCALE_OUTPUT is still around, and surely some tests using
it can be converted to e.g. always set GIT_TEST_GETTEXT_POISON=.

Notes on the implementation:

* We still compile a dedicated GETTEXT_POISON build in Travis
CI. Perhaps this should be revisited and integrated into the
"linux-gcc" build, see ae59a4e44f ("travis: run tests with
GIT_TEST_SPLIT_INDEX", 2018-01-07) for prior art in that area. Then
again maybe not, see [2].

* We now skip a test in t0000-basic.sh under
GIT_TEST_GETTEXT_POISON=YesPlease that wasn't skipped before. This
test relies on C locale output, but due to an edge case in how the
previous implementation of GETTEXT_POISON worked (reading it from
GIT-BUILD-OPTIONS) wasn't enabling poison correctly. Now it does,
and needs to be skipped.

* The getenv() function is not reentrant, so out of paranoia about
code of the form:

printf(_("%s"), getenv("some-env"));

call use_gettext_poison() in our early setup in git_setup_gettext()
so we populate the "poison_requested" variable in a codepath that's
won't suffer from that race condition.

* We error out in the Makefile if you're still saying
GETTEXT_POISON=YesPlease to prompt users to change their
invocation.

* We should not print out poisoned messages during the test
initialization itself to keep it more readable, so the test library
hides the variable if set in $GIT_TEST_GETTEXT_POISON_ORIG during
setup. See [3].

See also [4] for more on the motivation behind this patch, and the
history of the GETTEXT_POISON facility.

1. https://public-inbox.org/git/871s8gd32p.fsf@evledraar.gmail.com/
2. https://public-inbox.org/git/20181102163725.GY30222@szeder.dev/
3. https://public-inbox.org/git/20181022202241.18629-2-szeder.dev@gmail.com/
4. https://public-inbox.org/git/878t2pd6yu.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: combine error handlingDerrick Stolee Thu, 8 Nov 2018 04:40:31 +0000 (20:40 -0800)

merge-recursive: combine error handling

In handle_rename_rename_1to2(), we have duplicated error handling
around colliding paths. Specifically, when we want to write out
the file and there is a directory or untracked file in the way,
we need to create a temporary file to hold the contents. This has
some special output to alert the user, and this output is
duplicated for each side of the conflict.

Simplify the call by generating this new path in a helper
function.

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

t6036, t6043: increase code coverage for file collision... Elijah Newren Thu, 8 Nov 2018 04:40:30 +0000 (20:40 -0800)

t6036, t6043: increase code coverage for file collision handling

Stolee's coverage reports found a few code blocks for file collision
conflicts that had not previously been covered by testcases; add a few
more testcases to cover those too.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: improve rename/rename(1to2)/add[/add... Elijah Newren Thu, 8 Nov 2018 04:40:29 +0000 (20:40 -0800)

merge-recursive: improve rename/rename(1to2)/add[/add] handling

When we have a rename/rename(1to2) conflict, each of the renames can
collide with a file addition. Each of these rename/add conflicts suffered
from the same kinds of problems that normal rename/add suffered from.
Make the code use handle_file_conflicts() as well so that we get all the
same fixes and consistent behavior between the different conflict types.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: use handle_file_collision for add... Elijah Newren Thu, 8 Nov 2018 04:40:28 +0000 (20:40 -0800)

merge-recursive: use handle_file_collision for add/add conflicts

This results in no-net change of behavior, it simply ensures that all
file-collision conflict handling types are being handled the same by
calling the same function.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: improve handling for rename/rename... Elijah Newren Thu, 8 Nov 2018 04:40:27 +0000 (20:40 -0800)

merge-recursive: improve handling for rename/rename(2to1) conflicts

This makes the rename/rename(2to1) conflicts use the new
handle_file_collision() function. Since that function was based
originally on the rename/rename(2to1) handling code, the main
differences here are in what was added. In particular:

* Instead of storing files at collide_path~HEAD and collide_path~MERGE,
the files are two-way merged and recorded at collide_path.

* Instead of recording the version of the renamed file that existed
on the renamed side in the index (thus ignoring any changes that
were made to the file on the side of history without the rename),
we do a three-way content merge on the renamed path, then store
that at either stage 2 or stage 3.

* Note that since the content merge for each rename may have conflicts,
and then we have to merge the two renamed files, we can end up with
nested conflict markers.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: fix rename/add conflict handlingElijah Newren Thu, 8 Nov 2018 04:40:26 +0000 (20:40 -0800)

merge-recursive: fix rename/add conflict handling

This makes the rename/add conflict handling make use of the new
handle_file_collision() function, which fixes several bugs and improves
things for the rename/add case significantly. Previously, rename/add
would:

* Not leave any higher order stage entries in the index, making it
appear as if there were no conflict.
* Would place the rename file at the colliding path, and move the
added file elsewhere, which combined with the lack of higher order
stage entries felt really odd. It's not clear to me why the
rename should take precedence over the add; if one should be moved
out of the way, they both probably should.
* In the recursive case, it would do a two way merge of the added
file and the version of the renamed file on the renamed side,
completely excluding modifications to the renamed file on the
unrenamed side of history.

Use the new handle_file_collision() to fix all of these issues.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: new function for better colliding... Elijah Newren Thu, 8 Nov 2018 04:40:25 +0000 (20:40 -0800)

merge-recursive: new function for better colliding conflict resolutions

There are three conflict types that represent two (possibly entirely
unrelated) files colliding at the same location:
* add/add
* rename/add
* rename/rename(2to1)

These three conflict types already share more similarity than might be
immediately apparent from their description: (1) the handling of the
rename variants already involves removing any entries from the index
corresponding to the original file names[*], thus only leaving entries
in the index for the colliding path; (2) likewise, any trace of the
original file name in the working tree is also removed. So, in all
three cases we're left with how to represent two colliding files in both
the index and the working copy.

[*] Technically, this isn't quite true because rename/rename(2to1)
conflicts in the recursive (o->call_depth > 0) case do an "unrename"
since about seven years ago. But even in that case, Junio felt
compelled to explain that my decision to "unrename" wasn't necessarily
the only or right answer -- search for "Comment from Junio" in t6036 for
details.

My initial motivation for looking at these three conflict types was that
if the handling of these three conflict types is the same, at least in
the limited set of cases where a renamed file is unmodified on the side
of history where the file is not renamed, then a significant performance
improvement for rename detection during merges is possible. However,
while that served as motivation to look at these three types of
conflicts, the actual goal of this new function is to try to improve the
handling for all three cases, not to merely make them the same as each
other in that special circumstance.

=== Handling the working tree ===

The previous behavior for these conflict types in regards to the
working tree (assuming the file collision occurs at 'foo') was:
* add/add does a two-way merge of the two files and records it as 'foo'.
* rename/rename(2to1) records the two different files into two new
uniquely named files (foo~HEAD and foo~$MERGE), while removing 'foo'
from the working tree.
* rename/add records the two different files into two different
locations, recording the add at foo~$SIDE and, oddly, recording
the rename at foo (why is the rename more important than the add?)

So, the question for what to write to the working tree boils down to
whether the two colliding files should be two-way merged and recorded in
place, or recorded into separate files. As per discussion on the git
mailing lit, two-way merging was deemed to always be preferred, as that
makes these cases all more like content conflicts that users can handle
from within their favorite editor, IDE, or merge tool. Note that since
renames already involve a content merge, rename/add and
rename/rename(2to1) conflicts could result in nested conflict markers.

=== Handling of the index ===

For a typical rename, unpack_trees() would set up the index in the
following fashion:
old_path new_path
stage1: 5ca1ab1e 00000000
stage2: f005ba11 00000000
stage3: 00000000 b0a710ad
And merge-recursive would rewrite this to
new_path
stage1: 5ca1ab1e
stage2: f005ba11
stage3: b0a710ad
Removing old_path from the index means the user won't have to `git rm
old_path` manually every time a renamed path has a content conflict.
It also means they can use `git checkout [--ours|--theirs|--conflict|-m]
new_path`, `git diff [--ours|--theirs]` and various other commands that
would be difficult otherwise.

This strategy becomes a problem when we have a rename/add or
rename/rename(2to1) conflict, however, because then we have only three
slots to store blob sha1s and we need either four or six. Previously,
this was handled by continuing to delete old_path from the index, and
just outright ignoring any blob shas from old_path. That had the
downside of deleting any trace of changes made to old_path on the other
side of history. This function instead does a three-way content merge of
the renamed file, and stores the blob sha1 for that at either stage2 or
stage3 for new_path (depending on which side the rename came from). That
has the advantage of bringing information about changes on both sides and
still allows for easy resolution (no need to git rm old_path, etc.), but
does have the downside that if the content merge had conflict markers,
then what we store in the index is the sha1 of a blob with conflict
markers. While that is a downside, it seems less problematic than the
downsides of any obvious alternatives, and certainly makes more sense
than the previous handling. Further, it has a precedent in that when we
do recursive merges, we may accept a file with conflict markers as the
resolution for the merge of the merge-bases, which will then show up in
the index of the outer merge at stage 1 if a conflict exists at the outer
level.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: increase marker length with depth... Elijah Newren Thu, 8 Nov 2018 04:40:24 +0000 (20:40 -0800)

merge-recursive: increase marker length with depth of recursion

Later patches in this series will modify file collision conflict
handling (e.g. from rename/add and rename/rename(2to1) conflicts) so
that multiply nested conflict markers can arise even before considering
conflicts in the virtual merge base. Including the virtual merge base
will provide a way to get triply (or higher) nested conflict markers.
This new way to get nested conflict markers will force the need for a
more general mechanism to extend the length of conflict markers in order
to differentiate between different nestings.

Along with this change to conflict marker length handling, we want to
make sure that we don't regress handling for other types of conflicts
with nested conflict markers. Add a more involved testcase using
merge.conflictstyle=diff3, where not only does the virtual merge base
contain conflicts, but its virtual merge base does as well (i.e. a case
with triply nested conflict markers). While there are multiple
reasonable ways to handle nested conflict markers in the virtual merge
base for this type of situation, the easiest approach that dovetails
well with the new needs for the file collision conflict handling is to
require that the length of the conflict markers increase with each
subsequent nesting.

Subsequent patches which change the rename/add and rename/rename(2to1)
conflict handling will modify the extra_marker_size flag appropriately
for their new needs.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6036, t6042: testcases for rename collision of already... Elijah Newren Thu, 8 Nov 2018 04:40:23 +0000 (20:40 -0800)

t6036, t6042: testcases for rename collision of already conflicting files

When a single file is renamed, it can also be modified, yielding the
possibility of that renamed file having content conflicts. If two
different such files are renamed into the same location, then two-way
merging those files may result in nested conflicts. Add a testcase that
makes sure we get this case correct, and uses different lengths of
conflict markers to differentiate between the different nestings.

Also add another case with an extra (i.e. third) level of conflict
markers due to using merge.conflictstyle=diff3 and the virtual merge
base also having conflicts present.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: add tests for consistency in file collision... Elijah Newren Thu, 8 Nov 2018 04:40:22 +0000 (20:40 -0800)

t6042: add tests for consistency in file collision conflict handling

Add testcases dealing with file collisions for the following types of
conflicts:
* add/add
* rename/add
* rename/rename(2to1)

All these conflict types simplify down to two files "colliding"
and should thus be handled similarly. This means that rename/add and
rename/rename(2to1) conflicts need to be modified to behave the same as
add/add conflicts currently do: the colliding files should be two-way
merged (instead of the current behavior of writing the two colliding
files out to separate temporary unique pathnames). Add testcases which
check this; subsequent commits will fix the conflict handling to make
these tests pass.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

built-in rebase --autostash: leave the current branch... Johannes Schindelin Wed, 7 Nov 2018 14:00:50 +0000 (06:00 -0800)

built-in rebase --autostash: leave the current branch alone if possible

When we converted a `git reset --hard` call in the original Unix shell
script to built-in code, we asked to reset the worktree and the index
and explicitly *not* to detach the HEAD. By mistake, though, we still
did. Let's fix this.

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

built-in rebase: demonstrate regression with --autostashJohannes Schindelin Wed, 7 Nov 2018 14:00:48 +0000 (06:00 -0800)

built-in rebase: demonstrate regression with --autostash

An unnamed colleague of Ævar Arnfjörð Bjarmason reported a breakage
where a `pull --rebase` (which did not really need to do anything but
stash, see that nothing was changed, and apply the stash again) also
detached the HEAD.

This patch adds a minimal reproducer for this regression.

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

Windows: force-recompile git.res for differing architec... Johannes Schindelin Tue, 6 Nov 2018 14:55:50 +0000 (06:55 -0800)

Windows: force-recompile git.res for differing architectures

When git.rc is compiled into git.res, the result is actually dependent
on the architecture. That is, you cannot simply link a 32-bit git.res
into a 64-bit git.exe.

Therefore, to allow 32-bit and 64-bit builds in the same directory, we
let git.res depend on GIT-PREFIX so that it gets recompiled when
compiling for a different architecture (this works because the exec path
changes based on the architecture: /mingw32/libexec/git-core for 32-bit
and /mingw64/libexec/git-core for 64-bit).

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

approxidate: fix NULL dereference in date_time()Jeff King Wed, 7 Nov 2018 01:12:53 +0000 (20:12 -0500)

approxidate: fix NULL dereference in date_time()

When we see a time like "noon", we pass "12" to our date_time() helper,
which sets the hour to 12pm. If the current time is before noon, then we
wrap around to yesterday using date_yesterday(). But unlike the normal
calls to date_yesterday() from approxidate_alpha(), we pass a NULL "num"
parameter. Since c27cc94fad (approxidate: handle pending number for
"specials", 2018-11-02), that causes a segfault.

One way to fix this is by checking for NULL. But arguably date_time() is
abusing our helper by passing NULL in the first place (and this is the
only case where one of these "special" parsers is used this way). So
instead, let's have it just do the 1-day subtraction itself. It's still
just a one-liner due to our update_tm() helper.

Note that the test added here is a little funny, as we say "10am noon",
which makes the "10am" seem pointless. But this bug can only be
triggered when it the currently-parsed hour is before the special time.
The latest special time is "tea" at 1700, but t0006 uses a hard-coded
TEST_DATE_NOW of 1900. We could reset TEST_DATE_NOW, but that may lead
to confusion in other tests. Just saying "10am noon" makes this test
self-contained.

Reported-by: Carlo Arenas <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-objects: ignore ambiguous object warningsDerrick Stolee Tue, 6 Nov 2018 20:34:47 +0000 (12:34 -0800)

pack-objects: ignore ambiguous object warnings

A git push process runs several processes during its run, but one
includes git send-pack which calls git pack-objects and passes
the known have/wants into stdin using object ids. However, the
default setting for core.warnAmbiguousRefs requires git pack-objects
to check for ref names matching the ref_rev_parse_rules array in
refs.c. This means that every object is triggering at least six
"file exists?" queries. When there are a lot of refs, this can
add up significantly! I observed a simple push spending three
seconds checking these paths.

The fix here is similar to 4c30d50 "rev-list: disable object/refname
ambiguity check with --stdin". While the get_object_list() method
reads the objects from stdin, turn warn_on_object_refname_ambiguity
flag (which is usually true) to false. Just for code hygiene, save
away the original at the beginning and restore it once we are done.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pull: handle --verify-signatures for unborn branchJeff King Tue, 6 Nov 2018 07:52:13 +0000 (02:52 -0500)

pull: handle --verify-signatures for unborn branch

We usually just forward the --verify-signatures option along to
git-merge, and trust it to do the right thing. However, when we are on
an unborn branch (i.e., there is no HEAD yet), we handle this case
ourselves without even calling git-merge. And in this code path, we do
not respect the verification option at all.

It may be more maintainable in the long run to call git-merge for the
unborn case. That would fix this bug, as well as prevent similar ones in
the future. But unfortunately it's not easy to do. As t5520.3
demonstrates, there are some special cases that git-merge does not
handle, like "git pull .. master:master" (by the time git-merge is
invoked, we've overwritten the unborn HEAD).

So for now let's just teach git-pull to handle this feature.

Reported-by: Felix Eckhofer <felix@eckhofer.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge: handle --verify-signatures for unborn branchJeff King Tue, 6 Nov 2018 07:51:15 +0000 (02:51 -0500)

merge: handle --verify-signatures for unborn branch

When git-merge sees that we are on an unborn branch (i.e., there is no
HEAD), it follows a totally separate code path than the usual merge
logic. This code path does not know about verify_signatures, and so we
fail to notice bad or missing signatures.

This has been broken since --verify-signatures was added in efed002249
(merge/pull: verify GPG signatures of commits being merged, 2013-03-31).
In an ideal world, we'd unify the flow for this case with the regular
merge logic, which would fix this bug and avoid introducing similar
ones. But because the unborn case is so different, it would be a burden
on the rest of the function to continually handle the missing HEAD. So
let's just port the verification check to this special case.

Reported-by: Felix Eckhofer <felix@eckhofer.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge: extract verify_merge_signature() helperJeff King Tue, 6 Nov 2018 07:50:17 +0000 (02:50 -0500)

merge: extract verify_merge_signature() helper

The logic to implement "merge --verify-signatures" is inline in
cmd_merge(), but this site misses some cases. Let's extract the logic
into a function so we can call it from more places.

We'll move it to commit.[ch], since one of the callers (git-pull) is
outside our source file. This function isn't all that general (after
all, its main function is to exit the program) but it's not worth trying
to fix that. The heavy lifting is done by check_commit_signature(), and
our purpose here is just sharing the die() logic. We'll mark it with a
comment to make that clear.

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

Ninth batch for 2.20Junio C Hamano Tue, 6 Nov 2018 06:51:23 +0000 (15:51 +0900)

Ninth batch for 2.20

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

Merge branch 'sg/test-verbose-log'Junio C Hamano Tue, 6 Nov 2018 06:50:23 +0000 (15:50 +0900)

Merge branch 'sg/test-verbose-log'

Our test scripts can now take the '-V' option as a synonym for the
'--verbose-log' option.

* sg/test-verbose-log:
test-lib: introduce the '-V' short option for '--verbose-log'

Merge branch 'rj/header-cleanup'Junio C Hamano Tue, 6 Nov 2018 06:50:23 +0000 (15:50 +0900)

Merge branch 'rj/header-cleanup'

Code cleanup.

* rj/header-cleanup:
commit-reach.h: add missing declarations (hdr-check)
ewok_rlw.h: add missing 'inline' to function definition
fetch-object.h: add missing declaration (hdr-check)

Merge branch 'ss/travis-ci-force-vm-mode'Junio C Hamano Tue, 6 Nov 2018 06:50:23 +0000 (15:50 +0900)

Merge branch 'ss/travis-ci-force-vm-mode'

The "container" mode of TravisCI is going away. Our .travis.yml
file is getting prepared for the transition.

* ss/travis-ci-force-vm-mode:
travis-ci: no longer use containers

Merge branch 'sg/test-rebase-editor-fix'Junio C Hamano Tue, 6 Nov 2018 06:50:22 +0000 (15:50 +0900)

Merge branch 'sg/test-rebase-editor-fix'

* sg/test-rebase-editor-fix:
t3404-rebase-interactive: test abbreviated commands

Merge branch 'tb/char-may-be-unsigned'Junio C Hamano Tue, 6 Nov 2018 06:50:22 +0000 (15:50 +0900)

Merge branch 'tb/char-may-be-unsigned'

Build portability fix.

* tb/char-may-be-unsigned:
path.c: char is not (always) signed

Merge branch 'js/mingw-ns-filetime'Junio C Hamano Tue, 6 Nov 2018 06:50:21 +0000 (15:50 +0900)

Merge branch 'js/mingw-ns-filetime'

Windows port learned to use nano-second resolution file timestamps.

* js/mingw-ns-filetime:
mingw: implement nanosecond-precision file times
mingw: replace MSVCRT's fstat() with a Win32-based implementation
mingw: factor out code to set stat() data

Merge branch 'md/exclude-promisor-objects-fix'Junio C Hamano Tue, 6 Nov 2018 06:50:21 +0000 (15:50 +0900)

Merge branch 'md/exclude-promisor-objects-fix'

Operations on promisor objects make sense in the context of only a
small subset of the commands that internally use the revisions
machinery, but the "--exclude-promisor-objects" option were taken
and led to nonsense results by commands like "log", to which it
didn't make much sense. This has been corrected.

* md/exclude-promisor-objects-fix:
exclude-promisor-objects: declare when option is allowed
Documentation/git-log.txt: do not show --exclude-promisor-objects

Merge branch 'jw/send-email-no-auth'Junio C Hamano Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)

Merge branch 'jw/send-email-no-auth'

"git send-email" learned to disable SMTP authentication via the
"--smtp-auth=none" option, even when the smtp username is given
(which turns the authentication on by default).

* jw/send-email-no-auth:
send-email: explicitly disable authentication

Merge branch 'nd/submodule-unused-vars'Junio C Hamano Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)

Merge branch 'nd/submodule-unused-vars'

Code clean-up.

* nd/submodule-unused-vars:
submodule.c: remove some of the_repository references

Merge branch 'nd/unpack-trees-with-cache-tree'Junio C Hamano Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)

Merge branch 'nd/unpack-trees-with-cache-tree'

Trivial bugfix.

* nd/unpack-trees-with-cache-tree:
read-cache: use of memory after it is freed

Merge branch 'nd/completion-negation'Junio C Hamano Tue, 6 Nov 2018 06:50:19 +0000 (15:50 +0900)

Merge branch 'nd/completion-negation'

The command line completion machinery (in contrib/) has been
updated to allow the completion script to tweak the list of options
that are reported by the parse-options machinery correctly.

* nd/completion-negation:
completion: fix __gitcomp_builtin no longer consider extra options

Merge branch 'jt/upload-pack-v2-fix-shallow'Junio C Hamano Tue, 6 Nov 2018 06:50:19 +0000 (15:50 +0900)

Merge branch 'jt/upload-pack-v2-fix-shallow'

"git fetch" over protocol v2 into a shallow repository failed to
fetch full history behind a new tip of history that was diverged
before the cut-off point of the history that was previously fetched
shallowly.

* jt/upload-pack-v2-fix-shallow:
upload-pack: clear flags before each v2 request
upload-pack: make want_obj not global
upload-pack: make have_obj not global

Merge branch 'sb/submodule-url-to-absolute'Junio C Hamano Tue, 6 Nov 2018 06:50:19 +0000 (15:50 +0900)

Merge branch 'sb/submodule-url-to-absolute'

Some codepaths failed to form a proper URL when .gitmodules record
the URL to a submodule repository as relative to the repository of
superproject, which has been corrected.

* sb/submodule-url-to-absolute:
submodule helper: convert relative URL to absolute URL if needed

Merge branch 'js/shallow-and-fetch-prune'Junio C Hamano Tue, 6 Nov 2018 06:50:18 +0000 (15:50 +0900)

Merge branch 'js/shallow-and-fetch-prune'

"git repack" in a shallow clone did not correctly update the
shallow points in the repository, leading to a repository that
does not pass fsck.

* js/shallow-and-fetch-prune:
repack -ad: prune the list of shallow commits
shallow: offer to prune only non-existing entries
repack: point out a bug handling stale shallow info

Merge branch 'js/remote-archive-dwimfix'Junio C Hamano Tue, 6 Nov 2018 06:50:18 +0000 (15:50 +0900)

Merge branch 'js/remote-archive-dwimfix'

The logic to determine the archive type "git archive" uses did not
correctly kick in for "git archive --remote", which has been
corrected.

* js/remote-archive-dwimfix:
archive: initialize archivers earlier

completion: use __gitcomp_builtin for format-patchDuy Nguyen Sat, 3 Nov 2018 06:03:18 +0000 (07:03 +0100)

completion: use __gitcomp_builtin for format-patch

This helps format-patch gain completion for a couple new options,
notably --range-diff.

Since send-email completion relies on $__git_format_patch_options
which is now reduced, we need to do something not to regress
send-email completion.

The workaround here is implement --git-completion-helper in
send-email.perl just as a bridge to "format-patch --git-completion-helper".
This is enough to use __gitcomp_builtin on send-email (to take
advantage of caching).

In the end, send-email.perl can probably reuse the same info it passes
to GetOptions() to generate full --git-completion-helper output so
that we don't need to keep track of its options in git-completion.bash
anymore. But that's something for another boring day.

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

midx: double-check large object write loopJeff King Sun, 4 Nov 2018 02:27:46 +0000 (22:27 -0400)

midx: double-check large object write loop

The write_midx_large_offsets() function takes an array of object
entries, the number of entries in the array (nr_objects), and the number
of entries with large offsets (nr_large_offset). But we never actually
use nr_objects; instead we keep walking down the array and counting down
nr_large_offset until we've seen all of the large entries.

This is correct, but we can be a bit more defensive. If there were ever
a mismatch between nr_large_offset and the actual set of large-offset
objects, we'd walk off the end of the array.

Since we know the size of the array, we can use nr_objects to make sure
we don't walk too far.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

assert NOARG/NONEG behavior of parse-options callbacksJeff King Mon, 5 Nov 2018 06:45:42 +0000 (01:45 -0500)

assert NOARG/NONEG behavior of parse-options callbacks

When we define a parse-options callback, the flags we put in the option
struct must match what the callback expects. For example, a callback
which does not handle the "unset" parameter should only be used with
PARSE_OPT_NONEG. But since the callback and the option struct are not
defined next to each other, it's easy to get this wrong (as earlier
patches in this series show).

Fortunately, the compiler can help us here: compiling with
-Wunused-parameters can show us which callbacks ignore their "unset"
parameters (and likewise, ones that ignore "arg" expect to be triggered
with PARSE_OPT_NOARG).

But after we've inspected a callback and determined that all of its
callers use the right flags, what do we do next? We'd like to silence
the compiler warning, but do so in a way that will catch any wrong calls
in the future.

We can do that by actually checking those variables and asserting that
they match our expectations. Because this is such a common pattern,
we'll introduce some helper macros. The resulting messages aren't
as descriptive as we could make them, but the file/line information from
BUG() is enough to identify the problem (and anyway, the point is that
these should never be seen).

Each of the annotated callbacks in this patch triggers
-Wunused-parameters, and was manually inspected to make sure all callers
use the correct options (so none of these BUGs should be triggerable).

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

parse-options: drop OPT_DATE()Jeff King Mon, 5 Nov 2018 06:44:27 +0000 (01:44 -0500)

parse-options: drop OPT_DATE()

There are no users of OPT_DATE except for test-parse-options; its
only caller went away in 27ec394a97 (prune: introduce OPT_EXPIRY_DATE()
and use it, 2013-04-25).

It also has a bug: it does not specify PARSE_OPT_NONEG, but its callback
does not respect the "unset" flag, and will feed NULL to approxidate()
and segfault. Probably this should be marked with NONEG, or the callback
should set the timestamp to some sentinel value (e.g,. "0", or
"(time_t)-1").

But since there are no callers, deleting it means we don't even have to
think about what the right behavior should be.

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

apply: return -1 from option callback instead of callin... Jeff King Mon, 5 Nov 2018 06:43:59 +0000 (01:43 -0500)

apply: return -1 from option callback instead of calling exit(1)

The option callback for "apply --whitespace" exits with status "1" on
error. It makes more sense for it to just return an error to
parse-options. That code will exit, too, but it will use status "129"
that is customary for option errors.

The exit() dates back to aaf6c447aa (builtin/apply: make
parse_whitespace_option() return -1 instead of die()ing, 2016-08-08).
That commit gives no reason why we'd prefer the current exit status (it
looks like it was just bumping the "die" up a level in the callstack,
but did not go as far as it could have).

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

cat-file: report an error on multiple --batch optionsJeff King Mon, 5 Nov 2018 06:43:44 +0000 (01:43 -0500)

cat-file: report an error on multiple --batch options

The options callback for --batch and --batch-check detects when the two
mutually incompatible options are used. But it simply returns an error
code to parse-options, meaning the program will quit without any kind of
message to the user.

Instead, let's use error() to print something and return -1. Note that
this flips the error return from 1 to -1, but negative values are more
idiomatic here (and parse-options treats them the same).

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

tag: mark "--message" option with NONEGJeff King Mon, 5 Nov 2018 06:43:12 +0000 (01:43 -0500)

tag: mark "--message" option with NONEG

We do not allow "--no-message" to work now, as the option callback
returns "-1" when it sees a NULL arg. However, that will cause
parse-options to exit(129) without printing anything further, leaving
the user confused about what happened.

Instead, let's explicitly mark it as PARSE_OPT_NONEG, which will give a
useful error message (and print the usual -h output).

In theory this could be used to override an earlier "-m", but it's not
clear how it would interact with other message options (e.g., would it
also clear data read for "-F"?). Since it's already disabled and nobody
is asking for it, let's punt on that and just improve the error message.

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

show-branch: mark --reflog option as NONEGJeff King Mon, 5 Nov 2018 06:42:40 +0000 (01:42 -0500)

show-branch: mark --reflog option as NONEG

Running "git show-branch --no-reflog" will behave as if "--reflog" was
given with no options, which makes no sense.

In theory this option might be used to cancel an earlier "--reflog"
option, but the semantics are not clear. Let's punt on it and just
disallow the broken option.

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

format-patch: mark "--no-numbered" option with NONEGJeff King Mon, 5 Nov 2018 06:41:12 +0000 (01:41 -0500)

format-patch: mark "--no-numbered" option with NONEG

We have separate parse-options entries for "numbered" and "no-numbered",
which means that we accept "--no-no-numbered". It does not behave
sensibly, though (it ignores the "unset" flag and acts like
"--no-numbered").

We could fix that, but obviously this is silly and unintentional. Let's
just disallow it.

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

status: mark --find-renames option with NONEGJeff King Mon, 5 Nov 2018 06:40:53 +0000 (01:40 -0500)

status: mark --find-renames option with NONEG

If you run "git status --no-find-renames", it will behave the same as
"--find-renames", because we ignore the "unset" parameter (we see a NULL
"arg", but since the score argument is optional, we just think that the
user did not provide a score).

We already have a separate "--no-renames" to disable renames, so there's
not much point in supporting "--no-find-renames". Let's just flag it as
an error.

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

cat-file: mark batch options with NONEGJeff King Mon, 5 Nov 2018 06:40:10 +0000 (01:40 -0500)

cat-file: mark batch options with NONEG

Running "cat-file --no-batch" will behave as if "--batch" was given,
since the option callback does not handle the "unset" flag (likewise for
"--no-batch-check").

In theory this might be used to cancel an earlier --batch, but it's not
immediately obvious how that would interact with --batch-check. Let's
just disallow the negated form of both options.

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

pack-objects: mark index-version option as NONEGJeff King Mon, 5 Nov 2018 06:39:38 +0000 (01:39 -0500)

pack-objects: mark index-version option as NONEG

Running "git pack-objects --no-index-version" will segfault, since the
callback is not prepared to handle the "unset" flag.

In theory this might be used to counteract an earlier "--index-version",
or override a pack.indexversion config setting. But the semantics aren't
immediately obvious, and it's unlikely anybody wants this. Let's just
disable the broken option for now.

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

ls-files: mark exclude options as NONEGJeff King Mon, 5 Nov 2018 06:39:20 +0000 (01:39 -0500)

ls-files: mark exclude options as NONEG

Running "git ls-files --no-exclude" will currently segfault, as its
option callback does not handle the "unset" parameter.

In theory this could be used to clear the exclude list, but it is not
clear how that would interact with the other exclude options, nor is the
current code capable of clearing the list. Let's just disable the broken
option.

Note that --no-exclude-from will similarly segfault, but
--no-exclude-standard will not. It just silently does the wrong thing
(pretending as if --exclude-standard was specified).

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

am: handle --no-patch-format optionJeff King Mon, 5 Nov 2018 06:38:39 +0000 (01:38 -0500)

am: handle --no-patch-format option

Running "git am --no-patch-format" will currently segfault, since it
tries to parse a NULL argument. Instead, let's have it cancel any
previous --patch-format option.

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

apply: mark include/exclude options as NONEGJeff King Mon, 5 Nov 2018 06:38:19 +0000 (01:38 -0500)

apply: mark include/exclude options as NONEG

The options callback for "git apply --no-include" is not ready to handle
the "unset" parameter, and as a result will segfault when it adds a NULL
argument to the include list (likewise for "--no-exclude").

In theory this might be used to clear the list, but since both
"--include" and "--exclude" add to the same list, it's not immediately
obvious what the semantics should be. Let's punt on that for now and
just disallow the broken options.

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

refresh_index: remove unnecessary calls to preload_index()Ben Peart Mon, 5 Nov 2018 19:27:51 +0000 (14:27 -0500)

refresh_index: remove unnecessary calls to preload_index()

With refresh_index() learning to utilize preload_index() to speed up its
operation there is no longer any benefit to having the caller preload the
index first. Remove those unneeded calls by calling read_index() instead of
the preload variant.

There is no measurable performance impact of this patch - the 2nd call to
preload_index() bails out quickly but there is no reason to call it twice.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Clean up pthread_create() error handlingNguyễn Thái Ngọc Duy Sat, 3 Nov 2018 08:48:50 +0000 (09:48 +0100)

Clean up pthread_create() error handling

Normally pthread_create() rarely fails. But with new pthreads wrapper,
pthread_create() will return ENOSYS on a system without thread support.

Threaded code _is_ protected by HAVE_THREADS and pthread_create()
should never run in the first place. But the situation could change in
the future and bugs may sneak in. Make sure that all pthread_create()
reports the error cause.

While at there, mark these strings for translation if they aren't.

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