gitweb.git
Merge branch 'pw/unquote-path-in-git-pm'Junio C Hamano Mon, 10 Jul 2017 20:42:50 +0000 (13:42 -0700)

Merge branch 'pw/unquote-path-in-git-pm'

Code refactoring.

* pw/unquote-path-in-git-pm:
t9700: add tests for Git::unquote_path()
Git::unquote_path(): throw an exception on bad path
Git::unquote_path(): handle '\a'
add -i: move unquote_path() to Git.pm

Merge branch 'ks/commit-assuming-only-warning-removal'Junio C Hamano Mon, 10 Jul 2017 20:42:50 +0000 (13:42 -0700)

Merge branch 'ks/commit-assuming-only-warning-removal'

An old message shown in the commit log template was removed, as it
has outlived its usefulness.

* ks/commit-assuming-only-warning-removal:
commit-template: distinguish status information unconditionally
commit-template: remove outdated notice about explicit paths

ref-filter.c: drop return from void functionAlejandro R. Sedeño Mon, 10 Jul 2017 19:03:03 +0000 (15:03 -0400)

ref-filter.c: drop return from void function

Sun's C compiler errors out on this pattern:

void foo() { ... }
void bar() { return foo(); }

Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: de.po: fix typoRalf Thielow Mon, 10 Jul 2017 16:23:08 +0000 (18:23 +0200)

l10n: de.po: fix typo

Reported-by: Andre Hinrichs <andre.hinrichs@gmx.de>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: disable unaligned loads with UBSanJeff King Mon, 10 Jul 2017 13:24:50 +0000 (09:24 -0400)

Makefile: disable unaligned loads with UBSan

The undefined behavior sanitizer complains about unaligned
loads, even if they're OK for a particular platform in
practice. It's possible that they _are_ a problem, of
course, but since it's a known tradeoff the UBSan errors are
just noise.

Let's quiet it automatically by building with
NO_UNALIGNED_LOADS when SANITIZE=undefined is in use.

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

Makefile: turn off -fomit-frame-pointer with sanitizersJeff King Mon, 10 Jul 2017 13:24:47 +0000 (09:24 -0400)

Makefile: turn off -fomit-frame-pointer with sanitizers

The ASan manual recommends disabling this optimization, as
it can make the backtraces produced by the tool harder to
follow (and since this is a test-debug build, we don't care
about squeezing out every last drop of performance).

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

Makefile: add helper for compiling with -fsanitizeJeff King Mon, 10 Jul 2017 13:24:42 +0000 (09:24 -0400)

Makefile: add helper for compiling with -fsanitize

You can already build and test with ASan by doing:

make CFLAGS=-fsanitize=address test

but there are a few slight annoyances:

1. It's a little long to type.

2. It override your CFLAGS completely. You'd probably
still want -O2, for instance.

3. It's a good idea to also turn off "recovery", which
lets the program keep running after a problem is
detected (with the intention of finding as many bugs as
possible in a given run). Since Git's test suite should
generally run without triggering any problems, it's
better to abort immediately and fail the test when we
do find an issue.

With this patch, all of that happens automatically when you
run:

make SANITIZE=address test

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

test-lib: turn on ASan abort_on_error by defaultJeff King Mon, 10 Jul 2017 13:24:39 +0000 (09:24 -0400)

test-lib: turn on ASan abort_on_error by default

By default, ASan will exit with code 1 when it sees an
error. This means we'll notice a problem when we expected
git to succeed, but not in a test_must_fail block.

Let's ask it to actually raise SIGABRT instead. That will
give us a signal death that test_must_fail will notice. As a
bonus, it may also leave a coredump, which can be handy for
digging into a failure.

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

test-lib: set ASAN_OPTIONS variable before we run gitJeff King Mon, 10 Jul 2017 13:24:35 +0000 (09:24 -0400)

test-lib: set ASAN_OPTIONS variable before we run git

We turn off ASan's leak detection by default in the test
suite because it's too noisy. But we don't do so until
part-way through test-lib. This is before we've run any
tests, but after we do our initial "./git" to see if the
binary has even been built.

When built with clang, this seems to work fine. However,
using "gcc -fsanitize=address", the leak checker seems to
complain more aggressively:

$ ./git
...
==5352==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 2 byte(s) in 1 object(s) allocated from:
#0 0x7f120e7afcf8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1cf8)
#1 0x559fc2a3ce41 in do_xmalloc /home/peff/compile/git/wrapper.c:60
#2 0x559fc2a3cf1a in do_xmallocz /home/peff/compile/git/wrapper.c:100
#3 0x559fc2a3d0ad in xmallocz /home/peff/compile/git/wrapper.c:108
#4 0x559fc2a3d0ad in xmemdupz /home/peff/compile/git/wrapper.c:124
#5 0x559fc2a3d0ad in xstrndup /home/peff/compile/git/wrapper.c:130
#6 0x559fc274535a in main /home/peff/compile/git/common-main.c:39
#7 0x7f120dabd2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

This is a leak in the sense that we never free it, but it's
in a global that is meant to last the whole program. So it's
not really interesting or in need of fixing. And at any
rate, mentioning leaks outside of the test_expect blocks is
certainly unwelcome, as it pollutes stderr.

Let's bump the setting of ASAN_OPTIONS higher in test-lib.sh
to catch our initial "can we even run git?" test. While
we're at it, we can add a comment to make it a bit less
inscrutable.

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

doc: correct a mistake in an illustrationKaartic Sivaraam Mon, 10 Jul 2017 14:18:30 +0000 (19:48 +0530)

doc: correct a mistake in an illustration

The first illustration of the "RECOVERING FROM UPSTREAM REBASE"
section in the 'git-rebase' documentation meant to depict that
there are number of commits on the 'master' branch, but it is
longer than the 'master' branch in the following illustrations
by one commit, even though there is no resetting of 'master' to
lose that commit.

Correct it.

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wt-status: use separate variable for result of shorten_... René Scharfe Sat, 8 Jul 2017 10:51:01 +0000 (12:51 +0200)

wt-status: use separate variable for result of shorten_unambiguous_ref

Store the pointer to the string allocated by shorten_unambiguous_ref in
a dedicated variable, short_base, and keep base unchanged. A non-const
variable is more appropriate for such an object. It avoids having to
cast const away on free and stops redefining the meaning of base, making
the code slightly clearer.

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

progress: show overall rate in last updateRené Scharfe Sat, 8 Jul 2017 16:43:42 +0000 (18:43 +0200)

progress: show overall rate in last update

The values in struct throughput are only updated every 0.5 seconds. If
we're all done before that time span then the final update will show a
rate of 0 bytes/s, which is misleading if some bytes had been handled.
Remember the start time and show the total throughput instead.

And avoid division by zero by enforcing a minimum time span value of 1
(unit: 1/1024th of a second). That makes the resulting rate an
underestimation, but it's closer to the actual value than the currently
shown 0 bytes/s.

Reported-by: 積丹尼 Dan Jacobson <jidanni@jidanni.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

urlmatch: use hex2chr() in append_normalized_escapes()René Scharfe Sat, 8 Jul 2017 08:59:19 +0000 (10:59 +0200)

urlmatch: use hex2chr() in append_normalized_escapes()

Simplify the code by using hex2chr() to convert and check for invalid
characters at the same time instead of doing that sequentially with
one table lookup for each.

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

apply: use strcmp(3) for comparing strings in gitdiff_v... René Scharfe Sat, 8 Jul 2017 08:58:42 +0000 (10:58 +0200)

apply: use strcmp(3) for comparing strings in gitdiff_verify_name()

We don't know the length of the C string "another". It could be
shorter than "name", which we compare it to using memchr(3). Call
strcmp(3) instead to avoid running over the end of the former, and
get rid of a strlen(3) call as a bonus.

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

branch: set remote color in ref-filter branch immediatelyJeff King Sun, 9 Jul 2017 10:00:45 +0000 (06:00 -0400)

branch: set remote color in ref-filter branch immediately

We set the current and local branch colors at the top of the
build_format() function. Let's do the same for the remote
color. This saves a little bit of repetition, but more
importantly it puts all of the color-setting in the same
place. That makes it easier to see that we are coloring all
possibilities.

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

branch: use BRANCH_COLOR_LOCAL in ref-filter formatJeff King Sun, 9 Jul 2017 09:59:33 +0000 (05:59 -0400)

branch: use BRANCH_COLOR_LOCAL in ref-filter format

Since 949af0684 (branch: use ref-filter printing APIs,
2017-01-10), git-branch's output is generated by passing a
custom format to the ref-filter code. This format forgot to
pass BRANCH_COLOR_LOCAL, meaning that local branches
(besides the current one) were never colored at all.

We can add it in the %(if) block where we decide whether the
branch is "current" or merely "local". Note that this means
the current/local coloring is either/or. You can't set:

[color "branch"]
local = blue
current = bold

and expect the current branch to be "bold blue". This
matches the pre-949af0684 behavior.

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

branch: only perform HEAD check for local branchesJeff King Sun, 9 Jul 2017 09:58:10 +0000 (05:58 -0400)

branch: only perform HEAD check for local branches

When assembling the ref-filter format to show "git branch"
output, we put the "%(if)%(HEAD)" conditional at the start
of the overall format. But there's no point in checking
whether a remote branch matches HEAD, as it never will.
The check should go inside the local conditional; we
assemble that format inside the "local" strbuf.

By itself, this is just a minor optimization. But in a
future patch, we'll need this refactoring to fix
local-branch coloring.

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

unicode: update the width tables to Unicode 10Beat Bolli Fri, 7 Jul 2017 12:08:44 +0000 (14:08 +0200)

unicode: update the width tables to Unicode 10

Now that Unicode 10 has been announced[0], update the character
width tables to the new version.

[0] http://blog.unicode.org/2017/06/announcing-unicode-standard-version-100.html

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

reflog-walk: include all fields when freeing complete_r... Jeff King Fri, 7 Jul 2017 08:43:16 +0000 (04:43 -0400)

reflog-walk: include all fields when freeing complete_reflogs

When we encounter an error adding reflogs for a walk, we try
to free any logs we have read. But we didn't free all
fields, meaning that we could in theory leak all of the
"items" array (which would consitute the bulk of the
allocated memory).

This patch adds a helper which frees all of the entries and
uses it as appropriate.

As it turns out, the leak seems impossible to trigger with
the current code. Of the three error paths that free the
complete_reflogs struct, two only kick in when the items
array is empty, and the third was removed entirely in the
previous commit.

So this patch should be a noop in terms of behavior, but it
fixes a potential maintenance headache should anybody add a
new error path and copy the partial-free code. Which is
what happened in 5026b47175 (add_reflog_for_walk: avoid
memory leak, 2017-05-04), though its leaky call was the
third one that was recently removed.

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

reflog-walk: don't free reflogs added to cacheJeff King Fri, 7 Jul 2017 08:41:49 +0000 (04:41 -0400)

reflog-walk: don't free reflogs added to cache

The add_reflog_for_walk() function keeps a cache mapping
refnames to their reflog contents. We use a cached reflog
entry if available, and otherwise allocate and store a new
one.

Since 5026b47175 (add_reflog_for_walk: avoid memory leak,
2017-05-04), when we hit an error parsing a date-based
reflog spec, we free the reflog memory but leave the cache
entry pointing to the now-freed memory.

We can fix this by just leaving the memory intact once it
has made it into the cache. This may leave an unused entry
in the cache, but that's OK. And it means we also catch a
similar situation: we may not have allocated at all in this
invocation, but simply be pointing to a cached entry from a
previous invocation (which is relying on that entry being
present).

The new test in t1411 exercises this case and fails when run
with --valgrind or ASan.

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

reflog-walk: duplicate strings in complete_reflogs... Jeff King Fri, 7 Jul 2017 08:39:50 +0000 (04:39 -0400)

reflog-walk: duplicate strings in complete_reflogs list

As part of the add_reflog_to_walk() function, we keep a
string_list mapping refnames to their reflog contents. This
serves as a cache so that accessing the same reflog twice
requires only a single copy of the log in memory.

The string_list is initialized via xcalloc, meaning its
strdup_strings field is set to 0. But after inserting a
string into the list, we unconditionally call free() on the
string, leaving the list pointing to freed memory. If
another reflog is added (e.g., "git log -g HEAD HEAD"), then
the second one may have unpredictable results.

The extra free was added by 5026b47175 (add_reflog_for_walk:
avoid memory leak, 2017-05-04). Though if you look
carefully, you can see that the code was buggy even before
then. If we tried to read the reflogs by time but came up
with no entries, we exited with an error, freeing the string
in that code path. So the bug was harder to trigger, but
still there.

We can fix it by just asking the string list to make a copy
of the string. Technically we could fix the problem by not
calling free() on our string (and just handing over
ownership to the string list), but there are enough
conditionals that it's quite hard to figure out which code
paths need the free and which do not. Simpler is better
here.

The new test reliably shows the problem when run with
--valgrind or ASAN.

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

Fifteenth batch for 2.14Junio C Hamano Fri, 7 Jul 2017 01:26:13 +0000 (18:26 -0700)

Fifteenth batch for 2.14

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

Merge branch 'ab/strbuf-addftime-tzname-boolify'Junio C Hamano Fri, 7 Jul 2017 01:14:47 +0000 (18:14 -0700)

Merge branch 'ab/strbuf-addftime-tzname-boolify'

strbuf_addftime() is further getting tweaked.

* ab/strbuf-addftime-tzname-boolify:
strbuf: change an always NULL/"" strbuf_addftime() param to bool
strbuf.h comment: discuss strbuf_addftime() arguments in order

Merge branch 'xz/send-email-batch-size'Junio C Hamano Fri, 7 Jul 2017 01:14:46 +0000 (18:14 -0700)

Merge branch 'xz/send-email-batch-size'

"git send-email" learned to overcome some SMTP server limitation
that does not allow many pieces of e-mails to be sent over a single
session.

* xz/send-email-batch-size:
send-email: --batch-size to work around some SMTP server limit

Merge branch 'js/t5534-rev-parse-gives-multi-line-outpu... Junio C Hamano Fri, 7 Jul 2017 01:14:46 +0000 (18:14 -0700)

Merge branch 'js/t5534-rev-parse-gives-multi-line-output-fix'

A few tests that tried to verify the contents of push certificates
did not use 'git rev-parse' to formulate the line to look for in
the certificate correctly.

* js/t5534-rev-parse-gives-multi-line-output-fix:
t5534: fix misleading grep invocation

Merge branch 'sb/merge-recursive-code-cleanup'Junio C Hamano Fri, 7 Jul 2017 01:14:45 +0000 (18:14 -0700)

Merge branch 'sb/merge-recursive-code-cleanup'

Code clean-up.

* sb/merge-recursive-code-cleanup:
merge-recursive: use DIFF_XDL_SET macro

Merge branch 'rs/apply-avoid-over-reading'Junio C Hamano Fri, 7 Jul 2017 01:14:45 +0000 (18:14 -0700)

Merge branch 'rs/apply-avoid-over-reading'

Code clean-up to fix possible buffer over-reading.

* rs/apply-avoid-over-reading:
apply: use starts_with() in gitdiff_verify_name()

Merge branch 'ab/sha1dc-maint'Junio C Hamano Fri, 7 Jul 2017 01:14:44 +0000 (18:14 -0700)

Merge branch 'ab/sha1dc-maint'

Update the sha1dc again to fix portability glitches.

* ab/sha1dc-maint:
sha1dc: update from upstream

Merge branch 'jc/utf8-fprintf'Junio C Hamano Fri, 7 Jul 2017 01:14:44 +0000 (18:14 -0700)

Merge branch 'jc/utf8-fprintf'

Code cleanup.

* jc/utf8-fprintf:
submodule--helper: do not call utf8_fprintf() unnecessarily

Merge branch 'js/fsck-name-object'Junio C Hamano Fri, 7 Jul 2017 01:14:43 +0000 (18:14 -0700)

Merge branch 'js/fsck-name-object'

Test fix.

* js/fsck-name-object:
t1450: use egrep for regexp "alternation"

Merge branch 'aw/contrib-subtree-doc-asciidoctor'Junio C Hamano Fri, 7 Jul 2017 01:14:42 +0000 (18:14 -0700)

Merge branch 'aw/contrib-subtree-doc-asciidoctor'

The Makefile rule in contrib/subtree for building documentation
learned to honour USE_ASCIIDOCTOR just like the main documentation
set does.

* aw/contrib-subtree-doc-asciidoctor:
subtree: honour USE_ASCIIDOCTOR when set

builtin/commit.c: fix a typo in the commentKaartic Sivaraam Thu, 6 Jul 2017 03:19:57 +0000 (08:49 +0530)

builtin/commit.c: fix a typo in the comment

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cygwin: allow pushing to UNC pathsTorsten Bögershausen Mon, 3 Jul 2017 14:41:37 +0000 (16:41 +0200)

cygwin: allow pushing to UNC paths

cygwin can use an UNC path like //server/share/repo

$ cd //server/share/dir
$ mkdir test
$ cd test
$ git init --bare

However, when we try to push from a local Git repository to this repo,
there is a problem: Git converts the leading "//" into a single "/".

As cygwin handles an UNC path so well, Git can support them better:

- Introduce cygwin_offset_1st_component() which keeps the leading "//",
similar to what Git for Windows does.

- Move CYGWIN out of the POSIX in the tests for path normalization in t0060

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

Fourteenth batch for 2.14Junio C Hamano Wed, 5 Jul 2017 20:33:51 +0000 (13:33 -0700)

Fourteenth batch for 2.14

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

Merge branch 'jt/unify-object-info'Junio C Hamano Wed, 5 Jul 2017 20:32:57 +0000 (13:32 -0700)

Merge branch 'jt/unify-object-info'

Code clean-ups.

* jt/unify-object-info:
sha1_file: refactor has_sha1_file_with_flags
sha1_file: do not access pack if unneeded
sha1_file: teach sha1_object_info_extended more flags
sha1_file: refactor read_object
sha1_file: move delta base cache code up
sha1_file: rename LOOKUP_REPLACE_OBJECT
sha1_file: rename LOOKUP_UNKNOWN_OBJECT
sha1_file: teach packed_object_info about typename

Merge branch 'cc/shared-index-permfix'Junio C Hamano Wed, 5 Jul 2017 20:32:57 +0000 (13:32 -0700)

Merge branch 'cc/shared-index-permfix'

The split index code did not honor core.sharedrepository setting
correctly.

* cc/shared-index-permfix:
t1700: make sure split-index respects core.sharedrepository
t1301: move modebits() to test-lib-functions.sh
read-cache: use shared perms when writing shared index

Merge branch 'rs/sha1-name-readdir-optim'Junio C Hamano Wed, 5 Jul 2017 20:32:56 +0000 (13:32 -0700)

Merge branch 'rs/sha1-name-readdir-optim'

Optimize "what are the object names already taken in an alternate
object database?" query that is used to derive the length of prefix
an object name is uniquely abbreviated to.

* rs/sha1-name-readdir-optim:
sha1_file: guard against invalid loose subdirectory numbers
sha1_file: let for_each_file_in_obj_subdir() handle subdir names
p4205: add perf test script for pretty log formats
sha1_name: cache readdir(3) results in find_short_object_filename()

Merge branch 'bw/repo-object'Junio C Hamano Wed, 5 Jul 2017 20:32:55 +0000 (13:32 -0700)

Merge branch 'bw/repo-object'

Introduce a "repository" object to eventually make it easier to
work in multiple repositories (the primary focus is to work with
the superproject and its submodules) in a single process.

* bw/repo-object:
ls-files: use repository object
repository: enable initialization of submodules
submodule: convert is_submodule_initialized to work on a repository
submodule: add repo_read_gitmodules
submodule-config: store the_submodule_cache in the_repository
repository: add index_state to struct repo
config: read config from a repository object
path: add repo_worktree_path and strbuf_repo_worktree_path
path: add repo_git_path and strbuf_repo_git_path
path: worktree_git_path() should not use file relocation
path: convert do_git_path to take a 'struct repository'
path: convert strbuf_git_common_path to take a 'struct repository'
path: always pass in commondir to update_common_dir
path: create path.h
environment: store worktree in the_repository
environment: place key repository state in the_repository
repository: introduce the repository object
environment: remove namespace_len variable
setup: add comment indicating a hack
setup: don't perform lazy initialization of repository state

reflog-walk: skip over double-null oid due to HEAD... Jeff King Wed, 5 Jul 2017 07:57:37 +0000 (03:57 -0400)

reflog-walk: skip over double-null oid due to HEAD rename

Since 39ee4c6c2f (branch: record creation of renamed branch
in HEAD's log, 2017-02-20), a rename on the currently
checked out branch will create two entries in the HEAD
reflog: one where the branch goes away (switching to the
null oid), and one where it comes back (switching away from
the null oid).

This confuses the reflog-walk code. When walking backwards,
it first sees the null oid in the "old" field of the second
entry. Thanks to the "root commit" logic added by 71abeb753f
(reflog: continue walking the reflog past root commits,
2016-06-03), we keep looking for the next entry by scanning
the "new" field from the previous entry. But that field is
also null! We need to go just a tiny bit further, and look
at its "old" field. But with the current code, we decide the
reflog has nothing else to show and just give up. To the
user this looks like the reflog was truncated by the rename
operation, when in fact those entries are still there.

This patch does the absolute minimal fix, which is to look
back that one extra level and keep traversing.

The resulting behavior may not be the _best_ thing to do in
the long run (for example, we show both reflog entries each
with the same commit id), but it's a simple way to fix the
problem without risking further regressions.

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

t5534: fix misleading grep invocationJohannes Schindelin Wed, 5 Jul 2017 11:37:49 +0000 (13:37 +0200)

t5534: fix misleading grep invocation

It seems to be a little-known feature of `grep` (and it certainly came
as a surprise to this here developer who believed to know the Unix tools
pretty well) that multiple patterns can be passed in the same
command-line argument simply by separating them by newlines. Watch, and
learn:

$ printf '1\n2\n3\n' | grep "$(printf '1\n3\n')"
1
3

That behavior also extends to patterns passed via `-e`, and it is not
modified by passing the option `-E` (but trying this with -P issues the
error "grep: the -P option only supports a single pattern").

It seems that there are more old Unix hands who are surprised by this
behavior, as grep invocations of the form

grep "$(git rev-parse A B) C" file

were introduced in a85b377d041 (push: the beginning of "git push
--signed", 2014-09-12), and later faithfully copy-edited in b9459019bbb
(push: heed user.signingkey for signed pushes, 2014-10-22).

Please note that the output of `git rev-parse A B` separates the object
IDs via *newlines*, not via spaces, and those newlines are preserved
because the interpolation is enclosed in double quotes.

As a consequence, these tests try to validate that the file contains
either A's object ID, or B's object ID followed by C, or both. Clearly,
however, what the test wanted to see is that there is a line that
contains all of them.

This is clearly unintended, and the grep invocations in question really
match too many lines.

Fix the test by avoiding the newlines in the patterns.

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

send-email: --batch-size to work around some SMTP serve... xiaoqiang zhao Sun, 21 May 2017 12:59:50 +0000 (20:59 +0800)

send-email: --batch-size to work around some SMTP server limit

Some email servers (e.g. smtp.163.com) limit the number emails to be
sent per session (connection) and this will lead to a faliure when
sending many messages.

Teach send-email to disconnect after sending a number of messages
(configurable via the --batch-size=<num> option), wait for a few
seconds (configurable via the --relogin-delay=<seconds> option) and
reconnect, to work around such a limit.

Also add two configuration variables to give these options the default.

Note:

We will use this as a band-aid for now, but in the longer term, we
should look at and react to the SMTP error code from the server;
Xianqiang reports that 450 and 451 are returned by problematic
servers.

cf. https://public-inbox.org/git/7993e188.d18d.15c3560bcaf.Coremail.zxq_yx_007@163.com/

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1collisiondetection: automatically enable when submo... Junio C Hamano Sat, 1 Jul 2017 22:05:47 +0000 (22:05 +0000)

sha1collisiondetection: automatically enable when submodule is populated

If a user wants to experiment with the version of collision
detecting sha1 from the submodule, the user needed to not just
populate the submodule but also needed to turn the knob.

A Makefile trick is easy enough to do so, so let's do this. When
somebody with a copy of the submodule populated wants not to use it,
that can be done by overriding it in config.mak or from the command
line.

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>

sha1dc: optionally use sha1collisiondetection as a... Ævar Arnfjörð Bjarmason Sat, 1 Jul 2017 22:05:46 +0000 (22:05 +0000)

sha1dc: optionally use sha1collisiondetection as a submodule

Add an option to use the sha1collisiondetection library from the
submodule in sha1collisiondetection/ instead of in the copy in the
sha1dc/ directory.

This allows us to try out the submodule in sha1collisiondetection
without breaking the build for anyone who's not expecting them as we
work out any kinks.

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

sha1dc: update from upstreamÆvar Arnfjörð Bjarmason Sat, 1 Jul 2017 22:05:45 +0000 (22:05 +0000)

sha1dc: update from upstream

Update sha1dc from the latest version by the upstream maintainer[1].

See commit 6b851e536b ("sha1dc: update from upstream", 2017-06-06) for
the last update.

This solves the Big Endian detection on Solaris reported against
v2.13.2[2], hopefully without any regressions. A version of this has
been tested on two Solaris SPARC installations, Cygwin (by jturney on
cygwin@Freenode), and on numerous more boring systems (mainly
linux/x86_64). See [3] for a discussion of the implementation and
platform-specific issues.

See commit a0103914c2 ("sha1dc: update from upstream", 2017-05-20) and
6b851e536b ("sha1dc: update from upstream", 2017-06-06) for previous
attempts in the 2.13 series to address various compile-time feature
detection in this library.

1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/19d97bf5af05312267c2e874ee6bcf584d9e9681
2. <CAKKM46tHq13XiW5C8sux3=PZ1VHSu_npG8ExfWwcPD7rkZkyRQ@mail.gmail.com>
(https://public-inbox.org/git/CAKKM46tHq13XiW5C8sux3=PZ1VHSu_npG8ExfWwcPD7rkZkyRQ@mail.gmail.com/)
3. https://github.com/cr-marcstevens/sha1collisiondetection/pull/34

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

strbuf: change an always NULL/"" strbuf_addftime()... Ævar Arnfjörð Bjarmason Sat, 1 Jul 2017 13:15:47 +0000 (13:15 +0000)

strbuf: change an always NULL/"" strbuf_addftime() param to bool

strbuf_addftime() allows callers to pass a time zone name for
expanding %Z. The only current caller either passes the empty string
or NULL, in which case %Z is handed over verbatim to strftime(3).
Replace that string parameter with a flag controlling whether to
remove %Z from the format specification. This simplifies the code.

Commit-message-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

apply: use starts_with() in gitdiff_verify_name()René Scharfe Sat, 1 Jul 2017 09:10:07 +0000 (11:10 +0200)

apply: use starts_with() in gitdiff_verify_name()

Avoid running over the end of line -- a C string whose length is not
known to this function -- by using starts_with() instead of memcmp(3)
for checking if it starts with "/dev/null". Also simply include the
newline in the string constant to compare against. Drop a comment that
just states the obvious.

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

Thirteenth batch for 2.14Junio C Hamano Fri, 30 Jun 2017 20:47:49 +0000 (13:47 -0700)

Thirteenth batch for 2.14

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

Merge branch 'vs/typofixes'Junio C Hamano Fri, 30 Jun 2017 20:45:25 +0000 (13:45 -0700)

Merge branch 'vs/typofixes'

Many typofixes.

* vs/typofixes:
Spelling fixes

Merge branch 'rs/apply-validate-input'Junio C Hamano Fri, 30 Jun 2017 20:45:24 +0000 (13:45 -0700)

Merge branch 'rs/apply-validate-input'

Tighten error checks for invalid "git apply" input.

* rs/apply-validate-input:
apply: check git diffs for mutually exclusive header lines
apply: check git diffs for invalid file modes
apply: check git diffs for missing old filenames

Merge branch 'jc/pack-bitmap-unaligned'Junio C Hamano Fri, 30 Jun 2017 20:45:24 +0000 (13:45 -0700)

Merge branch 'jc/pack-bitmap-unaligned'

An unaligned 32-bit access in pack-bitmap code ahs been corrected.

* jc/pack-bitmap-unaligned:
pack-bitmap: don't perform unaligned memory access

Merge branch 'ah/doc-pretty-color-auto-prefix'Junio C Hamano Fri, 30 Jun 2017 20:45:23 +0000 (13:45 -0700)

Merge branch 'ah/doc-pretty-color-auto-prefix'

Doc update.

* ah/doc-pretty-color-auto-prefix:
doc: clarify syntax for %C(auto,...) in pretty formats

Merge branch 'ks/submodule-add-doc'Junio C Hamano Fri, 30 Jun 2017 20:45:22 +0000 (13:45 -0700)

Merge branch 'ks/submodule-add-doc'

Doc update.

* ks/submodule-add-doc:
Documentation/git-submodule: cleanup "add" section

Merge branch 'ks/status-initial-commit'Junio C Hamano Fri, 30 Jun 2017 20:45:22 +0000 (13:45 -0700)

Merge branch 'ks/status-initial-commit'

"git status" has long shown essentially the same message as "git
commit"; the message it gives while preparing for the root commit,
i.e. "Initial commit", was hard to understand for some new users.
Now it says "No commits yet" to stress more on the current status
(rather than the commit the user is preparing for, which is more in
line with the focus of "git commit").

* ks/status-initial-commit:
status: contextually notify user about an initial commit

Merge branch 'ab/die-errors-in-threaded'Junio C Hamano Fri, 30 Jun 2017 20:45:21 +0000 (13:45 -0700)

Merge branch 'ab/die-errors-in-threaded'

Traditionally, the default die() routine had a code to prevent it
from getting called multiple times, which interacted badly when a
threaded program used it (one downside is that the real error may
be hidden and instead the only error message given to the user may
end up being "die recursion detected", which is not very useful).

* ab/die-errors-in-threaded:
die(): stop hiding errors due to overzealous recursion guard

Merge branch 'pw/rebase-i-regression-fix-tests'Junio C Hamano Fri, 30 Jun 2017 20:45:21 +0000 (13:45 -0700)

Merge branch 'pw/rebase-i-regression-fix-tests'

Fix a recent regression to "git rebase -i" and add tests that would
have caught it and others.

* pw/rebase-i-regression-fix-tests:
t3420: fix under GETTEXT_POISON build
rebase: add more regression tests for console output
rebase: add regression tests for console output
rebase -i: add test for reflog message
sequencer: print autostash messages to stderr

hashmap: migrate documentation from Documentation/techn... Stefan Beller Fri, 30 Jun 2017 19:14:07 +0000 (12:14 -0700)

hashmap: migrate documentation from Documentation/technical into header

While at it, clarify the use of `key`, `keydata`, `entry_or_key` as well
as documenting the new data pointer for the compare function.

Rework the example.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

patch-ids.c: use hashmap correctlyStefan Beller Fri, 30 Jun 2017 19:14:06 +0000 (12:14 -0700)

patch-ids.c: use hashmap correctly

As alluded to in the previous patch, the code in patch-ids.c is
using the hashmaps API wrong.

Luckily we do not have a bug, as all hashmap functionality that we use
here (hashmap_get) passes through the keydata. If hashmap_get_next were
to be used, a bug would occur as that passes NULL for the key_data.

So instead use the hashmap API correctly and provide the caller required
data in the compare function via the first argument that always gets
passed and was setup via the hashmap_init function.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

hashmap.h: compare function has access to a data fieldStefan Beller Fri, 30 Jun 2017 19:14:05 +0000 (12:14 -0700)

hashmap.h: compare function has access to a data field

When using the hashmap a common need is to have access to caller provided
data in the compare function. A couple of times we abuse the keydata field
to pass in the data needed. This happens for example in patch-ids.c.

This patch changes the function signature of the compare function
to have one more void pointer available. The pointer given for each
invocation of the compare function must be defined in the init function
of the hashmap and is just passed through.

Documentation of this new feature is deferred to a later patch.
This is a rather mechanical conversion, just adding the new pass-through
parameter. However while at it improve the naming of the fields of all
compare functions used by hashmaps by ensuring unused parameters are
prefixed with 'unused_' and naming the parameters what they are (instead
of 'unused' make it 'unused_keydata').

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: use DIFF_XDL_SET macroStefan Beller Thu, 29 Jun 2017 22:19:32 +0000 (15:19 -0700)

merge-recursive: use DIFF_XDL_SET macro

Instead of implementing this on our own, just use a convenience macro.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep: remove redundant REG_NEWLINE when compiling fixed... Ævar Arnfjörð Bjarmason Thu, 29 Jun 2017 22:22:22 +0000 (22:22 +0000)

grep: remove redundant REG_NEWLINE when compiling fixed regex

Remove the redundant REG_NEWLINE regcomp() flag from the code that
compiles a fixed-string regular-expression.

The REG_NEWLINE causes metacharacters such as "." to match a newline,
since the basic_regex_quote_buf() function being called here escapes
all metacharacters using REG_NEWLINE is confusing and redundant.

The use of this flag was introduced as an unintended emergent property
of 793dc676e0 ("grep/icase: avoid kwsset when -F is specified",
2016-06-25).

That change amended the existing regflags, which were initialized to
REG_NEWLINE in init_grep_defaults() assuming a subsequent non-fixed
regcomp().

Manual testing reveals that this was always redundant, since no flags
of any use were inherited from opt->regflags even back
then. 793dc676e0 passes all tests with this on top:

diff --git a/grep.c b/grep.c
index 627ae3e3e8..89e84ed7fd 100644
--- a/grep.c
+++ b/grep.c
@@ -407,3 +407,3 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)
basic_regex_quote_buf(&sb, p->pattern);
- regflags = opt->regflags & ~REG_EXTENDED;
+ regflags = 0;
if (opt->ignore_case)

Since this isn't used for anything and never was, remove it to reduce
confusion when reading this code.

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

grep: remove regflags from the public grep_opt APIÆvar Arnfjörð Bjarmason Thu, 29 Jun 2017 22:22:21 +0000 (22:22 +0000)

grep: remove regflags from the public grep_opt API

Refactor calls to the grep machinery to always pass opt.ignore_case &
opt.extended_regexp_option instead of setting the equivalent regflags
bits.

The bug fixed when making -i work with -P in commit 9e3cbc59d5 ("log:
make --regexp-ignore-case work with --perl-regexp", 2017-05-20) was
really just plastering over the code smell which this change fixes.

The reason for adding the extensive commentary here is that I
discovered some subtle complexity in implementing this that really
should be called out explicitly to future readers.

Before this change we'd rely on the difference between
`extended_regexp_option` and `regflags` to serve as a membrane between
our preliminary parsing of grep.extendedRegexp and grep.patternType,
and what we decided to do internally.

Now that those two are the same thing, it's necessary to unset
`extended_regexp_option` just before we commit in cases where both of
those config variables are set. See 84befcd0a4 ("grep: add a
grep.patternType configuration setting", 2012-08-03) for the code and
documentation related to that.

The explanation of why the if/else branches in
grep_commit_pattern_type() are ordered the way they are exists in that
commit message, but I think it's worth calling this subtlety out
explicitly with a comment for future readers.

Even though grep_commit_pattern_type() is the only caller of
grep_set_pattern_type_option() it's simpler to reset the
extended_regexp_option flag in the latter, since 2/3 branches in the
former would otherwise need to reset it, this way we can do it in one
place.

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

grep: remove redundant and verbose re-assignments to 0Ævar Arnfjörð Bjarmason Thu, 29 Jun 2017 22:22:20 +0000 (22:22 +0000)

grep: remove redundant and verbose re-assignments to 0

Remove the redundant re-assignments of the fixed/pcre1/pcre2 fields to
zero right after the entire struct has been set to zero via
memset(...).

See an earlier related cleanup commit e0b9f8ae09 ("grep: remove
redundant regflags assignments", 2017-05-25) for an explanation of why
the code was structured like this to begin with.

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

grep: remove redundant "fixed" field re-assignment... Ævar Arnfjörð Bjarmason Thu, 29 Jun 2017 22:22:19 +0000 (22:22 +0000)

grep: remove redundant "fixed" field re-assignment to 0

Remove the redundant re-assignment of the fixed field to zero right
after the entire struct has been set to zero via memset(...).

Unlike some nearby commits this pattern doesn't date back to the
pattern described in e0b9f8ae09 ("grep: remove redundant regflags
assignments", 2017-05-25), instead it was apparently cargo-culted in
9eceddeec6 ("Use kwset in grep", 2011-08-21).

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

grep: adjust a redundant grep pattern type assignmentÆvar Arnfjörð Bjarmason Thu, 29 Jun 2017 22:22:18 +0000 (22:22 +0000)

grep: adjust a redundant grep pattern type assignment

Adjust a now-redundant assignment to extended_regexp_option to make it
zero if grep.extendedRegexp is not set. This is always called right
after init_grep_defaults() which memsets the entire structure to 0, so
there's no need to set it again to zero.

However the reason for the if/else pattern is a holdover from[1] where
this was adjusted from a bitfield assignment to a boolean. Rather than
getting rid of the assignment to 0 in all cases, let's just use the
value returned by git_config_bool(), which is more idiomatic and in
sync with the rest of the boolean handling in this function.

This is a logical follow-up to my commit to remove redundant regflags
assignments[2]. This logic was originally introduced in [3], but as
explained in the former commit it's working around a pattern in our
code that no longer exists, and is now confusing as it leads the
reader to think that this needs to be flipped back & forth.

1. 84befcd0a4 ("grep: add a grep.patternType configuration setting",
2012-08-03)
2. e0b9f8ae09 ("grep: remove redundant regflags assignments",
2017-05-25)
3. b22520a37c ("grep: allow -E and -n to be turned on by default via
configuration", 2011-03-30)

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

grep: remove redundant double assignment to 0Ævar Arnfjörð Bjarmason Thu, 29 Jun 2017 22:22:17 +0000 (22:22 +0000)

grep: remove redundant double assignment to 0

Stop assigning 0 to the extended_regexp_option field right after we've
zeroed out the entire struct with memset() just a few lines earlier.

Unlike some of the code being refactored in subsequent commits, this
was always completely redundant. See the original code introduced in
84befcd0a4 ("grep: add a grep.patternType configuration setting",
2012-08-03).

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

t9700: add tests for Git::unquote_path()Phillip Wood Fri, 30 Jun 2017 09:49:12 +0000 (10:49 +0100)

t9700: add tests for Git::unquote_path()

Check that unquote_path() handles spaces and escape sequences
properly.

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

Git::unquote_path(): throw an exception on bad pathPhillip Wood Fri, 30 Jun 2017 09:49:11 +0000 (10:49 +0100)

Git::unquote_path(): throw an exception on bad path

This is what the other routines in Git.pm do if there's an error.

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

Git::unquote_path(): handle '\a'Phillip Wood Fri, 30 Jun 2017 09:49:10 +0000 (10:49 +0100)

Git::unquote_path(): handle '\a'

unquote_path() does not handle quoted paths containing '\a',
even though quote.c::unquote_c_style() does, and quote.c:sq_lookup[]
tells quote.c::sq_must_quote() that '\007' must be quoted as '\a'.

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

add -i: move unquote_path() to Git.pmPhillip Wood Fri, 30 Jun 2017 09:49:09 +0000 (10:49 +0100)

add -i: move unquote_path() to Git.pm

Move unquote_path() from git-add--interactive to Git.pm so it can be
used by other scripts. Note this is a straight copy, it does not
handle '\a'. That will be fixed in the next commit.

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

commit-template: distinguish status information uncondi... Kaartic Sivaraam Fri, 30 Jun 2017 12:12:21 +0000 (17:42 +0530)

commit-template: distinguish status information unconditionally

The commit template adds the status information without
adding a new line to distinguish them in the absence
of optional parts. This results in difficulty in interpreting
it's content, specifically for inexperienced users.

Unconditionally, add new lines to separate the status message
from the other parts of the commit-template to make it more
readable.

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit-template: remove outdated notice about explicit... Kaartic Sivaraam Fri, 30 Jun 2017 12:12:20 +0000 (17:42 +0530)

commit-template: remove outdated notice about explicit paths

The notice that "git commit <paths>" default to "git commit
--only <paths>" was there since 756e3ee0 ("Merge branch
'jc/commit'", 2006-02-14). Back then, existing users of Git
expected the command doing "git commit --include <paths>", and
after the behaviour of the command was changed to align with
other people's "$scm commit <paths>", the text was added to help
them transition their expectations.

Remove the message that now has outlived its usefulness.

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

coccinelle: polish FREE_AND_NULL rulesRené Scharfe Sun, 25 Jun 2017 08:01:04 +0000 (10:01 +0200)

coccinelle: polish FREE_AND_NULL rules

There are two rules for using FREE_AND_NULL in free.cocci, one for
pointer types and one for expressions. Both cause coccinelle to remove
empty lines and even newline characters between replacements for some
reason; consecutive "free(x);/x=NULL;" sequences end up as multiple
FREE_AND_NULL calls on the same time.

Remove the type rule, as the expression rule already covers it, and
rearrange the lines of the latter to place the addition of FREE_AND_NULL
between the removals, which causes coccinelle to leave surrounding
whitespace untouched.

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

submodule--helper: do not call utf8_fprintf() unnecessarilyJunio C Hamano Wed, 28 Jun 2017 20:38:48 +0000 (13:38 -0700)

submodule--helper: do not call utf8_fprintf() unnecessarily

The helper function utf8_fprintf(fp, ...) has exactly the same
effect to the output stream fp as fprintf(fp, ...) does, and the
only difference is that its return value counts in display columns
consumed (assuming that the payload is encoded in UTF-8), as opposed
to number of bytes.

There is no reason to call it unless the caller cares about its
return value.

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

t1450: use egrep for regexp "alternation"Junio C Hamano Wed, 28 Jun 2017 17:17:04 +0000 (10:17 -0700)

t1450: use egrep for regexp "alternation"

GNU grep allows "\(A\|B\)" as alternation in BRE, but this is an
extension not understood by some other implementations of grep
(Michael Kebe reported an breakage on Solaris).

Rewrite the offending test to ERE and use egrep instead.

Noticed-by: Michael Kebe <michael.kebe@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

subtree: honour USE_ASCIIDOCTOR when setA. Wilcox Wed, 28 Jun 2017 02:49:16 +0000 (21:49 -0500)

subtree: honour USE_ASCIIDOCTOR when set

Defining USE_ASCIIDOCTOR=1 when building Git uses asciidoctor over
asciidoc when generating DocBook and man page documentation. However,
the contrib/subtree module does not presently honour that flag.

This causes a build failure when asciidoc is not present on the build
system. Instead, adapt the main Documentation/Makefile logic to use
asciidoctor when requested.

Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/fetch cleanup: always set default value for... Stefan Beller Tue, 27 Jun 2017 21:31:59 +0000 (14:31 -0700)

builtin/fetch cleanup: always set default value for submodule recursing

The check for the default was introduced with 88a21979c5 (fetch/pull:
recurse into submodules when necessary, 2011-03-06), which replaced an
older construct (builtin/fetchs own implementation of the super-prefix)
introduced in be254a0ea9 (Add the 'fetch.recurseSubmodules' config setting,
2010-11-11) which made sense at the time as there was no default fetch
option for submodules at the time.

Set builtin/fetch.c#recurse_submodules_default to the same value as
submodule.c#config_fetch_recurse_submodules which is set via
set_config_fetch_recurse_submodules, such that the condition for checking
whether we have to set the default value becomes unnecessary.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

apply: check git diffs for mutually exclusive header... René Scharfe Tue, 27 Jun 2017 17:03:39 +0000 (19:03 +0200)

apply: check git diffs for mutually exclusive header lines

A file can either be added, removed, copied, or renamed, but no two of
these actions can be done by the same patch. Some of these combinations
provoke error messages due to missing file names, and some are only
caught by an assertion. Check git patches already as they are parsed
and report conflicting lines on sight.

Found by Vegard Nossum using AFL.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

apply: check git diffs for invalid file modesRené Scharfe Tue, 27 Jun 2017 17:03:47 +0000 (19:03 +0200)

apply: check git diffs for invalid file modes

An empty string as mode specification is accepted silently by git apply,
as Vegard Nossum found out using AFL. It's interpreted as zero. Reject
such bogus file modes, and only accept ones consisting exclusively of
octal digits.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

apply: check git diffs for missing old filenamesRené Scharfe Tue, 27 Jun 2017 17:03:30 +0000 (19:03 +0200)

apply: check git diffs for missing old filenames

2c93286a (fix "git apply --index ..." not to deref NULL) added a check
for git patches missing a +++ line, preventing a segfault. Check for
missing --- lines as well, and add a test for each case.

Found by Vegard Nossum using AFL.

Original-patch-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Spelling fixesVille Skyttä Sun, 25 Jun 2017 10:20:41 +0000 (13:20 +0300)

Spelling fixes

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Twelfth batch for 2.14Junio C Hamano Mon, 26 Jun 2017 21:12:46 +0000 (14:12 -0700)

Twelfth batch for 2.14

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

Merge branch 'mb/reword-autocomplete-message'Junio C Hamano Mon, 26 Jun 2017 21:09:33 +0000 (14:09 -0700)

Merge branch 'mb/reword-autocomplete-message'

Message update.

* mb/reword-autocomplete-message:
auto-correct: tweak phrasing

Merge branch 'ks/t7508-indent-fix'Junio C Hamano Mon, 26 Jun 2017 21:09:32 +0000 (14:09 -0700)

Merge branch 'ks/t7508-indent-fix'

Cosmetic update to a test.

* ks/t7508-indent-fix:
t7508: fix a broken indentation

Merge branch 'jk/add-p-commentchar-fix'Junio C Hamano Mon, 26 Jun 2017 21:09:31 +0000 (14:09 -0700)

Merge branch 'jk/add-p-commentchar-fix'

"git add -p" were updated in 2.12 timeframe to cope with custom
core.commentchar but the implementation was buggy and a
metacharacter like $ and * did not work.

* jk/add-p-commentchar-fix:
add--interactive: quote commentChar regex
add--interactive: handle EOF in prompt_yesno

Merge branch 'dt/raise-core-packed-git-limit'Junio C Hamano Mon, 26 Jun 2017 21:09:30 +0000 (14:09 -0700)

Merge branch 'dt/raise-core-packed-git-limit'

Doc update for a topic already in 'master'.

* dt/raise-core-packed-git-limit:
docs: update 64-bit core.packedGitLimit default

Merge branch 'mh/packed-ref-store-prep'Junio C Hamano Mon, 26 Jun 2017 21:09:29 +0000 (14:09 -0700)

Merge branch 'mh/packed-ref-store-prep'

Bugfix for a topic that is (only) in 'master'.

* mh/packed-ref-store-prep:
for_each_bisect_ref(): don't trim refnames
lock_packed_refs(): fix cache validity check

Merge branch 'lb/status-stash-count'Junio C Hamano Mon, 26 Jun 2017 21:09:29 +0000 (14:09 -0700)

Merge branch 'lb/status-stash-count'

"git status" learned to optionally give how many stash entries the
user has in its output.

* lb/status-stash-count:
glossary: define 'stash entry'
status: add optional stash count information
stash: update documentation to use 'stash entry'

pack-bitmap: don't perform unaligned memory accessJames Clarke Mon, 26 Jun 2017 15:16:12 +0000 (16:16 +0100)

pack-bitmap: don't perform unaligned memory access

The preceding bitmap entries have a 1-byte XOR-offset and 1-byte flags,
so their size is not a multiple of 4. Thus the name-hash cache is only
guaranteed to be 2-byte aligned and so we must use get_be32 rather than
indexing the array directly.

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

sha1_file: refactor has_sha1_file_with_flagsJonathan Tan Thu, 22 Jun 2017 00:40:24 +0000 (17:40 -0700)

sha1_file: refactor has_sha1_file_with_flags

has_sha1_file_with_flags() implements many mechanisms in common with
sha1_object_info_extended(). Make has_sha1_file_with_flags() a
convenience function for sha1_object_info_extended() instead.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: do not access pack if unneededJonathan Tan Thu, 22 Jun 2017 00:40:23 +0000 (17:40 -0700)

sha1_file: do not access pack if unneeded

Currently, regardless of the contents of the "struct object_info" passed
to sha1_object_info_extended(), that function always accesses the
packfile whenever it returns information about a packed object, since it
needs to populate "u.packed".

Add the ability to pass NULL, and use NULL-ness of the argument to
activate an optimization in which sha1_object_info_extended() does not
needlessly access the packfile. A subsequent patch will make use of this
optimization.

A similar optimization is not made for the cached and loose cases as it
would not cause a significant performance improvement.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: teach sha1_object_info_extended more flagsJonathan Tan Thu, 22 Jun 2017 00:40:22 +0000 (17:40 -0700)

sha1_file: teach sha1_object_info_extended more flags

Improve sha1_object_info_extended() by supporting additional
flags. This allows has_sha1_file_with_flags() to be modified to use
sha1_object_info_extended() in a subsequent patch.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1700: make sure split-index respects core.sharedrepositoryChristian Couder Sun, 25 Jun 2017 04:34:29 +0000 (06:34 +0200)

t1700: make sure split-index respects core.sharedrepository

Add a few tests to check that both the split-index file and the
shared-index file are created using the right permissions when
core.sharedrepository is set.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1301: move modebits() to test-lib-functions.shChristian Couder Sun, 25 Jun 2017 04:34:28 +0000 (06:34 +0200)

t1301: move modebits() to test-lib-functions.sh

As the modebits() function can be useful outside t1301,
let's move it into test-lib-functions.sh, and while at
it let's rename it test_modebits().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-cache: use shared perms when writing shared indexChristian Couder Sun, 25 Jun 2017 04:34:27 +0000 (06:34 +0200)

read-cache: use shared perms when writing shared index

Since f6ecc62dbf (write_shared_index(): use tempfile module, 2015-08-10)
write_shared_index() has been using mks_tempfile() to create the
temporary file that will become the shared index.

But even before that, it looks like the functions used to create this
file didn't call adjust_shared_perm(), which means that the shared
index file has always been created with 600 permissions regardless
of the shared permission settings.

Because of that, on repositories created with `git init --shared=all`
and using the split index feature, one gets an error like:

fatal: .git/sharedindex.a52f910b489bc462f187ab572ba0086f7b5157de: index file open failed: Permission denied

when another user performs any operation that reads the shared index.

Call adjust_shared_perm() on the temporary file created by
mks_tempfile() ourselves to adjust the permission bits.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sync with 2.13.2Junio C Hamano Sat, 24 Jun 2017 22:34:14 +0000 (15:34 -0700)

Sync with 2.13.2

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

Git 2.13.2 v2.13.2Junio C Hamano Sat, 24 Jun 2017 22:31:36 +0000 (15:31 -0700)

Git 2.13.2

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

Merge branch 'sn/reset-doc-typofix' into maintJunio C Hamano Sat, 24 Jun 2017 22:29:35 +0000 (15:29 -0700)

Merge branch 'sn/reset-doc-typofix' into maint

Doc update.

* sn/reset-doc-typofix:
doc: git-reset: fix a trivial typo

Merge branch 'sg/doc-pretty-formats' into maintJunio C Hamano Sat, 24 Jun 2017 22:29:35 +0000 (15:29 -0700)

Merge branch 'sg/doc-pretty-formats' into maint

Doc update.

* sg/doc-pretty-formats:
docs/pretty-formats: stress that %- removes all preceding line-feeds

Merge branch 'sd/t3200-branch-m-test' into maintJunio C Hamano Sat, 24 Jun 2017 22:29:34 +0000 (15:29 -0700)

Merge branch 'sd/t3200-branch-m-test' into maint

New test.

* sd/t3200-branch-m-test:
t3200: add test for single parameter passed to -m option

Merge branch 'sg/revision-parser-skip-prefix' into... Junio C Hamano Sat, 24 Jun 2017 22:29:34 +0000 (15:29 -0700)

Merge branch 'sg/revision-parser-skip-prefix' into maint

Code clean-up.

* sg/revision-parser-skip-prefix:
revision.c: use skip_prefix() in handle_revision_pseudo_opt()
revision.c: use skip_prefix() in handle_revision_opt()
revision.c: stricter parsing of '--early-output'
revision.c: stricter parsing of '--no-{min,max}-parents'
revision.h: turn rev_info.early_output back into an unsigned int