gitweb.git
use strbuf_addstr() instead of strbuf_addf() with ... René Scharfe Tue, 27 Sep 2016 19:08:21 +0000 (21:08 +0200)

use strbuf_addstr() instead of strbuf_addf() with "%s", part 2

Replace uses of strbuf_addf() for adding strings with more lightweight
strbuf_addstr() calls. This is shorter and makes the intent clearer.

bc57b9c0cc5a123365a922fa1831177e3fd607ed already converted three cases,
this patch covers two more.

A semantic patch for Coccinelle is included for easier checking for
new cases that might be introduced in the future.

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

gitignore: ignore output files of coccicheck make targetRené Scharfe Tue, 27 Sep 2016 20:12:33 +0000 (22:12 +0200)

gitignore: ignore output files of coccicheck make target

Helped-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revision: new rev^-n shorthand for rev^n..revVegard Nossum Tue, 27 Sep 2016 08:32:49 +0000 (10:32 +0200)

revision: new rev^-n shorthand for rev^n..rev

"git log rev^..rev" is commonly used to show all work done on and merged
from a side branch. This patch introduces a shorthand "rev^-" for this
and additionally allows "rev^-$n" to mean "reachable from rev, excluding
what is reachable from the nth parent of rev". For example, for a
two-parent merge, you can use rev^-2 to get the set of commits which were
made to the main branch while the topic branch was prepared.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktree: honor configuration variablesJunio C Hamano Tue, 27 Sep 2016 06:49:39 +0000 (23:49 -0700)

worktree: honor configuration variables

The command accesses default_abbrev (defined in environment.c and is
updated via core.abbrev configuration), but never makes any call to
git_config(). The output from "worktree list" ignores the abbrev
setting for this reason.

Make a call to git_config() to read the default set of configuration
variables at the beginning of the command.

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

get_short_sha1: make default disambiguation configurableJeff King Tue, 27 Sep 2016 12:38:01 +0000 (08:38 -0400)

get_short_sha1: make default disambiguation configurable

When we find ambiguous short sha1s, we may get a
disambiguation rule from our caller's context. But if we
don't, we fall back to treating all sha1s the same, even
though most projects will tend to refer only to commits by
their short sha1s.

This patch introduces a configuration option that lets the
user pick a different fallback (e.g., only commits). It's
possible that we may want to make this the default, but it's
a good idea to start as a config option for two reasons:

1. It lets people experiment with this and see if it's a
good idea (i.e., the "tend to" above is an assumption;
we don't really know if this will break some obscure
cases).

2. Even if we do flip the default, it gives people an
escape hatch if it causes problems (you can sometimes
override it by asking for "1234^{tree}", but not all
combinations are possible).

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

xdiff: rename "struct group" to "struct xdlgroup"Jeff King Tue, 27 Sep 2016 04:37:33 +0000 (00:37 -0400)

xdiff: rename "struct group" to "struct xdlgroup"

Commit e8adf23 (xdl_change_compact(): introduce the concept
of a change group, 2016-08-22) added a "struct group" type
to xdiff/xdiffi.c. But the POSIX system header "grp.h"
already defines "struct group" (it is part of the getgrnam
interface). This happens to work because the new type is
local to xdiffi.c, and the xdiff code includes a relatively
small set of system headers. But it will break compilation
if xdiff ever switches to using git-compat-util.h. It can
also probably cause confusion with tools that look at the
whole code base, like coccinelle or ctags.

Let's resolve by giving the xdiff variant a scoped name,
which is closer to other xdiff types anyway (e.g.,
xdlfile_t, though note that xdiff is fond if typedefs when
Git usually is not).

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

add David Turner's Two Sigma addressDavid Turner Tue, 27 Sep 2016 00:11:33 +0000 (20:11 -0400)

add David Turner's Two Sigma address

Signed-off-by: David Turner <novalis@novalis.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Fifth batch for 2.11Junio C Hamano Mon, 26 Sep 2016 23:11:46 +0000 (16:11 -0700)

Fifth batch for 2.11

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

Merge branch 'jk/clone-recursive-progress'Junio C Hamano Mon, 26 Sep 2016 23:09:22 +0000 (16:09 -0700)

Merge branch 'jk/clone-recursive-progress'

"git clone --recurse-submodules" lost the progress eye-candy in
recent update, which has been corrected.

* jk/clone-recursive-progress:
clone: pass --progress decision to recursive submodules

Merge branch 'jk/doc-cvs-update'Junio C Hamano Mon, 26 Sep 2016 23:09:22 +0000 (16:09 -0700)

Merge branch 'jk/doc-cvs-update'

Documentation around tools to import from CVS was fairly outdated.

* jk/doc-cvs-update:
docs/cvs-migration: mention cvsimport caveats
docs/cvs-migration: update link to cvsps homepage
docs/cvsimport: prefer cvs-fast-export to parsecvs

Merge branch 'rt/rebase-i-broken-insn-advise'Junio C Hamano Mon, 26 Sep 2016 23:09:21 +0000 (16:09 -0700)

Merge branch 'rt/rebase-i-broken-insn-advise'

When "git rebase -i" is given a broken instruction, it told the
user to fix it with "--edit-todo", but didn't say what the step
after that was (i.e. "--continue").

* rt/rebase-i-broken-insn-advise:
rebase -i: improve advice on bad instruction lines

Merge branch 'rs/checkout-init-macro'Junio C Hamano Mon, 26 Sep 2016 23:09:21 +0000 (16:09 -0700)

Merge branch 'rs/checkout-init-macro'

Code cleanup.

* rs/checkout-init-macro:
introduce CHECKOUT_INIT

Merge branch 'ls/travis-homebrew-path-fix'Junio C Hamano Mon, 26 Sep 2016 23:09:20 +0000 (16:09 -0700)

Merge branch 'ls/travis-homebrew-path-fix'

The procedure to build Git on Mac OS X for Travis CI hardcoded the
internal directory structure we assumed HomeBrew uses, which was a
no-no. The procedure has been updated to ask HomeBrew things we
need to know to fix this.

* ls/travis-homebrew-path-fix:
travis-ci: ask homebrew for its path instead of hardcoding it

Merge branch 'tg/add-chmod+x-fix'Junio C Hamano Mon, 26 Sep 2016 23:09:20 +0000 (16:09 -0700)

Merge branch 'tg/add-chmod+x-fix'

"git add --chmod=+x <pathspec>" added recently only toggled the
executable bit for paths that are either new or modified. This has
been corrected to flip the executable bit for all paths that match
the given pathspec.

* tg/add-chmod+x-fix:
t3700-add: do not check working tree file mode without POSIXPERM
t3700-add: create subdirectory gently
add: modify already added files when --chmod is given
read-cache: introduce chmod_index_entry
update-index: add test for chmod flags

Merge branch 'js/regexec-buf'Junio C Hamano Mon, 26 Sep 2016 23:09:19 +0000 (16:09 -0700)

Merge branch 'js/regexec-buf'

Some codepaths in "git diff" used regexec(3) on a buffer that was
mmap(2)ed, which may not have a terminating NUL, leading to a read
beyond the end of the mapped region. This was fixed by introducing
a regexec_buf() helper that takes a <ptr,len> pair with REG_STARTEND
extension.

* js/regexec-buf:
regex: use regexec_buf()
regex: add regexec_buf() that can work on a non NUL-terminated string
regex: -G<pattern> feeds a non NUL-terminated string to regexec() and fails

Merge branch 'nd/checkout-disambiguation'Junio C Hamano Mon, 26 Sep 2016 23:09:18 +0000 (16:09 -0700)

Merge branch 'nd/checkout-disambiguation'

"git checkout <word>" does not follow the usual disambiguation
rules when the <word> can be both a rev and a path, to allow
checking out a branch 'foo' in a project that happens to have a
file 'foo' in the working tree without having to disambiguate.
This was poorly documented and the check was incorrect when the
command was run from a subdirectory.

* nd/checkout-disambiguation:
checkout: fix ambiguity check in subdir
checkout.txt: document a common case that ignores ambiguation rules
checkout: add some spaces between code and comment

Merge branch 'va/i18n-more'Junio C Hamano Mon, 26 Sep 2016 23:09:17 +0000 (16:09 -0700)

Merge branch 'va/i18n-more'

Even more i18n.

* va/i18n-more:
i18n: stash: mark messages for translation
i18n: notes-merge: mark die messages for translation
i18n: ident: mark hint for translation
i18n: i18n: diff: mark die messages for translation
i18n: connect: mark die messages for translation
i18n: commit: mark message for translation

Merge branch 'jt/format-patch-rfc'Junio C Hamano Mon, 26 Sep 2016 23:09:17 +0000 (16:09 -0700)

Merge branch 'jt/format-patch-rfc'

In some projects, it is common to use "[RFC PATCH]" as the subject
prefix for a patch meant for discussion rather than application. A
new option "--rfc" was a short-hand for "--subject-prefix=RFC PATCH"
to help the participants of such projects.

* jt/format-patch-rfc:
format-patch: add "--rfc" for the common case of [RFC PATCH]

Merge branch 'ep/doc-check-ref-format-example'Junio C Hamano Mon, 26 Sep 2016 23:09:17 +0000 (16:09 -0700)

Merge branch 'ep/doc-check-ref-format-example'

A shell script example in check-ref-format documentation has been
fixed.

* ep/doc-check-ref-format-example:
git-check-ref-format.txt: fixup documentation

Merge branch 'mh/diff-indent-heuristic'Junio C Hamano Mon, 26 Sep 2016 23:09:16 +0000 (16:09 -0700)

Merge branch 'mh/diff-indent-heuristic'

Output from "git diff" can be made easier to read by selecting
which lines are common and which lines are added/deleted
intelligently when the lines before and after the changed section
are the same. A command line option is added to help with the
experiment to find a good heuristics.

* mh/diff-indent-heuristic:
blame: honor the diff heuristic options and config
parse-options: add parse_opt_unknown_cb()
diff: improve positioning of add/delete blocks in diffs
xdl_change_compact(): introduce the concept of a change group
recs_match(): take two xrecord_t pointers as arguments
is_blank_line(): take a single xrecord_t as argument
xdl_change_compact(): only use heuristic if group can't be matched
xdl_change_compact(): fix compaction heuristic to adjust ixo

Merge branch 'rs/c-auto-resets-attributes'Junio C Hamano Mon, 26 Sep 2016 23:09:15 +0000 (16:09 -0700)

Merge branch 'rs/c-auto-resets-attributes'

The pretty-format specifier "%C(auto)" used by the "log" family of
commands to enable coloring of the output is taught to also issue a
color-reset sequence to the output.

* rs/c-auto-resets-attributes:
pretty: let %C(auto) reset all attributes

Merge branch 'mm/config-color-ui-default-to-auto'Junio C Hamano Mon, 26 Sep 2016 23:09:14 +0000 (16:09 -0700)

Merge branch 'mm/config-color-ui-default-to-auto'

Documentation for individual configuration variables to control use
of color (like `color.grep`) said that their default value is
'false', instead of saying their default is taken from `color.ui`.
When we updated the default value for color.ui from 'false' to
'auto' quite a while ago, all of them broke. This has been
corrected.

* mm/config-color-ui-default-to-auto:
Documentation/config: default for color.* is color.ui

Merge branch 'rs/cocci'Junio C Hamano Mon, 26 Sep 2016 23:09:14 +0000 (16:09 -0700)

Merge branch 'rs/cocci'

Code cleanup.

* rs/cocci:
use strbuf_addstr() for adding constant strings to a strbuf, part 2
add coccicheck make target
contrib/coccinelle: fix semantic patch for oid_to_hex_r()

get_short_sha1: list ambiguous objects on errorJeff King Mon, 26 Sep 2016 12:00:36 +0000 (08:00 -0400)

get_short_sha1: list ambiguous objects on error

When the user gives us an ambiguous short sha1, we print an
error and refuse to resolve it. In some cases, the next step
is for them to feed us more characters (e.g., if they were
retyping or cut-and-pasting from a full sha1). But in other
cases, that might be all they have. For example, an old
commit message may have used a 7-character hex that was
unique at the time, but is now ambiguous. Git doesn't
provide any information about the ambiguous objects it
found, so it's hard for the user to find out which one they
probably meant.

This patch teaches get_short_sha1() to list the sha1s of the
objects it found, along with a few bits of information that
may help the user decide which one they meant. Here's what
it looks like on git.git:

$ git rev-parse b2e1
error: short SHA1 b2e1 is ambiguous
hint: The candidates are:
hint: b2e1196 tag v2.8.0-rc1
hint: b2e11d1 tree
hint: b2e1632 commit 2007-11-14 - Merge branch 'bs/maint-commit-options'
hint: b2e1759 blob
hint: b2e18954 blob
hint: b2e1895c blob
fatal: ambiguous argument 'b2e1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

We show the tagname for tags, and the date and subject for
commits. For trees and blobs, in theory we could dig in the
history to find the paths at which they were present. But
that's very expensive (on the order of 30s for the kernel),
and it's not likely to be all that helpful. Most short
references are to commits, so the useful information is
typically going to be that the object in question _isn't_ a
commit. So it's silly to spend a lot of CPU preemptively
digging up the path; the user can do it themselves if they
really need to.

And of course it's somewhat ironic that we abbreviate the
sha1s in the disambiguation hint. But full sha1s would cause
annoying line wrapping for the commit lines, and presumably
the user is going to just re-issue their command immediately
with the corrected sha1.

We also restrict the list to those that match any
disambiguation hint. E.g.:

$ git rev-parse b2e1:foo
error: short SHA1 b2e1 is ambiguous
hint: The candidates are:
hint: b2e1196 tag v2.8.0-rc1
hint: b2e11d1 tree
hint: b2e1632 commit 2007-11-14 - Merge branch 'bs/maint-commit-options'
fatal: Invalid object name 'b2e1'.

does not bother reporting the blobs, because they cannot
work as a treeish.

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

for_each_abbrev: drop duplicate objectsJeff King Mon, 26 Sep 2016 12:00:33 +0000 (08:00 -0400)

for_each_abbrev: drop duplicate objects

If an object appears multiple times in the object database
(e.g., in both loose and packed form, or in two separate
packs), the disambiguation machinery may see it more than
once. The get_short_sha1() function handles this already,
but for_each_abbrev() blindly fires the callback for each
instance it finds.

We can fix this by collecting the output in a sha1 array and
de-duplicating it. As a bonus, the sort done for the
de-duplication means that our output will be stable,
regardless of the order in which the objects are found.

Note that the old code normalized the callback's output to
0/1 to store in the 1-bit ds->ambiguous flag (which both
halted the iteration and was returned from the
for_each_abbrev function). Now that we are using sha1_array,
we can return the real value. In practice, it doesn't matter
as the sole caller only ever returns 0.

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

sha1_array: let callbacks interrupt iterationJeff King Mon, 26 Sep 2016 12:00:29 +0000 (08:00 -0400)

sha1_array: let callbacks interrupt iteration

The callbacks for iterating a sha1_array must have a void
return. This is unlike our usual for_each semantics, where
a callback may interrupt iteration and have its value
propagated. Let's switch it to the usual form, which will
enable its use in more places (e.g., where we are replacing
an existing iteration with a different data structure).

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

get_short_sha1: mark ambiguity error for translationJeff King Mon, 26 Sep 2016 12:00:14 +0000 (08:00 -0400)

get_short_sha1: mark ambiguity error for translation

This is a human-readable message, and there's no reason it
should not be translated. While we're at it, let's drop the
period from the end, which is not our usual style.

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

get_short_sha1: NUL-terminate hex prefixJeff King Mon, 26 Sep 2016 12:00:07 +0000 (08:00 -0400)

get_short_sha1: NUL-terminate hex prefix

We store the hex prefix in a 40-byte buffer with the prefix
itself followed by 40-minus-len "x" characters. These x's
serve no purpose, and the lack of NUL termination makes the
prefix string annoying to use. Let's just terminate it.

Note that this is in contrast to the binary prefix, which
_must_ be zero-padded, because we look at the whole thing
during a binary search to find the first potential match in
each pack index. The loose-object hex search cannot use the
same trick because it has to do a linear walk through the
unsorted results of readdir() (and even if it could, you'd
want zeroes instead of x's).

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

get_short_sha1: refactor init of disambiguation codeJeff King Mon, 26 Sep 2016 12:00:04 +0000 (08:00 -0400)

get_short_sha1: refactor init of disambiguation code

The disambiguation machinery has two callers: get_short_sha1
and for_each_abbrev. Both need to repeat much of the same
setup: declaring buffers, sanity-checking lengths, preparing
the prefixes, etc. Let's pull that into a single init
function so we can avoid repeating ourselves.

Pulling the buffers into the "struct disambiguate_state"
isn't strictly necessary, but it does make things simpler
for the callers, who no longer have to worry about sizing
them correctly (i.e., it's an implicit requirement that
the caller provide 20- and 40-byte buffers).

And while we're touching this code, we can convert any
magic-number sizes to the more modern GIT_SHA1_* constants.

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

get_short_sha1: parse tags when looking for treeishJeff King Mon, 26 Sep 2016 11:59:48 +0000 (07:59 -0400)

get_short_sha1: parse tags when looking for treeish

The treeish disambiguation function tries to peel tags, but
it does so by calling:

deref_tag(lookup_object(sha1), ...);

This will only work if we have previously looked at the tag
and created a "struct tag" for it. Since parsing revision
arguments typically happens before anything else, this is
usually not the case, and we would fail to peel the tag (we
are lucky that deref_tag() gracefully handles the NULL and
does not segfault).

Instead, we can use parse_object(). Note that this is the
same fix done by 94d75d1 (get_short_sha1(): correctly
disambiguate type-limited abbreviation, 2013-07-01), but
that commit fixed only the committish disambiguator, and
left the bug in the treeish one.

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

get_sha1: propagate flags to child functionsJeff King Mon, 26 Sep 2016 11:59:41 +0000 (07:59 -0400)

get_sha1: propagate flags to child functions

The get_sha1() function is actually implementation by many
sub-functions, but we do not always pass our flags around to
all of those functions. As a result, we may forget that our
caller asked us to resolve with GET_SHA1_QUIETLY and output
messages. The two triggerable cases are:

1. Resolving treeish:path will resolve the "treeish"
portion using GET_SHA1_TREEISH, dropping all other
flags.

2. The peel_onion() function did not take flags at all
but recurses to get_sha1_1(), which does.

The solution for both is to bitwise-OR their new flags with
the existing ones (after dropping any mutually exclusive
disambiguation flags).

This bug can trigger with "git rev-parse --quiet", which
asks for quiet resolution. But it can also happen in a more
vanilla code path when we do a follow-up ONLY_TO_DIE
invocation of get_sha1(), and that's what the tests check.

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

get_sha1: avoid repeating ourselves via ONLY_TO_DIEJeff King Mon, 26 Sep 2016 11:59:15 +0000 (07:59 -0400)

get_sha1: avoid repeating ourselves via ONLY_TO_DIE

When the revision code cannot parse an argument like
"HEAD:foo", it will call maybe_die_on_misspelt_object_name(),
which re-runs get_sha1() with an extra ONLY_TO_DIE flag. We
then spend more effort to generate a better error message.

Unfortunately, a side effect is that our second call may
repeat the same error messages from the original get_sha1()
call. You can see this with:

$ git show 0017
error: short SHA1 0017 is ambiguous.
error: short SHA1 0017 is ambiguous.
fatal: ambiguous argument '0017': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

where the second "error:" line comes from the ONLY_TO_DIE
call.

To fix this, we can make ONLY_TO_DIE imply QUIETLY. This is
a little odd, because the whole point of ONLY_TO_DIE is to
output error messages. But what we want to do is tell the
rest of the get_sha1() code (particularly get_sha1_1()) that
the _regular_ messages should be quiet, but the only-to-die
ones should not.

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

get_sha1: detect buggy calls with multiple disambiguatorsJeff King Mon, 26 Sep 2016 11:59:01 +0000 (07:59 -0400)

get_sha1: detect buggy calls with multiple disambiguators

The get_sha1() family of functions takes a flags field, but
some of the flags are mutually exclusive. In particular, we
can only handle one disambiguating function, and the flags
quietly override each other. Let's instead detect these as
programming bugs.

Technically some of the flags are supersets of the others,
so treating COMMITTISH|TREEISH as just COMMITTISH is not
wrong, but it's a good sign the caller is confused. And
certainly asking for BLOB|TREE does not work.

We can do the check easily with some bit-twiddling, and as a
bonus, the bit-mask of disambiguators will come in handy in
a future patch.

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

unpack_sha1_header(): detect malformed object headerJunio C Hamano Mon, 26 Sep 2016 04:29:04 +0000 (21:29 -0700)

unpack_sha1_header(): detect malformed object header

When opening a loose object file, we often do this sequence:

- prepare a short buffer for the object header (on stack)

- call unpack_sha1_header() and have early part of the object data
inflated, enough to fill the buffer

- parse that data in the short buffer, assuming that the first part
of the object is <typename> SP <length> NUL

Because the parsing function parse_sha1_header_extended() is not
given the number of bytes inflated into the header buffer, it you
craft a file whose early part inflates a garbage sequence without SP
or NUL, and replace a loose object with it, it will end up reading
past the end of the inflated data.

To correct this, do the following four things:

- rename unpack_sha1_header() to unpack_sha1_short_header() and
have unpack_sha1_header_to_strbuf() keep calling that as its
helper function. This will detect and report zlib errors, but is
not aware of the format of a loose object (as before).

- introduce unpack_sha1_header() that calls the same helper
function, and when zlib reports it inflated OK into the buffer,
check if the inflated data has NUL. This would ensure that
parsing function will terminate within the buffer that holds the
inflated header.

- update unpack_sha1_header_to_strbuf() to check if the resulting
buffer has NUL for the same effect.

- update parse_sha1_header_extended() to make sure that its loop to
find the SP that terminates the <typename> stops at NUL.

Essentially, this makes unpack_*() functions that are asked to
unpack a loose object header to be a bit more strict and detect an
input that cannot possibly be a valid object header, even before the
parsing function kicks in.

Reported-by: Gustavo Grieco <gustavo.grieco@imag.fr>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

streaming: make sure to notice corrupt objectJunio C Hamano Mon, 26 Sep 2016 16:23:41 +0000 (09:23 -0700)

streaming: make sure to notice corrupt object

The streaming read interface from a loose object called
parse_sha1_header() but discarded its return value, without noticing
a potential error.

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

Merge branch 'va/i18n' of ../git-gui into va/git-gui... Junio C Hamano Mon, 26 Sep 2016 14:19:57 +0000 (07:19 -0700)

Merge branch 'va/i18n' of ../git-gui into va/git-gui-i18n

* 'va/i18n' of ../git-gui:
git-gui: l10n: add Portuguese translation
git-gui i18n: mark strings for translation

git-gui: l10n: add Portuguese translationVasco Almeida Fri, 6 May 2016 16:06:42 +0000 (16:06 +0000)

git-gui: l10n: add Portuguese translation

Add Portuguese glossary.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-gui i18n: mark strings for translationVasco Almeida Sun, 8 May 2016 10:52:54 +0000 (10:52 +0000)

git-gui i18n: mark strings for translation

Mark strings for translation in lib/index.tcl that were seemingly
left behind by 700e560 ("git-gui: Mark forgotten strings for
translation.", 2008-09-04) which marks string in do_revert_selection
procedure.
These strings are passed to unstage_help and add_helper procedures.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'rs/use-modern-git-merge-syntax' of git... Junio C Hamano Mon, 26 Sep 2016 14:16:29 +0000 (07:16 -0700)

Merge branch 'rs/use-modern-git-merge-syntax' of git-gui into rs/git-gui-use-modern-git-merge-syntax

* 'rs/use-modern-git-merge-syntax' of git-gui:
git-gui: stop using deprecated merge syntax

git-gui: stop using deprecated merge syntaxRené Scharfe Sat, 24 Sep 2016 11:30:22 +0000 (13:30 +0200)

git-gui: stop using deprecated merge syntax

Starting with v2.5.0 git merge can handle FETCH_HEAD internally and
warns when it's called like 'git merge <message> HEAD <commit>' because
that syntax is deprecated. Use this feature in git-gui and get rid of
that warning.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use COPY_ARRAYRené Scharfe Sun, 25 Sep 2016 07:24:03 +0000 (09:24 +0200)

use COPY_ARRAY

Add a semantic patch for converting certain calls of memcpy(3) to
COPY_ARRAY() and apply that transformation to the code base. The result
is
shorter and safer code. For now only consider calls where source and
destination have the same type, or in other words: easy cases.

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

add COPY_ARRAYRené Scharfe Sun, 25 Sep 2016 07:15:42 +0000 (09:15 +0200)

add COPY_ARRAY

Add COPY_ARRAY, a safe and convenient helper for copying arrays,
complementing ALLOC_ARRAY and REALLOC_ARRAY. Users just specify source,
destination and the number of elements; the size of an element is
inferred automatically.

It checks if the multiplication of size and element count overflows.
The inferred size is passed first to st_mult, which allows the division
there to be done at compilation time.

As a basic type safety check it makes sure the sizes of source and
destination elements are the same. That's evaluated at compilation time
as well.

COPY_ARRAY is safe to use with NULL as source pointer iff 0 elements are
to be copied. That convention is used in some cases for initializing
arrays. Raw memcpy(3) does not support it -- compilers are allowed to
assume that only valid pointers are passed to it and can optimize away
NULL checks after such a call.

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

gitweb: use highlight's shebang detectionIan Kelling Sat, 24 Sep 2016 22:32:58 +0000 (15:32 -0700)

gitweb: use highlight's shebang detection

The "highlight" binary can, in some cases, determine the language type
by the means of file contents, for example the shebang in the first line
for some scripting languages. Make use of this autodetection for files
which syntax is not known by gitweb. In that case, pass the blob
contents to "highlight --force"; the parameter is needed to make it
always generate HTML output (which includes HTML-escaping).

Although we now run highlight on files which do not end up highlighted,
performance is virtually unaffected because when we call highlight, it
is used for escaping HTML. In the case that highlight is used, gitweb
calls sanitize() instead of esc_html(), and the latter is significantly
slower (it does more, being roughly a superset of sanitize()). Simple
benchmark comparing performance of 'blob' view of files without syntax
highlighting in gitweb before and after this change indicates ±1%
difference in request time for all file types. Benchmark was performed
on local instance on Debian, using Apache/2.4.23 web server and CGI.

Document the feature and improve syntax highlight documentation, add
test to ensure gitweb doesn't crash when language detection is used.

Signed-off-by: Ian Kelling <ian@iankelling.org>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: remove unused guess_file_syntax() parameterIan Kelling Sat, 24 Sep 2016 22:32:57 +0000 (15:32 -0700)

gitweb: remove unused guess_file_syntax() parameter

Signed-off-by: Ian Kelling <ian@iankelling.org>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

init: kill git_link variableNguyễn Thái Ngọc Duy Sun, 25 Sep 2016 03:14:40 +0000 (10:14 +0700)

init: kill git_link variable

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

init: do not set unnecessary core.worktreeNguyễn Thái Ngọc Duy Sun, 25 Sep 2016 03:14:39 +0000 (10:14 +0700)

init: do not set unnecessary core.worktree

The function needs_work_tree_config() that is called from
create_default_files() is supposed to be fed the path to ".git" that
looks as if it is at the top of the working tree, and decide if that
location matches the actual worktree being used. This comparison allows
"git init" to decide if core.worktree needs to be recorded in the
working tree.

In the current code, however, we feed the return value from
get_git_dir(), which can be totally different from what the function
expects when "gitdir" file is involved. Instead of giving the path to
the ".git" at the top of the working tree, we end up feeding the actual
path that the file points at.

This original location of ".git" however is only known to init_db().
Make init_db() save it and have it passed to create_default_files() as a
new parameter, which passes the correct location down to
needs_work_tree_config() to fix this.

Noticed-by: Max Nordlund <max.nordlund@sqore.com>
Helped-by: Michael J Gruber <git@drmicha.warpmail.net>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

init: kill set_git_dir_init()Nguyễn Thái Ngọc Duy Sun, 25 Sep 2016 03:14:38 +0000 (10:14 +0700)

init: kill set_git_dir_init()

This is a pure code move, necessary to kill the global variable git_link
later (and also helps a bit in the next patch).

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

init: call set_git_dir_init() from within init_db()Nguyễn Thái Ngọc Duy Sun, 25 Sep 2016 03:14:37 +0000 (10:14 +0700)

init: call set_git_dir_init() from within init_db()

The next commit requires that set_git_dir_init() must be called before
init_db(). Let's make sure nobody can do otherwise.

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

init: correct re-initialization from a linked worktreeNguyễn Thái Ngọc Duy Sun, 25 Sep 2016 03:14:36 +0000 (10:14 +0700)

init: correct re-initialization from a linked worktree

When 'git init' is called from a linked worktree, we treat '.git'
dir (which is $GIT_COMMON_DIR/worktrees/something) as the main
'.git' (i.e. $GIT_COMMON_DIR) and populate the whole repository skeleton
in there. It does not harm anything (*) but it is still wrong.

Since 'git init' calls set_git_dir() at preparation time, which
indirectly calls get_common_dir() and correctly detects multiple
worktree setup, all git_path_buf() calls in create_default_files() will
return correct paths in both single and multiple worktree setups. The
only thing left is copy_templates(), which targets $GIT_DIR, not
$GIT_COMMON_DIR.

Fix that with get_git_common_dir(). This function will return $GIT_DIR
in single-worktree setup, so we don't have to make a special case for
multiple-worktree here.

(*) It does in fact, thanks to another bug. More on that later.

Noticed-by: Max Nordlund <max.nordlund@sqore.com>
Helped-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch-pack: do not reset in_vain on non-novel acksJonathan Tan Fri, 23 Sep 2016 17:41:35 +0000 (10:41 -0700)

fetch-pack: do not reset in_vain on non-novel acks

The MAX_IN_VAIN mechanism was introduced in commit f061e5f ("fetch-pack:
give up after getting too many "ack continue"", 2006-05-24) to stop ref
negotiation if a number of consecutive "have"s have been sent with no
corresponding new acks. This is to stop the client from digging too deep
in an irrelevant side branch in vain without ever finding a common
ancestor. A use case (as described in that commit) is the scenario in
which the local repository has more roots than the remote repository.

However, during a negotiation in which stateless RPCs are used,
MAX_IN_VAIN will (almost) never trigger (in the more-roots scenario
above and others) because in each new request, the client has to inform
the server of objects it already has and knows the server has (to remind
the server of the state), which the server then acks.

Make fetch-pack only consider, as new acks for the purpose of
MAX_IN_VAIN, acks for objects for which the client has never received an
ack before in this session.

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

ident: handle NULL ai_canonnameJeff King Fri, 23 Sep 2016 04:37:53 +0000 (00:37 -0400)

ident: handle NULL ai_canonname

We call getaddrinfo() to try to convert a short hostname
into a fully-qualified one (to use it as an email domain).
If there isn't a canonical name, getaddrinfo() will
generally return either a NULL addrinfo list, or one in
which ai->ai_canonname is a copy of the original name.

However, if the result of gethostname() looks like an IP
address, then getaddrinfo() behaves differently on some
systems. On OS X, it will return a "struct addrinfo" with a
NULL ai_canonname, and we segfault feeding it to strchr().

This is hard to test reliably because it involves not only a
system where we we have to fallback to gethostname() to come
up with an ident, but also where the hostname is a number
with no dots. But I was able to replicate the bug by faking
a hostname, like:

diff --git a/ident.c b/ident.c
index e20a772..b790d28 100644
--- a/ident.c
+++ b/ident.c
@@ -128,6 +128,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)
*is_bogus = 1;
return;
}
+ xsnprintf(buf, sizeof(buf), "1");
if (strchr(buf, '.'))
strbuf_addstr(out, buf);
else if (canonical_name(buf, out) < 0) {

and running "git var GIT_AUTHOR_IDENT" on an OS X system.

Before this patch it segfaults, and after we correctly
complain of the bogus "user@1.(none)" address (though this
bogus address would be suitable for non-object uses like
writing reflogs).

Reported-by: Jonas Thiel <jonas.lierschied@gmx.de>
Diagnosed-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

introduce CHECKOUT_INITRené Scharfe Thu, 22 Sep 2016 16:11:33 +0000 (18:11 +0200)

introduce CHECKOUT_INIT

Add a static initializer for struct checkout and use it throughout the
code base. It's shorter, avoids a memset(3) call and makes sure the
base_dir member is initialized to a valid (empty) string.

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

docs/cvs-migration: mention cvsimport caveatsJeff King Thu, 22 Sep 2016 07:26:28 +0000 (03:26 -0400)

docs/cvs-migration: mention cvsimport caveats

Back when this guide was written, cvsimport was the only
game in town. These days it is probably not the best option.
Rather than go into details, let's point people to the note
at the top of cvsimport which gives other options.

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

docs/cvs-migration: update link to cvsps homepageJeff King Thu, 22 Sep 2016 07:26:07 +0000 (03:26 -0400)

docs/cvs-migration: update link to cvsps homepage

The old page gives a 404 now. Searching for "cvsps" via
Google returns a GitHub project page as the top hit.

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

docs/cvsimport: prefer cvs-fast-export to parsecvsJeff King Thu, 22 Sep 2016 07:25:28 +0000 (03:25 -0400)

docs/cvsimport: prefer cvs-fast-export to parsecvs

parsecvs maintenance was taken over by ESR, and the name
changed to cvs-fast-export as it learned to support that
output format. Let's point to cvs-fast-export, as it should
have additional bug-fixes and be more convenient to use.

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

clone: pass --progress decision to recursive submodulesJeff King Thu, 22 Sep 2016 05:24:46 +0000 (01:24 -0400)

clone: pass --progress decision to recursive submodules

When cloning with "--recursive", we'd generally expect
submodules to show progress reports if the main clone did,
too.

In older versions of git, this mostly worked out of the
box. Since we show progress by default when stderr is a tty,
and since the child clones inherit the parent stderr, then
both processes would come to the same decision by default.
If the parent clone was asked for "--quiet", we passed down
"--quiet" to the child. However, if stderr was not a tty and
the user specified "--progress", we did not propagate this
to the child.

That's a minor bug, but things got much worse when we
switched recently to submodule--helper's update_clone
command. With that change, the stderr of the child clones
are always connected to a pipe, and we never output
progress at all.

This patch teaches git-submodule and git-submodule--helper
how to pass down an explicit "--progress" flag when cloning.
The clone command then decides to propagate that flag based
on the cloning decision made earlier (which takes into
account isatty(2) of the parent process, existing --progress
or --quiet flags, etc). Since the child processes always run
without a tty on stderr, we don't have to worry about
passing an explicit "--no-progress"; it's the default for
them.

This fixes the recent loss of progress during recursive
clones. And as a bonus, it makes:

git clone --recursive --progress ... 2>&1 | cat

work by triggering progress explicitly in the children.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

verify_packfile: check pack validity before accessing... Jeff King Thu, 22 Sep 2016 03:49:05 +0000 (23:49 -0400)

verify_packfile: check pack validity before accessing data

The verify_packfile() does not explicitly open the packfile;
instead, it starts with a sha1 checksum over the whole pack,
and relies on use_pack() to open the packfile as a side
effect.

If the pack cannot be opened for whatever reason (either
because its header information is corrupted, or perhaps
because a simultaneous repack deleted it), then use_pack()
will die(), as it has no way to return an error. This is not
ideal, as verify_packfile() otherwise tries to gently return
an error (this lets programs like git-fsck go on to check
other packs).

Instead, let's check is_pack_valid() up front, and return an
error if it fails. This will open the pack as a side effect,
and then use_pack() will later rely on our cached
descriptor, and avoid calling die().

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

travis-ci: ask homebrew for its path instead of hardcod... Lars Schneider Wed, 21 Sep 2016 08:45:18 +0000 (10:45 +0200)

travis-ci: ask homebrew for its path instead of hardcoding it

The TravisCI macOS build is broken because homebrew (a macOS dependency
manager) changed its internal directory structure [1]. This is a problem
because we modify the Perforce dependencies in the homebrew repository
before installing them.

Fix it by asking homebrew for its path instead of hardcoding it.

[1] https://github.com/Homebrew/brew/commit/0a09ae30f8b6117ad699b4a0439010738989c547

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

Fourth batch for 2.11Junio C Hamano Wed, 21 Sep 2016 22:20:44 +0000 (15:20 -0700)

Fourth batch for 2.11

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

Merge branch 'jk/reduce-gc-aggressive-depth'Junio C Hamano Wed, 21 Sep 2016 22:15:29 +0000 (15:15 -0700)

Merge branch 'jk/reduce-gc-aggressive-depth'

"git gc --aggressive" used to limit the delta-chain length to 250,
which is way too deep for gaining additional space savings and is
detrimental for runtime performance. The limit has been reduced to
50.

* jk/reduce-gc-aggressive-depth:
gc: default aggressive depth to 50

Merge branch 'jk/rebase-i-drop-ident-check'Junio C Hamano Wed, 21 Sep 2016 22:15:28 +0000 (15:15 -0700)

Merge branch 'jk/rebase-i-drop-ident-check'

Even when "git pull --rebase=preserve" (and the underlying "git
rebase --preserve") can complete without creating any new commit
(i.e. fast-forwards), it still insisted on having a usable ident
information (read: user.email is set correctly), which was less
than nice. As the underlying commands used inside "git rebase"
would fail with a more meaningful error message and advice text
when the bogus ident matters, this extra check was removed.

* jk/rebase-i-drop-ident-check:
rebase-interactive: drop early check for valid ident

Merge branch 'va/i18n'Junio C Hamano Wed, 21 Sep 2016 22:15:28 +0000 (15:15 -0700)

Merge branch 'va/i18n'

More i18n.

* va/i18n:
i18n: update-index: mark warnings for translation
i18n: show-branch: mark plural strings for translation
i18n: show-branch: mark error messages for translation
i18n: receive-pack: mark messages for translation
notes: spell first word of error messages in lowercase
i18n: notes: mark error messages for translation
i18n: merge-recursive: mark verbose message for translation
i18n: merge-recursive: mark error messages for translation
i18n: config: mark error message for translation
i18n: branch: mark option description for translation
i18n: blame: mark error messages for translation

Merge branch 'jt/format-patch-base-info-above-sig'Junio C Hamano Wed, 21 Sep 2016 22:15:27 +0000 (15:15 -0700)

Merge branch 'jt/format-patch-base-info-above-sig'

"git format-patch --base=..." feature that was recently added
showed the base commit information after "-- " e-mail signature
line, which turned out to be inconvenient. The base information
has been moved above the signature line.

* jt/format-patch-base-info-above-sig:
format-patch: show base info before email signature

Merge branch 'ks/perf-build-with-autoconf'Junio C Hamano Wed, 21 Sep 2016 22:15:27 +0000 (15:15 -0700)

Merge branch 'ks/perf-build-with-autoconf'

Performance tests done via "t/perf" did not use the same set of
build configuration if the user relied on autoconf generated
configuration.

* ks/perf-build-with-autoconf:
t/perf/run: copy config.mak.autogen & friends to build area

Merge branch 'mr/vcs-svn-printf-ulong'Junio C Hamano Wed, 21 Sep 2016 22:15:27 +0000 (15:15 -0700)

Merge branch 'mr/vcs-svn-printf-ulong'

Code cleanup.

* mr/vcs-svn-printf-ulong:
vcs-svn/fast_export: fix timestamp fmt specifiers

Merge branch 'rs/xdiff-merge-overlapping-hunks-for... Junio C Hamano Wed, 21 Sep 2016 22:15:26 +0000 (15:15 -0700)

Merge branch 'rs/xdiff-merge-overlapping-hunks-for-W-context'

"git diff -W" output needs to extend the context backward to
include the header line of the current function and also forward to
include the body of the entire current function up to the header
line of the next one. This process may have to merge to adjacent
hunks, but the code forgot to do so in some cases.

* rs/xdiff-merge-overlapping-hunks-for-W-context:
xdiff: fix merging of hunks with -W context and -u context

Merge branch 'rs/unpack-trees-reduce-file-scope-global'Junio C Hamano Wed, 21 Sep 2016 22:15:26 +0000 (15:15 -0700)

Merge branch 'rs/unpack-trees-reduce-file-scope-global'

Code cleanup.

* rs/unpack-trees-reduce-file-scope-global:
unpack-trees: pass checkout state explicitly to check_updates()

Merge branch 'rs/strbuf-remove-fix'Junio C Hamano Wed, 21 Sep 2016 22:15:25 +0000 (15:15 -0700)

Merge branch 'rs/strbuf-remove-fix'

Code cleanup.

* rs/strbuf-remove-fix:
strbuf: use valid pointer in strbuf_remove()

Merge branch 'rs/pack-sort-with-llist-mergesort'Junio C Hamano Wed, 21 Sep 2016 22:15:25 +0000 (15:15 -0700)

Merge branch 'rs/pack-sort-with-llist-mergesort'

Code cleanup.

* rs/pack-sort-with-llist-mergesort:
sha1_file: use llist_mergesort() for sorting packs

Merge branch 'rs/checkout-some-states-are-const'Junio C Hamano Wed, 21 Sep 2016 22:15:24 +0000 (15:15 -0700)

Merge branch 'rs/checkout-some-states-are-const'

Code cleanup.

* rs/checkout-some-states-are-const:
checkout: constify parameters of checkout_stage() and checkout_merged()

Merge branch 'jk/setup-sequence-update'Junio C Hamano Wed, 21 Sep 2016 22:15:23 +0000 (15:15 -0700)

Merge branch 'jk/setup-sequence-update'

There were numerous corner cases in which the configuration files
are read and used or not read at all depending on the directory a
Git command was run, leading to inconsistent behaviour. The code
to set-up repository access at the beginning of a Git process has
been updated to fix them.

* jk/setup-sequence-update:
t1007: factor out repeated setup
init: reset cached config when entering new repo
init: expand comments explaining config trickery
config: only read .git/config from configured repos
test-config: setup git directory
t1302: use "git -C"
pager: handle early config
pager: use callbacks instead of configset
pager: make pager_program a file-local static
pager: stop loading git_default_config()
pager: remove obsolete comment
diff: always try to set up the repository
diff: handle --no-index prefixes consistently
diff: skip implicit no-index check when given --no-index
patch-id: use RUN_SETUP_GENTLY
hash-object: always try to set up the git repository

Merge branch 'ew/http-do-not-forget-to-call-curl-multi... Junio C Hamano Wed, 21 Sep 2016 22:15:23 +0000 (15:15 -0700)

Merge branch 'ew/http-do-not-forget-to-call-curl-multi-remove-handle'

The http transport (with curl-multi option, which is the default
these days) failed to remove curl-easy handle from a curlm session,
which led to unnecessary API failures.

* ew/http-do-not-forget-to-call-curl-multi-remove-handle:
http: always remove curl easy from curlm session on release
http: consolidate #ifdefs for curl_multi_remove_handle
http: warn on curl_multi_add_handle failures

Merge branch 'bw/pathspec-remove-unused-extern-decl'Junio C Hamano Wed, 21 Sep 2016 22:15:22 +0000 (15:15 -0700)

Merge branch 'bw/pathspec-remove-unused-extern-decl'

Code cleanup.

* bw/pathspec-remove-unused-extern-decl:
pathspec: remove unnecessary function prototypes

Merge branch 'ks/pack-objects-bitmap'Junio C Hamano Wed, 21 Sep 2016 22:15:21 +0000 (15:15 -0700)

Merge branch 'ks/pack-objects-bitmap'

Some codepaths in "git pack-objects" were not ready to use an
existing pack bitmap; now they are and as the result they have
become faster.

* ks/pack-objects-bitmap:
pack-objects: use reachability bitmap index when generating non-stdout pack
pack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use

Merge branch 'jk/patch-ids-no-merges'Junio C Hamano Wed, 21 Sep 2016 22:15:20 +0000 (15:15 -0700)

Merge branch 'jk/patch-ids-no-merges'

"git log --cherry-pick" used to include merge commits as candidates
to be matched up with other commits, resulting a lot of wasted time.
The patch-id generation logic has been updated to ignore merges to
avoid the wastage.

* jk/patch-ids-no-merges:
patch-ids: refuse to compute patch-id for merge commit
patch-ids: turn off rename detection

Merge branch 'jk/delta-base-cache'Junio C Hamano Wed, 21 Sep 2016 22:15:20 +0000 (15:15 -0700)

Merge branch 'jk/delta-base-cache'

Recently we updated the code to manage the in-core cache that holds
objects that have recently been used to reconstitute other objects
that are stored as deltas against them, but the update used an
incorrect API function to manage the list of these objects. This
has been fixed.

* jk/delta-base-cache:
add_delta_base_cache: use list_for_each_safe

Merge branch 'et/add-chmod-x'Junio C Hamano Wed, 21 Sep 2016 22:15:19 +0000 (15:15 -0700)

Merge branch 'et/add-chmod-x'

"git add --chmod=+x" added recently lacked documentation, which has
been corrected.

* et/add-chmod-x:
add: document the chmod option

Merge branch 'js/cat-file-filters'Junio C Hamano Wed, 21 Sep 2016 22:15:18 +0000 (15:15 -0700)

Merge branch 'js/cat-file-filters'

Even though "git hash-objects", which is a tool to take an
on-filesystem data stream and put it into the Git object store,
allowed to perform the "outside-world-to-Git" conversions (e.g.
end-of-line conversions and application of the clean-filter), and
it had the feature on by default from very early days, its reverse
operation "git cat-file", which takes an object from the Git object
store and externalize for the consumption by the outside world,
lacked an equivalent mechanism to run the "Git-to-outside-world"
conversion. The command learned the "--filters" option to do so.

* js/cat-file-filters:
cat-file: support --textconv/--filters in batch mode
cat-file --textconv/--filters: allow specifying the path separately
cat-file: introduce the --filters option
cat-file: fix a grammo in the man page

Merge branch 'jt/accept-capability-advertisement-when... Junio C Hamano Wed, 21 Sep 2016 22:15:17 +0000 (15:15 -0700)

Merge branch 'jt/accept-capability-advertisement-when-fetching-from-void'

JGit can show a fake ref "capabilities^{}" to "git fetch" when it
does not advertise any refs, but "git fetch" was not prepared to
see such an advertisement. When the other side disconnects without
giving any ref advertisement, we used to say "there may not be a
repository at that URL", but we may have seen other advertisement
like "shallow" and ".have" in which case we definitely know that a
repository is there. The code to detect this case has also been
updated.

* jt/accept-capability-advertisement-when-fetching-from-void:
connect: advertized capability is not a ref
connect: tighten check for unexpected early hang up
tests: move test_lazy_prereq JGIT to test-lib.sh

t3700-add: do not check working tree file mode without... Johannes Sixt Tue, 20 Sep 2016 06:18:25 +0000 (08:18 +0200)

t3700-add: do not check working tree file mode without POSIXPERM

A recently introduced test checks the result of 'git status' after
setting the executable bit on a file. This check does not yield the
expected result when the filesystem does not support the executable
bit.

What we care about is that a file added with "--chmod=+x" has
executable bit in the index and that "--chmod=+x" (or any other
options for that matter) does not muck with working tree files.
The former is tested by other existing tests, so let's check the
latter more explicitly and only under POSIXPERM prerequisite.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

regex: use regexec_buf()Johannes Schindelin Wed, 21 Sep 2016 18:24:14 +0000 (20:24 +0200)

regex: use regexec_buf()

The new regexec_buf() function operates on buffers with an explicitly
specified length, rather than NUL-terminated strings.

We need to use this function whenever the buffer we want to pass to
regexec(3) may have been mmap(2)ed (and is hence not NUL-terminated).

Note: the original motivation for this patch was to fix a bug where
`git diff -G <regex>` would crash. This patch converts more callers,
though, some of which allocated to construct NUL-terminated strings,
or worse, modified buffers to temporarily insert NULs while calling
regexec(3). By converting them to use regexec_buf(), the code has
become much cleaner.

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

regex: add regexec_buf() that can work on a non NUL... Johannes Schindelin Wed, 21 Sep 2016 18:24:04 +0000 (20:24 +0200)

regex: add regexec_buf() that can work on a non NUL-terminated string

We just introduced a test that demonstrates that our sloppy use of
regexec() on a mmap()ed area can result in incorrect results or even
hard crashes.

So what we need to fix this is a function that calls regexec() on a
length-delimited, rather than a NUL-terminated, string.

Happily, there is an extension to regexec() introduced by the NetBSD
project and present in all major regex implementation including
Linux', MacOSX' and the one Git includes in compat/regex/: by using
the (non-POSIX) REG_STARTEND flag, it is possible to tell the
regexec() function that it should only look at the offsets between
pmatch[0].rm_so and pmatch[0].rm_eo.

That is exactly what we need.

Since support for REG_STARTEND is so widespread by now, let's just
introduce a helper function that always uses it, and tell people
on a platform whose regex library does not support it to use the
one from our compat/regex/ directory.

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

regex: -G<pattern> feeds a non NUL-terminated string... Johannes Schindelin Wed, 21 Sep 2016 18:23:22 +0000 (20:23 +0200)

regex: -G<pattern> feeds a non NUL-terminated string to regexec() and fails

When our pickaxe code feeds file contents to regexec(), it implicitly
assumes that the file contents are read into implicitly NUL-terminated
buffers (i.e. that we overallocate by 1, appending a single '\0').

This is not so.

In particular when the file contents are simply mmap()ed, we can be
virtually certain that the buffer is preceding uninitialized bytes, or
invalid pages.

Note that the test we add here is known to be flakey: we simply cannot
know whether the byte following the mmap()ed ones is a NUL or not.

Typically, on Linux the test passes. On Windows, it fails virtually
every time due to an access violation (that's a segmentation fault for
you Unix-y people out there). And Windows would be correct: the
regexec() call wants to operate on a regular, NUL-terminated string,
there is no NUL in the mmap()ed memory range, and it is undefined
whether the next byte is even legal to access.

When run with --valgrind it demonstrates quite clearly the breakage, of
course.

Being marked with `test_expect_failure`, this test will sometimes be
declare "TODO fixed", even if it only passes by mistake.

This test case represents a Minimal, Complete and Verifiable Example of
a breakage reported by Chris Sidi.

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

git-check-ref-format.txt: fixup documentationElia Pinto Tue, 20 Sep 2016 07:33:14 +0000 (07:33 +0000)

git-check-ref-format.txt: fixup documentation

die is not a standard shell function. Use
a different shell code for the example.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t3700-add: create subdirectory gentlyJohannes Sixt Tue, 20 Sep 2016 06:16:11 +0000 (08:16 +0200)

t3700-add: create subdirectory gently

The subdirectory 'sub' is created early in the test file. Later, a test
case removes it during its clean-up actions. However, this test case is
protected by POSIXPERM. Consequently, 'sub' remains when the POSIXPERM
prerequisite is not satisfied. Later, a recently introduced test case
creates 'sub' again. Use -p with mkdir so that it does not fail if 'sub'
already exists.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mailinfo: handle in-body header continuationsJonathan Tan Tue, 20 Sep 2016 17:17:53 +0000 (10:17 -0700)

mailinfo: handle in-body header continuations

Mailinfo currently handles multi-line headers, but it does not handle
multi-line in-body headers. Teach it to handle such headers, for
example, for this input:

From: author <author@example.com>
Date: Fri, 9 Jun 2006 00:44:16 -0700
Subject: a very long
broken line

Subject: another very long
broken line

interpret the in-body subject to be "another very long broken line"
instead of "another very long".

An existing test (t/t5100/msg0015) has an indented line immediately
after an in-body header - it has been modified to reflect the new
functionality.

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

i18n: stash: mark messages for translationVasco Almeida Mon, 19 Sep 2016 13:08:21 +0000 (13:08 +0000)

i18n: stash: mark messages for translation

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: notes-merge: mark die messages for translationVasco Almeida Mon, 19 Sep 2016 13:08:20 +0000 (13:08 +0000)

i18n: notes-merge: mark die messages for translation

Update test to reflect changes.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: ident: mark hint for translationVasco Almeida Mon, 19 Sep 2016 13:08:19 +0000 (13:08 +0000)

i18n: ident: mark hint for translation

Mark env_hint for translation.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: i18n: diff: mark die messages for translationJean-Noël AVILA Tue, 20 Sep 2016 19:04:27 +0000 (21:04 +0200)

i18n: i18n: diff: mark die messages for translation

While marking individual messages for translation, consolidate some
messages "option 'foo' requires a value" that is used for many
options into one by introducing a helper function to die with the
message with the option name embedded in it, and ask the translators
to localize that single message instead.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

format-patch: add "--rfc" for the common case of [RFC... Josh Triplett Tue, 20 Sep 2016 04:23:25 +0000 (21:23 -0700)

format-patch: add "--rfc" for the common case of [RFC PATCH]

Add an alias for --subject-prefix='RFC PATCH', which is used
commonly in some development communities to deserve such a
short-hand.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: fix ambiguity check in subdirNguyễn Thái Ngọc Duy Wed, 7 Sep 2016 11:19:41 +0000 (18:19 +0700)

checkout: fix ambiguity check in subdir

The two functions in parse_branchname_arg(), verify_non_filename and
check_filename, need correct prefix in order to reconstruct the paths
and check for their existence. With NULL prefix, they just check paths
at top dir instead.

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

checkout.txt: document a common case that ignores ambig... Nguyễn Thái Ngọc Duy Wed, 7 Sep 2016 11:19:40 +0000 (18:19 +0700)

checkout.txt: document a common case that ignores ambiguation rules

Normally we err on the safe side: if something can be seen as both an
SHA1 and a pathspec, we stop and scream. In checkout, there is one
exception added in 859fdab (git-checkout: improve error messages, detect
ambiguities. - 2008-07-23), to allow the common case "git checkout
branch". Let's document this exception.

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

mailinfo: make is_scissors_line take plain char *Jonathan Tan Mon, 19 Sep 2016 21:08:52 +0000 (14:08 -0700)

mailinfo: make is_scissors_line take plain char *

The is_scissors_line takes a struct strbuf * when a char * would
suffice. Make it take char *.

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

mailinfo: separate in-body header processingJonathan Tan Mon, 19 Sep 2016 21:08:50 +0000 (14:08 -0700)

mailinfo: separate in-body header processing

The check_header function contains logic specific to in-body headers,
although it is invoked during both the processing of actual headers and
in-body headers. Separate out the in-body header part into its own
function.

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

Sync with maintJunio C Hamano Mon, 19 Sep 2016 20:55:18 +0000 (13:55 -0700)

Sync with maint

* maint:
Start preparing for 2.10.1

Start preparing for 2.10.1Junio C Hamano Mon, 19 Sep 2016 20:54:50 +0000 (13:54 -0700)

Start preparing for 2.10.1

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

Merge branch 'sb/diff-cleanup' into maintJunio C Hamano Mon, 19 Sep 2016 20:51:45 +0000 (13:51 -0700)

Merge branch 'sb/diff-cleanup' into maint

Code cleanup.

* sb/diff-cleanup:
diff: remove dead code
diff: omit found pointer from emit_callback
diff.c: use diff_options directly

Merge branch 'ah/misc-message-fixes' into maintJunio C Hamano Mon, 19 Sep 2016 20:51:45 +0000 (13:51 -0700)

Merge branch 'ah/misc-message-fixes' into maint

Message cleanup.

* ah/misc-message-fixes:
unpack-trees: do not capitalize "working"
git-merge-octopus: do not capitalize "octopus"
git-rebase--interactive: fix English grammar
cat-file: put spaces around pipes in usage string
am: put spaces around pipe in usage string

Merge branch 'sb/transport-report-missing-submodule... Junio C Hamano Mon, 19 Sep 2016 20:51:45 +0000 (13:51 -0700)

Merge branch 'sb/transport-report-missing-submodule-on-stderr' into maint

Message cleanup.

* sb/transport-report-missing-submodule-on-stderr:
transport: report missing submodule pushes consistently on stderr