gitweb.git
t9813: avoid using pipesPranit Bauva Tue, 3 Jan 2017 19:57:08 +0000 (01:27 +0530)

t9813: avoid using pipes

The exit code of the upstream in a pipe is ignored thus we should avoid
using it. By writing out the output of the git command to a file, we can
test the exit codes of both the commands.

Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
Acked-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pathspec: rename prefix_pathspec to init_pathspec_itemBrandon Williams Wed, 4 Jan 2017 18:04:11 +0000 (10:04 -0800)

pathspec: rename prefix_pathspec to init_pathspec_item

Give a more relevant name to the prefix_pathspec function as it does
more than just prefix a pathspec element.

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

pathspec: small readability changesBrandon Williams Wed, 4 Jan 2017 18:04:10 +0000 (10:04 -0800)

pathspec: small readability changes

A few small changes to improve readability. This is done by grouping related
assignments, adding blank lines, ensuring lines are <80 characters, and
adding additional comments.

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

pathspec: create strip submodule slash helpersBrandon Williams Wed, 4 Jan 2017 18:04:09 +0000 (10:04 -0800)

pathspec: create strip submodule slash helpers

Factor out the logic responsible for stripping the trailing slash on
pathspecs referencing submodules into its own function.

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

pathspec: create parse_element_magic helperBrandon Williams Wed, 4 Jan 2017 18:04:08 +0000 (10:04 -0800)

pathspec: create parse_element_magic helper

Factor out the logic responsible for the magic in a pathspec element
into its own function.

Also avoid calling into the parsing functions when
`PATHSPEC_LITERAL_PATH` is specified since it causes magic to be
ignored and all paths to be treated as literals.

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

pathspec: create parse_long_magic functionBrandon Williams Wed, 4 Jan 2017 18:04:07 +0000 (10:04 -0800)

pathspec: create parse_long_magic function

Factor out the logic responsible for parsing long magic into its own
function. As well as hoist the prefix check logic outside of the inner
loop as there isn't anything that needs to be done after matching
"prefix:".

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

pathspec: create parse_short_magic functionBrandon Williams Wed, 4 Jan 2017 18:04:06 +0000 (10:04 -0800)

pathspec: create parse_short_magic function

Factor out the logic responsible for parsing short magic into its own
function.

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

pathspec: factor global magic into its own functionBrandon Williams Wed, 4 Jan 2017 18:04:05 +0000 (10:04 -0800)

pathspec: factor global magic into its own function

Create helper functions to read the global magic environment variables
in additon to factoring out the global magic gathering logic into its
own function.

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

pathspec: simpler logic to prefix original pathspec... Brandon Williams Wed, 4 Jan 2017 18:04:04 +0000 (10:04 -0800)

pathspec: simpler logic to prefix original pathspec elements

The logic used to prefix an original pathspec element with 'prefix'
magic is more general purpose and can be used for more than just short
magic. Remove the extra code paths and rename 'prefix_short_magic' to
'prefix_magic' to better indicate that it can be used in more general
situations.

Also, slightly change the logic which decides when to prefix the
original element in order to prevent a pathspec of "." from getting
converted to "" (empty string).

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

pathspec: always show mnemonic and name in unsupported_... Brandon Williams Wed, 4 Jan 2017 18:04:03 +0000 (10:04 -0800)

pathspec: always show mnemonic and name in unsupported_magic

For better clarity, always show the mnemonic and name of the unsupported
magic being used. This lets users have a more clear understanding of
what magic feature isn't supported. And if they supplied a mnemonic,
the user will be told what its corresponding name is which will allow
them to more easily search the man pages for that magic type.

This also avoids passing an extra parameter around the pathspec
initialization code.

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

pathspec: remove unused variable from unsupported_magicBrandon Williams Wed, 4 Jan 2017 18:04:02 +0000 (10:04 -0800)

pathspec: remove unused variable from unsupported_magic

Removed unused variable 'n' from the 'unsupported_magic()' function.

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

pathspec: copy and free owned memoryBrandon Williams Wed, 4 Jan 2017 18:04:01 +0000 (10:04 -0800)

pathspec: copy and free owned memory

The 'original' string entry in a pathspec_item is only duplicated some
of the time, instead always make a copy of the original and take
ownership of the memory.

Since both 'match' and 'original' string entries in a pathspec_item are
owned by the pathspec struct, they need to be freed when clearing the
pathspec struct (in 'clear_pathspec()') and duplicated when copying the
pathspec struct (in 'copy_pathspec()').

Also change the type of 'match' and 'original' to 'char *' in order to
more explicitly show the ownership of the memory.

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

pathspec: remove the deprecated get_pathspec functionBrandon Williams Wed, 4 Jan 2017 18:04:00 +0000 (10:04 -0800)

pathspec: remove the deprecated get_pathspec function

Now that all callers of the old 'get_pathspec' interface have been
migrated to use the new pathspec struct interface it can be removed
from the codebase.

Since there are no more users of the '_raw' field in the pathspec struct
it can also be removed. This patch also removes the old functionality
of modifying the const char **argv array that was passed into
parse_pathspec. Instead the constructed 'match' string (which is a
pathspec element with the prefix prepended) is only stored in its
corresponding pathspec_item entry.

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

ls-tree: convert show_recursive to use the pathspec... Brandon Williams Wed, 4 Jan 2017 18:03:59 +0000 (10:03 -0800)

ls-tree: convert show_recursive to use the pathspec struct interface

Convert 'show_recursive()' to use the pathspec struct interface from
using the '_raw' entry in the pathspec struct.

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

dir: convert fill_directory to use the pathspec struct... Brandon Williams Wed, 4 Jan 2017 18:03:58 +0000 (10:03 -0800)

dir: convert fill_directory to use the pathspec struct interface

Convert 'fill_directory()' to use the pathspec struct interface from
using the '_raw' entry in the pathspec struct.

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

dir: remove struct path_simplifyBrandon Williams Wed, 4 Jan 2017 18:03:57 +0000 (10:03 -0800)

dir: remove struct path_simplify

Teach simplify_away() and exclude_matches_pathspec() to handle struct
pathspec directly, eliminating the need for the struct path_simplify.

Also renamed the len parameter to pathlen in exclude_matches_pathspec()
to match the parameter names used in simplify_away().

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

mv: remove use of deprecated 'get_pathspec()'Brandon Williams Wed, 4 Jan 2017 18:03:56 +0000 (10:03 -0800)

mv: remove use of deprecated 'get_pathspec()'

Convert the 'internal_copy_pathspec()' function to 'prefix_path()'
instead of using the deprecated 'get_pathspec()' interface. Also,
rename 'internal_copy_pathspec()' to 'internal_prefix_pathspec()' to be
more descriptive of what the funciton is actually doing.

In addition to this, fix a memory leak caused by only duplicating some
of the pathspec elements. Instead always duplicate all of the the
pathspec elements as an intermediate step (with modificationed based on
the passed in flags). This way the intermediate strings can then be
freed after getting the result from 'prefix_path()'.

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

blame: output porcelain "previous" header for each... Jeff King Fri, 6 Jan 2017 04:20:51 +0000 (23:20 -0500)

blame: output porcelain "previous" header for each file

It's possible for content currently found in one file to
have originated in two separate files, each of which may
have been modified in some single older commit. The
--porcelain output generates an incorrect "previous" header
in this case, whereas --line-porcelain gets it right. The
problem is that the porcelain output tries to omit repeated
details of commits, and treats "previous" as a property of
the commit, when it is really a property of the blamed block
of lines.

Let's look at an example. In a case like this, you might see
this output from --line-porcelain:

SOME_SHA1 1 1 1
author ...
committer ...
previous SOME_SHA1^ file_one
filename file_one
...some line content...
SOME_SHA1 2 1 1
author ...
committer ...
previous SOME_SHA1^ file_two
filename file_two
...some different content....

The "filename" fields tell us that the two lines are from
two different files. But notice that the filename also
appears in the "previous" field, which tells us where to
start a re-blame. The second content line never appeared in
file_one at all, so we would obviously need to re-blame from
file_two (or possibly even some other file, if had just been
renamed to file_two in SOME_SHA1).

So far so good. Now here's what --porcelain looks like:

SOME_SHA1 1 1 1
author ...
committer ...
previous SOME_SHA1^ file_one
filename file_one
...some line content...
SOME_SHA1 2 1 1
filename file_two
...some different content....

We've dropped the author and committer fields from the
second line, as they would just be repeats. But we can't
omit "filename", because it depends on the actual block of
blamed lines, not just the commit. This is handled by
emit_porcelain_details(), which will show the filename
either if it is the first mention of the commit _or_ if the
commit has multiple paths in it.

But we don't give "previous" the same handling. It's written
inside emit_one_suspect_detail(), which bails early if we've
already seen that commit. And so the output above is wrong;
a reader would assume that the correct place to re-blame
line two is from file_one, but that's obviously nonsense.

Let's treat "previous" the same as "filename", and show it
fresh whenever we know we are in a confusing case like this.

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

blame: handle --no-abbrevJeff King Fri, 6 Jan 2017 04:18:08 +0000 (23:18 -0500)

blame: handle --no-abbrev

You can already ask blame for full sha1s with "-l" or with
"--abbrev=40". But for consistency with other parts of Git,
we should support "--no-abbrev".

Worse, blame already accepts --no-abbrev, but it's totally
broken. When we see --no-abbrev, the abbrev variable is set
to 0, which is then used as a printf precision. For regular
sha1s, that means we print nothing at all (which is very
wrong). For boundary commits we decrement it to "-1", which
printf interprets as "no limit" (which is almost correct,
except it misses the 39-length magic explained in the
previous commit).

Let's detect --no-abbrev and behave as if --abbrev=40 was
given.

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

blame: fix alignment with --abbrev=40Jeff King Fri, 6 Jan 2017 04:17:40 +0000 (23:17 -0500)

blame: fix alignment with --abbrev=40

The blame command internally adds 1 to any requested sha1
abbreviation length, and then subtracts it when outputting a
boundary commit. This lets regular and boundary sha1s line
up visually, but it misses one corner case.

When the requested length is 40, we bump the value to 41.
But since we only have 40 characters, that's all we can show
(fortunately the truncation is done by a printf precision
field, so it never tries to read past the end of the
buffer). So a normal sha1 shows 40 hex characters, and a
boundary sha1 shows "^" plus 40 hex characters. The result
is misaligned.

The "-l" option to show long sha1s gets around this by
skipping the "abbrev" variable entirely and just always
using GIT_SHA1_HEXSZ. This avoids the "+1" issue, but it
does mean that boundary commits only have 39 characters
printed. This is somewhat odd, but it does look good
visually: the results are aligned and left-justified. The
alternative would be to allocate an extra column that would
contain either an extra space or the "^" boundary marker.

As this is by definition the human-readable view, it's
probably not that big a deal either way (and of course
--porcelain, etc, correctly produce correct 40-hex sha1s).
But for consistency, this patch teaches --abbrev=40 to
produce the same output as "-l" (always left-aligned, with
40-hex for normal sha1s, and "^" plus 39-hex for
boundaries).

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

rebase--interactive: count squash commits above 10... Jeff King Sat, 7 Jan 2017 08:23:19 +0000 (03:23 -0500)

rebase--interactive: count squash commits above 10 correctly

We generate the squash commit message incrementally running
a sed script once for each commit. It parses "This is
a combination of <N> commits" from the first line of the
existing message, adds one to <N>, and uses the result as
the number of our current message.

Since f2d17068fd (i18n: rebase-interactive: mark comments of
squash for translation, 2016-06-17), the first line may be
localized, and sed uses a pretty liberal regex, looking for:

/^#.*([0-9][0-9]*)/

The "[0-9][0-9]*" tries to match double digits, but it
doesn't quite work. The first ".*" is greedy, so if you
have:

This is a combination of 10 commits.

it will eat up "This is a combination of 1", leaving "0" to
match the first "[0-9]" digit, and then skipping the
optional match of "[0-9]*".

As a result, the count resets every 10 commits, and a
15-commit squash would end up as:

# This is a combination of 5 commits.
# This is the 1st commit message:
...
# This is the commit message #2:
... and so on ..
# This is the commit message #10:
...
# This is the commit message #1:
...
# This is the commit message #2:
... etc, up to 5 ...

We can fix this by making the ".*" less greedy. Instead of
depending on ".*?" working portably, we can just limit the
match to non-digit characters, which accomplishes the same
thing.

Reported-by: Brandon Tolsch <btolsch@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

branch_get_push: do not segfault when HEAD is detachedKyle Meyer Sat, 7 Jan 2017 01:12:15 +0000 (20:12 -0500)

branch_get_push: do not segfault when HEAD is detached

Move the detached HEAD check from branch_get_push_1() to
branch_get_push() to avoid setting branch->push_tracking_ref when
branch is NULL.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive-zip: load userdiff configJeff King Mon, 2 Jan 2017 22:25:09 +0000 (17:25 -0500)

archive-zip: load userdiff config

Since 4aff646d17 (archive-zip: mark text files in archives,
2015-03-05), the zip archiver will look at the userdiff
driver to decide whether a file is text or binary. This
usually doesn't need to look any further than the attributes
themselves (e.g., "-diff", etc). But if the user defines a
custom driver like "diff=foo", we need to look at
"diff.foo.binary" in the config. Prior to this patch, we
didn't actually load it.

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

mingw: add a regression test for pushing to UNC pathsJohannes Schindelin Mon, 2 Jan 2017 10:40:20 +0000 (11:40 +0100)

mingw: add a regression test for pushing to UNC paths

On Windows, there are "UNC paths" to access network (AKA shared)
folders, of the form \\server\sharename\directory. This provides a
convenient way for Windows developers to share their Git repositories
without having to have a dedicated server.

Git for Windows v2.11.0 introduced a regression where pushing to said
UNC paths no longer works, although fetching and cloning still does, as
reported here: https://github.com/git-for-windows/git/issues/979

This regression was fixed in 7814fbe3f1 (normalize_path_copy(): fix
pushing to //server/share/dir on Windows, 2016-12-14).

Let's make sure that it does not regress again, by introducing a test
that uses so-called "administrative shares": disk volumes are
automatically shared under certain circumstances, e.g. the C: drive is
shared as \\localhost\c$. The test needs to be skipped if the current
directory is inaccessible via said administrative share, of course.

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

don't use test_must_fail with grepPranit Bauva Tue, 3 Jan 2017 19:57:07 +0000 (01:27 +0530)

don't use test_must_fail with grep

test_must_fail should only be used for testing git commands. To test the
failure of other commands use `!`.

Reported-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule.c: use GIT_DIR_ENVIRONMENT consistentlyStefan Beller Tue, 3 Jan 2017 18:30:47 +0000 (10:30 -0800)

submodule.c: use GIT_DIR_ENVIRONMENT consistently

In C code we have the luxury of having constants for all the important
things that are hard coded. This is the only place in C that hard codes
the git directory environment variable, so fix it.

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

gitk: ru.po: Update Russian translationDimitriy Ryazantcev Wed, 14 Dec 2016 22:34:26 +0000 (00:34 +0200)

gitk: ru.po: Update Russian translation

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

git-p4: do not pass '-r 0' to p4 commandsIgor Kushnir Thu, 29 Dec 2016 10:22:23 +0000 (12:22 +0200)

git-p4: do not pass '-r 0' to p4 commands

git-p4 crashes when used with a very old p4 client version
that does not support the '-r <number>' option in its commands.

Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.

Alternatively git-p4.retries could be made opt-in.
But since only very old, barely maintained p4 versions don't support
the '-r' option, the setting-retries-to-0 workaround would do.

The "-r retries" option is present in Perforce 2012.2 Command Reference,
but absent from Perforce 2012.1 Command Reference.

Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
Acked-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

repack: die on incremental + write-bitmap-indexDavid Turner Wed, 28 Dec 2016 22:45:42 +0000 (17:45 -0500)

repack: die on incremental + write-bitmap-index

The bitmap index only works for single packs, so requesting an
incremental repack with bitmap indexes makes no sense.

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

auto gc: don't write bitmaps for incremental repacksDavid Turner Wed, 28 Dec 2016 22:45:41 +0000 (17:45 -0500)

auto gc: don't write bitmaps for incremental repacks

When git gc --auto does an incremental repack of loose objects, we do
not expect to be able to write a bitmap; it is very likely that
objects in the new pack will have references to objects outside of the
pack. So we shouldn't try to write a bitmap, because doing so will
likely issue a warning.

This warning was making its way into gc.log. When the gc.log was
present, future auto gc runs would refuse to run.

Patch by Jeff King.
Bug report, test, and commit message by David Turner.

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

rm: absorb a submodules git dir before deletionStefan Beller Tue, 27 Dec 2016 19:03:14 +0000 (11:03 -0800)

rm: absorb a submodules git dir before deletion

When deleting a submodule, we need to keep the actual git directory around,
such that we do not lose local changes in there and at a later checkout
of the submodule we don't need to clone it again.

Now that the functionality is available to absorb the git directory of a
submodule, rewrite the checking in git-rm to not complain, but rather
relocate the git directories inside the superproject.

An alternative solution was discussed to have a function
`depopulate_submodule`. That would couple the check for its git directory
and possible relocation before the the removal, such that it is less
likely to miss the check in the future. But the indirection with such
a function added seemed also complex. The reason for that was that this
possible move of the git directory was also implemented in
`ok_to_remove_submodule`, such that this function could truthfully
answer whether it is ok to remove the submodule.

The solution proposed here defers all these checks to the caller.

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

submodule: rename and add flags to ok_to_remove_submoduleStefan Beller Tue, 20 Dec 2016 23:20:11 +0000 (15:20 -0800)

submodule: rename and add flags to ok_to_remove_submodule

In different contexts the question "Is it ok to delete a submodule?"
may be answered differently.

In 293ab15eea (submodule: teach rm to remove submodules unless they
contain a git directory, 2012-09-26) a case was made that we can safely
ignore ignored untracked files for removal as we explicitely ask for the
removal of the submodule.

In a later patch we want to remove submodules even when the user doesn't
explicitly ask for it (e.g. checking out a tree-ish in which the submodule
doesn't exist). In that case we want to be more careful when it comes
to deletion of untracked files. As of this patch it is unclear how this
will be implemented exactly, so we'll offer flags in which the caller
can specify how the different untracked files ought to be handled.

As the flags allow the function to not die on an error when spawning
a child process, we need to find an appropriate return code for the
case when the child process could not be started. As in that case we
cannot tell if the submodule is ok to remove, we'd want to return 'false'.

As only 0 is understood as false, rename the function to invert the
meaning, i.e. the return code of 0 signals the removal of the submodule
is fine, and other values can be used to return a more precise answer
what went wrong.

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

submodule: modernize ok_to_remove_submodule to use... Stefan Beller Tue, 20 Dec 2016 23:20:10 +0000 (15:20 -0800)

submodule: modernize ok_to_remove_submodule to use argv_array

Instead of constructing the NULL terminated array ourselves, we
should make use of the argv_array infrastructure.

While at it, adapt the error messages to reflect the actual invocation.

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

submodule.h: add extern keyword to functionsStefan Beller Tue, 20 Dec 2016 23:20:09 +0000 (15:20 -0800)

submodule.h: add extern keyword to functions

As the upcoming series will add a lot of functions to the submodule
header, let's first make the header consistent to the rest of the project
by adding the extern keyword to functions.

As per the CodingGuidelines we try to stay below 80 characters per line,
so adapt all those functions to stay below 80 characters that are already
using more than one line. Those function using just one line are better
kept in one line than breaking them up into multiple lines just for the
goal of staying below the character limit as it makes grepping
for functions easier if they are one liners.

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

worktree: initialize return value for submodule_uses_wo... Stefan Beller Tue, 27 Dec 2016 17:50:13 +0000 (09:50 -0800)

worktree: initialize return value for submodule_uses_worktrees

When the worktrees directory is empty, the `ret` will be returned
uninitialized. Fix it by initializing the value.

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

Fourth batch for 2.12Junio C Hamano Tue, 27 Dec 2016 17:17:51 +0000 (09:17 -0800)

Fourth batch for 2.12

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

Merge branch 'jc/lock-report-on-error'Junio C Hamano Tue, 27 Dec 2016 17:17:32 +0000 (09:17 -0800)

Merge branch 'jc/lock-report-on-error'

* jc/lock-report-on-error:
lockfile: move REPORT_ON_ERROR bit elsewhere

lockfile: move REPORT_ON_ERROR bit elsewhereJunio C Hamano Tue, 27 Dec 2016 17:12:09 +0000 (09:12 -0800)

lockfile: move REPORT_ON_ERROR bit elsewhere

There was LOCK_NO_DEREF defined as 2 = 1<<1 with the same value,
which was missed due to a huge comment block. Deconflict by moving
the new one to 4 = 1<<2 for now.

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

Merge branch 'js/mingw-isatty'Junio C Hamano Tue, 27 Dec 2016 08:11:46 +0000 (00:11 -0800)

Merge branch 'js/mingw-isatty'

Update the isatty() emulation for Windows by updating the previous
hack that depended on internals of (older) MSVC runtime.

* js/mingw-isatty:
mingw: replace isatty() hack
mingw: fix colourization on Cygwin pseudo terminals
mingw: adjust is_console() to work with stdin

Merge branch 'ls/p4-lfs'Junio C Hamano Tue, 27 Dec 2016 08:11:46 +0000 (00:11 -0800)

Merge branch 'ls/p4-lfs'

Update GitLFS integration with "git p4".

* ls/p4-lfs:
git-p4: add diff/merge properties to .gitattributes for GitLFS files

Merge branch 'va/i18n-even-more'Junio C Hamano Tue, 27 Dec 2016 08:11:45 +0000 (00:11 -0800)

Merge branch 'va/i18n-even-more'

* va/i18n-even-more:
i18n: fix misconversion in shell scripts

Merge branch 'lt/shortlog-by-committer'Junio C Hamano Tue, 27 Dec 2016 08:11:44 +0000 (00:11 -0800)

Merge branch 'lt/shortlog-by-committer'

"git shortlog" learned "--committer" option to group commits by
committer, instead of author.

* lt/shortlog-by-committer:
t4201: make tests work with and without the MINGW prerequiste
shortlog: test and document --committer option
shortlog: group by committer information

Merge branch 'mk/mingw-winansi-ttyname-termination... Junio C Hamano Tue, 27 Dec 2016 08:11:44 +0000 (00:11 -0800)

Merge branch 'mk/mingw-winansi-ttyname-termination-fix'

A potential but unlikely buffer overflow in Windows port has been
fixed.

* mk/mingw-winansi-ttyname-termination-fix:
mingw: consider that UNICODE_STRING::Length counts bytes

Merge branch 'gv/p4-multi-path-commit-fix'Junio C Hamano Tue, 27 Dec 2016 08:11:43 +0000 (00:11 -0800)

Merge branch 'gv/p4-multi-path-commit-fix'

"git p4" that tracks multile p4 paths imported a single changelist
that touches files in these multiple paths as one commit, followed
by many empty commits. This has been fixed.

* gv/p4-multi-path-commit-fix:
git-p4: fix multi-path changelist empty commits

Merge branch 'jk/difftool-in-subdir'Junio C Hamano Tue, 27 Dec 2016 08:11:43 +0000 (00:11 -0800)

Merge branch 'jk/difftool-in-subdir'

Even though an fix was attempted in Git 2.9.3 days, but running
"git difftool --dir-diff" from a subdirectory never worked. This
has been fixed.

* jk/difftool-in-subdir:
difftool: rename variables for consistency
difftool: chdir as early as possible
difftool: sanitize $workdir as early as possible
difftool: fix dir-diff index creation when in a subdirectory

Merge branch 'ld/p4-compare-dir-vs-symlink'Junio C Hamano Tue, 27 Dec 2016 08:11:42 +0000 (00:11 -0800)

Merge branch 'ld/p4-compare-dir-vs-symlink'

"git p4" misbehaved when swapping a directory and a symbolic link.

* ld/p4-compare-dir-vs-symlink:
git-p4: avoid crash adding symlinked directory

Merge branch 'ls/filter-process'Junio C Hamano Tue, 27 Dec 2016 08:11:42 +0000 (00:11 -0800)

Merge branch 'ls/filter-process'

Doc update.

* ls/filter-process:
t0021: fix flaky test
docs: warn about possible '=' in clean/smudge filter process values

Merge branch 'bw/transport-protocol-policy'Junio C Hamano Tue, 27 Dec 2016 08:11:41 +0000 (00:11 -0800)

Merge branch 'bw/transport-protocol-policy'

Finer-grained control of what protocols are allowed for transports
during clone/fetch/push have been enabled via a new configuration
mechanism.

* bw/transport-protocol-policy:
http: respect protocol.*.allow=user for http-alternates
transport: add from_user parameter to is_transport_allowed
http: create function to get curl allowed protocols
transport: add protocol policy config option
http: always warn if libcurl version is too old
lib-proto-disable: variable name fix

Merge branch 'cp/merge-continue'Junio C Hamano Tue, 27 Dec 2016 08:11:41 +0000 (00:11 -0800)

Merge branch 'cp/merge-continue'

"git merge --continue" has been added as a synonym to "git commit"
to conclude a merge that has stopped due to conflicts.

* cp/merge-continue:
merge: mark usage error strings for translation
merge: ensure '--abort' option takes no arguments
completion: add --continue option for merge
merge: add '--continue' option as a synonym for 'git commit'

Merge branch 'va/i18n-perl-scripts'Junio C Hamano Tue, 27 Dec 2016 08:11:40 +0000 (00:11 -0800)

Merge branch 'va/i18n-perl-scripts'

Porcelain scripts written in Perl are getting internationalized.

* va/i18n-perl-scripts:
i18n: difftool: mark warnings for translation
i18n: send-email: mark composing message for translation
i18n: send-email: mark string with interpolation for translation
i18n: send-email: mark warnings and errors for translation
i18n: send-email: mark strings for translation
i18n: add--interactive: mark status words for translation
i18n: add--interactive: remove %patch_modes entries
i18n: add--interactive: mark edit_hunk_manually message for translation
i18n: add--interactive: i18n of help_patch_cmd
i18n: add--interactive: mark patch prompt for translation
i18n: add--interactive: mark plural strings
i18n: clean.c: match string with git-add--interactive.perl
i18n: add--interactive: mark strings with interpolation for translation
i18n: add--interactive: mark simple here-documents for translation
i18n: add--interactive: mark strings for translation
Git.pm: add subroutines for commenting lines

Merge branch 'sb/submodule-config-cleanup'Junio C Hamano Tue, 27 Dec 2016 08:11:40 +0000 (00:11 -0800)

Merge branch 'sb/submodule-config-cleanup'

Minor code clean-up.

* sb/submodule-config-cleanup:
submodule-config: clarify parsing of null_sha1 element
submodule-config: rename commit_sha1 to treeish_name
submodule config: inline config_from_{name, path}

Merge branch 'jc/push-default-explicit'Junio C Hamano Tue, 27 Dec 2016 08:11:40 +0000 (00:11 -0800)

Merge branch 'jc/push-default-explicit'

A lazy "git push" without refspec did not internally use a fully
specified refspec to perform 'current', 'simple', or 'upstream'
push, causing unnecessary "ambiguous ref" errors.

* jc/push-default-explicit:
push: test pushing ambiguously named branches
push: do not use potentially ambiguous default refspec

diff: retire "compaction" heuristicsJunio C Hamano Fri, 23 Dec 2016 20:32:22 +0000 (12:32 -0800)

diff: retire "compaction" heuristics

When a patch inserts a block of lines, whose last lines are the
same as the existing lines that appear before the inserted block,
"git diff" can choose any place between these existing lines as the
boundary between the pre-context and the added lines (adjusting the
end of the inserted block as appropriate) to come up with variants
of the same patch, and some variants are easier to read than others.

We have been trying to improve the choice of this boundary, and Git
2.11 shipped with an experimental "compaction-heuristic". Since
then another attempt to improve the logic further resulted in a new
"indent-heuristic" logic. It is agreed that the latter gives better
result overall, and the former outlived its usefulness.

Retire "compaction", and keep "indent" as an experimental feature.
The latter hopefully will be turned on by default in a future
release, but that should be done as a separate step.

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

config.abbrev: document the new default that auto-scalesJunio C Hamano Wed, 2 Nov 2016 01:34:07 +0000 (18:34 -0700)

config.abbrev: document the new default that auto-scales

We somehow forgot to update the "default is 7" in the
documentation. Also give a way to explicitly ask the auto-scaling
by setting config.abbrev to "auto".

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

config.c: handle lock file in error case in git_config_... Nguyễn Thái Ngọc Duy Tue, 20 Dec 2016 09:48:36 +0000 (16:48 +0700)

config.c: handle lock file in error case in git_config_rename_...

We could rely on atexit() to clean up everything, but let's be
explicit when we can. And it's good anyway because the function is
called the second time in the same process, we're in trouble.

This function should not affect the successful case because after
commit_lock_file() is called, rollback_lock_file() becomes no-op,
as long as it is initialized.

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

grep: search history of moved submodulesBrandon Williams Fri, 16 Dec 2016 19:03:22 +0000 (11:03 -0800)

grep: search history of moved submodules

If a submodule was renamed at any point since it's inception then if you
were to try and grep on a commit prior to the submodule being moved, you
wouldn't be able to find a working directory for the submodule since the
path in the past is different from the current path.

This patch teaches grep to find the .git directory for a submodule in
the parents .git/modules/ directory in the event the path to the
submodule in the commit that is being searched differs from the state of
the currently checked out commit. If found, the child process that is
spawned to grep the submodule will chdir into its gitdir instead of a
working directory.

In order to override the explicit setting of submodule child process's
gitdir environment variable (which was introduced in '10f5c526')
`GIT_DIR_ENVIORMENT` needs to be pushed onto child process's env_array.
This allows the searching of history from a submodule's gitdir, rather
than from a working directory.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep: enable recurse-submodules to work on <tree> objectsBrandon Williams Fri, 16 Dec 2016 19:03:21 +0000 (11:03 -0800)

grep: enable recurse-submodules to work on <tree> objects

Teach grep to recursively search in submodules when provided with a
<tree> object. This allows grep to search a submodule based on the state
of the submodule that is present in a commit of the super project.

When grep is provided with a <tree> object, the name of the object is
prefixed to all output. In order to provide uniformity of output
between the parent and child processes the option `--parent-basename`
has been added so that the child can preface all of it's output with the
name of the parent's object instead of the name of the commit SHA1 of
the submodule. This changes output from the command
`git grep -e. -l --recurse-submodules HEAD` from:

HEAD:file
<commit sha1 of submodule>:sub/file

to:

HEAD:file
HEAD:sub/file

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep: optionally recurse into submodulesBrandon Williams Fri, 16 Dec 2016 19:03:20 +0000 (11:03 -0800)

grep: optionally recurse into submodules

Allow grep to recognize submodules and recursively search for patterns in
each submodule. This is done by forking off a process to recursively
call grep on each submodule. The top level --super-prefix option is
used to pass a path to the submodule which can in turn be used to
prepend to output or in pathspec matching logic.

Recursion only occurs for submodules which have been initialized and
checked out by the parent project. If a submodule hasn't been
initialized and checked out it is simply skipped.

In order to support the existing multi-threading infrastructure in grep,
output from each child process is captured in a strbuf so that it can be
later printed to the console in an ordered fashion.

To limit the number of theads that are created, each child process has
half the number of threads as its parents (minimum of 1), otherwise we
potentailly have a fork-bomb.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep: add submodules as a grep source typeBrandon Williams Fri, 16 Dec 2016 19:03:19 +0000 (11:03 -0800)

grep: add submodules as a grep source type

Add `GREP_SOURCE_SUBMODULE` as a grep_source type and cases for this new
type in the various switch statements in grep.c.

When initializing a grep_source with type `GREP_SOURCE_SUBMODULE` the
identifier can either be NULL (to indicate that the working tree will be
used) or a SHA1 (the REV of the submodule to be grep'd). If the
identifier is a SHA1 then we want to fall through to the
`GREP_SOURCE_SHA1` case to handle the copying of the SHA1.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodules: load gitmodules file from commit sha1Brandon Williams Fri, 16 Dec 2016 19:03:18 +0000 (11:03 -0800)

submodules: load gitmodules file from commit sha1

teach submodules to load a '.gitmodules' file from a commit sha1. This
enables the population of the submodule_cache to be based on the state
of the '.gitmodules' file from a particular commit.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodules: add helper to determine if a submodule... Brandon Williams Fri, 16 Dec 2016 19:03:17 +0000 (11:03 -0800)

submodules: add helper to determine if a submodule is initialized

Add the `is_submodule_initialized()` helper function to submodules.c.
`is_submodule_initialized()` performs a check to determine if the
submodule at the given path has been initialized.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodules: add helper to determine if a submodule... Brandon Williams Fri, 16 Dec 2016 19:03:16 +0000 (11:03 -0800)

submodules: add helper to determine if a submodule is populated

Add the `is_submodule_populated()` helper function to submodules.c.
`is_submodule_populated()` performes a check to see if a submodule has
been checkout out (and has a valid .git directory/file) at the given path.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

real_path: canonicalize directory separators in root... Johannes Sixt Wed, 21 Dec 2016 21:51:35 +0000 (22:51 +0100)

real_path: canonicalize directory separators in root parts

When an absolute path is resolved, resolution begins at the first path
component after the root part. The root part is just copied verbatim,
because it must not be inspected for symbolic links. For POSIX paths,
this is just the initial slash, but on Windows, the root part has the
forms c:\ or \\server\share. We do want to canonicalize the back-slashes
in the root part because these parts are compared to the result of
getcwd(), which does return a fully canonicalized path.

Factor out a helper that splits off the root part, and have it
canonicalize the copied part.

This change was prompted because t1504-ceiling-dirs.sh caught a breakage
in GIT_CEILING_DIRECTORIES handling on Windows.

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

mingw: replace isatty() hackJeff Hostetler Thu, 22 Dec 2016 17:09:23 +0000 (18:09 +0100)

mingw: replace isatty() hack

Git for Windows has carried a patch that depended on internals
of MSVC runtime, but it does not work correctly with recent MSVC
runtime. A replacement was written originally for compiling
with VC++. The patch in this message is a backport of that
replacement, and it also fixes the previous attempt to make
isatty() tell that /dev/null is *not* an interactive terminal.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Tested-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mingw: fix colourization on Cygwin pseudo terminalsAlan Davies Thu, 22 Dec 2016 17:09:18 +0000 (18:09 +0100)

mingw: fix colourization on Cygwin pseudo terminals

Git only colours the output and uses pagination if isatty() returns 1.
MSYS2 and Cygwin emulate pseudo terminals via named pipes, meaning that
isatty() returns 0.

f7f90e0f4f (mingw: make isatty() recognize MSYS2's pseudo terminals
(/dev/pty*), 2016-04-27) fixed this for MSYS2 terminals, but not for
Cygwin.

The named pipes that Cygwin and MSYS2 use are very similar. MSYS2 PTY pipes
are called 'msys-*-pty*' and Cygwin uses 'cygwin-*-pty*'. This commit
modifies the existing check to allow both MSYS2 and Cygwin PTY pipes to be
identified as TTYs.

Note that pagination is still broken when running Git for Windows from
within Cygwin, as MSYS2's less.exe is spawned (and does not like to
interact with Cygwin's PTY).

This partially fixes https://github.com/git-for-windows/git/issues/267

Signed-off-by: Alan Davies <alan.n.davies@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mingw: adjust is_console() to work with stdinJohannes Schindelin Thu, 22 Dec 2016 17:08:57 +0000 (18:08 +0100)

mingw: adjust is_console() to work with stdin

When determining whether a handle corresponds to a *real* Win32 Console
(as opposed to, say, a character device such as /dev/null), we use the
GetConsoleOutputBufferInfo() function as a tell-tale.

However, that does not work for *input* handles associated with a
console. Let's just use the GetConsoleMode() function for input handles,
and since it does not work on output handles fall back to the previous
method for those.

This patch prepares for using is_console() instead of my previous
misguided attempt in cbb3f3c9b1 (mingw: intercept isatty() to handle
/dev/null as Git expects it, 2016-12-11) that broke everything on
Windows.

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

Third batch for 2.12Junio C Hamano Wed, 21 Dec 2016 22:57:26 +0000 (14:57 -0800)

Third batch for 2.12

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

Merge branch 'jt/mailinfo-fold-in-body-headers'Junio C Hamano Wed, 21 Dec 2016 22:55:03 +0000 (14:55 -0800)

Merge branch 'jt/mailinfo-fold-in-body-headers'

Fix for NDEBUG builds.

* jt/mailinfo-fold-in-body-headers:
mailinfo.c: move side-effects outside of assert

Merge branch 'jk/index-pack-wo-repo-from-stdin'Junio C Hamano Wed, 21 Dec 2016 22:55:03 +0000 (14:55 -0800)

Merge branch 'jk/index-pack-wo-repo-from-stdin'

"git index-pack --stdin" needs an access to an existing repository,
but "git index-pack file.pack" to generate an .idx file that
corresponds to a packfile does not.

* jk/index-pack-wo-repo-from-stdin:
index-pack: skip collision check when not in repository
t: use nongit() function where applicable
index-pack: complain when --stdin is used outside of a repo
t5000: extract nongit function to test-lib-functions.sh

Merge branch 'jk/parseopt-usage-msg-opt'Junio C Hamano Wed, 21 Dec 2016 22:55:03 +0000 (14:55 -0800)

Merge branch 'jk/parseopt-usage-msg-opt'

The function usage_msg_opt() has been updated to say "fatal:"
before the custom message programs give, when they want to die
with a message about wrong command line options followed by the
standard usage string.

* jk/parseopt-usage-msg-opt:
parse-options: print "fatal:" before usage_msg_opt()

Merge branch 'jk/quote-env-path-list-component'Junio C Hamano Wed, 21 Dec 2016 22:55:02 +0000 (14:55 -0800)

Merge branch 'jk/quote-env-path-list-component'

A recent update to receive-pack to make it easier to drop garbage
objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
have a pathname with a colon in it (no surprise!), and this in turn
made it impossible to push into a repository at such a path. This
has been fixed by introducing a quoting mechanism used when
appending such a path to the colon-separated list.

* jk/quote-env-path-list-component:
t5615-alternate-env: double-quotes in file names do not work on Windows
t5547-push-quarantine: run the path separator test on Windows, too
tmp-objdir: quote paths we add to alternates
alternates: accept double-quoted paths

Merge branch 'vs/submodule-clone-nested-submodules... Junio C Hamano Wed, 21 Dec 2016 22:55:02 +0000 (14:55 -0800)

Merge branch 'vs/submodule-clone-nested-submodules-alternates'

"git clone --reference $there --recurse-submodules $super" has been
taught to guess repositories usable as references for submodules of
$super that are embedded in $there while making a clone of the
superproject borrow objects from $there; extend the mechanism to
also allow submodules of these submodules to borrow repositories
embedded in these clones of the submodules embedded in the clone of
the superproject.

* vs/submodule-clone-nested-submodules-alternates:
submodule--helper: set alternateLocation for cloned submodules

Merge branch 'nd/shallow-fixup'Junio C Hamano Wed, 21 Dec 2016 22:55:01 +0000 (14:55 -0800)

Merge branch 'nd/shallow-fixup'

Code cleanup in shallow boundary computation.

* nd/shallow-fixup:
shallow.c: remove useless code
shallow.c: bit manipulation tweaks
shallow.c: avoid theoretical pointer wrap-around
shallow.c: make paint_alloc slightly more robust
shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
shallow.c: rename fields in paint_info to better express their purposes

Merge branch 'sb/sequencer-abort-safety'Junio C Hamano Wed, 21 Dec 2016 22:55:01 +0000 (14:55 -0800)

Merge branch 'sb/sequencer-abort-safety'

Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
to where cherry-pick started while picking multiple changes, when
the cherry-pick stopped to ask for help from the user, and the user
did "git reset --hard" to a different commit in order to re-attempt
the operation.

* sb/sequencer-abort-safety:
Revert "sequencer: remove useless get_dir() function"
sequencer: remove useless get_dir() function
sequencer: make sequencer abort safer
t3510: test that cherry-pick --abort does not unsafely change HEAD
am: change safe_to_abort()'s not rewinding error into a warning
am: fix filename in safe_to_abort() error message

t5615-alternate-env: double-quotes in file names do... Johannes Sixt Wed, 21 Dec 2016 21:33:43 +0000 (22:33 +0100)

t5615-alternate-env: double-quotes in file names do not work on Windows

Protect a recently added test case with !MINGW.

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

fast-import: properly fanout notes when tree is importedMike Hommey Tue, 20 Dec 2016 21:04:48 +0000 (06:04 +0900)

fast-import: properly fanout notes when tree is imported

In typical uses of fast-import, trees are inherited from a parent
commit. In that case, the tree_entry for the branch looks like:

.versions[1].sha1 = $some_sha1
.tree = <tree structure loaded from $some_sha1>

However, when trees are imported, rather than inherited, that is not the
case. One can import a tree with a filemodify command, replacing the
root tree object.

e.g.
"M 040000 $some_sha1 \n"

In this case, the tree_entry for the branch looks like:

.versions[1].sha1 = $some_sha1
.tree = NULL

When adding new notes with the notemodify command, do_change_note_fanout
is called to get a notes count, and to do so, it loops over the
tree_entry->tree, but doesn't do anything when the tree is NULL.

In the latter case above, it means do_change_note_fanout thinks the tree
contains no notes, and new notes are added with no fanout.

Interestingly, do_change_note_fanout does check whether subdirectories
have a NULL .tree, in which case it uses load_tree(). Which means the
right behaviour happens when using the filemodify command to import
subdirectories.

This change makes do_change_note_fanount call load_tree() whenever the
tree_entry it is given has no tree loaded, making all cases handled
equally.

Signed-off-by: Mike Hommey <mh@glandium.org>
Reviewed-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4201: make tests work with and without the MINGW prere... Junio C Hamano Tue, 20 Dec 2016 18:35:54 +0000 (10:35 -0800)

t4201: make tests work with and without the MINGW prerequiste

Make sure the tests do not depend on the result of the previous
tests. With MINGW prerequisite satisfied, a "reset to original and
rebuild" in an earlier test was skipped, resulting in different
history being tested with this and the next tests.

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

config.c: rename label unlock_and_outNguyễn Thái Ngọc Duy Tue, 20 Dec 2016 09:48:35 +0000 (16:48 +0700)

config.c: rename label unlock_and_out

There are two ways to unlock a file: commit, or revert. Rename it to
commit_and_out to avoid confusion.

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

config.c: handle error case for fstat() callsNguyễn Thái Ngọc Duy Mon, 19 Dec 2016 09:21:55 +0000 (16:21 +0700)

config.c: handle error case for fstat() calls

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

git-p4: add diff/merge properties to .gitattributes... Lars Schneider Sun, 18 Dec 2016 19:01:40 +0000 (20:01 +0100)

git-p4: add diff/merge properties to .gitattributes for GitLFS files

The `git lfs track` command generates a .gitattributes file with diff
and merge properties [1]. Set the same .gitattributes format for files
tracked with GitLFS in git-p4.

[1] https://github.com/git-lfs/git-lfs/blob/v1.5.3/commands/command_track.go#L121

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: fix misconversion in shell scriptsJunio C Hamano Tue, 20 Dec 2016 17:36:23 +0000 (09:36 -0800)

i18n: fix misconversion in shell scripts

An earlier series that was merged at 2703572b3a ("Merge branch
'va/i18n-even-more'", 2016-07-13) failed to use $(eval_gettext
"string with \$variable interpolation") and instead used gettext in
a few places, and ended up showing the variable names in the
message, e.g.

$ git submodule
fatal: $program_name cannot be used without a working tree.

Catch these mistakes with

$ git grep -n '[^_]gettext .*\\\$'

and fix them all to use eval_gettext instead.

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

mailinfo.c: move side-effects outside of assertKyle J. McKay Mon, 19 Dec 2016 23:13:00 +0000 (15:13 -0800)

mailinfo.c: move side-effects outside of assert

Since 6b4b013f18 (mailinfo: handle in-body header continuations,
2016-09-20, v2.11.0) mailinfo.c has contained new code with an
assert of the form:

assert(call_a_function(...))

The function in question, check_header, has side effects. This
means that when NDEBUG is defined during a release build the
function call is omitted entirely, the side effects do not
take place and tests (fortunately) start failing.

Since the only time that mi->inbody_header_accum is appended to is
in check_inbody_header, and appending onto a blank
mi->inbody_header_accum always happens when is_inbody_header is
true, this guarantees a prefix that causes check_header to always
return true.

Therefore replace the assert with an if !check_header + DIE
combination to reflect this.

Helped-by: Jonathan Tan <jonathantanmy@google.com>
Helped-by: Jeff King <peff@peff.net>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mingw: consider that UNICODE_STRING::Length counts... Max Kirillov Mon, 19 Dec 2016 21:32:00 +0000 (23:32 +0200)

mingw: consider that UNICODE_STRING::Length counts bytes

UNICODE_STRING::Length field means size of buffer in bytes[1],
despite of buffer itself being array of wchar_t. Because of that
terminating zero is placed twice as far. Fix it.

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380518.aspx

Signed-off-by: Max Kirillov <max@max630.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Second batch for 2.12Junio C Hamano Mon, 19 Dec 2016 22:50:31 +0000 (14:50 -0800)

Second batch for 2.12

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

Merge branch 'kh/tutorial-grammofix'Junio C Hamano Mon, 19 Dec 2016 22:45:41 +0000 (14:45 -0800)

Merge branch 'kh/tutorial-grammofix'

* kh/tutorial-grammofix:
doc: omit needless "for"
doc: make the intent of sentence clearer
doc: add verb in front of command to run
doc: add articles (grammar)

Merge branch 'da/mergetool-xxdiff-hotkey'Junio C Hamano Mon, 19 Dec 2016 22:45:41 +0000 (14:45 -0800)

Merge branch 'da/mergetool-xxdiff-hotkey'

The way to specify hotkeys to "xxdiff" that is used by "git
mergetool" has been modernized to match recent versions of xxdiff.

* da/mergetool-xxdiff-hotkey:
mergetools: fix xxdiff hotkeys

Merge branch 'lr/doc-fix-cet'Junio C Hamano Mon, 19 Dec 2016 22:45:41 +0000 (14:45 -0800)

Merge branch 'lr/doc-fix-cet'

* lr/doc-fix-cet:
date-formats.txt: Typo fix

Merge branch 'sb/t3600-cleanup'Junio C Hamano Mon, 19 Dec 2016 22:45:39 +0000 (14:45 -0800)

Merge branch 'sb/t3600-cleanup'

Code cleanup.

* sb/t3600-cleanup:
t3600: slightly modernize style
t3600: remove useless redirect

Merge branch 'jc/pull-rebase-ff'Junio C Hamano Mon, 19 Dec 2016 22:45:38 +0000 (14:45 -0800)

Merge branch 'jc/pull-rebase-ff'

"git pull --rebase", when there is no new commits on our side since
we forked from the upstream, should be able to fast-forward without
invoking "git rebase", but it didn't.

* jc/pull-rebase-ff:
pull: fast-forward "pull --rebase=true"

Merge branch 'ld/p4-worktree'Junio C Hamano Mon, 19 Dec 2016 22:45:37 +0000 (14:45 -0800)

Merge branch 'ld/p4-worktree'

"git p4" didn't interact with the internal of .git directory
correctly in the modern "git-worktree"-enabled world.

* ld/p4-worktree:
git-p4: support git worktrees

Merge branch 'jk/make-tags-find-sources-tweak'Junio C Hamano Mon, 19 Dec 2016 22:45:37 +0000 (14:45 -0800)

Merge branch 'jk/make-tags-find-sources-tweak'

Update the procedure to generate "tags" for developer support.

* jk/make-tags-find-sources-tweak:
Makefile: exclude contrib from FIND_SOURCE_FILES
Makefile: match shell scripts in FIND_SOURCE_FILES
Makefile: exclude test cruft from FIND_SOURCE_FILES
Makefile: reformat FIND_SOURCE_FILES

Merge branch 'js/normalize-path-copy-ceil'Junio C Hamano Mon, 19 Dec 2016 22:45:37 +0000 (14:45 -0800)

Merge branch 'js/normalize-path-copy-ceil'

A pathname that begins with "//" or "\\" on Windows is special but
path normalization logic was unaware of it.

* js/normalize-path-copy-ceil:
normalize_path_copy(): fix pushing to //server/share/dir on Windows

Merge branch 'bb/unicode-9.0'Junio C Hamano Mon, 19 Dec 2016 22:45:36 +0000 (14:45 -0800)

Merge branch 'bb/unicode-9.0'

The character width table has been updated to match Unicode 9.0

* bb/unicode-9.0:
unicode_width.h: update the width tables to Unicode 9.0
update_unicode.sh: remove the plane filter
update_unicode.sh: automatically download newer definition files
update_unicode.sh: pin the uniset repo to a known good commit
update_unicode.sh: remove an unnecessary subshell level
update_unicode.sh: move it into contrib/update-unicode

Merge branch 'jk/readme-gmane-is-no-more'Junio C Hamano Mon, 19 Dec 2016 22:45:35 +0000 (14:45 -0800)

Merge branch 'jk/readme-gmane-is-no-more'

* jk/readme-gmane-is-no-more:
README: replace gmane link with public-inbox

Merge branch 'jc/lock-report-on-error'Junio C Hamano Mon, 19 Dec 2016 22:45:35 +0000 (14:45 -0800)

Merge branch 'jc/lock-report-on-error'

Git 2.11 had a minor regression in "merge --ff-only" that competed
with another process that simultanously attempted to update the
index. We used to explain what went wrong with an error message,
but the new code silently failed. The error message has been
resurrected.

* jc/lock-report-on-error:
lockfile: LOCK_REPORT_ON_ERROR
hold_locked_index(): align error handling with hold_lockfile_for_update()
wt-status: implement opportunisitc index update correctly

Merge branch 'jk/xdiff-drop-xdl-fast-hash'Junio C Hamano Mon, 19 Dec 2016 22:45:35 +0000 (14:45 -0800)

Merge branch 'jk/xdiff-drop-xdl-fast-hash'

Retire the "fast hash" that had disastrous performance issues in
some corner cases.

* jk/xdiff-drop-xdl-fast-hash:
xdiff: drop XDL_FAST_HASH

Merge branch 'nd/rebase-forget'Junio C Hamano Mon, 19 Dec 2016 22:45:35 +0000 (14:45 -0800)

Merge branch 'nd/rebase-forget'

"git rebase" learned "--quit" option, which allows a user to
remove the metadata left by an earlier "git rebase" that was
manually aborted without using "git rebase --abort".

* nd/rebase-forget:
rebase: add --quit to cleanup rebase, leave everything else untouched

Merge branch 'jk/trailers-placeholder-in-pretty'Junio C Hamano Mon, 19 Dec 2016 22:45:34 +0000 (14:45 -0800)

Merge branch 'jk/trailers-placeholder-in-pretty'

In addition to %(subject), %(body), "log --pretty=format:..."
learned a new placeholder %(trailers).

* jk/trailers-placeholder-in-pretty:
ref-filter: add support to display trailers as part of contents
pretty: add %(trailers) format for displaying trailers of a commit message

Merge branch 'ak/commit-only-allow-empty'Junio C Hamano Mon, 19 Dec 2016 22:45:34 +0000 (14:45 -0800)

Merge branch 'ak/commit-only-allow-empty'

"git commit --allow-empty --only" (no pathspec) with dirty index
ought to be an acceptable way to create a new commit that does not
change any paths, but it was forbidden, perhaps because nobody
needed it so far.

* ak/commit-only-allow-empty:
commit: remove 'Clever' message for --only --amend
commit: make --only --allow-empty work without paths

Merge branch 'da/difftool-dir-diff-fix'Junio C Hamano Mon, 19 Dec 2016 22:45:33 +0000 (14:45 -0800)

Merge branch 'da/difftool-dir-diff-fix'

"git difftool --dir-diff" had a minor regression when started from
a subdirectory, which has been fixed.

* da/difftool-dir-diff-fix:
difftool: fix dir-diff index creation when in a subdirectory