gitweb.git
hoist out handle_nonblock function for xread and xwriteEric Wong Sun, 10 Jul 2016 08:20:46 +0000 (08:20 +0000)

hoist out handle_nonblock function for xread and xwrite

At least for me, this improves the readability of xread and
xwrite; hopefully allowing missing "continue" statements to
be spotted more easily.

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

am: counteract gender biasJohannes Schindelin Fri, 8 Jul 2016 07:17:34 +0000 (09:17 +0200)

am: counteract gender bias

Since 47f0b6d5 (Fall back to three-way merge when applying a patch.,
2005-10-06), i.e. for almost 11 years already, we used a male form
to describe "the other tree".

While it was unintended, this gave the erroneous impression as if
the Git developers thought of users as male, and were unaware of the
important role in software development played by female actors such
as Ada Lovelace, Grace Hopper and Margaret Hamilton. In fact, the
first professional software developers were all female.

Let's change those unfortunate references to the gender neutral
"their tree". Doing so also makes the fallback_merge_recursive(),
which is an oddball, more in line with the other parts of the system
where we contrast what we have vs what we obtain from others by
saying "ours" vs "theirs". This inconsistency was also unintended.

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

notes-merge: use O_EXCL to avoid overwriting existing... René Scharfe Thu, 7 Jul 2016 20:08:30 +0000 (22:08 +0200)

notes-merge: use O_EXCL to avoid overwriting existing files

Use the open(2) flag O_EXCL to ensure the file doesn't already exist
instead of (racily) calling stat(2) through file_exists(). While at it
switch to xopen() to reduce code duplication and get more consistent
error messages.

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

.gitattributes: set file type for C filesRené Scharfe Thu, 7 Jul 2016 20:11:50 +0000 (22:11 +0200)

.gitattributes: set file type for C files

Set the diff attribute for C source file to "cpp" in order to improve
git's ability to determine hunk headers. In particular it helps avoid
showing unindented labels in hunk headers. That in turn is useful for
git diff -W and git grep -W, which show whole functions now instead of
stopping at a label.

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

sideband.c: small optimization of strbuf usageNicolas Pitre Tue, 5 Jul 2016 20:35:50 +0000 (16:35 -0400)

sideband.c: small optimization of strbuf usage

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

More fixes for 2.9.1Junio C Hamano Wed, 6 Jul 2016 20:08:02 +0000 (13:08 -0700)

More fixes for 2.9.1

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

Merge branch 'jc/deref-tag' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:46 +0000 (13:06 -0700)

Merge branch 'jc/deref-tag' into maint

Code clean-up.

* jc/deref-tag:
blame, line-log: do not loop around deref_tag()

Merge branch 'pb/strbuf-read-file-doc' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:45 +0000 (13:06 -0700)

Merge branch 'pb/strbuf-read-file-doc' into maint

Minor doc update.

* pb/strbuf-read-file-doc:
strbuf: describe the return value of strbuf_read_file

Merge branch 'jk/fetch-prune-doc' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:44 +0000 (13:06 -0700)

Merge branch 'jk/fetch-prune-doc' into maint

Minor doc update.

* jk/fetch-prune-doc:
fetch: document that pruning happens before fetching

Merge branch 'pc/occurred' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:43 +0000 (13:06 -0700)

Merge branch 'pc/occurred' into maint

Typofix.

* pc/occurred:
config.c: fix misspelt "occurred" in an error message
refs.h: fix misspelt "occurred" in a comment

Merge branch 'mg/cherry-pick-multi-on-unborn' into... Junio C Hamano Wed, 6 Jul 2016 20:06:42 +0000 (13:06 -0700)

Merge branch 'mg/cherry-pick-multi-on-unborn' into maint

"git cherry-pick A" worked on an unborn branch, but "git
cherry-pick A..B" didn't.

* mg/cherry-pick-multi-on-unborn:
cherry-pick: allow to pick to unborn branches

Merge branch 'em/newer-freebsd-shells-are-fine-with... Junio C Hamano Wed, 6 Jul 2016 20:06:41 +0000 (13:06 -0700)

Merge branch 'em/newer-freebsd-shells-are-fine-with-returns' into maint

Comments about misbehaving FreeBSD shells have been clarified with
the version number (9.x and before are broken, newer ones are OK).

* em/newer-freebsd-shells-are-fine-with-returns:
rebase: update comment about FreeBSD /bin/sh

Merge branch 'lv/status-say-working-tree-not-directory... Junio C Hamano Wed, 6 Jul 2016 20:06:40 +0000 (13:06 -0700)

Merge branch 'lv/status-say-working-tree-not-directory' into maint

"git status" used to say "working directory" when it meant "working
tree".

* lv/status-say-working-tree-not-directory:
Use "working tree" instead of "working directory" for git status

Merge branch 'nb/gnome-keyring-build' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:40 +0000 (13:06 -0700)

Merge branch 'nb/gnome-keyring-build' into maint

Build improvements for gnome-keyring (in contrib/)

* nb/gnome-keyring-build:
gnome-keyring: Don't hard-code pkg-config executable

Merge branch 'et/add-chmod-x' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:39 +0000 (13:06 -0700)

Merge branch 'et/add-chmod-x' into maint

"git update-index --add --chmod=+x file" may be usable as an escape
hatch, but not a friendly thing to force for people who do need to
use it regularly. "git add --chmod=+x file" can be used instead.

* et/add-chmod-x:
add: add --chmod=+x / --chmod=-x options

Merge branch 'jk/avoid-unbounded-alloca' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:39 +0000 (13:06 -0700)

Merge branch 'jk/avoid-unbounded-alloca' into maint

A codepath that used alloca(3) to place an unbounded amount of data
on the stack has been updated to avoid doing so.

* jk/avoid-unbounded-alloca:
tree-diff: avoid alloca for large allocations

Merge branch 'rj/compat-regex-size-max-fix' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:38 +0000 (13:06 -0700)

Merge branch 'rj/compat-regex-size-max-fix' into maint

A compilation fix.

* rj/compat-regex-size-max-fix:
regex: fix a SIZE_MAX macro redefinition warning

Merge branch 'vs/prompt-avoid-unset-variable' into... Junio C Hamano Wed, 6 Jul 2016 20:06:38 +0000 (13:06 -0700)

Merge branch 'vs/prompt-avoid-unset-variable' into maint

The git-prompt scriptlet (in contrib/) was not friendly with those
who uses "set -u", which has been fixed.

* vs/prompt-avoid-unset-variable:
git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION, $short_sha

Merge branch 'sg/reflog-past-root' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:37 +0000 (13:06 -0700)

Merge branch 'sg/reflog-past-root' into maint

"git reflog" stopped upon seeing an entry that denotes a branch
creation event (aka "unborn"), which made it appear as if the
reflog was truncated.

* sg/reflog-past-root:
reflog: continue walking the reflog past root commits

Merge branch 'dn/gpg-doc' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:36 +0000 (13:06 -0700)

Merge branch 'dn/gpg-doc' into maint

The documentation tries to consistently spell "GPG"; when
referring to the specific program name, "gpg" is used.

* dn/gpg-doc:
Documentation: GPG capitalization

Merge branch 'ap/git-svn-propset-doc' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:35 +0000 (13:06 -0700)

Merge branch 'ap/git-svn-propset-doc' into maint

"git svn propset" subcommand that was added in 2.3 days is
documented now.

* ap/git-svn-propset-doc:
git-svn: document the 'git svn propset' command

Merge branch 'tr/doc-tt' into maintJunio C Hamano Wed, 6 Jul 2016 20:06:34 +0000 (13:06 -0700)

Merge branch 'tr/doc-tt' into maint

The documentation set has been updated so that literal commands,
configuration variables and environment variables are consistently
typeset in fixed-width font and bold in manpages.

* tr/doc-tt:
doc: change configuration variables format
doc: more consistency in environment variables format
doc: change environment variables format
doc: clearer rule about formatting literals

t7610: test for mktemp before test executionArmin Kunaschik Sat, 2 Jul 2016 19:01:51 +0000 (21:01 +0200)

t7610: test for mktemp before test execution

mktemp is not available on all platforms, so the test
'temporary filenames are used with mergetool.writeToTemp'
fails there.
This patch does not replace mktemp but just disables
the test that otherwise would fail.
mergetool checks itself before executing mktemp and
reports an error.

Signed-off-by: Armin Kunaschik <megabreit@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: unify the "auto" handling of CRLFTorsten Bögershausen Tue, 28 Jun 2016 08:01:13 +0000 (10:01 +0200)

convert: unify the "auto" handling of CRLF

Before this change,
$ echo "* text=auto" >.gitattributes
$ echo "* eol=crlf" >>.gitattributes

would have the same effect as
$ echo "* text" >.gitattributes
$ git config core.eol crlf

Since the 'eol' attribute had higher priority than 'text=auto', this may
corrupt binary files and is not what most users expect to happen.

Make the 'eol' attribute to obey 'text=auto' and now
$ echo "* text=auto" >.gitattributes
$ echo "* eol=crlf" >>.gitattributes
behaves the same as
$ echo "* text=auto" >.gitattributes
$ git config core.eol crlf

In other words,
$ echo "* text=auto eol=crlf" >.gitattributes
has the same effect as
$ git config core.autocrlf true

and
$ echo "* text=auto eol=lf" >.gitattributes
has the same effect as
$ git config core.autocrlf input

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

Makefile: use VCSSVN_LIB to refer to svn libraryJeff King Fri, 1 Jul 2016 07:59:44 +0000 (03:59 -0400)

Makefile: use VCSSVN_LIB to refer to svn library

We have an abstracted variable; let's use it consistently.

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

Makefile: drop extra dependencies for test helpersJeff King Fri, 1 Jul 2016 07:56:52 +0000 (03:56 -0400)

Makefile: drop extra dependencies for test helpers

A few test-helpers have Makefile dependencies on specific
object files. But since these files are part of libgit.a
(which all of the helpers link against), the inclusion is
simply redundant.

These were once necessary, but became redundant due to
5c5ba73 (Makefile: Use generic rule to build test programs,
2007-05-31), which added the $(GITLIBS) dependency (but
didn't prune the extra dependency lines). Later commits then
cargo-culted the practice (e.g., b4285c7).

Note that we _do_ need to leave the dependencies on the svn
library, as that is not part of the usual link command.

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

mailmap: use main email address for dturnerDavid Turner Mon, 4 Jul 2016 06:05:24 +0000 (02:05 -0400)

mailmap: use main email address for dturner

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

parse_options: allocate a new array when concatenatingJeff King Tue, 5 Jul 2016 20:44:47 +0000 (16:44 -0400)

parse_options: allocate a new array when concatenating

In exactly one callers (builtin/revert.c), we build up the
options list dynamically from multiple arrays. We do so by
manually inserting "filler" entries into one array, and then
copying the other array into the allocated space.

This is tedious and error-prone, as you have to adjust the
filler any time the second array is modified (although we do
at least check and die() when the counts do not match up).

Instead, let's just allocate a new array.

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

Merge branch 'jk/common-main-2.8' into jk/common-mainJunio C Hamano Wed, 6 Jul 2016 17:02:57 +0000 (10:02 -0700)

Merge branch 'jk/common-main-2.8' into jk/common-main

* jk/common-main-2.8:
mingw: declare main()'s argv as const
common-main: call git_setup_gettext()
common-main: call restore_sigpipe_to_default()
common-main: call sanitize_stdfds()
common-main: call git_extract_argv0_path()
add an extra level of indirection to main()

mingw: declare main()'s argv as constJohannes Schindelin Fri, 1 Jul 2016 13:01:28 +0000 (15:01 +0200)

mingw: declare main()'s argv as const

In 84d32bf (sparse: Fix mingw_main() argument number/type errors,
2013-04-27), we addressed problems identified by the 'sparse' tool where
argv was declared inconsistently. The way we addressed it was by casting
from the non-const version to the const-version.

This patch is long overdue, fixing compat/mingw.h's declaration to
make the "argv" parameter const. This also allows us to lose the
"const" trickery introduced earlier to common-main.c:main().

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

t/lib-git-daemon: use test_match_signalJeff King Fri, 24 Jun 2016 19:45:12 +0000 (15:45 -0400)

t/lib-git-daemon: use test_match_signal

When git-daemon exits, we expect it to be with the SIGTERM
we just sent it. If we see anything else, we'll complain.
But our check against exit code "143" is not portable. For
example:

$ ksh93 t5570-git-daemon.sh
[...]
error: git daemon exited with status: 271

We can fix this by using test_match_signal.

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

test_must_fail: use test_match_signalJeff King Fri, 24 Jun 2016 19:45:04 +0000 (15:45 -0400)

test_must_fail: use test_match_signal

In 8bf4bec (add "ok=sigpipe" to test_must_fail and use it to
fix flaky tests, 2015-11-27), test_must_fail learned to
recognize "141" as a sigpipe failure. However, testing for
a signal is more complicated than that; we should use
test_match_signal to implement more portable checking.

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

t0005: use test_match_signal as appropriateJeff King Fri, 24 Jun 2016 19:44:50 +0000 (15:44 -0400)

t0005: use test_match_signal as appropriate

The first test already uses this more portable construct
(that was where it was factored from initially), but the
later tests do a raw comparison against 141 to look for
SIGPIPE, which can fail on some shells and platforms.

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

tests: factor portable signal check out of t0005Jeff King Thu, 30 Jun 2016 08:16:18 +0000 (04:16 -0400)

tests: factor portable signal check out of t0005

In POSIX shells, a program which exits due to a signal
generally has an exit code of 128 plus the signal number.
However, ksh uses 256 plus the signal number. We've
accounted for that in t0005, but not in other tests. Let's
pull out the logic so we can use it elsewhere.

It would be nice for debugging if this additionally printed
errors to stderr, like our other test_* helpers. But we're
going to need to use it in other places besides the innards
of a test_expect block. So let's leave it as generic as
possible.

Note that we also leave the magic "3" for Windows out of the
generic helper. This is an artifact of the way we use
raise() to kill ourselves in test-sigchain.c, and will not
necessarily apply to all programs. So it's better to keep it
out of the helper, to reduce the chance of confusing it with
a real call to exit(3).

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

common-main: call git_setup_gettext()Jeff King Fri, 1 Jul 2016 06:07:01 +0000 (02:07 -0400)

common-main: call git_setup_gettext()

This should be part of every program, as otherwise users do
not get translated error messages. However, some external
commands forgot to do so (e.g., git-credential-store). This
fixes them, and eliminates the repeated code in programs
that did remember to use it.

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

common-main: call restore_sigpipe_to_default()Jeff King Fri, 1 Jul 2016 06:06:35 +0000 (02:06 -0400)

common-main: call restore_sigpipe_to_default()

This is another safety/sanity setup that should be in force
everywhere, but which we only applied in git.c. This did
catch most cases, since even external commands are typically
run via "git ..." (and the restoration applies to
sub-processes, too). But there were cases we missed, such as
somebody calling git-upload-pack directly via ssh, or
scripts which use dashed external commands directly.

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

common-main: call sanitize_stdfds()Jeff King Fri, 1 Jul 2016 06:06:02 +0000 (02:06 -0400)

common-main: call sanitize_stdfds()

This is setup that should be done in every program for
safety, but we never got around to adding it everywhere (so
builtins benefited from the call in git.c, but any external
commands did not). Putting it in the common main() gives us
this safety everywhere.

Note that the case in daemon.c is a little funny. We wait
until we know whether we want to daemonize, and then either:

- call daemonize(), which will close stdio and reopen it to
/dev/null under the hood

- sanitize_stdfds(), to fix up any odd cases

But that is way too late; the point of sanitizing is to give
us reliable descriptors on 0/1/2, and we will already have
executed code, possibly called die(), etc. The sanitizing
should be the very first thing that happens.

With this patch, git-daemon will sanitize first, and can
remove the call in the non-daemonize case. It does mean that
daemonize() may just end up closing the descriptors we
opened, but that's not a big deal (it's not wrong to do so,
nor is it really less optimal than the case where our parent
process redirected us from /dev/null ahead of time).

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

common-main: call git_extract_argv0_path()Jeff King Fri, 1 Jul 2016 06:04:04 +0000 (02:04 -0400)

common-main: call git_extract_argv0_path()

Every program which links against libgit.a must call this
function, or risk hitting an assert() in system_path() that
checks whether we have configured argv0_path (though only
when RUNTIME_PREFIX is defined, so essentially only on
Windows).

Looking at the diff, you can see that putting it into the
common main() saves us having to do it individually in each
of the external commands. But what you can't see are the
cases where we _should_ have been doing so, but weren't
(e.g., git-credential-store, and all of the t/helper test
programs).

This has been an accident-waiting-to-happen for a long time,
but wasn't triggered until recently because it involves one
of those programs actually calling system_path(). That
happened with git-credential-store in v2.8.0 with ae5f677
(lazily load core.sharedrepository, 2016-03-11). The
program:

- takes a lock file, which...

- opens a tempfile, which...

- calls adjust_shared_perm to fix permissions, which...

- lazy-loads the config (as of ae5f677), which...

- calls system_path() to find the location of
/etc/gitconfig

On systems with RUNTIME_PREFIX, this means credential-store
reliably hits that assert() and cannot be used.

We never noticed in the test suite, because we set
GIT_CONFIG_NOSYSTEM there, which skips the system_path()
lookup entirely. But if we were to tweak git_config() to
find /etc/gitconfig even when we aren't going to open it,
then the test suite shows multiple failures (for
credential-store, and for some other test helpers). I didn't
include that tweak here because it's way too specific to
this particular call to be worth carrying around what is
essentially dead code.

The implementation is fairly straightforward, with one
exception: there is exactly one caller (git.c) that actually
cares about the result of the function, and not the
side-effect of setting up argv0_path. We can accommodate
that by simply replacing the value of argv[0] in the array
we hand down to cmd_main().

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

add an extra level of indirection to main()Jeff King Fri, 1 Jul 2016 05:58:58 +0000 (01:58 -0400)

add an extra level of indirection to main()

There are certain startup tasks that we expect every git
process to do. In some cases this is just to improve the
quality of the program (e.g., setting up gettext()). In
others it is a requirement for using certain functions in
libgit.a (e.g., system_path() expects that you have called
git_extract_argv0_path()).

Most commands are builtins and are covered by the git.c
version of main(). However, there are still a few external
commands that use their own main(). Each of these has to
remember to include the correct startup sequence, and we are
not always consistent.

Rather than just fix the inconsistencies, let's make this
harder to get wrong by providing a common main() that can
run this standard startup.

We basically have two options to do this:

- the compat/mingw.h file already does something like this by
adding a #define that replaces the definition of main with a
wrapper that calls mingw_startup().

The upside is that the code in each program doesn't need
to be changed at all; it's rewritten on the fly by the
preprocessor.

The downside is that it may make debugging of the startup
sequence a bit more confusing, as the preprocessor is
quietly inserting new code.

- the builtin functions are all of the form cmd_foo(),
and git.c's main() calls them.

This is much more explicit, which may make things more
obvious to somebody reading the code. It's also more
flexible (because of course we have to figure out _which_
cmd_foo() to call).

The downside is that each of the builtins must define
cmd_foo(), instead of just main().

This patch chooses the latter option, preferring the more
explicit approach, even though it is more invasive. We
introduce a new file common-main.c, with the "real" main. It
expects to call cmd_main() from whatever other objects it is
linked against.

We link common-main.o against anything that links against
libgit.a, since we know that such programs will need to do
this setup. Note that common-main.o can't actually go inside
libgit.a, as the linker would not pick up its main()
function automatically (it has no callers).

The rest of the patch is just adjusting all of the various
external programs (mostly in t/helper) to use cmd_main().
I've provided a global declaration for cmd_main(), which
means that all of the programs also need to match its
signature. In particular, many functions need to switch to
"const char **" instead of "char **" for argv. This effect
ripples out to a few other variables and functions, as well.

This makes the patch even more invasive, but the end result
is much better. We should be treating argv strings as const
anyway, and now all programs conform to the same signature
(which also matches the way builtins are defined).

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

grep: fix grepping for "intent to add" filesCharles Bailey Thu, 30 Jun 2016 10:13:48 +0000 (11:13 +0100)

grep: fix grepping for "intent to add" files

This reverts commit 4d5520053 (grep: make it clear i-t-a entries are
ignored, 2015-12-27) and adds an alternative fix to maintain the -L
--cached behavior.

4d5520053 caused 'git grep' to no longer find matches in new files in
the working tree where the corresponding index entry had the "intent to
add" bit set, despite the fact that these files are tracked.

The content in the index of a file for which the "intent to add" bit is
set is considered indeterminate and not empty. For most grep queries we
want these to behave the same, however for -L --cached (files without a
match) we don't want to respond positively for "intent to add" files as
their contents are indeterminate. This is in contrast to files with
empty contents in the index (no lines implies no matches for any grep
query expression) which should be reported in the output of a grep -L
--cached invocation.

Add tests to cover this case and a few related cases which previously
lacked coverage.

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

t7810-grep.sh: fix a whitespace inconsistencyCharles Bailey Thu, 30 Jun 2016 10:13:47 +0000 (11:13 +0100)

t7810-grep.sh: fix a whitespace inconsistency

Signed-off-by: Charles Bailey <charles@hashpling.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7810-grep.sh: fix duplicated test nameCharles Bailey Thu, 30 Jun 2016 10:13:46 +0000 (11:13 +0100)

t7810-grep.sh: fix duplicated test name

Signed-off-by: Charles Bailey <charles@hashpling.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sideband.c: refactor recv_sideband()Lukas Fleischer Tue, 28 Jun 2016 04:35:26 +0000 (06:35 +0200)

sideband.c: refactor recv_sideband()

We used character buffer manipulations to split messages from the
sideband at line breaks and insert "remote: " at the beginning of
each line, using the packet size to determine the end of a message.

However, since it is safe to assume that diagnostic messages from
the sideband never contain NUL characters, we can also NUL-terminate
the buffer, use strpbrk() for splitting lines and use format strings
to insert the prefix, to make the code easier to read and maintain.

A strbuf is used for accumulating the output which is then printed
using a single write(2) call to ensure the atomicity of the output.
See 9ac13ec (atomic write for sideband remote messages, 2006-10-11)
for details.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep.c: reuse "icase" variableNguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:38 +0000 (07:22 +0200)

grep.c: reuse "icase" variable

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

diffcore-pickaxe: support case insensitive match on... Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:37 +0000 (07:22 +0200)

diffcore-pickaxe: support case insensitive match on non-ascii

Similar to the "grep -F -i" case, we can't use kws on icase search
outside ascii range, so we quote the string and pass it to regcomp as
a basic regexp and let regex engine deal with case sensitivity.

The new test is put in t7812 instead of t4209-log-pickaxe because
lib-gettext.sh might cause problems elsewhere, probably.

Noticed-by: Plamen Totev <plamen.totev@abv.bg>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diffcore-pickaxe: Add regcomp_or_die()Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:36 +0000 (07:22 +0200)

diffcore-pickaxe: Add regcomp_or_die()

There's another regcomp code block coming in this function that needs
the same error handling. This function can help avoid duplicating
error handling code.

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

grep/pcre: support utf-8Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:35 +0000 (07:22 +0200)

grep/pcre: support utf-8

In the previous change in this function, we add locale support for
single-byte encodings only. It looks like pcre only supports utf-* as
multibyte encodings, the others are left in the cold (which is
fine).

We need to enable PCRE_UTF8 so pcre can find character boundary
correctly. It's needed for case folding (when --ignore-case is used)
or '*', '+' or similar syntax is used.

The "has_non_ascii()" check is to be on the conservative side. If
there's non-ascii in the pattern, the searched content could still be
in utf-8, but we can treat it just like a byte stream and everything
should work. If we force utf-8 based on locale only and pcre validates
utf-8 and the file content is in non-utf8 encoding, things break.

Noticed-by: Plamen Totev <plamen.totev@abv.bg>
Helped-by: Plamen Totev <plamen.totev@abv.bg>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gettext: add is_utf8_locale()Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:34 +0000 (07:22 +0200)

gettext: add is_utf8_locale()

This function returns true if git is running under an UTF-8
locale. pcre in the next patch will need this.

is_encoding_utf8() is used instead of strcmp() to catch both "utf-8"
and "utf8" suffixes.

When built with no gettext support, we peek in several env variables
to detect UTF-8. pcre library might support utf-8 even if libc is
built without locale support.. The peeking code is a copy from
compat/regex/regcomp.c

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep/pcre: prepare locale-dependent tables for icase... Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:33 +0000 (07:22 +0200)

grep/pcre: prepare locale-dependent tables for icase matching

The default tables are usually built with C locale and only suitable
for LANG=C or similar. This should make case insensitive search work
correctly for all single-byte charsets.

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

grep: rewrite an if/else condition to avoid duplicate... Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:32 +0000 (07:22 +0200)

grep: rewrite an if/else condition to avoid duplicate expression

"!icase || ascii_only" is repeated twice in this if/else chain as this
series evolves. Rewrite it (and basically revert the first if
condition back to before the "grep: break down an "if" stmt..." commit).

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

grep/icase: avoid kwsset when -F is specifiedNguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:31 +0000 (07:22 +0200)

grep/icase: avoid kwsset when -F is specified

Similar to the previous commit, we can't use kws on icase search
outside ascii range. But we can't simply pass the pattern to
regcomp/pcre like the previous commit because it may contain regex
special characters, so we need to quote the regex first.

To avoid misquote traps that could lead to undefined behavior, we
always stick to basic regex engine in this case. We don't need fancy
features for grepping a literal string anyway.

basic_regex_quote_buf() assumes that if the pattern is in a multibyte
encoding, ascii chars must be unambiguously encoded as single
bytes. This is true at least for UTF-8. For others, let's wait until
people yell up. Chances are nobody uses multibyte, non utf-8 charsets
anymore.

Noticed-by: Plamen Totev <plamen.totev@abv.bg>
Helped-by: René Scharfe <l.s.r@web.de>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit -S: avoid invalid pointer with empty messageJohannes Schindelin Wed, 29 Jun 2016 14:14:54 +0000 (16:14 +0200)

commit -S: avoid invalid pointer with empty message

While it is not recommended, fsck.c says:

Not having a body is not a crime [...]

... which means that we cannot assume that the commit buffer
contains an empty line to separate header from body. A commit
object with only a header without any body, not even without
a blank line after the header, is valid.

So let's tread carefully here. strstr("\n\n") may find nothing
and return NULL.

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

reset --hard: skip blank lines when reporting the commi... Johannes Schindelin Wed, 29 Jun 2016 14:14:50 +0000 (16:14 +0200)

reset --hard: skip blank lines when reporting the commit subject

When there are blank lines at the beginning of a commit message, the
pretty printing machinery already skips them when showing a commit
subject (or the complete commit message). We shall henceforth do the
same when reporting the commit subject after the user called

git reset --hard <commit>

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

sequencer: use skip_blank_lines() to find the commit... Johannes Schindelin Wed, 29 Jun 2016 14:14:46 +0000 (16:14 +0200)

sequencer: use skip_blank_lines() to find the commit subject

Just like we already taught the find_commit_subject() function (to make
it consistent with the code in pretty.c), we now simply skip leading
blank lines of the commit message.

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

commit -C: skip blank lines at the beginning of the... Johannes Schindelin Wed, 29 Jun 2016 14:14:42 +0000 (16:14 +0200)

commit -C: skip blank lines at the beginning of the message

Consistent with the pretty-printing machinery, we skip leading blank
lines (if any) of existing commit messages.

While Git itself only produces commit objects with a single empty line
between commit header and commit message, it is legal to have more than
one blank line (i.e. lines containing only white space, or no
characters) at the beginning of the commit message, and the
pretty-printing code already handles that.

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

t3404: fix a grammo (commands are ran -> commands are... Johannes Schindelin Wed, 29 Jun 2016 14:31:03 +0000 (16:31 +0200)

t3404: fix a grammo (commands are ran -> commands are run)

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

rebase -i: restore autostash on abortPatrick Steinhardt Wed, 29 Jun 2016 06:21:27 +0000 (08:21 +0200)

rebase -i: restore autostash on abort

When we abort an interactive rebase we do so by calling
`die_abort`, which cleans up after us by removing the rebase
state directory. If the user has requested to use the autostash
feature, though, the state directory may also contain a reference
to the autostash, which will now be deleted.

Fix the issue by trying to re-apply the autostash in `die_abort`.
This will also handle the case where the autostash does not apply
cleanly anymore by recording it in a user-visible stash.

Reported-by: Daniel Hahler <git@thequod.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

contrib/subtree: Add a test for subtree rebase that... David A. Greene Tue, 28 Jun 2016 10:54:02 +0000 (05:54 -0500)

contrib/subtree: Add a test for subtree rebase that loses commits

This test merges an external tree in as a subtree, makes some commits
on top of it and splits it back out. In the process the added commits
are lost or the rebase aborts with an internal error. The tests are
marked to expect failure so that we don't forget to fix it.

Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

color.h: remove obsolete comment about limitations... Johannes Schindelin Tue, 28 Jun 2016 10:02:49 +0000 (12:02 +0200)

color.h: remove obsolete comment about limitations on Windows

Originally, ANSI color sequences were supported on Windows only by
overriding the printf() and fprintf() functions, as mentioned in e7821d7
(Add a notice that only certain functions can print color escape codes,
2009-11-27).

As of eac14f8 (Win32: Thread-safe windows console output, 2012-01-14),
however, this is no longer the case, as the ANSI color sequence support
code needed to be replaced with a thread-safe version, one side effect
being that stdout and stderr handled no matter which function is used to
write to it.

So let's just remove the comment that is now obsolete.

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

doc: typeset HEAD and variants as literalMatthieu Moy Tue, 28 Jun 2016 11:40:15 +0000 (13:40 +0200)

doc: typeset HEAD and variants as literal

This is an application of the newly added CodingGuidelines to HEAD and
variants like FETCH_HEAD. It was obtained with:

perl -pi -e "s/'([A-Z_]*HEAD)'/\`\$1\`/g" *.txt

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

CodingGuidelines: formatting HEAD in documentationMatthieu Moy Tue, 28 Jun 2016 11:40:14 +0000 (13:40 +0200)

CodingGuidelines: formatting HEAD in documentation

The current practice is:

git/Documentation$ git grep "'HEAD'" | wc -l
24
git/Documentation$ git grep "\`HEAD\`" | wc -l
66

Let's adopt the majority as a guideline.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: typeset long options with argument as literalMatthieu Moy Tue, 28 Jun 2016 11:40:13 +0000 (13:40 +0200)

doc: typeset long options with argument as literal

We previously reformatted '--option' to `--option`. This patch reformats
'--option <arg>' to `--option <arg>`. Obtained with:

perl -pi -e "s/'(--[a-z][a-z=<>-]* <[^>]*>)'/\`\$1\`/g" *.txt

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: typeset '--' as literalMatthieu Moy Tue, 28 Jun 2016 11:40:12 +0000 (13:40 +0200)

doc: typeset '--' as literal

This was obtained with:

perl -pi -e "s/'--'/\`--\`/g" *.txt

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: typeset long command-line options as literalMatthieu Moy Tue, 28 Jun 2016 11:40:11 +0000 (13:40 +0200)

doc: typeset long command-line options as literal

Similarly to the previous commit, use backquotes instead of
forward-quotes, for long options.

This was obtained with:

perl -pi -e "s/'(--[a-z][a-z=<>-]*)'/\`\$1\`/g" *.txt

and manual tweak to remove false positive in ascii-art (o'--o'--o' to
describe rewritten history).

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: typeset short command-line options as literalMatthieu Moy Tue, 28 Jun 2016 11:40:10 +0000 (13:40 +0200)

doc: typeset short command-line options as literal

It was common in our documentation to surround short option names with
forward quotes, which renders as italic in HTML. Instead, use backquotes
which renders as monospace. This is one more step toward conformance to
Documentation/CodingGuidelines.

This was obtained with:

perl -pi -e "s/'(-[a-z])'/\`\$1\`/g" *.txt

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-mv.txt: fix whitespace indentationMatthieu Moy Tue, 28 Jun 2016 11:40:09 +0000 (13:40 +0200)

Documentation/git-mv.txt: fix whitespace indentation

Replace spaces with tabs to avoid a warning when further patches change
these lines.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Start preparing for 2.9.1Junio C Hamano Mon, 27 Jun 2016 16:59:51 +0000 (09:59 -0700)

Start preparing for 2.9.1

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

Merge branch 'rs/xdiff-hunk-with-func-line' into maintJunio C Hamano Mon, 27 Jun 2016 16:56:24 +0000 (09:56 -0700)

Merge branch 'rs/xdiff-hunk-with-func-line' into maint

"git show -W" (extend hunks to cover the entire function, delimited
by lines that match the "funcname" pattern) used to show the entire
file when a change added an entire function at the end of the file,
which has been fixed.

* rs/xdiff-hunk-with-func-line:
xdiff: fix merging of appended hunk with -W
grep: -W: don't extend context to trailing empty lines
t7810: add test for grep -W and trailing empty context lines
xdiff: don't trim common tail with -W
xdiff: -W: don't include common trailing empty lines in context
xdiff: ignore empty lines before added functions with -W
xdiff: handle appended chunks better with -W
xdiff: factor out match_func_rec()
t4051: rewrite, add more tests

Merge branch 'jk/rev-list-count-with-bitmap' into maintJunio C Hamano Mon, 27 Jun 2016 16:56:24 +0000 (09:56 -0700)

Merge branch 'jk/rev-list-count-with-bitmap' into maint

"git rev-list --count" whose walk-length is limited with "-n"
option did not work well with the counting optimized to look at the
bitmap index.

* jk/rev-list-count-with-bitmap:
rev-list: disable bitmaps when "-n" is used with listing objects
rev-list: "adjust" results of "--count --use-bitmap-index -n"

Merge branch 'et/pretty-format-c-auto' into maintJunio C Hamano Mon, 27 Jun 2016 16:56:23 +0000 (09:56 -0700)

Merge branch 'et/pretty-format-c-auto' into maint

The commands in `git log` family take %C(auto) in a custom format
string. This unconditionally turned the color on, ignoring
--no-color or with --color=auto when the output is not connected to
a tty; this was corrected to make the format truly behave as
"auto".

* et/pretty-format-c-auto:
format_commit_message: honor `color=auto` for `%C(auto)`

Merge branch 'ew/daemon-socket-keepalive' into maintJunio C Hamano Mon, 27 Jun 2016 16:56:22 +0000 (09:56 -0700)

Merge branch 'ew/daemon-socket-keepalive' into maint

When "git daemon" is run without --[init-]timeout specified, a
connection from a client that silently goes offline can hang around
for a long time, wasting resources. The socket-level KEEPALIVE has
been enabled to allow the OS to notice such failed connections.

* ew/daemon-socket-keepalive:
daemon: enable SO_KEEPALIVE for all sockets

xwrite: poll on non-blocking FDsEric Wong Sun, 26 Jun 2016 23:21:12 +0000 (23:21 +0000)

xwrite: poll on non-blocking FDs

write(2) can hit the same EAGAIN/EWOULDBLOCK errors as read(2),
so busy-looping on a non-blocking FD is a waste of resources.

Currently, I do not know of a way for this happen:

* the NonBlocking directive in systemd does not apply to stdin,
stdout, or stderr.

* xinetd provides no way to set the non-blocking flag at all

But theoretically, it's possible a careless C10K HTTP server
could use pipe2(..., O_NONBLOCK) to setup a pipe for
git-http-backend with only the intent to use non-blocking reads;
but accidentally leave non-blocking set on the write end passed
as stdout to git-upload-pack.

Followup-to: 1079c4be0b720 ("xread: poll on non blocking fds")

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

xread: retry after poll on EAGAIN/EWOULDBLOCKEric Wong Mon, 27 Jun 2016 03:56:35 +0000 (03:56 +0000)

xread: retry after poll on EAGAIN/EWOULDBLOCK

We should continue to loop after EAGAIN/EWOULDBLOCK as the
intent of xread is to try until there is available data,
EOF, or an unrecoverable error.

Fixes: 1079c4be0b720 ("xread: poll on non blocking fds")

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

unpack-trees: fix English grammar in do-this-before... Alex Henrie Sat, 25 Jun 2016 06:34:04 +0000 (00:34 -0600)

unpack-trees: fix English grammar in do-this-before-that messages

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: fix off-by-one error with gc.autoPackLimitEric Wong Sat, 25 Jun 2016 06:46:47 +0000 (06:46 +0000)

gc: fix off-by-one error with gc.autoPackLimit

This matches the documentation and allows gc.autoPackLimit=1
to maintain a single pack without attempting a repack on every
"git gc --auto" invocation.

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

grep/icase: avoid kwsset on literal non-ascii stringsNguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:30 +0000 (07:22 +0200)

grep/icase: avoid kwsset on literal non-ascii strings

When we detect the pattern is just a literal string, we avoid heavy
regex engine and use fast substring search implemented in kwsset.c.
But kws uses git-ctype which is locale-independent so it does not know
how to fold case properly outside ascii range. Let regcomp or pcre
take care of this case instead. Slower, but accurate.

Noticed-by: Plamen Totev <plamen.totev@abv.bg>
Helped-by: René Scharfe <l.s.r@web.de>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-regex: expose full regcomp() to the command lineNguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:29 +0000 (07:22 +0200)

test-regex: expose full regcomp() to the command line

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

test-regex: isolate the bug test codeNguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:28 +0000 (07:22 +0200)

test-regex: isolate the bug test code

This is in preparation to turn test-regex into some generic regex
testing command.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

grep: break down an "if" stmt in preparation for next... Nguyễn Thái Ngọc Duy Sat, 25 Jun 2016 05:22:27 +0000 (07:22 +0200)

grep: break down an "if" stmt in preparation for next changes

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

new-command.txt: correct the command description fileNguyễn Thái Ngọc Duy Sat, 25 Jun 2016 13:55:14 +0000 (15:55 +0200)

new-command.txt: correct the command description file

It has always been command-list.txt even at the time this
new-command.txt document is added.

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

t2300: "git --exec-path" is not usable in $PATH on... Johannes Schindelin Sat, 18 Jun 2016 10:49:11 +0000 (12:49 +0200)

t2300: "git --exec-path" is not usable in $PATH on Windows as-is

The "git" command prepends the exec-path to the PATH environment
variable for processes it spawns. That is how ". git-sh-setup" in
our scripted Porcelains can find the dot-sourced file in the
exec-path location that is not usually on user's PATH.

When t2300 runs, because it is not spawned by the "git" command, the
scriptlet being tested did not run with a realistic setting of PATH
environment. It lacked the exec-path on the PATH, and failed to
find the dot-sourced file. A recent update to t2300 attempted to
fix this, with "PATH=$(git --exec-path):$PATH", which has been the
recommended way around v1.6.0 days (a script whose original was
written before that release that survives to this day is likely to
have such a line).

However, the "git --exec-path" command outputs C:\path\to\exec\dir
(not /c/path/to/exec/dir) on Windows; the recent update failed to
consider the problem that comes from it.

Even though Git itself, when doing the equivalent internally, does
so in a platform native way (i.e. on Windows, C:\path\to\exec\dir is
prepended to the existing value of %PATH% using ';' as a component
separator), the result is further massaged by bash and gets turned
into $PATH that uses /c/path/to/exec/dir with ':' separating the
components, which is the form understood by bash, so scripted
Porcelains find commands from PATH correctly.

An end user script written in shell, however, cannot prepend
"C:\path\to\exec\dir:" to the existing value of $PATH and expect
bash to magically turn it into the form it understands. In other
words, "PATH=$(git --exec-path):$PATH" does not work as an emulation
of what "Git" internally does to the PATH on Windows.

To correctly emulate how exec-path is prepended to the PATH
environment internally on Windows, we'd need to convert
C:\git-sdk-64\usr\src\git to at least /c\git-sdk-64\usr\src\git
ourselves before prepending it to PATH.

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

commit.c: make find_commit_subject() more robustJohannes Schindelin Wed, 22 Jun 2016 20:20:20 +0000 (22:20 +0200)

commit.c: make find_commit_subject() more robust

Just like the pretty printing machinery, we should simply ignore
blank lines at the beginning of the commit messages.

This discrepancy was noticed when an early version of the
rebase--helper produced commit objects with more than one empty line
between the header and the commit message.

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

pretty: make the skip_blank_lines() function publicJohannes Schindelin Wed, 22 Jun 2016 20:20:16 +0000 (22:20 +0200)

pretty: make the skip_blank_lines() function public

This function will be used also in the find_commit_subject()
function.

While at it, rename the function to reflect that it skips not only
empty lines, but any lines consisting of only whitespace, too.

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

doc: git-htmldocs.googlecode.com is no moreJonathan Nieder Wed, 22 Jun 2016 17:38:25 +0000 (10:38 -0700)

doc: git-htmldocs.googlecode.com is no more

http://git-htmldocs.googlecode.com/git/git.html says

There was no service found for the uri requested.

Link to the rendered documentation on Jekyll instead.

Reported-by: Andrea Stacchiotti <andreastacchiotti@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-p4: correct hasBranchPrefix verbose outputAndrew Oakley Wed, 22 Jun 2016 09:26:11 +0000 (10:26 +0100)

git-p4: correct hasBranchPrefix verbose output

The logic here was inverted, you got a message saying the file is
ignored for each file that is not ignored.

Signed-off-by: Andrew Oakley <aoakley@roku.com>
Acked-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7810: fix duplicated test titleCharles Bailey Tue, 21 Jun 2016 21:14:11 +0000 (14:14 -0700)

t7810: fix duplicated test title

Signed-off-by: Charles Bailey <charles@hashpling.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5614: don't use subshellsStefan Beller Mon, 20 Jun 2016 17:21:18 +0000 (10:21 -0700)

t5614: don't use subshells

Using a subshell for just one git command is both a waste in compute
overhead (create a new process) as well as in line count.

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

t7800: readlink may not be availableArmin Kunaschik Tue, 31 May 2016 00:26:12 +0000 (02:26 +0200)

t7800: readlink may not be available

The readlink(1) command is not available on all platforms (notably
not on AIX and HP-UX) and can be replaced in this test with the
"workaround"

ls -ld <name> | sed -e 's/.* -> //'

This is no universal readlink replacement but works in the
controlled test environment well enough.

Signed-off-by: Armin Kunaschik <megabreit@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

perf: accommodate for MacOSXJohannes Schindelin Tue, 21 Jun 2016 13:53:43 +0000 (15:53 +0200)

perf: accommodate for MacOSX

As this developer has no access to MacOSX developer setups anymore,
Travis becomes the best bet to run performance tests on that OS.

However, on MacOSX /usr/bin/time is that good old BSD executable that
no Linux user cares about, as demonstrated by the perf-lib.sh's use
of GNU-ish extensions. And by the hard-coded path.

Let's just work around this issue by using gtime on MacOSX, the
Homebrew-provided GNU implementation onto which pretty much every
MacOSX power user falls back anyway.

To help other developers use Travis to run performance tests on
MacOSX, the .travis.yml file now sports a commented-out line that
installs GNU time via Homebrew.

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

local_tzoffset: detect errors from tm_to_time_tJeff King Mon, 20 Jun 2016 21:14:14 +0000 (17:14 -0400)

local_tzoffset: detect errors from tm_to_time_t

When we want to know the local timezone offset at a given
timestamp, we compute it by asking for localtime() at the
given time, and comparing the offset to GMT at that time.
However, there's some juggling between time_t and "struct
tm" which happens, which involves calling our own
tm_to_time_t().

If that function returns an error (e.g., because it only
handles dates up to the year 2099), it returns "-1", which
we treat as a time_t, and is clearly bogus, leading to
bizarre timestamps (that seem to always adjust the time back
to (time_t)(uint32_t)-1, in the year 2106).

It's not a good idea for local_tzoffset() to simply die
here; it would make it hard to run "git log" on a repository
with funny timestamps. Instead, let's just treat such cases
as "zero offset".

Reported-by: Norbert Kiesel <nkiesel@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t0006: test various date formatsJeff King Mon, 20 Jun 2016 21:11:59 +0000 (17:11 -0400)

t0006: test various date formats

We ended up testing some of these date formats throughout
the rest of the suite (e.g., via for-each-ref's
"$(authordate:...)" format), but we never did so
systematically. t0006 is the right place for unit-testing of
our date-handling code.

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

t0006: rename test-date's "show" to "relative"Jeff King Mon, 20 Jun 2016 21:10:29 +0000 (17:10 -0400)

t0006: rename test-date's "show" to "relative"

The "show" tests are really only checking relative formats;
we should make that more clear.

This also frees up the "show" name to later check other
formats. We could later fold "relative" into a more generic
"show" command, but it's not worth it. Relative times are a
special case already because we have to munge the concept of
"now" in our tests.

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

mingw: let the build succeed with DEVELOPER=1Johannes Schindelin Sat, 18 Jun 2016 12:38:36 +0000 (14:38 +0200)

mingw: let the build succeed with DEVELOPER=1

The recently introduced developer flags identified a couple of
old-style function declarations in the Windows-specific code where
the parameter list was left empty instead of specifying "void"
explicitly. Let's just fix them.

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

clone: do not let --depth imply --shallow-submodulesJunio C Hamano Sun, 19 Jun 2016 20:51:56 +0000 (13:51 -0700)

clone: do not let --depth imply --shallow-submodules

In v2.9.0, we prematurely flipped the default to force cloning
submodules shallowly, when the superproject is getting cloned
shallowly. This is likely to fail when the upstream repositories
submodules are cloned from a repository that is not prepared to
serve histories that ends at a commit that is not at the tip of a
branch, and we know the world is not yet ready.

Use a safer default to clone the submodules fully, unless the user
tells us that she knows that the upstream repository of the
submodules are willing to cooperate with "--shallow-submodules"
option.

Noticed-by: Vadim Eisenberg <VADIME@il.ibm.com>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sh-setup: enclose setting of ${VAR=default} in double... LE Manh Cuong Sat, 18 Jun 2016 20:26:03 +0000 (03:26 +0700)

sh-setup: enclose setting of ${VAR=default} in double-quotes

We often make sure an environment variable is set to
something, either set by the user (in which case we do not
molest it) or set it to our default value (otherwise), with

: ${VAR=default value}

i.e. running the no-op command ":" with ${VAR} as its
parameters (or the default value we supply), relying on that
":" is a no-op.

This pattern, even though it is no-op from correctness point
of view, still can be expensive if the existing value in VAR
has shell glob (because they will be expanded against
filesystem entities) and IFS whitespaces (because the value
need to be split into multiple parameters). Our invocation
of ":" command does not care if the parameter given to it is
after the value in VAR goes through these processing.

Enclosing the whole thing in double-quote, i.e.

: "${VAR=default value}"

avoids paying the unnecessary cost, so let's do so.

Signed-off-by: LE Manh Cuong <cuong.manhle.vn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/technical: signed merge tag formatMichael J Gruber Fri, 17 Jun 2016 07:46:11 +0000 (09:46 +0200)

Documentation/technical: signed merge tag format

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/technical: signed commit formatMichael J Gruber Fri, 17 Jun 2016 07:46:10 +0000 (09:46 +0200)

Documentation/technical: signed commit format

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/technical: signed tag formatMichael J Gruber Fri, 17 Jun 2016 07:46:09 +0000 (09:46 +0200)

Documentation/technical: signed tag format

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/technical: describe signature formatsMichael J Gruber Fri, 17 Jun 2016 07:46:08 +0000 (09:46 +0200)

Documentation/technical: describe signature formats

We use different types of signature formats in different places.
Set up the infrastructure and overview to describe them systematically
in our technical documentation.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase: update comment about FreeBSD /bin/shEd Maste Fri, 17 Jun 2016 15:33:29 +0000 (11:33 -0400)

rebase: update comment about FreeBSD /bin/sh

Commit 9f50d32 introduced a fix for FreeBSD /bin/sh misbehaviour
when dot-sourcing a file containing "return" statements outside of
any function, from a function in another shell script. That issue
affects FreeBSD 9.x, and is not present in the /bin/sh in FreeBSD
10.3 and later. Update the comment to clarify this.

The example from 9f50d32's commit message produces the expected output
on FreeBSD 10.3 and -CURRENT (the upcoming 11.0):

% sh script1.sh
only this line should show
%

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>