gitweb.git
skip_prefix: add case-insensitive variantJeff King Sun, 13 May 2018 16:57:14 +0000 (12:57 -0400)

skip_prefix: add case-insensitive variant

We have the convenient skip_prefix() helper, but if you want
to do case-insensitive matching, you're stuck doing it by
hand. We could add an extra parameter to the function to
let callers ask for this, but the function is small and
somewhat performance-critical. Let's just re-implement it
for the case-insensitive version.

Signed-off-by: Jeff King <peff@peff.net>

is_{hfs,ntfs}_dotgitmodules: add testsJohannes Schindelin Sat, 12 May 2018 20:16:51 +0000 (22:16 +0200)

is_{hfs,ntfs}_dotgitmodules: add tests

This tests primarily for NTFS issues, but also adds one example of an
HFS+ issue.

Thanks go to Congyi Wu for coming up with the list of examples where
NTFS would possibly equate the filename with `.gitmodules`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff King <peff@peff.net>

is_ntfs_dotgit: match other .git filesJohannes Schindelin Fri, 11 May 2018 14:03:54 +0000 (16:03 +0200)

is_ntfs_dotgit: match other .git files

When we started to catch NTFS short names that clash with .git, we only
looked for GIT~1. This is sufficient because we only ever clone into an
empty directory, so .git is guaranteed to be the first subdirectory or
file in that directory.

However, even with a fresh clone, .gitmodules is *not* necessarily the
first file to be written that would want the NTFS short name GITMOD~1: a
malicious repository can add .gitmodul0000 and friends, which sorts
before `.gitmodules` and is therefore checked out *first*. For that
reason, we have to test not only for ~1 short names, but for others,
too.

It's hard to just adapt the existing checks in is_ntfs_dotgit(): since
Windows 2000 (i.e., in all Windows versions still supported by Git),
NTFS short names are only generated in the <prefix>~<number> form up to
number 4. After that, a *different* prefix is used, calculated from the
long file name using an undocumented, but stable algorithm.

For example, the short name of .gitmodules would be GITMOD~1, but if it
is taken, and all of ~2, ~3 and ~4 are taken, too, the short name
GI7EBA~1 will be used. From there, collisions are handled by
incrementing the number, shortening the prefix as needed (until ~9999999
is reached, in which case NTFS will not allow the file to be created).

We'd also want to handle .gitignore and .gitattributes, which suffer
from a similar problem, using the fall-back short names GI250A~1 and
GI7D29~1, respectively.

To accommodate for that, we could reimplement the hashing algorithm, but
it is just safer and simpler to provide the known prefixes. This
algorithm has been reverse-engineered and described at
https://usn.pw/blog/gen/2015/06/09/filenames/, which is defunct but
still available via https://web.archive.org/.

These can be recomputed by running the following Perl script:

-- snip --
use warnings;
use strict;

sub compute_short_name_hash ($) {
my $checksum = 0;
foreach (split('', $_[0])) {
$checksum = ($checksum * 0x25 + ord($_)) & 0xffff;
}

$checksum = ($checksum * 314159269) & 0xffffffff;
$checksum = 1 + (~$checksum & 0x7fffffff) if ($checksum & 0x80000000);
$checksum -= (($checksum * 1152921497) >> 60) * 1000000007;

return scalar reverse sprintf("%x", $checksum & 0xffff);
}

print compute_short_name_hash($ARGV[0]);
-- snap --

E.g., running that with the argument ".gitignore" will
result in "250a" (which then becomes "gi250a" in the code).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff King <peff@peff.net>

is_hfs_dotgit: match other .git filesJeff King Wed, 2 May 2018 19:23:45 +0000 (15:23 -0400)

is_hfs_dotgit: match other .git files

Both verify_path() and fsck match ".git", ".GIT", and other
variants specific to HFS+. Let's allow matching other
special files like ".gitmodules", which we'll later use to
enforce extra restrictions via verify_path() and fsck.

Signed-off-by: Jeff King <peff@peff.net>

is_ntfs_dotgit: use a size_t for traversing stringJeff King Sun, 13 May 2018 16:09:42 +0000 (12:09 -0400)

is_ntfs_dotgit: use a size_t for traversing string

We walk through the "name" string using an int, which can
wrap to a negative value and cause us to read random memory
before our array (e.g., by creating a tree with a name >2GB,
since "int" is still 32 bits even on most 64-bit platforms).
Worse, this is easy to trigger during the fsck_tree() check,
which is supposed to be protecting us from malicious
garbage.

Note one bit of trickiness in the existing code: we
sometimes assign -1 to "len" at the end of the loop, and
then rely on the "len++" in the for-loop's increment to take
it back to 0. This is still legal with a size_t, since
assigning -1 will turn into SIZE_MAX, which then wraps
around to 0 on increment.

Signed-off-by: Jeff King <peff@peff.net>

submodule-config: verify submodule names as pathsJeff King Mon, 30 Apr 2018 07:25:25 +0000 (03:25 -0400)

submodule-config: verify submodule names as paths

Submodule "names" come from the untrusted .gitmodules file,
but we blindly append them to $GIT_DIR/modules to create our
on-disk repo paths. This means you can do bad things by
putting "../" into the name (among other things).

Let's sanity-check these names to avoid building a path that
can be exploited. There are two main decisions:

1. What should the allowed syntax be?

It's tempting to reuse verify_path(), since submodule
names typically come from in-repo paths. But there are
two reasons not to:

a. It's technically more strict than what we need, as
we really care only about breaking out of the
$GIT_DIR/modules/ hierarchy. E.g., having a
submodule named "foo/.git" isn't actually
dangerous, and it's possible that somebody has
manually given such a funny name.

b. Since we'll eventually use this checking logic in
fsck to prevent downstream repositories, it should
be consistent across platforms. Because
verify_path() relies on is_dir_sep(), it wouldn't
block "foo\..\bar" on a non-Windows machine.

2. Where should we enforce it? These days most of the
.gitmodules reads go through submodule-config.c, so
I've put it there in the reading step. That should
cover all of the C code.

We also construct the name for "git submodule add"
inside the git-submodule.sh script. This is probably
not a big deal for security since the name is coming
from the user anyway, but it would be polite to remind
them if the name they pick is invalid (and we need to
expose the name-checker to the shell anyway for our
test scripts).

This patch issues a warning when reading .gitmodules
and just ignores the related config entry completely.
This will generally end up producing a sensible error,
as it works the same as a .gitmodules file which is
missing a submodule entry (so "submodule update" will
barf, but "git clone --recurse-submodules" will print
an error but not abort the clone.

There is one minor oddity, which is that we print the
warning once per malformed config key (since that's how
the config subsystem gives us the entries). So in the
new test, for example, the user would see three
warnings. That's OK, since the intent is that this case
should never come up outside of malicious repositories
(and then it might even benefit the user to see the
message multiple times).

Credit for finding this vulnerability and the proof of
concept from which the test script was adapted goes to
Etienne Stalmans.

Signed-off-by: Jeff King <peff@peff.net>

Git 2.13.6 v2.13.6Junio C Hamano Fri, 22 Sep 2017 05:49:24 +0000 (14:49 +0900)

Git 2.13.6

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

Sync with 2.12.5Junio C Hamano Fri, 22 Sep 2017 05:48:08 +0000 (14:48 +0900)

Sync with 2.12.5

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

Git 2.12.5 v2.12.5Junio C Hamano Fri, 22 Sep 2017 05:47:41 +0000 (14:47 +0900)

Git 2.12.5

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

Sync with 2.11.4Junio C Hamano Fri, 22 Sep 2017 05:45:30 +0000 (14:45 +0900)

Sync with 2.11.4

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

Git 2.11.4 v2.11.4Junio C Hamano Fri, 22 Sep 2017 05:44:45 +0000 (14:44 +0900)

Git 2.11.4

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

Sync with 2.10.5Junio C Hamano Fri, 22 Sep 2017 05:43:13 +0000 (14:43 +0900)

Sync with 2.10.5

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

Git 2.10.5 v2.10.5Junio C Hamano Fri, 22 Sep 2017 05:42:22 +0000 (14:42 +0900)

Git 2.10.5

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

Merge branch 'jk/safe-pipe-capture' into maint-2.10Junio C Hamano Fri, 22 Sep 2017 05:34:34 +0000 (14:34 +0900)

Merge branch 'jk/safe-pipe-capture' into maint-2.10

Merge branch 'jk/cvsimport-quoting' into maint-2.10Junio C Hamano Fri, 22 Sep 2017 05:34:34 +0000 (14:34 +0900)

Merge branch 'jk/cvsimport-quoting' into maint-2.10

Merge branch 'jc/cvsserver' into maint-2.10Junio C Hamano Fri, 22 Sep 2017 05:34:34 +0000 (14:34 +0900)

Merge branch 'jc/cvsserver' into maint-2.10

Merge branch 'jk/git-shell-drop-cvsserver' into maint... Junio C Hamano Fri, 22 Sep 2017 05:34:34 +0000 (14:34 +0900)

Merge branch 'jk/git-shell-drop-cvsserver' into maint-2.10

cvsimport: shell-quote variable used in backticksJeff King Mon, 11 Sep 2017 14:24:26 +0000 (10:24 -0400)

cvsimport: shell-quote variable used in backticks

We run `git rev-parse` though the shell, and quote its
argument only with single-quotes. This prevents most
metacharacters from being a problem, but misses the obvious
case when $name itself has single-quotes in it. We can fix
this by applying the usual shell-quoting formula.

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

archimport: use safe_pipe_capture for user inputJeff King Mon, 11 Sep 2017 14:24:11 +0000 (10:24 -0400)

archimport: use safe_pipe_capture for user input

Refnames can contain shell metacharacters which need to be
passed verbatim to sub-processes. Using safe_pipe_capture
skips the shell entirely.

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

shell: drop git-cvsserver support by defaultJeff King Mon, 11 Sep 2017 15:27:51 +0000 (11:27 -0400)

shell: drop git-cvsserver support by default

The git-cvsserver script is old and largely unmaintained
these days. But git-shell allows untrusted users to run it
out of the box, significantly increasing its attack surface.

Let's drop it from git-shell's list of internal handlers so
that it cannot be run by default. This is not backwards
compatible. But given the age and development activity on
CVS-related parts of Git, this is likely to impact very few
users, while helping many more (i.e., anybody who runs
git-shell and had no intention of supporting CVS).

There's no configuration mechanism in git-shell for us to
add a boolean and flip it to "off". But there is a mechanism
for adding custom commands, and adding CVS support here is
fairly trivial. Let's document it to give guidance to
anybody who really is still running cvsserver.

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

cvsserver: use safe_pipe_capture for `constant commands... Junio C Hamano Mon, 11 Sep 2017 05:45:54 +0000 (14:45 +0900)

cvsserver: use safe_pipe_capture for `constant commands` as well

This is not strictly necessary, but it is a good code hygiene.

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

cvsserver: use safe_pipe_capture instead of backticksjoernchen Mon, 11 Sep 2017 05:45:09 +0000 (14:45 +0900)

cvsserver: use safe_pipe_capture instead of backticks

This makes the script pass arguments that are derived from end-user
input in safer way when invoking subcommands.

Reported-by: joernchen <joernchen@phenoelit.de>
Signed-off-by: joernchen <joernchen@phenoelit.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cvsserver: move safe_pipe_capture() to the main packageJunio C Hamano Mon, 11 Sep 2017 05:44:24 +0000 (14:44 +0900)

cvsserver: move safe_pipe_capture() to the main package

As a preparation for replacing `command` with a call to this
function from outside GITCVS::updater package, move it to the main
package.

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

Git 2.13.5 v2.13.5Junio C Hamano Tue, 1 Aug 2017 19:30:00 +0000 (12:30 -0700)

Git 2.13.5

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

Merge tag 'v2.12.4' into maintJunio C Hamano Tue, 1 Aug 2017 19:27:31 +0000 (12:27 -0700)

Merge tag 'v2.12.4' into maint

Git 2.13.4 v2.13.4Junio C Hamano Tue, 1 Aug 2017 18:45:17 +0000 (11:45 -0700)

Git 2.13.4

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

Preparation for 2.13.4 continuesJunio C Hamano Mon, 31 Jul 2017 20:52:40 +0000 (13:52 -0700)

Preparation for 2.13.4 continues

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

Merge branch 'ks/doc-fixes' into maintJunio C Hamano Mon, 31 Jul 2017 20:51:06 +0000 (13:51 -0700)

Merge branch 'ks/doc-fixes' into maint

Doc clean-up.

* ks/doc-fixes:
doc: reformat the paragraph containing the 'cut-line'
doc: camelCase the i18n config variables to improve readability

Merge branch 'jk/test-copy-bytes-fix' into maintJunio C Hamano Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)

Merge branch 'jk/test-copy-bytes-fix' into maint

A test fix.

* jk/test-copy-bytes-fix:
t: handle EOF in test_copy_bytes()

Merge branch 'pw/unquote-path-in-git-pm' into maintJunio C Hamano Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)

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

Code refactoring.

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

Merge branch 'jk/gc-pre-detach-under-hook' into maintJunio C Hamano Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)

Merge branch 'jk/gc-pre-detach-under-hook' into maint

We run an early part of "git gc" that deals with refs before
daemonising (and not under lock) even when running a background
auto-gc, which caused multiple gc processes attempting to run the
early part at the same time. This is now prevented by running the
early part also under the GC lock.

* jk/gc-pre-detach-under-hook:
gc: run pre-detach operations under lock

Merge branch 'jn/hooks-pre-rebase-sample-fix' into... Junio C Hamano Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)

Merge branch 'jn/hooks-pre-rebase-sample-fix' into maint

Code clean-up, that makes us in sync with Debian by one patch.

* jn/hooks-pre-rebase-sample-fix:
pre-rebase hook: capture documentation in a <<here document

Merge branch 'rs/progress-overall-throughput-at-the... Junio C Hamano Mon, 31 Jul 2017 20:51:04 +0000 (13:51 -0700)

Merge branch 'rs/progress-overall-throughput-at-the-end' into maint

The progress meter did not give a useful output when we haven't had
0.5 seconds to measure the throughput during the interval. Instead
show the overall throughput rate at the end, which is a much more
useful number.

* rs/progress-overall-throughput-at-the-end:
progress: show overall rate in last update

Merge branch 'tb/push-to-cygwin-unc-path' into maintJunio C Hamano Mon, 31 Jul 2017 20:51:04 +0000 (13:51 -0700)

Merge branch 'tb/push-to-cygwin-unc-path' into maint

On Cygwin, similar to Windows, "git push //server/share/repository"
ought to mean a repository on a network share that can be accessed
locally, but this did not work correctly due to stripping the double
slashes at the beginning.

This may need to be heavily tested before it gets unleashed to the
wild, as the change is at a fairly low-level code and would affect
not just the code to decide if the push destination is local. There
may be unexpected fallouts in the path normalization.

* tb/push-to-cygwin-unc-path:
cygwin: allow pushing to UNC paths

Merge branch 'rs/apply-avoid-over-reading' into maintJunio C Hamano Mon, 31 Jul 2017 20:51:04 +0000 (13:51 -0700)

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

Code cleanup.

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

Git 2.12.4 v2.12.4Junio C Hamano Sun, 30 Jul 2017 22:06:06 +0000 (15:06 -0700)

Git 2.12.4

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

Merge tag 'v2.11.3' into maint-2.12Junio C Hamano Sun, 30 Jul 2017 22:04:22 +0000 (15:04 -0700)

Merge tag 'v2.11.3' into maint-2.12

Git 2.11.3

Merge branch 'jk/lib-proto-disable-cleanup' into maint... Junio C Hamano Sun, 30 Jul 2017 22:03:21 +0000 (15:03 -0700)

Merge branch 'jk/lib-proto-disable-cleanup' into maint-2.12

Git 2.11.3 v2.11.3Junio C Hamano Sun, 30 Jul 2017 22:02:37 +0000 (15:02 -0700)

Git 2.11.3

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

Merge tag 'v2.10.4' into maint-2.11Junio C Hamano Sun, 30 Jul 2017 22:01:31 +0000 (15:01 -0700)

Merge tag 'v2.10.4' into maint-2.11

Git 2.10.4

Git 2.10.4 v2.10.4Junio C Hamano Sun, 30 Jul 2017 22:00:04 +0000 (15:00 -0700)

Git 2.10.4

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

Merge tag 'v2.9.5' into maint-2.10Junio C Hamano Sun, 30 Jul 2017 21:57:33 +0000 (14:57 -0700)

Merge tag 'v2.9.5' into maint-2.10

Git 2.9.5

Git 2.9.5 v2.9.5Junio C Hamano Sun, 30 Jul 2017 21:53:25 +0000 (14:53 -0700)

Git 2.9.5

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

Merge tag 'v2.8.6' into maint-2.9Junio C Hamano Sun, 30 Jul 2017 21:52:14 +0000 (14:52 -0700)

Merge tag 'v2.8.6' into maint-2.9

Git 2.8.6

Git 2.8.6 v2.8.6Junio C Hamano Sun, 30 Jul 2017 21:49:08 +0000 (14:49 -0700)

Git 2.8.6

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

Merge tag 'v2.7.6' into maint-2.8Junio C Hamano Sun, 30 Jul 2017 21:46:43 +0000 (14:46 -0700)

Merge tag 'v2.7.6' into maint-2.8

Git 2.7.6

Git 2.7.6 v2.7.6Junio C Hamano Sun, 30 Jul 2017 21:45:13 +0000 (14:45 -0700)

Git 2.7.6

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

Merge branch 'jk/ssh-funny-url' into maint-2.7Junio C Hamano Fri, 28 Jul 2017 23:11:54 +0000 (16:11 -0700)

Merge branch 'jk/ssh-funny-url' into maint-2.7

connect: reject paths that look like command line optionsJeff King Fri, 28 Jul 2017 19:28:55 +0000 (15:28 -0400)

connect: reject paths that look like command line options

If we get a repo path like "-repo.git", we may try to invoke
"git-upload-pack -repo.git". This is going to fail, since
upload-pack will interpret it as a set of bogus options. But
let's reject this before we even run the sub-program, since
we would not want to allow any mischief with repo names that
actually are real command-line options.

You can still ask for such a path via git-daemon, but there's no
security problem there, because git-daemon enters the repo itself
and then passes "." on the command line.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

connect: reject dashed arguments for proxy commandsJeff King Fri, 28 Jul 2017 19:26:50 +0000 (15:26 -0400)

connect: reject dashed arguments for proxy commands

If you have a GIT_PROXY_COMMAND configured, we will run it
with the host/port on the command-line. If a URL contains a
mischievous host like "--foo", we don't know how the proxy
command may handle it. It's likely to break, but it may also
do something dangerous and unwanted (technically it could
even do something useful, but that seems unlikely).

We should err on the side of caution and reject this before
we even run the command.

The hostname check matches the one we do in a similar
circumstance for ssh. The port check is not present for ssh,
but there it's not necessary because the syntax is "-p
<port>", and there's no ambiguity on the parsing side.

It's not clear whether you can actually get a negative port
to the proxy here or not. Doing:

git fetch git://remote:-1234/repo.git

keeps the "-1234" as part of the hostname, with the default
port of 9418. But it's a good idea to keep this check close
to the point of running the command to make it clear that
there's no way to circumvent it (and at worst it serves as a
belt-and-suspenders check).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

connect: factor out "looks like command line option... Jeff King Fri, 28 Jul 2017 19:25:45 +0000 (15:25 -0400)

connect: factor out "looks like command line option" check

We reject hostnames that start with a dash because they may
be confused for command-line options. Let's factor out that
notion into a helper function, as we'll use it in more
places. And while it's simple now, it's not clear if some
systems might need more complex logic to handle all cases.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5813: add test for hostname starting with dashJeff King Fri, 28 Jul 2017 19:23:32 +0000 (15:23 -0400)

t5813: add test for hostname starting with dash

Per the explanation in the previous patch, this should be
(and is) rejected.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

connect: reject ssh hostname that begins with a dashJunio C Hamano Wed, 26 Jul 2017 17:24:20 +0000 (10:24 -0700)

connect: reject ssh hostname that begins with a dash

When commands like "git fetch" talk with ssh://$rest_of_URL/, the
code splits $rest_of_URL into components like host, port, etc., and
then spawns the underlying "ssh" program by formulating argv[] array
that has:

- the path to ssh command taken from GIT_SSH_COMMAND, etc.

- dashed options like '-batch' (for Tortoise), '-p <port>' as
needed.

- ssh_host, which is supposed to be the hostname parsed out of
$rest_of_URL.

- then the command to be run on the other side, e.g. git
upload-pack.

If the ssh_host ends up getting '-<anything>', the argv[] that is
used to spawn the command becomes something like:

{ "ssh", "-p", "22", "-<anything>", "command", "to", "run", NULL }

which obviously is bogus, but depending on the actual value of
"<anything>", will make "ssh" parse and use it as an option.

Prevent this by forbidding ssh_host that begins with a "-".

Noticed-by: Joern Schneeweisz of Recurity Labs
Reported-by: Brian at GitLab
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/lib-proto-disable: restore protocol.allow after confi... Jeff King Fri, 28 Jul 2017 21:47:48 +0000 (17:47 -0400)

t/lib-proto-disable: restore protocol.allow after config tests

The tests for protocol.allow actually set that variable in
the on-disk config, run a series of tests, and then never
clean up after themselves. This means that whatever tests we
run after have protocol.allow=never, which may influence
their results.

In most cases we either exit after running these tests, or
do another round of test_proto(). In the latter case, this happens to
work because:

1. Tests of the GIT_ALLOW_PROTOCOL environment variable
override the config.

2. Tests of the specific config "protocol.foo.allow"
override the protocol.allow config.

3. The next round of protocol.allow tests start off by
setting the config to a known value.

However, it's a land-mine waiting to trap somebody adding
new tests to one of the t581x test scripts. Let's make sure
we clean up after ourselves.

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

fixes from 'master' for 2.13.4Junio C Hamano Fri, 21 Jul 2017 22:06:09 +0000 (15:06 -0700)

fixes from 'master' for 2.13.4

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

Merge branch 'ew/fd-cloexec-fix' into maintJunio C Hamano Fri, 21 Jul 2017 22:03:40 +0000 (15:03 -0700)

Merge branch 'ew/fd-cloexec-fix' into maint

Portability/fallback fix.

* ew/fd-cloexec-fix:
set FD_CLOEXEC properly when O_CLOEXEC is not supported

Merge branch 'ks/fix-rebase-doc-picture' into maintJunio C Hamano Fri, 21 Jul 2017 22:03:39 +0000 (15:03 -0700)

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

Doc update.

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

Merge branch 'js/alias-case-sensitivity' into maintJunio C Hamano Fri, 21 Jul 2017 22:03:38 +0000 (15:03 -0700)

Merge branch 'js/alias-case-sensitivity' into maint

A recent update broke an alias that contained an uppercase letter.

* js/alias-case-sensitivity:
alias: compare alias name *case-insensitively*
t1300: demonstrate that CamelCased aliases regressed

Merge branch 'bb/unicode-10.0' into maintJunio C Hamano Fri, 21 Jul 2017 22:03:38 +0000 (15:03 -0700)

Merge branch 'bb/unicode-10.0' into maint

Update the character width tables.

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

doc: reformat the paragraph containing the 'cut-line'Kaartic Sivaraam Tue, 18 Jul 2017 14:34:27 +0000 (20:04 +0530)

doc: reformat the paragraph containing the 'cut-line'

The paragraph that describes the 'scissors' cleanup mode of
'commit' had the 'cut-line' in the middle of a sentence. This
made it possible for the line to get wrapped on smaler windows.
This shouldn't be the case as it makes it hard for the user to
understand the structure of the cut-line.

Reformat the pragraph to make the 'cut-line' stand on a line of
it's own thus distinguishing it from the rest of the paragraph.
This further prevents it from getting wrapped to some extent.

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

doc: camelCase the i18n config variables to improve... Kaartic Sivaraam Mon, 17 Jul 2017 15:39:00 +0000 (21:09 +0530)

doc: camelCase the i18n config variables to improve readability

The i18n config variable used weren't readable as they were in
the crude form of how git stores/uses it's config variables.

Improve it's readability by replacing them with camelCased versions
of config variables as it doesn't have any impact on it's usage.

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

t: handle EOF in test_copy_bytes()Jeff King Sun, 16 Jul 2017 10:45:32 +0000 (06:45 -0400)

t: handle EOF in test_copy_bytes()

The test_copy_bytes() function claims to read up to N bytes,
or until it gets EOF. But we never handle EOF in our loop,
and a short input will cause perl to go into an infinite
loop of read() getting zero bytes.

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

set FD_CLOEXEC properly when O_CLOEXEC is not supportedEric Wong Sat, 15 Jul 2017 18:55:40 +0000 (18:55 +0000)

set FD_CLOEXEC properly when O_CLOEXEC is not supported

FD_CLOEXEC only applies to the file descriptor, so it needs to be
manipuluated via F_GETFD/F_SETFD. F_GETFL/F_SETFL are for file
description flags.

Verified via strace with o_cloexec set to zero.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

alias: compare alias name *case-insensitively*Johannes Schindelin Fri, 14 Jul 2017 08:39:38 +0000 (10:39 +0200)

alias: compare alias name *case-insensitively*

It is totally legitimate to add CamelCased aliases, but due to the way
config keys are compared, the case does not matter.

Therefore, we must compare the alias name insensitively to the config
keys.

This fixes a regression introduced by a9bcf6586d1 (alias: use
the early config machinery to expand aliases, 2017-06-14).

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

t1300: demonstrate that CamelCased aliases regressedJohannes Schindelin Fri, 14 Jul 2017 08:39:29 +0000 (10:39 +0200)

t1300: demonstrate that CamelCased aliases regressed

It is totally legitimate to add CamelCased aliases, but due to the way
config keys are compared, the case does not matter.

Except that now it does: the alias name is expected to be all
lower-case. This is a regression introduced by a9bcf6586d1 (alias: use
the early config machinery to expand aliases, 2017-06-14).

Noticed by Alejandro Pauly, diagnosed by Kevin Willford.

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

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

Git 2.13.3

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

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

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

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

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

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

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

Typofix.

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

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

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

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

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

gc: run pre-detach operations under lockJeff King Tue, 11 Jul 2017 09:06:35 +0000 (05:06 -0400)

gc: run pre-detach operations under lock

We normally try to avoid having two auto-gc operations run
at the same time, because it wastes resources. This was done
long ago in 64a99eb47 (gc: reject if another gc is running,
unless --force is given, 2013-08-08).

When we do a detached auto-gc, we run the ref-related
commands _before_ detaching, to avoid confusing lock
contention. This was done by 62aad1849 (gc --auto: do not
lock refs in the background, 2014-05-25).

These two features do not interact well. The pre-detach
operations are run before we check the gc.pid lock, meaning
that on a busy repository we may run many of them
concurrently. Ideally we'd take the lock before spawning any
operations, and hold it for the duration of the program.

This is tricky, though, with the way the pid-file interacts
with the daemonize() process. Other processes will check
that the pid recorded in the pid-file still exists. But
detaching causes us to fork and continue running under a
new pid. So if we take the lock before detaching, the
pid-file will have a bogus pid in it. We'd have to go back
and update it with the new pid after detaching. We'd also
have to play some tricks with the tempfile subsystem to
tweak the "owner" field, so that the parent process does not
clean it up on exit, but the child process does.

Instead, we can do something a bit simpler: take the lock
only for the duration of the pre-detach work, then detach,
then take it again for the post-detach work. Technically,
this means that the post-detach lock could lose to another
process doing pre-detach work. But in the long run this
works out.

That second process would then follow-up by doing
post-detach work. Unless it was in turn blocked by a third
process doing pre-detach work, and so on. This could in
theory go on indefinitely, as the pre-detach work does not
repack, and so need_to_gc() will continue to trigger. But
in each round we are racing between the pre- and post-detach
locks. Eventually, one of the post-detach locks will win the
race and complete the full gc. So in the worst case, we may
racily repeat the pre-detach work, but we would never do so
simultaneously (it would happen via a sequence of serialized
race-wins).

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

pre-rebase hook: capture documentation in a <<here... Jonathan Nieder Mon, 10 Jul 2017 23:35:25 +0000 (16:35 -0700)

pre-rebase hook: capture documentation in a <<here document

Without this change, the sample hook does not pass a syntax check
(sh -n):

$ sh -n hooks--pre-rebase.sample
hooks--pre-rebase.sample: line 101: syntax error near unexpected token `('
hooks--pre-rebase.sample: line 101: ` merged into it again (either directly or indirectly).'

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

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

Prepare for 2.13.3

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

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

Code clean-up.

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

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

Merge branch 'jc/utf8-fprintf' into maint

Code cleanup.

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

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

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

Test fix.

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

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

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

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

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

Merge branch 'ab/sha1dc-maint' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:06 +0000 (13:59 -0700)

Merge branch 'ab/sha1dc-maint' into maint

Update the sha1dc again to fix portability glitches.

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

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

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

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

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

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

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

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

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

Merge branch 'ah/doc-pretty-color-auto-prefix' into... Junio C Hamano Mon, 10 Jul 2017 20:59:05 +0000 (13:59 -0700)

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

Doc update.

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

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

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

Message update.

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

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

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

Cosmetic update to a test.

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

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

Merge branch 'sb/t4005-modernize' into maint

Test clean-up.

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

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

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

Tighten error checks for invalid "git apply" input.

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

Merge branch 'jc/pack-bitmap-unaligned' into maintJunio C Hamano Mon, 10 Jul 2017 20:59:00 +0000 (13:59 -0700)

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

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

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

Merge branch 'pw/rebase-i-regression-fix-tests' into... Junio C Hamano Mon, 10 Jul 2017 20:58:59 +0000 (13:58 -0700)

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

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

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

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

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

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

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

Merge branch 'js/alias-early-config' into maintJunio C Hamano Mon, 10 Jul 2017 20:58:57 +0000 (13:58 -0700)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ref-filter.c: drop return from void function

Sun's C compiler errors out on this pattern:

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

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

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

l10n: de.po: fix typo

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

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

doc: correct a mistake in an illustration

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

Correct it.

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

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

progress: show overall rate in last update

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

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

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

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

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

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

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

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

branch: set remote color in ref-filter branch immediately

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

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

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

branch: use BRANCH_COLOR_LOCAL in ref-filter format

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

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

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

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

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

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

branch: only perform HEAD check for local branches

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

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

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