gitweb.git
provide --color option for all ref-filter usersJeff King Tue, 3 Oct 2017 13:45:47 +0000 (09:45 -0400)

provide --color option for all ref-filter users

When ref-filter learned about want_color() in 11b087adfd
(ref-filter: consult want_color() before emitting colors,
2017-07-13), it became useful to be able to turn colors off
and on for specific commands. For git-branch, you can do so
with --color/--no-color.

But for git-for-each-ref and git-tag, the other users of
ref-filter, you have no option except to tweak the
"color.ui" config setting. Let's give both of these commands
the usual color command-line options.

This is a bit more obvious as a method for overriding the
config. And it also prepares us for the behavior of "always"
changing (so that we are still left with a way of forcing
color when our output goes to a non-terminal).

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

t3205: use --color instead of color.branch=alwaysJeff King Tue, 3 Oct 2017 13:45:18 +0000 (09:45 -0400)

t3205: use --color instead of color.branch=always

To test the color output, we must convince "git branch" to
write colors to a non-terminal. We do that now by setting
the color config to "always". In preparation for the
behavior of "always" changing, let's switch to using the
"--color" command-line option, which is more direct.

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

t3203: drop "always" color testJeff King Tue, 3 Oct 2017 13:44:39 +0000 (09:44 -0400)

t3203: drop "always" color test

In preparation for the behavior of "always" changing to
match "auto", we can simply drop this test. We already check
other forms (like "--color") independently.

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

t6006: drop "always" color config testsJeff King Tue, 3 Oct 2017 13:44:27 +0000 (09:44 -0400)

t6006: drop "always" color config tests

We test the %C() format placeholders with a variety of
color-inducing options, including "--color" and
"-c color.ui=always". In preparation for the behavior of
"always" changing, we need to do something with those
"always" tests.

We can drop ones that expect "always" to turn on color even
to a file, as that will become a synonym for "auto", which
is already tested.

For the "--no-color" test, we need to make sure that color
would otherwise be shown. To do this, we can use
test_terminal, which enables colors in the default setup.

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

t7502: use diff.noprefix for --verbose testJeff King Tue, 3 Oct 2017 13:43:47 +0000 (09:43 -0400)

t7502: use diff.noprefix for --verbose test

To check that "status -v" respects diff config, we set
"color.diff" and look at the output of "status". We could
equally well use any diff config. Since color output depends
on a lot of other factors (like whether stdout is a tty, and
how we interpret "always"), let's use a more mundane option.

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

t7508: use test_terminal for color outputJeff King Tue, 3 Oct 2017 13:43:29 +0000 (09:43 -0400)

t7508: use test_terminal for color output

This script tests the output of status with various formats
when color is enabled. It uses the "always" setting so that
the output is valid even though we capture it in a file.
Using test_terminal gives us a more realistic environment,
and prepares us for the behavior of "always" changing.

Arguably we are testing less than before, since "auto" is
already the default, and we can no longer tell if the config
is actually doing anything.

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

t3701: use test-terminal to collect color outputJeff King Tue, 3 Oct 2017 13:42:15 +0000 (09:42 -0400)

t3701: use test-terminal to collect color output

When testing whether "add -p" can generate colors, we set
color.ui to "always". This isn't a very good test, as in the
real-world a user typically has "auto" coupled with stdout
going to a terminal (and it's plausible that this could mask
a real bug in add--interactive if we depend on plumbing's
isatty check).

Let's switch to test_terminal, which gives us a more
realistic environment. This also prepare us for future
changes to the "always" color option.

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

t4015: prefer --color to -c color.diff=alwaysJeff King Tue, 3 Oct 2017 13:40:19 +0000 (09:40 -0400)

t4015: prefer --color to -c color.diff=always

t4015 contains many color-related tests which need to
override the "is stdout a tty" check. They do so by setting
the color.diff config, but we can accomplish the same with
the --color option. Besides being shorter to type, switching
will prepare us for upcoming changes to "always" when see it
in config.

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

test-terminal: set TERM=vt100Jeff King Tue, 3 Oct 2017 13:39:34 +0000 (09:39 -0400)

test-terminal: set TERM=vt100

The point of the test-terminal script is to simulate in the
test scripts an environment where output is going to a real
terminal.

But since test-lib.sh also sets TERM=dumb, the simulation
isn't very realistic. The color code will skip auto-coloring
for TERM=dumb, leading to us liberally sprinkling

test_terminal env TERM=vt100 git ...

through the test suite to convince the tests to actually
generate colors. Let's set TERM for programs run under
test_terminal, which is one less thing for test-writers to
remember.

In most cases the callers can be simplified, but note there
is one interesting case in t4202. It uses test_terminal to
check the auto-enabling of --decorate, but the expected
output _doesn't_ contain colors (because TERM=dumb
suppresses them). Using TERM=vt100 is closer to what the
real world looks like; adjust the expected output to match.

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

ref-filter: consult want_color() before emitting colorsJeff King Thu, 13 Jul 2017 15:09:32 +0000 (11:09 -0400)

ref-filter: consult want_color() before emitting colors

When color placeholders like %(color:red) are used in a
ref-filter format, we unconditionally output the colors,
even if the user has asked us for no colors. This usually
isn't a problem when the user is constructing a --format on
the command line, but it means we may do the wrong thing
when the format is fed from a script or alias. For example:

$ git config alias.b 'branch --format=%(color:green)%(refname)'
$ git b --no-color

should probably omit the green color. Likewise, running:

$ git b >branches

should probably also omit the color, just as we would for
all baked-in coloring (and as we recently started to do for
user-specified colors in --pretty formats).

This commit makes both of those cases work by teaching
the ref-filter code to consult want_color() before
outputting any color. The color flag in ref_format defaults
to "-1", which means we'll consult color.ui, which in turn
defaults to the usual isatty() check on stdout. However,
callers like git-branch which support their own color config
(and command-line options) can override that.

The new tests independently cover all three of the callers
of ref-filter (for-each-ref, tag, and branch). Even though
these seem redundant, it confirms that we've correctly
plumbed through all of the necessary config to make colors
work by default.

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

pretty: respect color settings for %C placeholdersJeff King Thu, 13 Jul 2017 15:08:46 +0000 (11:08 -0400)

pretty: respect color settings for %C placeholders

The color placeholders have traditionally been
unconditional, showing colors even when git is not otherwise
configured to do so. This was not so bad for their original
use, which was on the command-line (and the user could
decide at that moment whether to add colors or not). But
these days we have configured formats via pretty.*, and
those should operate correctly in multiple contexts.

In 3082517 (log --format: teach %C(auto,black) to respect
color config, 2012-12-17), we gave an extended placeholder
that could be used to accomplish this. But it's rather
clunky to use, because you have to specify it individually
for each color (and their matching resets) in the format.
We shied away from just switching the default to auto,
because it is technically breaking backwards compatibility.

However, there's not really a use case for unconditional
colors. The most plausible reason you would want them is to
redirect "git log" output to a file. But there, the right
answer is --color=always, as it does the right thing both
with custom user-format colors and git-generated colors.

So let's switch to the more useful default. In the
off-chance that somebody really does find a use for
unconditional colors without wanting to enable the rest of
git's colors, we provide a new %C(always,...) to enable the
old behavior. And we can remind them of --color=always in
the documentation.

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

rev-list: pass diffopt->use_colors through to pretty... Jeff King Thu, 13 Jul 2017 15:07:30 +0000 (11:07 -0400)

rev-list: pass diffopt->use_colors through to pretty-print

When rev-list pretty-prints a commit, it creates a new
pretty_print_context and copies items from the rev_info
struct. We don't currently copy the "use_color" field,
though. Nobody seems to have noticed because the only part
of pretty.c that cares is the %C(auto,...) placeholder, and
presumably not many people use that with the rev-list
plumbing (as opposed to with git-log).

It will become more noticeable in a future patch, though,
when we start treating all user-format colors as auto-colors
(in which case it would become impossible to format colors
with rev-list, even with --color=always).

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

for-each-ref: load config earlierJeff King Thu, 13 Jul 2017 15:07:14 +0000 (11:07 -0400)

for-each-ref: load config earlier

In most commands we load config before parsing command line
options, since it lets the latter override the former with a
simple variable assignment. In the case of for-each-ref,
though, we do it in the reverse order. This is OK with
the current code, since there's no interaction between the
config and command-line options.

However, as the ref-filter code starts to care about config
during verify_ref_format(), we'll want to make sure the
config is loaded. Let's bump the config to the usual spot
near the top of the function.

We can drop the comment there; it's impossible to keep a
"why we load the config" comment like this up to date with
every config option we might be interested in. And indeed,
it's already stale; we'd care about core.abbrev, for
instance, when %(objectname:short) is used.

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

color: check color.ui in git_default_config()Jeff King Thu, 13 Jul 2017 15:07:03 +0000 (11:07 -0400)

color: check color.ui in git_default_config()

Back in prehistoric times, our decision on whether or not to
show color by default relied on using a config callback that
either did or didn't load color config like color.diff.
When we introduced color.ui, we put it in the same boat:
commands had to manually respect it by using git_color_config()
or its git_color_default_config() convenience wrapper.

But in 4c7f1819b (make color.ui default to 'auto',
2013-06-10), that changed. Since then, we default color.ui
to auto in all programs, meaning that even plumbing commands
like "git diff-tree --pretty" might colorize the output.
Nobody seems to have complained in the intervening years,
presumably because the "is stdout a tty" check does a good
job of catching the right cases.

But that leaves an interesting curiosity: color.ui defaults
to auto even in plumbing, but you can't actually _disable_
the color via config. So if you really hate color and set
"color.ui" to false, diff-tree will still show color (but
porcelain like git-diff won't). Nobody noticed that either,
probably because very few people disable color.

One could argue that the plumbing should _always_ disable
color unless an explicit --color option is given on the
command line. But in practice, this creates a lot of
complications for scripts which do want plumbing to show
user-visible output. They can't just pass "--color" blindly;
they need to check the user's config and decide what to
send.

Given that nobody has complained about the current behavior,
let's assume it's a good path, and follow it to its
conclusion: supporting color.ui everywhere.

Note that you can create havoc by setting color.ui=always in
your config, but that's more or less already the case. We
could disallow it entirely, but it is handy for one-offs
like:

git -c color.ui=always foo >not-a-tty

when "foo" does not take a --color option itself.

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

ref-filter: pass ref_format struct to atom parsersJeff King Thu, 13 Jul 2017 15:06:40 +0000 (11:06 -0400)

ref-filter: pass ref_format struct to atom parsers

The callback for parsing each formatting atom gets to see
only the atom struct (which it's filling in) and the text to
be parsed. This doesn't leave any room for it to behave
differently based on context known only to the ref_format.

We can solve this by passing in the surrounding ref_format
to each parser. Note that this makes things slightly awkward
for sort strings, which parse atoms without having a
ref_format. We'll solve that by using a dummy ref_format
with default parameters.

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

ref-filter: factor out the parsing of sorting atomsJeff King Thu, 13 Jul 2017 15:02:58 +0000 (11:02 -0400)

ref-filter: factor out the parsing of sorting atoms

We parse sort strings as single formatting atoms, and just
build on parse_ref_filter_atom(). Let's pull this idea into
its own function, since it's about to get a little more
complex. As a bonus, we can give the function a slightly
more natural interface, since our single atoms are in their
own strings.

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

ref-filter: make parse_ref_filter_atom a private functionJeff King Thu, 13 Jul 2017 15:02:52 +0000 (11:02 -0400)

ref-filter: make parse_ref_filter_atom a private function

The parse_ref_filter_atom() function really shouldn't be
exposed outside of ref-filter.c; its return value is an
integer index into an array that is private in that file.

Since the previous commit removed the sole external caller
(and replaced it with a public function at a more
appropriately level), we can just make this static.

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

ref-filter: provide a function for parsing sort optionsJeff King Thu, 13 Jul 2017 15:02:44 +0000 (11:02 -0400)

ref-filter: provide a function for parsing sort options

The ref-filter module currently provides a callback suitable
for parsing command-line --sort options. But since git-tag
also supports the tag.sort config option, it needs a
function whose implementation is quite similar, but with a
slightly different interface. The end result is that
builtin/tag.c has a copy-paste of parse_opt_ref_sorting().

Instead, let's provide a function to parse an arbitrary
sort string, which we can then trivially wrap to make the
parse_opt variant.

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

ref-filter: move need_color_reset_at_eol into ref_formatJeff King Thu, 13 Jul 2017 15:02:30 +0000 (11:02 -0400)

ref-filter: move need_color_reset_at_eol into ref_format

Calling verify_ref_format() doesn't just confirm that the
format is sane; it actually sets some global variables that
will be used later when formatting the refs. These logically
should belong to the ref_format, which would make it
possible to use multiple formats within a single program
invocation.

Let's move one such flag into the ref_format struct. There
are still others that would need to be moved before it would
be safe to use multiple formats, but this commit gives a
blueprint for how that should look.

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

ref-filter: abstract ref format into its own structJeff King Thu, 13 Jul 2017 15:01:18 +0000 (11:01 -0400)

ref-filter: abstract ref format into its own struct

The ref-filter module provides routines for formatting a ref
for output. The fundamental interface for the format is a
"const char *" containing the format, and any additional
options need to be passed to each invocation of
show_ref_array_item.

Instead, let's make a ref_format struct that holds the
format, along with any associated format options. That will
make some enhancements easier in the future:

1. new formatting options can be added without disrupting
existing callers

2. some state can be carried in the struct rather than as
global variables

For now this just has the text format itself along with the
quote_style option, but we'll add more fields in future patches.

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

ref-filter: simplify automatic color resetJeff King Thu, 13 Jul 2017 14:58:56 +0000 (10:58 -0400)

ref-filter: simplify automatic color reset

When the user-format doesn't add the closing color reset, we
add one automatically. But we do so by parsing the "reset"
string. We can just use the baked-in string literal, which
is simpler.

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

t: use test_decode_color rather than literal ANSI codesJeff King Thu, 13 Jul 2017 14:58:41 +0000 (10:58 -0400)

t: use test_decode_color rather than literal ANSI codes

When we put literal ANSI terminal codes into our test
scripts, it makes diffs on those scripts hard to read (the
colors may be indistinguishable from diff coloring, or in
the case of a reset, may not be visible at all).

Some scripts get around this by including human-readable
names and converting to literal codes with a git-config
hack. This makes the actual code diffs look OK, but test_cmp
output suffers from the same problem.

Let's use test_decode_color instead, which turns the codes
into obvious text tags.

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

docs/for-each-ref: update pointer to color syntaxJeff King Thu, 13 Jul 2017 14:56:21 +0000 (10:56 -0400)

docs/for-each-ref: update pointer to color syntax

The documentation for the %(color) placeholder refers to the
color.branch.* config for more details. But those details
moved to their own section in b92c1a28f
(Documentation/config.txt: describe 'color' value type in
the "Values" section, 2015-03-03). Let's update our
pointer. We can steal the text from 30cfe72d3 (pretty: fix
document link for color specification, 2016-10-11), which
fixed the same problem in a different place.

While we're at it, let's give an example, which makes the
syntax much more clear than just the text.

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

check return value of verify_ref_format()Jeff King Thu, 13 Jul 2017 14:56:10 +0000 (10:56 -0400)

check return value of verify_ref_format()

Users of the ref-filter code must call verify_ref_format()
before formatting any refs, but most ignore its return
value. This means we may print an error on a syntactically
bogus pattern, but keep going anyway.

In most cases this results in a fatal error when we actually
try to format a ref. But if you have no refs to show at all,
then the behavior is confusing: git prints the error from
verify_ref_format(), then exits with code 0 without showing
any output. Let's instead abort immediately if we know we
have a bogus format.

We'll output the usage information if we have it handy (just
like the existing call in cmd_for_each_ref() does), and
otherwise just die().

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

Sync with v2.13.3Junio C Hamano Wed, 12 Jul 2017 22:25:14 +0000 (15:25 -0700)

Sync with v2.13.3

Git 2.13.3 v2.13.3Junio C Hamano Wed, 12 Jul 2017 22:24:15 +0000 (15:24 -0700)

Git 2.13.3

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

Merge branch 'kn/ref-filter-branch-list' into maintJunio C Hamano Wed, 12 Jul 2017 22:23:09 +0000 (15:23 -0700)

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

The rewrite of "git branch --list" using for-each-ref's internals
that happened in v2.13 regressed its handling of color.branch.local;
this has been fixed.

* kn/ref-filter-branch-list:
ref-filter.c: drop return from void function
branch: set remote color in ref-filter branch immediately
branch: use BRANCH_COLOR_LOCAL in ref-filter format
branch: only perform HEAD check for local branches

Merge branch 'ks/typofix-commit-c-comment' into maintJunio C Hamano Wed, 12 Jul 2017 22:20:48 +0000 (15:20 -0700)

Merge branch 'ks/typofix-commit-c-comment' into maint

Typofix.

* ks/typofix-commit-c-comment:
builtin/commit.c: fix a typo in the comment

Merge branch 'jk/reflog-walk-maint' into maintJunio C Hamano Wed, 12 Jul 2017 22:20:35 +0000 (15:20 -0700)

Merge branch 'jk/reflog-walk-maint' into maint

After "git branch --move" of the currently checked out branch, the
code to walk the reflog of HEAD via "log -g" and friends
incorrectly stopped at the reflog entry that records the renaming
of the branch.

* jk/reflog-walk-maint:
reflog-walk: include all fields when freeing complete_reflogs
reflog-walk: don't free reflogs added to cache
reflog-walk: duplicate strings in complete_reflogs list
reflog-walk: skip over double-null oid due to HEAD rename

Hopefully the last batch before -rc0Junio C Hamano Wed, 12 Jul 2017 22:19:27 +0000 (15:19 -0700)

Hopefully the last batch before -rc0

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

Merge branch 'ks/fix-rebase-doc-picture'Junio C Hamano Wed, 12 Jul 2017 22:18:24 +0000 (15:18 -0700)

Merge branch 'ks/fix-rebase-doc-picture'

Doc update.

* ks/fix-rebase-doc-picture:
doc: correct a mistake in an illustration

Merge branch 'rs/wt-status-cleanup'Junio C Hamano Wed, 12 Jul 2017 22:18:23 +0000 (15:18 -0700)

Merge branch 'rs/wt-status-cleanup'

Code cleanup.

* rs/wt-status-cleanup:
wt-status: use separate variable for result of shorten_unambiguous_ref

Merge branch 'rs/use-div-round-up'Junio C Hamano Wed, 12 Jul 2017 22:18:23 +0000 (15:18 -0700)

Merge branch 'rs/use-div-round-up'

Code cleanup.

* rs/use-div-round-up:
use DIV_ROUND_UP

Merge branch 'kn/ref-filter-branch-list'Junio C Hamano Wed, 12 Jul 2017 22:18:23 +0000 (15:18 -0700)

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

The rewrite of "git branch --list" using for-each-ref's internals
that happened in v2.13 regressed its handling of color.branch.local;
this has been fixed.

* kn/ref-filter-branch-list:
ref-filter.c: drop return from void function
branch: set remote color in ref-filter branch immediately
branch: use BRANCH_COLOR_LOCAL in ref-filter format
branch: only perform HEAD check for local branches

Merge branch 'rs/urlmatch-cleanup'Junio C Hamano Wed, 12 Jul 2017 22:18:22 +0000 (15:18 -0700)

Merge branch 'rs/urlmatch-cleanup'

Code cleanup.

* rs/urlmatch-cleanup:
urlmatch: use hex2chr() in append_normalized_escapes()

Merge branch 'rs/apply-avoid-over-reading'Junio C Hamano Wed, 12 Jul 2017 22:18:22 +0000 (15:18 -0700)

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

Code cleanup.

* rs/apply-avoid-over-reading:
apply: use strcmp(3) for comparing strings in gitdiff_verify_name()

Merge branch 'sb/submodule-doc'Junio C Hamano Wed, 12 Jul 2017 22:18:21 +0000 (15:18 -0700)

Merge branch 'sb/submodule-doc'

Doc update.

* sb/submodule-doc:
submodules: overhaul documentation

use DIV_ROUND_UPRené Scharfe Sat, 8 Jul 2017 10:35:35 +0000 (12:35 +0200)

use DIV_ROUND_UP

Convert code that divides and rounds up to use DIV_ROUND_UP to make the
intent clearer and reduce the number of magic constants.

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

Sync with maintJunio C Hamano Mon, 10 Jul 2017 21:02:45 +0000 (14:02 -0700)

Sync with maint

Prepare for 2.13.3Junio C Hamano Mon, 10 Jul 2017 21:02:07 +0000 (14:02 -0700)

Prepare for 2.13.3

Merge branch 'sb/merge-recursive-code-cleanup' into... Junio C Hamano Mon, 10 Jul 2017 20:59:09 +0000 (13:59 -0700)

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

Code clean-up.

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

Merge branch 'jc/utf8-fprintf' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:08 +0000 (13:59 -0700)

Merge branch 'jc/utf8-fprintf' into maint

Code cleanup.

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

Merge branch 'js/fsck-name-object' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:08 +0000 (13:59 -0700)

Merge branch 'js/fsck-name-object' into maint

Test fix.

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

Merge branch 'js/t5534-rev-parse-gives-multi-line-outpu... Junio C Hamano Mon, 10 Jul 2017 20:59:07 +0000 (13:59 -0700)

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

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 'ab/sha1dc-maint' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:06 +0000 (13:59 -0700)

Merge branch 'ab/sha1dc-maint' into maint

Update the sha1dc again to fix portability glitches.

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

Merge branch 'aw/contrib-subtree-doc-asciidoctor' into... Junio C Hamano Mon, 10 Jul 2017 20:59:06 +0000 (13:59 -0700)

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

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

Merge branch 'cc/shared-index-permfix' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:05 +0000 (13:59 -0700)

Merge branch 'cc/shared-index-permfix' into maint

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 'ah/doc-pretty-color-auto-prefix' into... Junio C Hamano Mon, 10 Jul 2017 20:59:05 +0000 (13:59 -0700)

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

Doc update.

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

Merge branch 'mb/reword-autocomplete-message' into... Junio C Hamano Mon, 10 Jul 2017 20:59:04 +0000 (13:59 -0700)

Merge branch 'mb/reword-autocomplete-message' into maint

Message update.

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

Merge branch 'ks/t7508-indent-fix' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:03 +0000 (13:59 -0700)

Merge branch 'ks/t7508-indent-fix' into maint

Cosmetic update to a test.

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

Merge branch 'sb/t4005-modernize' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:02 +0000 (13:59 -0700)

Merge branch 'sb/t4005-modernize' into maint

Test clean-up.

* sb/t4005-modernize:
t4005: modernize style and drop hard coded sha1

Merge branch 'rs/apply-validate-input' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:01 +0000 (13:59 -0700)

Merge branch 'rs/apply-validate-input' into maint

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' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:00 +0000 (13:59 -0700)

Merge branch 'jc/pack-bitmap-unaligned' into maint

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 'pw/rebase-i-regression-fix-tests' into... Junio C Hamano Mon, 10 Jul 2017 20:58:59 +0000 (13:58 -0700)

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

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

Merge branch 'jk/add-p-commentchar-fix' into maintJunio C Hamano Mon, 10 Jul 2017 20:58:58 +0000 (13:58 -0700)

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

"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 'js/alias-early-config' into maintJunio C Hamano Mon, 10 Jul 2017 20:58:57 +0000 (13:58 -0700)

Merge branch 'js/alias-early-config' into maint

The code to pick up and execute command alias definition from the
configuration used to switch to the top of the working tree and
then come back when the expanded alias was executed, which was
unnecessarilyl complex. Attempt to simplify the logic by using the
early-config mechanism that does not chdir around.

* js/alias-early-config:
alias: use the early config machinery to expand aliases
t7006: demonstrate a problem with aliases in subdirectories
t1308: relax the test verifying that empty alias values are disallowed
help: use early config when autocorrecting aliases
config: report correct line number upon error
discover_git_directory(): avoid setting invalid git_dir

Merge branch 'rs/pretty-add-again' into maintJunio C Hamano Mon, 10 Jul 2017 20:58:57 +0000 (13:58 -0700)

Merge branch 'rs/pretty-add-again' into maint

The pretty-format specifiers like '%h', '%t', etc. had an
optimization that no longer works correctly. In preparation/hope
of getting it correctly implemented, first discard the optimization
that is broken.

* rs/pretty-add-again:
pretty: recalculate duplicate short hashes

Merge branch 'ah/doc-gitattributes-empty-index' into... Junio C Hamano Mon, 10 Jul 2017 20:58:56 +0000 (13:58 -0700)

Merge branch 'ah/doc-gitattributes-empty-index' into maint

An example in documentation that does not work in multi worktree
configuration has been corrected.

* ah/doc-gitattributes-empty-index:
doc: do not use `rm .git/index` when normalizing line endings

Merge branch 'da/mergetools-meld-output-opt-on-macos... Junio C Hamano Mon, 10 Jul 2017 20:58:56 +0000 (13:58 -0700)

Merge branch 'da/mergetools-meld-output-opt-on-macos' into maint

"git mergetool" learned to work around a wrapper MacOS X adds
around underlying meld.

* da/mergetools-meld-output-opt-on-macos:
mergetools/meld: improve compatibiilty with Meld on macOS X

Merge branch 'jk/diff-highlight-module' into maintJunio C Hamano Mon, 10 Jul 2017 20:58:56 +0000 (13:58 -0700)

Merge branch 'jk/diff-highlight-module' into maint

The 'diff-highlight' program (in contrib/) has been restructured
for easier reuse by an external project 'diff-so-fancy'.

* jk/diff-highlight-module:
diff-highlight: split code into module

Sixteenth batch for 2.14Junio C Hamano Mon, 10 Jul 2017 20:44:30 +0000 (13:44 -0700)

Sixteenth batch for 2.14

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

Merge branch 'jk/reflog-walk-maint'Junio C Hamano Mon, 10 Jul 2017 20:42:52 +0000 (13:42 -0700)

Merge branch 'jk/reflog-walk-maint'

After "git branch --move" of the currently checked out branch, the
code to walk the reflog of HEAD via "log -g" and friends
incorrectly stopped at the reflog entry that records the renaming
of the branch.

* jk/reflog-walk-maint:
reflog-walk: include all fields when freeing complete_reflogs
reflog-walk: don't free reflogs added to cache
reflog-walk: duplicate strings in complete_reflogs list
reflog-walk: skip over double-null oid due to HEAD rename

Merge branch 'bb/unicode-10.0'Junio C Hamano Mon, 10 Jul 2017 20:42:52 +0000 (13:42 -0700)

Merge branch 'bb/unicode-10.0'

Update the character width tables.

* bb/unicode-10.0:
unicode: update the width tables to Unicode 10

Merge branch 'ks/typofix-commit-c-comment'Junio C Hamano Mon, 10 Jul 2017 20:42:51 +0000 (13:42 -0700)

Merge branch 'ks/typofix-commit-c-comment'

Typofix.

* ks/typofix-commit-c-comment:
builtin/commit.c: fix a typo in the comment

Merge branch 'ab/wildmatch'Junio C Hamano Mon, 10 Jul 2017 20:42:51 +0000 (13:42 -0700)

Merge branch 'ab/wildmatch'

Minor code cleanup.

* ab/wildmatch:
wildmatch: remove unused wildopts parameter

Merge branch 'ab/sha1dc'Junio C Hamano Mon, 10 Jul 2017 20:42:51 +0000 (13:42 -0700)

Merge branch 'ab/sha1dc'

The "collission-detecting" implementation of SHA-1 hash we borrowed
from is replaced by directly binding the upstream project as our
submodule. Glitches on minority platforms are still being worked out.

* ab/sha1dc:
sha1collisiondetection: automatically enable when submodule is populated
sha1dc: optionally use sha1collisiondetection as a submodule

Merge branch 'rs/free-and-null'Junio C Hamano Mon, 10 Jul 2017 20:42:51 +0000 (13:42 -0700)

Merge branch 'rs/free-and-null'

Code cleanup.

* rs/free-and-null:
coccinelle: polish FREE_AND_NULL rules

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>

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>

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>

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>