gitweb.git
Merge branch 'js/find-commit-subject-ignore-leading... Junio C Hamano Mon, 11 Jul 2016 17:31:07 +0000 (10:31 -0700)

Merge branch 'js/find-commit-subject-ignore-leading-blanks'

A helper function that takes the contents of a commit object and
finds its subject line did not ignore leading blank lines, as is
commonly done by other codepaths. Make it ignore leading blank
lines to match.

* js/find-commit-subject-ignore-leading-blanks:
reset --hard: skip blank lines when reporting the commit subject
sequencer: use skip_blank_lines() to find the commit subject
commit -C: skip blank lines at the beginning of the message
commit.c: make find_commit_subject() more robust
pretty: make the skip_blank_lines() function public

Merge branch 'jn/preformatted-doc-url'Junio C Hamano Mon, 11 Jul 2016 17:31:06 +0000 (10:31 -0700)

Merge branch 'jn/preformatted-doc-url'

The top level documentation "git help git" still pointed at the
documentation set hosted at now-defunct google-code repository.
Update it to point to https://git.github.io/htmldocs/git.html
instead.

* jn/preformatted-doc-url:
doc: git-htmldocs.googlecode.com is no more

Merge branch 'jk/perf-any-version'Junio C Hamano Mon, 11 Jul 2016 17:31:06 +0000 (10:31 -0700)

Merge branch 'jk/perf-any-version'

Allow t/perf framework to use the features from the most recent
version of Git even when testing an older installed version.

* jk/perf-any-version:
p4211: explicitly disable renames in no-rename test
t/perf: fix regression in testing older versions of git

Merge branch 'jk/ansi-color'Junio C Hamano Mon, 11 Jul 2016 17:31:05 +0000 (10:31 -0700)

Merge branch 'jk/ansi-color'

The output coloring scheme learned two new attributes, italic and
strike, in addition to existing bold, reverse, etc.

* jk/ansi-color:
color: support strike-through attribute
color: support "italic" attribute
color: allow "no-" for negating attributes
color: refactor parse_attr
add skip_prefix_mem helper
doc: refactor description of color format
color: fix max-size comment

Merge branch 'sb/submodule-clone-retry'Junio C Hamano Mon, 11 Jul 2016 17:31:04 +0000 (10:31 -0700)

Merge branch 'sb/submodule-clone-retry'

"git submodule update" that drives many "git clone" could
eventually hit flaky servers/network conditions on one of the
submodules; the command learned to retry the attempt.

* sb/submodule-clone-retry:
submodule update: continue when a clone fails
submodule--helper: initial clone learns retry logic

Merge branch 'jc/send-email-skip-backup'Junio C Hamano Mon, 11 Jul 2016 17:31:04 +0000 (10:31 -0700)

Merge branch 'jc/send-email-skip-backup'

A careless invocation of "git send-email directory/" after editing
0001-change.patch with an editor often ends up sending both
0001-change.patch and its backup file, 0001-change.patch~, causing
embarrassment and a minor confusion. Detect such an input and
offer to skip the backup files when sending the patches out.

* jc/send-email-skip-backup:
send-email: detect and offer to skip backup files

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>

git-svn: warn instead of dying when commit data is... Eric Wong Sat, 2 Jul 2016 10:33:18 +0000 (10:33 +0000)

git-svn: warn instead of dying when commit data is missing

It is possible to have refs globbed by git-svn which stores data
purely in git; gently skip those instead of dying and assuming
user error.

ref: http://mid.gmane.org/CALi1mtdtNF_GtzyPTbfb7N51wwxsFY7zm8hsgwxr3tHcZZboyg@mail.gmail.com

Suggested-by: Jacob Godserv <jacobgodserv@gmail.com>
Cc: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-p4: place temporary refs used for branch import... Lars Schneider Wed, 29 Jun 2016 07:35:27 +0000 (09:35 +0200)

git-p4: place temporary refs used for branch import under refs/git-p4-tmp

Git-P4 used to place temporary refs under "git-p4-tmp". Since 3da1f37
Git checks that all refs are placed under "refs". Instruct Git-P4 to
place temporary refs under "refs/git-p4-tmp". There are no backwards
compatibility considerations as these refs are transient.

Use "git show-ref --verify" to check the (non-)existience of the refs
instead of file checks assuming the file-based ref backend.

All refs under "refs" are shared across all worktrees. This is not
desired for temporary Git-P4 refs and will be adressed in a later patch.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Vitor Antunes <vitor.hda@gmail.com>
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>

commit.c: remove print_commit_list()Junio C Hamano Fri, 8 Jul 2016 17:09:28 +0000 (10:09 -0700)

commit.c: remove print_commit_list()

The helper function tries to offer a way to conveniently show the
last one differently from others, presumably to allow you to say
something like

A, B, and C.

while iterating over a list that has these three elements.

However, there is only one caller, and it passes the same format
string "%s\n" for both the last one and the other ones. Retire the
helper function and update the caller with a simplified version.

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

avoid using sha1_to_hex output as printf formatJeff King Fri, 8 Jul 2016 10:35:15 +0000 (06:35 -0400)

avoid using sha1_to_hex output as printf format

We know that it should not contain any percent-signs, but
it's a good habit not to feed non-literals to printf
formatters.

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

walker: let walker_say take arbitrary formatsJeff King Fri, 8 Jul 2016 09:25:23 +0000 (05:25 -0400)

walker: let walker_say take arbitrary formats

We take a printf-style format and a single "char *"
parameter, and the format must therefore have at most one
"%s" in it. Besides being error-prone (and tickling
-Wformat-nonliteral), this is unnecessarily restrictive. We
can just provide the usual varargs interface.

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

branch: use write_file_buf instead of write_fileJeff King Fri, 8 Jul 2016 09:16:53 +0000 (05:16 -0400)

branch: use write_file_buf instead of write_file

If we already have a strbuf, then using write_file_buf is a
little nicer to read (no wondering whether "%s" will eat
your NULs), and it's more efficient (no extra formatting
step).

We don't care about the newline magic of write_file(), as we
have our own multi-line content.

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

use write_file_buf where applicableJeff King Fri, 8 Jul 2016 09:12:55 +0000 (05:12 -0400)

use write_file_buf where applicable

There are several places where we open a file, write some
content from a strbuf, and close it. These can be simplified
with write_file_buf(). As a bonus, many of these did not
catch write problems at close() time.

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

write_file: add format attributeJeff King Fri, 8 Jul 2016 09:12:42 +0000 (05:12 -0400)

write_file: add format attribute

This gives us compile-time checking of our format strings,
which is a good thing.

I had also hoped it would help with confusing write_file()
and write_file_buf(), since the former's "..." can make it
match the signature of the latter. But given that the buffer
for write_file_buf() is generally not a string literal, the
compiler won't complain unless -Wformat-nonliteral is on,
and that creates a ton of false positives elsewhere in the
code base.

While we're there, let's also give the function a docstring,
which it never had.

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

write_file: add pointer+len variantJeff King Fri, 8 Jul 2016 09:12:22 +0000 (05:12 -0400)

write_file: add pointer+len variant

There are many callsites which could use write_file, but for
which it is a little awkward because they have a strbuf or
other pointer/len combo. Specifically:

1. write_file() takes a format string, so we have to use
"%s" or "%.*s", which are ugly.

2. Using any form of "%s" does not handle embedded NULs in
the output. That probably doesn't matter for our
call-sites, but it's nicer not to have to worry.

3. It's less efficient; we format into another strbuf
just to do the write. That's probably not measurably
slow for our uses, but it's simply inelegant.

We can fix this by providing a helper to write out the
formatted buffer, and just calling it from write_file().

Note that we don't do the usual "complete with a newline"
that write_file does. If the caller has their own buffer,
there's a reasonable chance they're doing something more
complicated than a single line, and they can call
strbuf_complete_line() themselves.

We could go even further and add strbuf_write_file(), but it
doesn't save much:

- write_file_buf(path, sb.buf, sb.len);
+ strbuf_write_file(&sb, path);

It would also be somewhat asymmetric with strbuf_read_file,
which actually returns errors rather than dying (and the
error handling is most of the benefit of write_file() in the
first place).

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

write_file: use xopenJeff King Fri, 8 Jul 2016 09:10:08 +0000 (05:10 -0400)

write_file: use xopen

This simplifies the code a tiny bit, and provides consistent
error messages with other users of xopen().

While we're here, let's also switch to using O_WRONLY. We
know we're only going to open/write/close the file, so
there's no point in asking for O_RDWR.

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

write_file: drop "gently" formJeff King Fri, 8 Jul 2016 09:09:34 +0000 (05:09 -0400)

write_file: drop "gently" form

There are no callers left of write_file_gently(). Let's drop
it, as it doesn't seem likely for new callers to be added
(since its inception, the only callers who wanted the gentle
form generally just died immediately themselves, and have
since been converted).

While we're there, let's also drop the "int" return from
write_file, as it is never meaningful (in the non-gentle
form, we always either die or return 0).

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

branch: use non-gentle write_file for branch descriptionJeff King Fri, 8 Jul 2016 09:08:54 +0000 (05:08 -0400)

branch: use non-gentle write_file for branch description

We use write_file_gently() to do this job currently.
However, if we see an error, we simply complain via
error_errno() and then end up exiting with an error code.

By switching to the non-gentle form, the function will die
for us, with a better error. It is more specific about which
syscall caused the error, and that mentions the
actual filename we're trying to write.

Our exit code for the error case does switch from "1" to
"128", but that's OK; it wasn't a meaningful documented code
(and in fact it was odd that it was a different exit code
than most other error conditions).

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

am: ignore return value of write_file()René Scharfe Fri, 8 Jul 2016 09:08:05 +0000 (05:08 -0400)

am: ignore return value of write_file()

write_file() either returns 0 or dies, so there is no point in checking
its return value. The callers of the wrappers write_state_text(),
write_state_count() and write_state_bool() consequently already ignore
their return values. Stop pretending we care and make them void.

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

config: fix bogus fd check when setting up default... Jeff King Fri, 8 Jul 2016 09:06:50 +0000 (05:06 -0400)

config: fix bogus fd check when setting up default config

Since 9830534 (config --global --edit: create a template
file if needed, 2014-07-25), an edit of the global config
file will try to open() it with O_EXCL, and wants to handle
three cases:

1. We succeeded; the user has no config file, and we
should fill in the default template.

2. We got EEXIST; they have a file already, proceed as usual.

3. We got another error; we should complain.

However, the check for case 1 does "if (fd)", which will
generally _always_ be true (except for the oddball case that
somehow our stdin got closed and opening really did give us
a new descriptor 0).

So in the EEXIST case, we tried to write the default config
anyway! Fortunately, this turns out to be a noop, since we
just end up writing to and closing "-1", which does nothing.

But in case 3, we would fail to notice any other errors, and
just silently continue (given that we don't actually notice
write errors for the template either, it's probably not that
big a deal; we're about to spawn the editor, so it would
notice any problems. But the code is clearly _trying_ to hit
cover this case and failing).

We can fix it easily by using "fd >= 0" for case 1.

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

Makefile: add NEEDS_LIBRT to optionally link with librtRonald Wampler Thu, 7 Jul 2016 20:45:54 +0000 (16:45 -0400)

Makefile: add NEEDS_LIBRT to optionally link with librt

We unconditionally link with librt, when HAVE_CLOCK_GETTIME is defined.
But clock_gettime() has been available in most libc implementations for
some time now (e.g., for glibc since version 2.17) and no longer
requires linking with librt. Furthermore, commit a6c3c63 (configure.ac:
check for clock_gettime() and CLOCK_MONOTONIC) will automatically
determined which library (libc or librt) is required for linking when
checking for clock_gettime().

The assumption to unconditionally link with librt was OK, since either
almost every Unix-like system provides a version of librt for backwards
compatibility or other systems, namely Windows or OS X, never provided
clock_gettime(). However, in the latest release of OS X (macOS Sierra),
this function has been added to OS X libc version. As a result, when
running the configuration script, HAVE_CLOCK_GETTIME is set and since
librt is not present, it causes a linker error.

This patches requires those not building via the configuration scripts
to define NEEDS_LIBRT in addition to HAVE_CLOCK_GETTIME, if needed.

Signed-off-by: Ronald Wampler <rdwampler@gmail.com>
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>

connect: read $GIT_SSH_COMMAND from config fileNguyễn Thái Ngọc Duy Sun, 26 Jun 2016 11:16:35 +0000 (13:16 +0200)

connect: read $GIT_SSH_COMMAND from config file

Similar to $GIT_ASKPASS or $GIT_PROXY_COMMAND, we also read from
config file first then fall back to $GIT_SSH_COMMAND.

This is useful for selecting different private keys targetting the
same host (e.g. github)

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

Third batch of topics for 2.10Junio C Hamano Wed, 6 Jul 2016 20:42:58 +0000 (13:42 -0700)

Third batch of topics for 2.10

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

Sync with maintJunio C Hamano Wed, 6 Jul 2016 20:42:37 +0000 (13:42 -0700)

Sync with maint

* maint:
More fixes for 2.9.1
mailmap: use main email address for dturner

Merge branch 'jc/t2300-setup'Junio C Hamano Wed, 6 Jul 2016 20:38:19 +0000 (13:38 -0700)

Merge branch 'jc/t2300-setup'

Portability fix for Windows.

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

Merge branch 'ao/p4-has-branch-prefix-fix'Junio C Hamano Wed, 6 Jul 2016 20:38:19 +0000 (13:38 -0700)

Merge branch 'ao/p4-has-branch-prefix-fix'

A bug, which caused "git p4" while running under verbose mode to
report paths that are omitted due to branch prefix incorrectly, has
been fixed; the command said "Ignoring file outside of prefix" for
paths that are _inside_.

* ao/p4-has-branch-prefix-fix:
git-p4: correct hasBranchPrefix verbose output

Merge branch 'cb/t7810-test-label-fix'Junio C Hamano Wed, 6 Jul 2016 20:38:18 +0000 (13:38 -0700)

Merge branch 'cb/t7810-test-label-fix'

Test clean-up.

* cb/t7810-test-label-fix:
t7810: fix duplicated test title

Merge branch 'sb/t5614-modernize'Junio C Hamano Wed, 6 Jul 2016 20:38:17 +0000 (13:38 -0700)

Merge branch 'sb/t5614-modernize'

Test clean-up.

* sb/t5614-modernize:
t5614: don't use subshells

Merge branch 'js/perf-on-apple'Junio C Hamano Wed, 6 Jul 2016 20:38:16 +0000 (13:38 -0700)

Merge branch 'js/perf-on-apple'

t/perf needs /usr/bin/time with GNU extension; the invocation of it
is updated to "gtime" on Darwin.

* js/perf-on-apple:
perf: accommodate for MacOSX

Merge branch 'ak/t7800-wo-readlink'Junio C Hamano Wed, 6 Jul 2016 20:38:16 +0000 (13:38 -0700)

Merge branch 'ak/t7800-wo-readlink'

One among four invocations of readlink(1) in our test suite has
been rewritten so that the test can run on systems without the
command (others are in valgrind test framework and t9802).

* ak/t7800-wo-readlink:
t7800: readlink may not be available

Merge branch 'jk/tzoffset-fix'Junio C Hamano Wed, 6 Jul 2016 20:38:15 +0000 (13:38 -0700)

Merge branch 'jk/tzoffset-fix'

The internal code used to show local timezone offset is not
prepared to handle timestamps beyond year 2100, and gave a
bogus offset value to the caller. Use a more benign looking
+0000 instead and let "git log" going in such a case, instead
of aborting.

* jk/tzoffset-fix:
local_tzoffset: detect errors from tm_to_time_t
t0006: test various date formats
t0006: rename test-date's "show" to "relative"

Merge branch 'js/mingw-parameter-less-c-functions'Junio C Hamano Wed, 6 Jul 2016 20:38:14 +0000 (13:38 -0700)

Merge branch 'js/mingw-parameter-less-c-functions'

Some platform-specific code had non-ANSI strict declarations of C
functions that do not take any parameters, which has been
corrected.

* js/mingw-parameter-less-c-functions:
mingw: let the build succeed with DEVELOPER=1

Merge branch 'lc/shell-default-value-noexpand'Junio C Hamano Wed, 6 Jul 2016 20:38:14 +0000 (13:38 -0700)

Merge branch 'lc/shell-default-value-noexpand'

Fix unnecessarily waste in the idiomatic use of ': ${VAR=default}'
to set the default value, without enclosing it in double quotes.

* lc/shell-default-value-noexpand:
sh-setup: enclose setting of ${VAR=default} in double-quotes

Merge branch 'sb/clone-shallow-passthru'Junio C Hamano Wed, 6 Jul 2016 20:38:13 +0000 (13:38 -0700)

Merge branch 'sb/clone-shallow-passthru'

Fix an unintended regression in v2.9 that breaks "clone --depth"
that recurses down to submodules by forcing the submodules to also
be cloned shallowly, which many server instances that host upstream
of the submodules are not prepared for.

* sb/clone-shallow-passthru:
clone: do not let --depth imply --shallow-submodules

Merge branch 'jk/gpg-interface-cleanup'Junio C Hamano Wed, 6 Jul 2016 20:38:12 +0000 (13:38 -0700)

Merge branch 'jk/gpg-interface-cleanup'

A new run-command API function pipe_command() is introduced to
sanely feed data to the standard input while capturing data from
the standard output and the standard error of an external process,
which is cumbersome to hand-roll correctly without deadlocking.

The codepath to sign data in a prepared buffer with GPG has been
updated to use this API to read from the status-fd to check for
errors (instead of relying on GPG's exit status).

* jk/gpg-interface-cleanup:
gpg-interface: check gpg signature creation status
sign_buffer: use pipe_command
verify_signed_buffer: use pipe_command
run-command: add pipe_command helper
verify_signed_buffer: use tempfile object
verify_signed_buffer: drop pbuf variable
gpg-interface: use child_process.args

Merge branch 'mg/signature-doc'Junio C Hamano Wed, 6 Jul 2016 20:38:12 +0000 (13:38 -0700)

Merge branch 'mg/signature-doc'

Formats of the various data (and how to validate them) where we use
GPG signature have been documented.

* mg/signature-doc:
Documentation/technical: signed merge tag format
Documentation/technical: signed commit format
Documentation/technical: signed tag format
Documentation/technical: describe signature formats

Merge branch 'nd/graph-width-padded'Junio C Hamano Wed, 6 Jul 2016 20:38:12 +0000 (13:38 -0700)

Merge branch 'nd/graph-width-padded'

"log --graph --format=" learned that "%>|(N)" specifies the width
relative to the terminal's left edge, not relative to the area to
draw text that is to the right of the ancestry-graph section. It
also now accepts negative N that means the column limit is relative
to the right border.

* nd/graph-width-padded:
pretty.c: support <direction>|(<negative number>) forms
pretty: pass graph width to pretty formatting for use in '%>|(N)'

Merge branch 'jk/repack-keep-unreachable'Junio C Hamano Wed, 6 Jul 2016 20:38:11 +0000 (13:38 -0700)

Merge branch 'jk/repack-keep-unreachable'

"git repack" learned the "--keep-unreachable" option, which sends
loose unreachable objects to a pack instead of leaving them loose.
This helps heuristics based on the number of loose objects
(e.g. "gc --auto").

* jk/repack-keep-unreachable:
repack: extend --keep-unreachable to loose objects
repack: add --keep-unreachable option
repack: document --unpack-unreachable option

Merge branch 'ew/mboxrd-format-am'Junio C Hamano Wed, 6 Jul 2016 20:38:11 +0000 (13:38 -0700)

Merge branch 'ew/mboxrd-format-am'

Teach format-patch and mailsplit (hence "am") how a line that
happens to begin with "From " in the e-mail message is quoted with
">", so that these lines can be restored to their original shape.

* ew/mboxrd-format-am:
am: support --patch-format=mboxrd
mailsplit: support unescaping mboxrd messages
pretty: support "mboxrd" output format

Merge branch 'jk/upload-pack-hook'Junio C Hamano Wed, 6 Jul 2016 20:38:11 +0000 (13:38 -0700)

Merge branch 'jk/upload-pack-hook'

"upload-pack" allows a custom "git pack-objects" replacement when
responding to "fetch/clone" via the uploadpack.packObjectsHook.

* jk/upload-pack-hook:
upload-pack: provide a hook for running pack-objects
t1308: do not get fooled by symbolic links to the source tree
config: add a notion of "scope"
config: return configset value for current_config_ functions
config: set up config_source for command-line config
git_config_parse_parameter: refactor cleanup code
git_config_with_options: drop "found" counting

Merge branch 'nd/worktree-cleanup-post-head-protection'Junio C Hamano Wed, 6 Jul 2016 20:38:11 +0000 (13:38 -0700)

Merge branch 'nd/worktree-cleanup-post-head-protection'

Further preparatory clean-up for "worktree" feature continues.

* nd/worktree-cleanup-post-head-protection:
worktree: simplify prefixing paths
worktree: avoid 0{40}, too many zeroes, hard to read
worktree.c: use is_dot_or_dotdot()
git-worktree.txt: keep subcommand listing in alphabetical order
worktree.c: rewrite mark_current_worktree() to avoid strbuf
completion: support git-worktree

Merge branch 'jk/bisect-show-tree'Junio C Hamano Wed, 6 Jul 2016 20:38:10 +0000 (13:38 -0700)

Merge branch 'jk/bisect-show-tree'

"git bisect" makes an internal call to "git diff-tree" when
bisection finds the culprit, but this call did not initialize the
data structure to pass to the diff-tree API correctly.

* jk/bisect-show-tree:
bisect: always call setup_revisions after init_revisions

Merge branch 'lf/sideband-returns-void'Junio C Hamano Wed, 6 Jul 2016 20:38:09 +0000 (13:38 -0700)

Merge branch 'lf/sideband-returns-void'

A small internal API cleanup.

* lf/sideband-returns-void:
upload-pack.c: make send_client_data() return void
sideband.c: make send_sideband() return void

Merge branch 'jk/add-i-diff-compact-heuristics'Junio C Hamano Wed, 6 Jul 2016 20:38:09 +0000 (13:38 -0700)

Merge branch 'jk/add-i-diff-compact-heuristics'

"git add -i/-p" learned to honor diff.compactionHeuristic
experimental knob, so that the user can work on the same hunk split
as "git diff" output.

* jk/add-i-diff-compact-heuristics:
add--interactive: respect diff.compactionHeuristic

Merge branch 'km/fetch-do-not-free-remote-name'Junio C Hamano Wed, 6 Jul 2016 20:38:08 +0000 (13:38 -0700)

Merge branch 'km/fetch-do-not-free-remote-name'

The ownership rule for the piece of memory that hold references to
be fetched in "git fetch" was screwy, which has been cleaned up.

* km/fetch-do-not-free-remote-name:
builtin/fetch.c: don't free remote->name after fetch

Merge branch 'nd/test-lib-httpd-show-error-log-in-verbose'Junio C Hamano Wed, 6 Jul 2016 20:38:08 +0000 (13:38 -0700)

Merge branch 'nd/test-lib-httpd-show-error-log-in-verbose'

HTTPd tests learned to show the server error log to help diagnosing
a failing tests.

* nd/test-lib-httpd-show-error-log-in-verbose:
lib-httpd.sh: print error.log on error

Merge branch 'jk/string-list-static-init'Junio C Hamano Wed, 6 Jul 2016 20:38:07 +0000 (13:38 -0700)

Merge branch 'jk/string-list-static-init'

Instead of taking advantage of a struct string_list that is
allocated with all NULs happens to be STRING_LIST_INIT_NODUP kind,
initialize them explicitly as such, to document their behaviour
better.

* jk/string-list-static-init:
use string_list initializer consistently
blame,shortlog: don't make local option variables static
interpret-trailers: don't duplicate option strings
parse_opt_string_list: stop allocating new strings

Merge branch 'jk/send-pack-stdio'Junio C Hamano Wed, 6 Jul 2016 20:38:07 +0000 (13:38 -0700)

Merge branch 'jk/send-pack-stdio'

Code clean-up.

* jk/send-pack-stdio:
write_or_die: remove the unused write_or_whine() function
send-pack: use buffered I/O to talk to pack-objects

Merge branch 'pb/commit-editmsg-path'Junio C Hamano Wed, 6 Jul 2016 20:38:06 +0000 (13:38 -0700)

Merge branch 'pb/commit-editmsg-path'

Code clean-up.

* pb/commit-editmsg-path:
builtin/commit.c: memoize git-path for COMMIT_EDITMSG

Merge branch 'ep/http-curl-trace'Junio C Hamano Wed, 6 Jul 2016 20:38:06 +0000 (13:38 -0700)

Merge branch 'ep/http-curl-trace'

HTTP transport gained an option to produce more detailed debugging
trace.

* ep/http-curl-trace:
imap-send.c: introduce the GIT_TRACE_CURL enviroment variable
http.c: implement the GIT_TRACE_CURL environment variable

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>

fetch: reduce duplicate in ref update status lines... Nguyễn Thái Ngọc Duy Fri, 1 Jul 2016 16:03:31 +0000 (18:03 +0200)

fetch: reduce duplicate in ref update status lines with placeholder

In the "remote -> local" line, if either ref is a substring of the
other, the common part in the other string is replaced with "*". For
example

abc -> origin/abc
refs/pull/123/head -> pull/123

become

abc -> origin/*
refs/*/head -> pull/123

Activated with fetch.output=compact.

For the record, this output is not perfect. A single giant ref can
push all refs very far to the right and likely be wrapped around. We
may have a few options:

- exclude these long lines smarter

- break the line after "->", exclude it from column width calculation

- implement a new format, { -> origin/}foo, which makes the problem
go away at the cost of a bit harder to read

- reverse all the arrows so we have "* <- looong-ref", again still
hard to read.

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

fetch: align all "remote -> local" outputNguyễn Thái Ngọc Duy Fri, 1 Jul 2016 16:03:30 +0000 (18:03 +0200)

fetch: align all "remote -> local" output

We do align "remote -> local" output by allocating 10 columns to
"remote". That produces aligned output only for short refs. An extra
pass is performed to find the longest remote ref name (that does not
produce a line longer than terminal width) to produce better aligned
output.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
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>

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>

git-svn: clone: Fail on missing url argumentChristopher Layne Sun, 3 Jul 2016 05:39:23 +0000 (05:39 +0000)

git-svn: clone: Fail on missing url argument

cmd_clone should detect a missing $url arg before using it otherwise
an uninitialized value error is emitted in even the simplest case of
'git svn clone' without arguments.

Signed-off-by: Christopher Layne <clayne@anodized.com>
Signed-off-by: Eric Wong <e@80x24.org>

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>

t5541: become resilient to GETTEXT_POISONVasco Almeida Thu, 30 Jun 2016 16:49:18 +0000 (16:49 +0000)

t5541: become resilient to GETTEXT_POISON

Use test_i18n* functions for testing text already marked for
translation.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
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>