git
6 years agouserdiff: fix HTML hunk header regexp
Ilya Kantor [Sat, 23 Sep 2017 07:53:47 +0000 (10:53 +0300)] 
userdiff: fix HTML hunk header regexp

Current HTML header regexp doesn't match headers without attributes.

So it fails to match <h1>...</h1>, while <h1 class="smth">...</h1> matches.

Make attributes optional to fix this.  The regexp is still far from
perfect, but now it at least handles the common case.

Signed-off-by: Ilya Kantor <iliakan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: put literal block delimiter around table
Jeff King [Sat, 23 Sep 2017 05:55:26 +0000 (01:55 -0400)] 
doc: put literal block delimiter around table

The git-read-tree manpage has a table that is meant to
be shown with its spacing exactly as it is in the source. We
mark it as a "literal paragraph" by indenting each line by
at least one space. This renders OK with asciidoc for both
the HTML and manpage versions.

But there are two problems when we render it with
asciidoctor.

The first is that some lines mix tabs and spaces.  Even if
asciidoctor is correctly configured for 8-space tabs, it
seems to handle this case differently, soaking up some of
the initial literal-paragraph spaces and mis-aligning the
table text.

The second problem is that the table uses blank lines to
group rows. But as blank lines separate paragraphs in
asciidoc, this actually means that each chunk of the table
is rendered in its own pre-formatted <div> block. This
happens even with vanilla asciidoc, but there's no visible
result because the literal paragraphs aren't styled in any
special way. But with asciidoctor (or at least the styles
used on git-scm.com), literal paragraphs are styled with a
different background.  This breaks the table into a visually
distracting sequence of chunks.

We can fix both by adding a literal-paragraph block
delimiter. That turns the whole table into a single block
(for both implementations) and causes asciidoctor to render
the indentation as it is in the source.

Reported-at: https://github.com/git/git-scm.com/issues/1023
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.14.2 v2.14.2
Junio C Hamano [Fri, 22 Sep 2017 05:51:37 +0000 (14:51 +0900)] 
Git 2.14.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSync with 2.13.6
Junio C Hamano [Fri, 22 Sep 2017 05:50:02 +0000 (14:50 +0900)] 
Sync with 2.13.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.13.6 v2.13.6
Junio C Hamano [Fri, 22 Sep 2017 05:49:24 +0000 (14:49 +0900)] 
Git 2.13.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSync with 2.12.5
Junio C Hamano [Fri, 22 Sep 2017 05:48:08 +0000 (14:48 +0900)] 
Sync with 2.12.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.12.5 v2.12.5
Junio C Hamano [Fri, 22 Sep 2017 05:47:41 +0000 (14:47 +0900)] 
Git 2.12.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSync with 2.11.4
Junio C Hamano [Fri, 22 Sep 2017 05:45:30 +0000 (14:45 +0900)] 
Sync with 2.11.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.11.4 v2.11.4
Junio C Hamano [Fri, 22 Sep 2017 05:44:45 +0000 (14:44 +0900)] 
Git 2.11.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSync with 2.10.5
Junio C Hamano [Fri, 22 Sep 2017 05:43:13 +0000 (14:43 +0900)] 
Sync with 2.10.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.10.5 v2.10.5
Junio C Hamano [Fri, 22 Sep 2017 05:42:22 +0000 (14:42 +0900)] 
Git 2.10.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jk/safe-pipe-capture' into maint-2.10
Junio C Hamano [Fri, 22 Sep 2017 05:34:34 +0000 (14:34 +0900)] 
Merge branch 'jk/safe-pipe-capture' into maint-2.10

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

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

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

6 years agoALLOC_GROW: avoid -Wsign-compare warnings
Ramsay Jones [Thu, 21 Sep 2017 16:49:38 +0000 (17:49 +0100)] 
ALLOC_GROW: avoid -Wsign-compare warnings

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocache.h: hex2chr() - avoid -Wsign-compare warnings
Ramsay Jones [Thu, 21 Sep 2017 16:48:38 +0000 (17:48 +0100)] 
cache.h: hex2chr() - avoid -Wsign-compare warnings

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocommit-slab.h: avoid -Wsign-compare warnings
Ramsay Jones [Thu, 21 Sep 2017 16:47:36 +0000 (17:47 +0100)] 
commit-slab.h: avoid -Wsign-compare warnings

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit-compat-util.h: xsize_t() - avoid -Wsign-compare warnings
Ramsay Jones [Thu, 21 Sep 2017 16:46:24 +0000 (17:46 +0100)] 
git-compat-util.h: xsize_t() - avoid -Wsign-compare warnings

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocat-file: handle NULL object_context.path
Jeff King [Thu, 21 Sep 2017 06:21:40 +0000 (02:21 -0400)] 
cat-file: handle NULL object_context.path

Commit dc944b65f1 (get_sha1_with_context: dynamically
allocate oc->path, 2017-05-19) changed the rules that
callers must follow for seeing if we parsed a path in the
object name. The rules switched from "check if the oc.path
buffer is empty" to "check if the oc.path pointer is NULL".
But that commit forgot to update some sites in
cat_one_file(), meaning we might dereference a NULL pointer.

You can see this by making a path-aware request like
--textconv without specifying --path, and giving an object
name that doesn't have a path in it. Like:

  git cat-file --textconv HEAD

which will reliably segfault.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubmodule.h: typofix
Han-Wen Nienhuys [Thu, 21 Sep 2017 12:43:37 +0000 (14:43 +0200)] 
submodule.h: typofix

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: fix "skip_branch_tip_with_tag()" string comparison
Lars Schneider [Thu, 21 Sep 2017 20:48:30 +0000 (22:48 +0200)] 
travis-ci: fix "skip_branch_tip_with_tag()" string comparison

09f5e97 ("travis-ci: skip a branch build if equal tag is present",
2017-09-17) introduced the "skip_branch_tip_with_tag" function with
a broken string comparison. Fix it!

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofast-export: do not copy from modified file
Jonathan Tan [Wed, 20 Sep 2017 23:55:02 +0000 (16:55 -0700)] 
fast-export: do not copy from modified file

When run with the "-C" option, fast-export writes 'C' commands in its
output whenever the internal diff mechanism detects a file copy,
indicating that fast-import should copy the given existing file to the
given new filename. However, the diff mechanism works against the
prior version of the file, whereas fast-import uses whatever is current.
This causes issues when a commit both modifies a file and uses it as the
source for a copy.

Therefore, teach fast-export to refrain from writing 'C' when it has
already written a modification command for a file.

An existing test in t9350-fast-export is also fixed in this patch. The
existing line "C file6 file7" copies the wrong version of file6, but it
has coincidentally worked because file7 was subsequently overridden.

Reported-by: Juraj Oršulić <juraj.orsulic@fer.hr>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-lint: echo -e (or -E) is not portable
Torsten Bögershausen [Sun, 17 Sep 2017 05:43:18 +0000 (07:43 +0200)] 
test-lint: echo -e (or -E) is not portable

Some implementations of `echo` support the '-e' option to enable
backslash interpretation of the following string.
As an addition, they support '-E' to turn it off.

However, none of these are portable, POSIX doesn't even mention them,
and many implementations don't support them.

A check for '-n' is already done in check-non-portable-shell.pl,
extend it to cover '-n', '-e' or '-E'.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofor_each_string_list_item: avoid undefined behavior for empty list
Michael Haggerty [Wed, 20 Sep 2017 05:27:05 +0000 (22:27 -0700)] 
for_each_string_list_item: avoid undefined behavior for empty list

If you pass a newly initialized or newly cleared `string_list` to
`for_each_string_list_item()`, then the latter does

    for (
            item = (list)->items; /* NULL */
            item < (list)->items + (list)->nr; /* NULL + 0 */
            ++item)

Even though this probably works almost everywhere, it is undefined
behavior, and it could plausibly cause highly-optimizing compilers to
misbehave.  C99 section 6.5.6 paragraph 8 explains:

    If both the pointer operand and the result point to elements
    of the same array object, or one past the last element of the
    array object, the evaluation shall not produce an overflow;
    otherwise, the behavior is undefined.

and (6.3.2.3.3) a null pointer does not point to anything.

Guard the loop with a NULL check to make the intent crystal clear to
even the most pedantic compiler.  A suitably clever compiler could let
the NULL check only run in the first iteration, but regardless, this
overhead is likely to be dwarfed by the work to be done on each item.

This problem was noticed by Coverity.

[jn: using a NULL check instead of a placeholder empty list;
 fleshed out the commit message based on mailing list discussion]

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread_info_alternates: warn on non-trivial errors
Jeff King [Tue, 19 Sep 2017 19:41:10 +0000 (15:41 -0400)] 
read_info_alternates: warn on non-trivial errors

When we fail to open $GIT_DIR/info/alternates, we silently
assume there are no alternates. This is the right thing to
do for ENOENT, but not for other errors.

A hard error is probably overkill here. If we fail to read
an alternates file then either we'll complete our operation
anyway, or we'll fail to find some needed object. Either
way, a warning is good idea. And we already have a helper
function to handle this pattern; let's just call
warn_on_fopen_error().

Note that technically the errno from strbuf_read_file()
might be from a read() error, not open(). But since read()
would never return ENOENT or ENOTDIR, and since it produces
a generic "unable to access" error, it's suitable for
handling errors from either.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jk/info-alternates-fix-2.11' into jk/info-alternates-fix
Junio C Hamano [Wed, 20 Sep 2017 02:33:06 +0000 (11:33 +0900)] 
Merge branch 'jk/info-alternates-fix-2.11' into jk/info-alternates-fix

* jk/info-alternates-fix-2.11:
  read_info_alternates: read contents into strbuf

6 years agoread_info_alternates: read contents into strbuf
Jeff King [Tue, 19 Sep 2017 19:41:07 +0000 (15:41 -0400)] 
read_info_alternates: read contents into strbuf

This patch fixes a regression in v2.11.1 where we might read
past the end of an mmap'd buffer. It was introduced in
cf3c635210.

The link_alt_odb_entries() function has always taken a
ptr/len pair as input. Until cf3c635210 (alternates: accept
double-quoted paths, 2016-12-12), we made a copy of those
bytes in a string. But after that commit, we switched to
parsing the input left-to-right, and we ignore "len"
totally, instead reading until we hit a NUL.

This has mostly gone unnoticed for a few reasons:

  1. All but one caller passes a NUL-terminated string, with
     "len" pointing to the NUL.

  2. The remaining caller, read_info_alternates(), passes in
     an mmap'd file. Unless the file is an exact multiple of
     the page size, it will generally be followed by NUL
     padding to the end of the page, which just works.

The easiest way to demonstrate the problem is to build with:

  make SANITIZE=address NO_MMAP=Nope test

Any test which involves $GIT_DIR/info/alternates will fail,
as the mmap emulation (correctly) does not add an extra NUL,
and ASAN complains about reading past the end of the buffer.

One solution would be to teach link_alt_odb_entries() to
respect "len". But it's actually a bit tricky, since we
depend on unquote_c_style() under the hood, and it has no
ptr/len variant.

We could also just make a NUL-terminated copy of the input
bytes and operate on that. But since all but one caller
already is passing a string, instead let's just fix that
caller to provide NUL-terminated input in the first place,
by swapping out mmap for strbuf_read_file().

There's no advantage to using mmap on the alternates file.
It's not expected to be large (and anyway, we're copying its
contents into an in-memory linked list). Nor is using
git_open() buying us anything here, since we don't keep the
descriptor open for a long period of time.

Let's also drop the "len" parameter entirely from
link_alt_odb_entries(), since it's completely ignored. That
will avoid any new callers re-introducing a similar bug.

Reported-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot/README: fix typo and grammatically improve a sentence
Kaartic Sivaraam [Sun, 17 Sep 2017 10:18:15 +0000 (10:18 +0000)] 
t/README: fix typo and grammatically improve a sentence

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogc: call fscanf() with %<len>s, not %<len>c, when reading hostname
Junio C Hamano [Sun, 17 Sep 2017 03:16:55 +0000 (12:16 +0900)] 
gc: call fscanf() with %<len>s, not %<len>c, when reading hostname

Earlier in this codepath, we (ab)used "%<len>c" to read the hostname
recorded in the lockfile into locking_host[HOST_NAME_MAX + 1] while
substituting <len> with the actual value of HOST_NAME_MAX.

This turns out to be incorrect, as it is an instruction to read
exactly the specified number of bytes.  Because we are trying to
read at most that many bytes, we should be using "%<len>s" instead.

Helped-by: A. Wilcox <awilfox@adelielinux.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodescribe: fix matching to actually match all patterns
Max Kirillov [Sat, 16 Sep 2017 05:53:44 +0000 (08:53 +0300)] 
describe: fix matching to actually match all patterns

`git describe --match` with multiple patterns matches only first pattern.
If it fails, next patterns are not tried.

Fix it, add test cases and update existing test which has wrong
expectation.

Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread_pack_header: handle signed/unsigned comparison in read result
Jeff King [Wed, 13 Sep 2017 18:47:22 +0000 (14:47 -0400)] 
read_pack_header: handle signed/unsigned comparison in read result

The result of read_in_full() may be -1 if we saw an error.
But in comparing it to a sizeof() result, that "-1" will be
promoted to size_t. In fact, the largest possible size_t
which is much bigger than our struct size. This means that
our "< sizeof(header)" error check won't trigger.

In practice, we'd go on to read uninitialized memory and
compare it to the PACK signature, which is likely to fail.
But we shouldn't get there.

We can fix this by making a direct "!=" comparison to the
requested size, rather than "<". This means that errors get
lumped in with short reads, but that's sufficient for our
purposes here. There's no PH_ERROR tp represent our case.
And anyway, this function reads from pipes and network
sockets. A network error may racily appear as EOF to us
anyway if there's data left in the socket buffers.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: flip return value of store_write_*()
Jeff King [Wed, 13 Sep 2017 17:17:57 +0000 (13:17 -0400)] 
config: flip return value of store_write_*()

The store_write_section() and store_write_pairs() functions
are basically high-level wrappers around write(). But their
return values are flipped from our usual convention, using
"1" for success and "0" for failure.

Let's flip them to follow the usual write() conventions and
update all callers. As these are local to config.c, it's
unlikely that we'd have new callers in any topics in flight
(which would be silently broken by our change). But just to
be on the safe side, let's rename them to just
write_section() and write_pairs().  That also accentuates
their relationship with write().

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agonotes-merge: use ssize_t for write_in_full() return value
Jeff King [Wed, 13 Sep 2017 17:17:44 +0000 (13:17 -0400)] 
notes-merge: use ssize_t for write_in_full() return value

We store the return value of write_in_full() in a long,
though the return is actually an ssize_t. This probably
doesn't matter much in practice (since the buffer size is
alredy an unsigned long), but it might if the size if
between what can be represented in "long" and "unsigned
long", and if your size_t is larger than a "long" (as it is
on 64-bit Windows).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopkt-line: check write_in_full() errors against "< 0"
Jeff King [Wed, 13 Sep 2017 17:17:30 +0000 (13:17 -0400)] 
pkt-line: check write_in_full() errors against "< 0"

As with the previous two commits, we prefer to check
write_in_full()'s return value to see if it is negative,
rather than comparing it to the input length.

These cases actually flip the logic to check for success,
making conversion a little different than in other cases. We
could of course write:

  if (write_in_full(...) >= 0)
          return 0;
  return error(...);

But our usual method of spelling write() error checks is
just "< 0". So let's flip the logic for each of these
conditionals to our usual style.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconvert less-trivial versions of "write_in_full() != len"
Jeff King [Wed, 13 Sep 2017 17:16:28 +0000 (13:16 -0400)] 
convert less-trivial versions of "write_in_full() != len"

The prior commit converted many sites to check the return
value of write_in_full() for negativity, rather than a
mismatch with the input length. This patch covers similar
cases, but where the return value is stored in an
intermediate variable. These should get the same treatment,
but they need to be reviewed more carefully since it would
be a bug if the return value is stored in an unsigned type
(which indeed, it is in one of the cases).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoavoid "write_in_full(fd, buf, len) != len" pattern
Jeff King [Wed, 13 Sep 2017 17:16:03 +0000 (13:16 -0400)] 
avoid "write_in_full(fd, buf, len) != len" pattern

The return value of write_in_full() is either "-1", or the
requested number of bytes[1]. If we make a partial write
before seeing an error, we still return -1, not a partial
value. This goes back to f6aa66cb95 (write_in_full: really
write in full or return error on disk full., 2007-01-11).

So checking anything except "was the return value negative"
is pointless. And there are a couple of reasons not to do
so:

  1. It can do a funny signed/unsigned comparison. If your
     "len" is signed (e.g., a size_t) then the compiler will
     promote the "-1" to its unsigned variant.

     This works out for "!= len" (unless you really were
     trying to write the maximum size_t bytes), but is a
     bug if you check "< len" (an example of which was fixed
     recently in config.c).

     We should avoid promoting the mental model that you
     need to check the length at all, so that new sites are
     not tempted to copy us.

  2. Checking for a negative value is shorter to type,
     especially when the length is an expression.

  3. Linus says so. In d34cf19b89 (Clean up write_in_full()
     users, 2007-01-11), right after the write_in_full()
     semantics were changed, he wrote:

       I really wish every "write_in_full()" user would just
       check against "<0" now, but this fixes the nasty and
       stupid ones.

     Appeals to authority aside, this makes it clear that
     writing it this way does not have an intentional
     benefit. It's a historical curiosity that we never
     bothered to clean up (and which was undoubtedly
     cargo-culted into new sites).

So let's convert these obviously-correct cases (this
includes write_str_in_full(), which is just a wrapper for
write_in_full()).

[1] A careful reader may notice there is one way that
    write_in_full() can return a different value. If we ask
    write() to write N bytes and get a return value that is
    _larger_ than N, we could return a larger total. But
    besides the fact that this would imply a totally broken
    version of write(), it would already invoke undefined
    behavior. Our internal remaining counter is an unsigned
    size_t, which means that subtracting too many byte will
    wrap it around to a very large number. So we'll instantly
    begin reading off the end of the buffer, trying to write
    gigabytes (or petabytes) of data.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoget-tar-commit-id: check write_in_full() return against 0
Jeff King [Wed, 13 Sep 2017 17:11:28 +0000 (13:11 -0400)] 
get-tar-commit-id: check write_in_full() return against 0

We ask to write 41 bytes and make sure that the return value
is at least 41. This is the same "dangerous" pattern that
was fixed in the prior commit (wherein a negative return
value is promoted to unsigned), though it is not dangerous
here because our "41" is a constant, not an unsigned
variable.

But we should convert it anyway to avoid modeling a
dangerous construct.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: avoid "write_in_full(fd, buf, len) < len" pattern
Jeff King [Wed, 13 Sep 2017 18:15:16 +0000 (14:15 -0400)] 
config: avoid "write_in_full(fd, buf, len) < len" pattern

The return type of write_in_full() is a signed ssize_t,
because we may return "-1" on failure (even if we succeeded
in writing some bytes). But "len" itself is may be an
unsigned type (the function takes a size_t, but of course we
may have something else in the calling function). So while
it seems like:

  if (write_in_full(fd, buf, len) < len)
die_errno("write error");

would trigger on error, it won't if "len" is unsigned.  The
compiler sees a signed/unsigned comparison and promotes the
signed value, resulting in (size_t)-1, the highest possible
size_t (or again, whatever type the caller has). This cannot
possibly be smaller than "len", and so the conditional can
never trigger.

I scoured the code base for cases of this, but it turns out
that these two in git_config_set_multivar_in_file_gently()
are the only ones. Here our "len" is the difference between
two size_t variables, making the result an unsigned size_t.
We can fix this by just checking for a negative return value
directly, as write_in_full() will never return any value
except -1 or the full count.

There's no addition to the test suite here, since you need
to convince write() to fail in order to see the problem. The
simplest reproduction recipe I came up with is to trigger
ENOSPC:

  # make a limited-size filesystem
  dd if=/dev/zero of=small.disk bs=1M count=1
  mke2fs small.disk
  mkdir mnt
  sudo mount -o loop small.disk mnt
  cd mnt
  sudo chown $USER:$USER .

  # make a config file with some content
  git config --file=config one.key value
  git config --file=config two.key value

  # now fill up the disk
  dd if=/dev/zero of=fill

  # and try to delete a key, which requires copying the rest
  # of the file to config.lock, and will fail on write()
  git config --file=config --unset two.key

That final command should (and does after this patch)
produce an error message due to the failed write, and leave
the file intact. Instead, it silently ignores the failure
and renames config.lock into place, leaving you with a
totally empty config file!

Reported-by: demerphq <demerphq@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: fix minor typos (extra/duplicated words)
Evan Zacks [Tue, 12 Sep 2017 22:58:39 +0000 (15:58 -0700)] 
doc: fix minor typos (extra/duplicated words)

Following are several fixes for duplicated words ("of of") and one
case where an extra article ("a") slipped in.

Signed-off-by: Evan Zacks <zackse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoarchive: don't add empty directories to archives
René Scharfe [Tue, 12 Sep 2017 22:43:57 +0000 (00:43 +0200)] 
archive: don't add empty directories to archives

While git doesn't track empty directories, git archive can be tricked
into putting some into archives.  One way is to construct an empty tree
object, as t5004 does.  While that is supported by the object database,
it can't be represented in the index and thus it's unlikely to occur in
the wild.

Another way is using the literal name of a directory in an exclude
pathspec -- its contents are are excluded, but the directory stub is
included.  That's inconsistent: exclude pathspecs containing wildcards
don't leave empty directories in the archive.

Yet another way is have a few levels of nested subdirectories (e.g.
d1/d2/d3/file1) and ignoring the entries at the leaves (e.g. file1).
The directories with the ignored content are ignored as well (e.g. d3),
but their empty parents are included (e.g. d2).

As empty directories are not supported by git, they should also not be
written into archives.  If an empty directory is really needed then it
can be tracked and archived by placing an empty .gitignore file in it.

There already is a mechanism in place for suppressing empty directories.
When read_tree_recursive() encounters a directory excluded by a pathspec
then it enters it anyway because it might contain included entries.  It
calls the callback function before it is able to decide if the directory
is actually needed.  For that reason git archive adds directories to a
queue and writes entries for them only when it encounters the first
child item -- but currently only if pathspecs with wildcards are used.

Queue *all* directories, no matter if there even are pathspecs present.
This prevents git archive from writing entries for empty directories in
all cases.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorefs: strip out not allowed flags from ref_transaction_update
Thomas Gummerer [Tue, 12 Sep 2017 22:59:21 +0000 (23:59 +0100)] 
refs: strip out not allowed flags from ref_transaction_update

Callers are only allowed to pass certain flags into
ref_transaction_update, other flags are internal to it.  To prevent
mistakes from the callers, strip the internal only flags out before
continuing.

This was noticed because of a compiler warning gcc 7.1.1 issued about
passing a NULL parameter as second parameter to memcpy (through
hashcpy):

In file included from refs.c:5:0:
refs.c: In function ‘ref_transaction_verify’:
cache.h:948:2: error: argument 2 null where non-null expected [-Werror=nonnull]
  memcpy(sha_dst, sha_src, GIT_SHA1_RAWSZ);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from git-compat-util.h:165:0,
                 from cache.h:4,
                 from refs.c:5:
/usr/include/string.h:43:14: note: in a call to function ‘memcpy’ declared here
 extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
              ^~~~~~

The call to hascpy in ref_transaction_add_update is protected by the
passed in flags, but as we only add flags there, gcc notices
REF_HAVE_NEW or REF_HAVE_OLD flags could be passed in from the outside,
which would potentially result in passing in NULL as second parameter to
memcpy.

Fix both the compiler warning, and make the interface safer for its
users by stripping the internal flags out.

Suggested-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc/for-each-ref: explicitly specify option names
Kevin Daudt [Mon, 11 Sep 2017 19:33:38 +0000 (21:33 +0200)] 
doc/for-each-ref: explicitly specify option names

For count, sort and format, only the argument names were listed under
OPTIONS, not the option names.

Add the option names to make it clear the options exist

Signed-off-by: Kevin Daudt <me@ikke.info>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc/for-each-ref: consistently use '=' to between argument names and values
Kevin Daudt [Mon, 11 Sep 2017 19:33:37 +0000 (21:33 +0200)] 
doc/for-each-ref: consistently use '=' to between argument names and values

The synopsis and description inconsistently add a '=' between the
argument name and it's value. Make this consistent.

Signed-off-by: Kevin Daudt <me@ikke.info>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsimport: shell-quote variable used in backticks
Jeff King [Mon, 11 Sep 2017 14:24:26 +0000 (10:24 -0400)] 
cvsimport: shell-quote variable used in backticks

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

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoarchimport: use safe_pipe_capture for user input
Jeff King [Mon, 11 Sep 2017 14:24:11 +0000 (10:24 -0400)] 
archimport: use safe_pipe_capture for user input

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

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoshell: drop git-cvsserver support by default
Jeff King [Mon, 11 Sep 2017 15:27:51 +0000 (11:27 -0400)] 
shell: drop git-cvsserver support by default

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

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

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

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsserver: use safe_pipe_capture for `constant commands` as well
Junio C Hamano [Mon, 11 Sep 2017 05:45:54 +0000 (14:45 +0900)] 
cvsserver: use safe_pipe_capture for `constant commands` as well

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsserver: use safe_pipe_capture instead of backticks
joernchen [Mon, 11 Sep 2017 05:45:09 +0000 (14:45 +0900)] 
cvsserver: use safe_pipe_capture instead of backticks

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

Reported-by: joernchen <joernchen@phenoelit.de>
Signed-off-by: joernchen <joernchen@phenoelit.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsserver: move safe_pipe_capture() to the main package
Junio C Hamano [Mon, 11 Sep 2017 05:44:24 +0000 (14:44 +0900)] 
cvsserver: move safe_pipe_capture() to the main package

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubprocess: loudly die when subprocess asks for an unsupported capability
Junio C Hamano [Mon, 11 Sep 2017 03:21:29 +0000 (12:21 +0900)] 
subprocess: loudly die when subprocess asks for an unsupported capability

The handshake_capabilities() function first advertises the set of
capabilities it supports, so that the other side can pick and choose
which ones to use and ask us to enable in its response.  Then we
read the response that tells us what choice the other side made.  If
we saw something that we never advertised, that indicates one of two
things.  The other side, i.e. the "upgraded" filter, is not paying
attention of the capabilities advertisement, and asking something
its correct operation relies on, but we are not capable of giving
that unknown feature and operate without it, so after that point the
exchange of data is a garbage-in-garbage-out.  Or the other side
wanted to ask for one of the capabilities we advertised, but the
code has typo and their wish to enable a capability that its correct
operation relies on is not understood on this end.  The result is
the same garbage-in-garbage-out.

Instead of sweeping such a potential bug under the rug, die loudly
when we see a request for an unsupported capability in order to
force sloppily-written filter scripts to get corrected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis: dedent a few scripts that are indented overly deeply
Junio C Hamano [Mon, 11 Sep 2017 01:18:29 +0000 (10:18 +0900)] 
travis: dedent a few scripts that are indented overly deeply

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: skip a branch build if equal tag is present
Lars Schneider [Sun, 10 Sep 2017 14:44:29 +0000 (16:44 +0200)] 
travis-ci: skip a branch build if equal tag is present

If we push a branch and a tag pointing to the HEAD of this branch,
then Travis CI would run the build twice. This wastes resources and
slows the testing.

Add a function to detect this situation and skip the build the branch
if appropriate. Invoke this function on every build.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: move Travis CI code into dedicated scripts
Lars Schneider [Sun, 10 Sep 2017 14:44:28 +0000 (16:44 +0200)] 
travis-ci: move Travis CI code into dedicated scripts

Most of the Travis CI commands are in the '.travis.yml'. The yml format
does not support functions and therefore code duplication is necessary
to run commands across all builds.

To fix this, add a library for common CI functions. Move all Travis CI
code into dedicated scripts and make them call the library first.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoRelNotes: further fixes for 2.14.2 from the master front
Junio C Hamano [Sun, 10 Sep 2017 08:06:09 +0000 (17:06 +0900)] 
RelNotes: further fixes for 2.14.2 from the master front

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jt/doc-pack-objects-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:10 +0000 (17:03 +0900)] 
Merge branch 'jt/doc-pack-objects-fix' into maint

Doc updates.

* jt/doc-pack-objects-fix:
  Doc: clarify that pack-objects makes packs, plural

6 years agoMerge branch 'jn/vcs-svn-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:09 +0000 (17:03 +0900)] 
Merge branch 'jn/vcs-svn-cleanup' into maint

Code clean-up.

* jn/vcs-svn-cleanup:
  vcs-svn: move remaining repo_tree functions to fast_export.h
  vcs-svn: remove repo_delete wrapper function
  vcs-svn: remove custom mode constants
  vcs-svn: remove more unused prototypes and declarations

6 years agoMerge branch 'bc/vcs-svn-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:08 +0000 (17:03 +0900)] 
Merge branch 'bc/vcs-svn-cleanup' into maint

Code clean-up.

* bc/vcs-svn-cleanup:
  vcs-svn: rename repo functions to "svn_repo"
  vcs-svn: remove unused prototypes

6 years agoMerge branch 'jk/doc-the-this' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:07 +0000 (17:03 +0900)] 
Merge branch 'jk/doc-the-this' into maint

Doc clean-up.

* jk/doc-the-this:
  doc: fix typo in sendemail.identity

6 years agoMerge branch 'rs/commit-h-single-parent-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:07 +0000 (17:03 +0900)] 
Merge branch 'rs/commit-h-single-parent-cleanup' into maint

Code clean-up.

* rs/commit-h-single-parent-cleanup:
  commit: remove unused inline function single_parent()

6 years agoMerge branch 'mg/format-ref-doc-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:06 +0000 (17:03 +0900)] 
Merge branch 'mg/format-ref-doc-fix' into maint

Doc fix.

* mg/format-ref-doc-fix:
  Documentation/git-for-each-ref: clarify peeling of tags for --format
  Documentation: use proper wording for ref format strings

6 years agoMerge branch 'sb/submodule-parallel-update' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:06 +0000 (17:03 +0900)] 
Merge branch 'sb/submodule-parallel-update' into maint

Code clean-up.

* sb/submodule-parallel-update:
  submodule.sh: remove unused variable

6 years agoMerge branch 'hv/t5526-andand-chain-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:05 +0000 (17:03 +0900)] 
Merge branch 'hv/t5526-andand-chain-fix' into maint

Test fix.

* hv/t5526-andand-chain-fix:
  t5526: fix some broken && chains

6 years agoMerge branch 'sb/sha1-file-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:04 +0000 (17:03 +0900)] 
Merge branch 'sb/sha1-file-cleanup' into maint

Code clean-up.

* sb/sha1-file-cleanup:
  sha1_file: make read_info_alternates static

6 years agoMerge branch 'rs/t1002-do-not-use-sum' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:04 +0000 (17:03 +0900)] 
Merge branch 'rs/t1002-do-not-use-sum' into maint

Test simplification.

* rs/t1002-do-not-use-sum:
  t1002: stop using sum(1)

6 years agoMerge branch 'ah/doc-empty-string-is-false' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:03 +0000 (17:03 +0900)] 
Merge branch 'ah/doc-empty-string-is-false' into maint

Doc update.

* ah/doc-empty-string-is-false:
  doc: clarify "config --bool" behaviour with empty string

6 years agoMerge branch 'rs/merge-microcleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)] 
Merge branch 'rs/merge-microcleanup' into maint

Code clean-up.

* rs/merge-microcleanup:
  merge: use skip_prefix()

6 years agoMerge branch 'rs/find-pack-entry-bisection' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)] 
Merge branch 'rs/find-pack-entry-bisection' into maint

Code clean-up.

* rs/find-pack-entry-bisection:
  sha1_file: avoid comparison if no packed hash matches the first byte

6 years agoMerge branch 'rs/apply-lose-prefix-length' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:01 +0000 (17:03 +0900)] 
Merge branch 'rs/apply-lose-prefix-length' into maint

Code clean-up.

* rs/apply-lose-prefix-length:
  apply: remove prefix_length member from apply_state

6 years agoMerge branch 'rj/add-chmod-error-message' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:00 +0000 (17:03 +0900)] 
Merge branch 'rj/add-chmod-error-message' into maint

Message fix.

* rj/add-chmod-error-message:
  builtin/add: add detail to a 'cannot chmod' error message

6 years agoMerge branch 'jk/hashcmp-memcmp' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:59 +0000 (17:02 +0900)] 
Merge branch 'jk/hashcmp-memcmp' into maint

Code clean-up.

* jk/hashcmp-memcmp:
  hashcmp: use memcmp instead of open-coded loop

6 years agoMerge branch 'rs/t3700-clean-leftover' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:58 +0000 (17:02 +0900)] 
Merge branch 'rs/t3700-clean-leftover' into maint

A test fix.

* rs/t3700-clean-leftover:
  t3700: fix broken test under !POSIXPERM

6 years agoMerge branch 'jc/perl-git-comment-typofix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:57 +0000 (17:02 +0900)] 
Merge branch 'jc/perl-git-comment-typofix' into maint

A comment fix.

* jc/perl-git-comment-typofix:
  perl/Git.pm: typofix in a comment

6 years agoMerge branch 'mf/no-dashed-subcommands' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:56 +0000 (17:02 +0900)] 
Merge branch 'mf/no-dashed-subcommands' into maint

Code clean-up.

* mf/no-dashed-subcommands:
  scripts: use "git foo" not "git-foo"

6 years agoMerge branch 'ab/ref-filter-no-contains' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:56 +0000 (17:02 +0900)] 
Merge branch 'ab/ref-filter-no-contains' into maint

A test fix.

* ab/ref-filter-no-contains:
  tests: don't give unportable ">" to "test" built-in, use -gt

6 years agoMerge branch 'rs/archive-excluded-directory' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'rs/archive-excluded-directory' into maint

"git archive" did not work well with pathspecs and the
export-ignore attribute.

We may want to resurrect the "we don't archive an empty directory"
bonus patch, but I do not mind merging the above early to 'next'
and leave it as a separate follow-up enhancement.
cf. <20170820090629.tumvqwzkromcykjf@sigill.intra.peff.net>

* rs/archive-excluded-directory:
  archive: don't queue excluded directories
  archive: factor out helper functions for handling attributes
  t5001: add tests for export-ignore attributes and exclude pathspecs

6 years agoMerge branch 'mg/killed-merge' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'mg/killed-merge' into maint

Killing "git merge --edit" before the editor returns control left
the repository in a state with MERGE_MSG but without MERGE_HEAD,
which incorrectly tells the subsequent "git commit" that there was
a squash merge in progress.  This has been fixed.

* mg/killed-merge:
  merge: save merge state earlier
  merge: split write_merge_state in two
  merge: clarify call chain
  Documentation/git-merge: explain --continue

6 years agoMerge branch 'tb/apply-with-crlf' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'tb/apply-with-crlf' into maint

"git apply" that is used as a better "patch -p1" failed to apply a
taken from a file with CRLF line endings to a file with CRLF line
endings.  The root cause was because it misused convert_to_git()
that tried to do "safe-crlf" processing by looking at the index
entry at the same path, which is a nonsense---in that mode, "apply"
is not working on the data in (or derived from) the index at all.
This has been fixed.

* tb/apply-with-crlf:
  apply: file commited with CRLF should roundtrip diff and apply
  convert: add SAFE_CRLF_KEEP_CRLF

6 years agoMerge branch 'cc/subprocess-handshake-missing-capabilities' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'cc/subprocess-handshake-missing-capabilities' into maint

When handshake with a subprocess filter notices that the process
asked for an unknown capability, Git did not report what program
the offending subprocess was running.  This has been corrected.

We may want a follow-up fix to tighten the error checking, though.

* cc/subprocess-handshake-missing-capabilities:
  sub-process: print the cmd when a capability is unsupported

6 years agoMerge branch 'as/grep-quiet-no-match-exit-code-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'as/grep-quiet-no-match-exit-code-fix' into maint

"git grep -L" and "git grep --quiet -L" reported different exit
codes; this has been corrected.

* as/grep-quiet-no-match-exit-code-fix:
  git-grep: correct exit code with --quiet and -L

6 years agoMerge branch 'kd/stash-with-bash-4.4' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:54 +0000 (17:02 +0900)] 
Merge branch 'kd/stash-with-bash-4.4' into maint

bash 4.4 or newer gave a warning on NUL byte in command
substitution done in "git stash"; this has been squelched.

* kd/stash-with-bash-4.4:
  stash: prevent warning about null bytes in input

6 years agoMerge branch 'rs/win32-syslog-leakfix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:54 +0000 (17:02 +0900)] 
Merge branch 'rs/win32-syslog-leakfix' into maint

Memory leak in an error codepath has been plugged.

* rs/win32-syslog-leakfix:
  win32: plug memory leak on realloc() failure in syslog()

6 years agoMerge branch 'rs/unpack-entry-leakfix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:53 +0000 (17:02 +0900)] 
Merge branch 'rs/unpack-entry-leakfix' into maint

Memory leak in an error codepath has been plugged.

* rs/unpack-entry-leakfix:
  sha1_file: release delta_stack on error in unpack_entry()

6 years agoMerge branch 'rs/fsck-obj-leakfix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)] 
Merge branch 'rs/fsck-obj-leakfix' into maint

Memory leak in an error codepath has been plugged.

* rs/fsck-obj-leakfix:
  fsck: free buffers on error in fsck_obj()

6 years agoMerge branch 'ur/svn-local-zone' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)] 
Merge branch 'ur/svn-local-zone' into maint

"git svn" used with "--localtime" option did not compute the tz
offset for the timestamp in question and instead always used the
current time, which has been corrected.

* ur/svn-local-zone:
  git svn fetch: Create correct commit timestamp when using --localtime

6 years agoMerge branch 'pw/am-signoff' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)] 
Merge branch 'pw/am-signoff' into maint

"git am -s" has been taught that some input may end with a trailer
block that is not Signed-off-by: and it should refrain from adding
an extra blank line before adding a new sign-off in such a case.

* pw/am-signoff:
  am: fix signoff when other trailers are present

6 years agoMerge branch 'rs/in-obsd-basename-dirname-take-const' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)] 
Merge branch 'rs/in-obsd-basename-dirname-take-const' into maint

Portability fix.

* rs/in-obsd-basename-dirname-take-const:
  test-path-utils: handle const parameter of basename and dirname

6 years agoMerge branch 'rs/t4062-obsd' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)] 
Merge branch 'rs/t4062-obsd' into maint

Test portability fix.

* rs/t4062-obsd:
  t4062: use less than 256 repetitions in regex

6 years agoMerge branch 'rs/obsd-getcwd-workaround' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:50 +0000 (17:02 +0900)] 
Merge branch 'rs/obsd-getcwd-workaround' into maint

Test portability fix for BSDs.

* rs/obsd-getcwd-workaround:
  t0001: skip test with restrictive permissions if getpwd(3) respects them

6 years agoMerge branch 'bw/clone-recursive-quiet' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)] 
Merge branch 'bw/clone-recursive-quiet' into maint

"git clone --recurse-submodules --quiet" did not pass the quiet
option down to submodules.

* bw/clone-recursive-quiet:
  clone: teach recursive clones to respect -q

6 years agoMerge branch 'pw/sequence-rerere-autoupdate' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)] 
Merge branch 'pw/sequence-rerere-autoupdate' into maint

Commands like "git rebase" accepted the --rerere-autoupdate option
from the command line, but did not always use it.  This has been
fixed.

* pw/sequence-rerere-autoupdate:
  cherry-pick/revert: reject --rerere-autoupdate when continuing
  cherry-pick/revert: remember --rerere-autoupdate
  t3504: use test_commit
  rebase -i: honor --rerere-autoupdate
  rebase: honor --rerere-autoupdate
  am: remember --rerere-autoupdate setting

6 years agoMerge branch 'bw/push-options-recursively-to-submodules' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)] 
Merge branch 'bw/push-options-recursively-to-submodules' into maint

"git push --recurse-submodules $there HEAD:$target" was not
propagated down to the submodules, but now it is.

* bw/push-options-recursively-to-submodules:
  submodule--helper: teach push-check to handle HEAD

6 years agoMerge branch 'ma/pager-per-subcommand-action' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)] 
Merge branch 'ma/pager-per-subcommand-action' into maint

The "tag.pager" configuration variable was useless for those who
actually create tag objects, as it interfered with the use of an
editor.  A new mechanism has been introduced for commands to enable
pager depending on what operation is being carried out to fix this,
and then "git tag -l" is made to run pager by default.

If this works out OK, I think there are low-hanging fruits in
other commands like "git branch" that outputs long list in one mode
while taking input in another.

* ma/pager-per-subcommand-action:
  git.c: ignore pager.* when launching builtin as dashed external
  tag: change default of `pager.tag` to "on"
  tag: respect `pager.tag` in list-mode only
  t7006: add tests for how git tag paginates
  git.c: provide setup_auto_pager()
  git.c: let builtins opt for handling `pager.foo` themselves
  builtin.h: take over documentation from api-builtin.txt

6 years agoMerge branch 'jk/rev-list-empty-input' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)] 
Merge branch 'jk/rev-list-empty-input' into maint

"git log --tag=no-such-tag" showed log starting from HEAD, which
has been fixed---it now shows nothing.

* jk/rev-list-empty-input:
  revision: do not fallback to default when rev_input_given is set
  rev-list: don't show usage when we see empty ref patterns
  revision: add rev_input_given flag
  t6018: flesh out empty input/output rev-list tests

6 years agoMerge branch 'st/lib-gpg-kill-stray-agent' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)] 
Merge branch 'st/lib-gpg-kill-stray-agent' into maint

Some versions of GnuPG fails to kill gpg-agent it auto-spawned
and such a left-over agent can interfere with a test.  Work it
around by attempting to kill one before starting a new test.

* st/lib-gpg-kill-stray-agent:
  t: lib-gpg: flush gpg agent on startup

6 years agocommit-tree: do not complete line in -F input
Ross Kabus [Thu, 7 Sep 2017 14:41:11 +0000 (10:41 -0400)] 
commit-tree: do not complete line in -F input

"git commit-tree -F <file>", unlike "cat <file> | git
commit-tree" (i.e. feeding the same contents from the standard
input), added a missing final newline when the input ended in an
incomplete line.

Correct this inconsistency by leaving the incomplete line as-is,
as erring on the side of not touching the input is preferrable
and expected for a plumbing command like "commit-tree".

Signed-off-by: Ross Kabus <rkabus@aerotech.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit_extract_argv0_path: do nothing without RUNTIME_PREFIX
Jeff King [Wed, 6 Sep 2017 12:32:10 +0000 (08:32 -0400)] 
git_extract_argv0_path: do nothing without RUNTIME_PREFIX

When the RUNTIME_PREFIX compile-time knob isn't set, we
never look at the argv0_path we extract. We can push its
declaration inside the #ifdef to make it more clear that the
extract code is effectively a noop.

This also un-confuses leak-checking of the argv0_path
variable when RUNTIME_PREFIX isn't set. The compiler is free
to drop this static variable that we set but never look at
(and "gcc -O2" does so).  But the compiler still must call
strbuf_detach(), since it doesn't know whether that function
has side effects; it just throws away the result rather than
putting it into the global.

Leak-checkers which work by scanning the data segment for
pointers to heap blocks would normally consider the block
as reachable at program end. But if the compiler removes the
variable entirely, there's nothing to find.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosystem_path: move RUNTIME_PREFIX to a sub-function
Jeff King [Wed, 6 Sep 2017 12:30:28 +0000 (08:30 -0400)] 
system_path: move RUNTIME_PREFIX to a sub-function

The system_path() function has an #ifdef in the middle of
it. Let's move the conditional logic into a sub-function.
This isolates it more, which will make it easier to change
and add to.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation: mention that `eol` can change the dirty status of paths
Ben Boeckel [Thu, 31 Aug 2017 13:19:36 +0000 (09:19 -0400)] 
Documentation: mention that `eol` can change the dirty status of paths

When setting the `eol` attribute, paths can change their dirty status
without any change in the working directory. This can cause confusion
and should at least be mentioned with a remedy.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Reviewed-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorev-parse: don't trim bisect refnames
Jeff King [Wed, 6 Sep 2017 11:53:10 +0000 (07:53 -0400)] 
rev-parse: don't trim bisect refnames

Using for_each_ref_in() with a full refname has always been
a questionable practice, but it became an error with
b9c8e7f2fb (prefix_ref_iterator: don't trim too much,
2017-05-22), making "git rev-parse --bisect" pretty reliably
show a BUG.

Commit 03df567fbf (for_each_bisect_ref(): don't trim
refnames, 2017-06-18) fixed this case for revision.c, but
rev-parse handles this option on its own. We can use the
same solution here (and piggy-back on its test).

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>