git
6 years agot5526: fix some broken && chains
Heiko Voigt [Thu, 17 Aug 2017 10:36:13 +0000 (12:36 +0200)] 
t5526: fix some broken && chains

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubmodule.sh: remove unused variable
Stefan Beller [Wed, 16 Aug 2017 22:50:42 +0000 (15:50 -0700)] 
submodule.sh: remove unused variable

This could have been part of 48308681b0 (git submodule update: have a
dedicated helper for cloning, 2016-02-29).

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconvert: add SAFE_CRLF_KEEP_CRLF
Torsten Bögershausen [Sun, 13 Aug 2017 08:51:04 +0000 (10:51 +0200)] 
convert: add SAFE_CRLF_KEEP_CRLF

When convert_to_git() is called, the caller may want to keep CRLF to
be kept as CRLF (and not converted into LF).

This will be used in the next commit, when apply works with files
that have CRLF and patches are applied onto these files.

Add the new value "SAFE_CRLF_KEEP_CRLF" to safe_crlf.

Prepare convert_to_git() to be able to run the clean filter, skip
the CRLF conversion and run the ident filter.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosub-process: print the cmd when a capability is unsupported
Christian Couder [Wed, 16 Aug 2017 12:40:36 +0000 (14:40 +0200)] 
sub-process: print the cmd when a capability is unsupported

In handshake_capabilities() we use warning() when a capability
is not supported, so the exit code of the function is 0 and no
further error is shown. This is a problem because the warning
message doesn't tell us which subprocess cmd failed.

On the contrary if we cannot write a packet from this function,
we use error() and then subprocess_start() outputs:

    initialization for subprocess '<cmd>' failed

so we can know which subprocess cmd failed.

Let's improve the warning() message, so that we can know which
subprocess cmd failed.

Helped-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: make read_info_alternates static
Stefan Beller [Tue, 15 Aug 2017 20:13:19 +0000 (13:13 -0700)] 
sha1_file: make read_info_alternates static

read_info_alternates is not used from outside, so let's make it static.

We have to declare the function before link_alt_odb_entry instead of
moving the code around, link_alt_odb_entry calls read_info_alternates,
which in turn calls link_alt_odb_entry.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot1002: stop using sum(1)
René Scharfe [Mon, 14 Aug 2017 20:16:34 +0000 (22:16 +0200)] 
t1002: stop using sum(1)

sum(1) is a command for calculating checksums of the contents of files.
It was part of early editions of Unix ("Research Unix", 1972/1973, [1]).
cksum(1) appeared in 4.4BSD (1993) as a replacement [2], and became part
of POSIX.1-2008 [3].  OpenBSD 5.6 (2014) removed sum(1).

We only use sum(1) in t1002 to check for changes in three files.  On
MinGW we use md5sum(1) instead.  We could switch to the standard command
cksum(1) for all platforms; MinGW comes with GNU coreutils now, which
provides sum(1), cksum(1) and md5sum(1).  Use our standard method for
checking for file changes instead: test_cmp.

It's more convenient because it shows differences nicely, it's faster on
MinGW because we have a special implementation there based only on
shell-internal commands, it's simpler as it allows us to avoid stripping
out unnecessary entries from the checksum file using grep(1), and it's
more consistent with the rest of the test suite.

We already compare changed files with their expected new contents using
diff(1), so we don't need to check with "test_must_fail test_cmp" if
they differ from their original state.  A later patch could convert the
direct diff(1) calls to test_cmp as well.

With all sum(1) calls gone, remove the MinGW-specific implementation
from test-lib.sh as well.

[1] http://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man1/sum.1
[2] http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/share/man/cat1/cksum.0
[3] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cksum.html

Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: clarify "config --bool" behaviour with empty string
Andreas Heiduk [Mon, 14 Aug 2017 22:12:18 +0000 (00:12 +0200)] 
doc: clarify "config --bool" behaviour with empty string

`git config --bool xxx.yyy` returns `true` for `[xxx]yyy` but
`false` for `[xxx]yyy=` or `[xxx]yyy=""`.  This is tested in
t1300-repo-config.sh since 09bc098c2.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: prevent warning about null bytes in input
Kevin Daudt [Mon, 14 Aug 2017 21:43:33 +0000 (23:43 +0200)] 
stash: prevent warning about null bytes in input

The `no_changes` function calls the `untracked_files` function through
command substitution. `untracked_files` will return null bytes because it
runs ls-files with the '-z' option.

Bash since version 4.4 warns about these null bytes. As they are not
required for the test that is being done, make sure `untracked_files`
does not output null bytes when not required.

This is achieved by adding a parameter to the `untracked_files` function to
specify wither `-z` should be passed to ls-files or not.

This warning is triggered when running git stash save -u resulting in
two warnings:

    git-stash: line 43: warning: command substitution: ignored null byte
    in input

Signed-off-by: Kevin Daudt <me@ikke.info>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: release delta_stack on error in unpack_entry()
René Scharfe [Thu, 10 Aug 2017 09:42:21 +0000 (11:42 +0200)] 
sha1_file: release delta_stack on error in unpack_entry()

When unpack_entry() encounters a broken packed object, it returns early.
It adjusts the reference count of the pack window, but leaks the buffer
for a big delta stack in case the small automatic one was not enough.
Jump to the cleanup code at end instead, which takes care of that.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofsck: free buffers on error in fsck_obj()
René Scharfe [Thu, 10 Aug 2017 09:42:10 +0000 (11:42 +0200)] 
fsck: free buffers on error in fsck_obj()

Move the code for releasing tree buffers and commit buffers in
fsck_obj() to the end of the function and make sure it's executed no
matter of an error is encountered or not.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowin32: plug memory leak on realloc() failure in syslog()
René Scharfe [Thu, 10 Aug 2017 10:23:45 +0000 (12:23 +0200)] 
win32: plug memory leak on realloc() failure in syslog()

If realloc() fails then the original buffer is still valid.  Free it
before exiting the function.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge: use skip_prefix()
René Scharfe [Thu, 10 Aug 2017 16:47:55 +0000 (18:47 +0200)] 
merge: use skip_prefix()

Get rid of a magic string length constant by using skip_prefix() instead
of starts_with().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohashcmp: use memcmp instead of open-coded loop
Jeff King [Wed, 9 Aug 2017 10:16:45 +0000 (06:16 -0400)] 
hashcmp: use memcmp instead of open-coded loop

In 1a812f3a70 (hashcmp(): inline memcmp() by hand to
optimize, 2011-04-28), it was reported that an open-coded
loop outperformed memcmp() for comparing sha1s.

Discussion[1] a few years later in 2013 showed that this
depends on your libc's version of memcmp(). In particular,
glibc 2.13 optimized their memcmp around 2011. Here are
current timings with glibc 2.24 (best-of-five, on
linux.git):

  [before this patch, open-coded]
  $ time git rev-list --objects --all
  real 0m35.357s
  user 0m35.016s
  sys 0m0.340s

  [after this patch, memcmp]
  real 0m32.930s
  user 0m32.630s
  sys 0m0.300s

Now that we've had 6 years for that version of glibc to
make its way onto people's machines, it's worth revisiting
our benchmarks and switching to memcmp().

It may be that there are other non-glibc systems where
memcmp() isn't as well optimized. But since our single data
point in favor of open-coding was on a now-ancient glibc, we
should probably assume the system memcmp is good unless
proven otherwise. We may end up with a SLOW_MEMCMP Makefile
knob, but we can hold off on that until we actually find
such a system in practice.

[1] https://public-inbox.org/git/20130318073229.GA5551@sigill.intra.peff.net/

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoapply: remove prefix_length member from apply_state
René Scharfe [Wed, 9 Aug 2017 15:54:46 +0000 (17:54 +0200)] 
apply: remove prefix_length member from apply_state

Use a NULL-and-NUL check to see if we have a prefix and consistently use
C string functions on it instead of storing its length in a member of
struct apply_state.  This avoids strlen() calls and simplifies the code.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/add: add detail to a 'cannot chmod' error message
Ramsay Jones [Wed, 9 Aug 2017 00:51:23 +0000 (01:51 +0100)] 
builtin/add: add detail to a 'cannot chmod' error message

In addition to adding the missing newline, add the x-ecutable bit
'mode change' character to the error message. This message now has
the same form as similar messages output by 'update-index'.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: avoid comparison if no packed hash matches the first byte
René Scharfe [Tue, 8 Aug 2017 22:07:30 +0000 (00:07 +0200)] 
sha1_file: avoid comparison if no packed hash matches the first byte

find_pack_entry_one() uses the fan-out table of pack indexes to find out
which entries match the first byte of the searched hash and does a
binary search on this subset of the main index table.

If there are no matching entries then lo and hi will have the same
value.  The binary search still starts and compares the hash of the
following entry (which has a non-matching first byte, so won't cause any
trouble), or whatever comes after the sorted list of entries.

The probability of that stray comparison matching by mistake is low, but
let's not take any chances and check when entering the binary search
loop if we're actually done already.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4062: use less than 256 repetitions in regex
René Scharfe [Wed, 9 Aug 2017 14:15:10 +0000 (16:15 +0200)] 
t4062: use less than 256 repetitions in regex

OpenBSD's regex library has a repetition limit (RE_DUP_MAX) of 255.
That's the minimum acceptable value according to POSIX.  In t4062 we use
4096 repetitions in the test "-G matches", though, causing it to fail.
Combine two repetition operators, both less than 256, to arrive at 4096
zeros instead of using a single one, to fix the test on OpenBSD.

Original-patch-by: David Coppa <dcoppa@openbsd.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot3700: fix broken test under !POSIXPERM
René Scharfe [Tue, 8 Aug 2017 19:21:41 +0000 (21:21 +0200)] 
t3700: fix broken test under !POSIXPERM

76e368c378 (t3700: fix broken test under !SANITY) explains that the test
'git add --chmod=[+-]x changes index with already added file' can fail
if xfoo3 is still present as a symlink from a previous test and deletes
it with rm(1).  That still leaves it present in the index, which causes
the test to fail if POSIXPERM is not defined.  Get rid of it by calling
"git reset --hard" as well, as 76e368c378 already mentioned in passing.

Helped-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoam: fix signoff when other trailers are present
Phillip Wood [Tue, 8 Aug 2017 10:25:33 +0000 (11:25 +0100)] 
am: fix signoff when other trailers are present

If there was no 'Signed-off-by:' trailer but another trailer such as
'Reported-by:' then 'git am --signoff' would add a blank line between
the existing trailers and the added 'Signed-off-by:' line. e.g.

    Rebase accepts '--rerere-autoupdate' as an option but only honors
    it if '-m' is also given. Fix it for a non-interactive rebase by
    passing on the option to 'git am' and 'git cherry-pick'.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Fix by using the code provided for this purpose in sequencer.c.
Change the tests so that they check the formatting of the
'Signed-off-by:' lines rather than just grepping for them.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit svn fetch: Create correct commit timestamp when using --localtime
Urs Thuermann [Sat, 5 Aug 2017 00:12:15 +0000 (02:12 +0200)] 
git svn fetch: Create correct commit timestamp when using --localtime

In parse_svn_date() prepend the correct UTC offset to the timestamp
returned.  This is the offset in effect at the commit time instead of
the offset in effect at calling time.

Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>
Reviewed-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoperl/Git.pm: typofix in a comment
Junio C Hamano [Mon, 7 Aug 2017 22:15:57 +0000 (15:15 -0700)] 
perl/Git.pm: typofix in a comment

No change of behaviour intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoscripts: use "git foo" not "git-foo"
Michael Forney [Sat, 5 Aug 2017 06:49:05 +0000 (23:49 -0700)] 
scripts: use "git foo" not "git-foo"

We want to make sure that people who copy & paste code would see
fewer instances of "git-foo".  The use of these dashed forms have
been discouraged since v1.6.0 days.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-path-utils: handle const parameter of basename and dirname
René Scharfe [Mon, 7 Aug 2017 13:57:31 +0000 (15:57 +0200)] 
test-path-utils: handle const parameter of basename and dirname

The parameter to basename(3) and dirname(3) traditionally had the type
"char *", but on OpenBSD it's been "const char *" for years.  That
causes (at least) Clang to throw an incompatible-pointer-types warning
for test-path-utils, where we try to pass around pointers to these
functions.

Avoid this warning (which is fatal in DEVELOPER mode) by ignoring the
promise of OpenBSD's implementations to keep input strings unmodified
and enclosing them in POSIX-compatible wrappers.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot0001: skip test with restrictive permissions if getpwd(3) respects them
René Scharfe [Mon, 7 Aug 2017 11:04:18 +0000 (13:04 +0200)] 
t0001: skip test with restrictive permissions if getpwd(3) respects them

The sub-test "init in long base path" in t0001 checks the ability to
handle long base paths with restrictive permissions (--x).  On OpenBSD
getcwd(3) fails in that case even for short paths.  Check the two
aspects separately by trying to use a long base path both with and
without execute-only permissions.  Only attempt the former if we know
that getcwd(3) doesn't care.

Original-patch-by: David Coppa <dcoppa@openbsd.org>
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotests: don't give unportable ">" to "test" built-in, use -gt
Ævar Arnfjörð Bjarmason [Sun, 6 Aug 2017 23:38:50 +0000 (23:38 +0000)] 
tests: don't give unportable ">" to "test" built-in, use -gt

Change an argument to test_line_count (which'll ultimately be turned
into a "test" expression) to use "-gt" instead of ">" for an
arithmetic test.

This broken on e.g. OpenBSD as of v2.13.0 with my commit
ac3f5a3468 ("ref-filter: add --no-contains option to
tag/branch/for-each-ref", 2017-03-24).

Downstream just worked around it by patching git and didn't tell us
about it, I discovered this when reading various Git packaging
implementations: https://github.com/openbsd/ports/commit/7e48bf88a20

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.14.1 v2.14.1
Junio C Hamano [Fri, 4 Aug 2017 19:41:48 +0000 (12:41 -0700)] 
Git 2.14.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.13.5' into maint
Junio C Hamano [Fri, 4 Aug 2017 19:40:37 +0000 (12:40 -0700)] 
Merge tag 'v2.13.5' into maint

6 years agoGit 2.14 v2.14.0
Junio C Hamano [Fri, 4 Aug 2017 16:31:12 +0000 (09:31 -0700)] 
Git 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ah/patch-id-doc'
Junio C Hamano [Fri, 4 Aug 2017 16:29:15 +0000 (09:29 -0700)] 
Merge branch 'ah/patch-id-doc'

Docfix.

* ah/patch-id-doc:
  doc: remove unsupported parameter from patch-id

6 years agoMerge branch 'as/diff-options-grammofix'
Junio C Hamano [Fri, 4 Aug 2017 16:29:14 +0000 (09:29 -0700)] 
Merge branch 'as/diff-options-grammofix'

A grammofix.

* as/diff-options-grammofix:
  diff-options doc: grammar fix

6 years agoclone: teach recursive clones to respect -q
Brandon Williams [Thu, 3 Aug 2017 22:25:44 +0000 (15:25 -0700)] 
clone: teach recursive clones to respect -q

Teach 'git clone --recurse-submodules' to respect the '-q' option by
passing down the quiet flag to the process which handles cloning of
submodules.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit.c: ignore pager.* when launching builtin as dashed external
Martin Ågren [Wed, 2 Aug 2017 19:40:55 +0000 (21:40 +0200)] 
git.c: ignore pager.* when launching builtin as dashed external

When running, e.g., `git -c alias.bar=foo bar`, we expand the alias and
execute `git-foo` as a dashed external. This is true even if git foo is
a builtin. That is on purpose, and is motivated in a comment which was
added in commit 441981bc ("git: simplify environment save/restore
logic", 2016-01-26).

Shortly before we launch a dashed external, and unless we have already
found out whether we should use a pager, we check `pager.foo`. This was
added in commit 92058e4d ("support pager.* for external commands",
2011-08-18). If the dashed external is a builtin, this does not match
that commit's intention and is arguably wrong, since it would be cleaner
if we let the "dashed external builtin" handle `pager.foo`.

This has not mattered in practice, but a recent patch taught `git-tag`
to ignore `pager.tag` under certain circumstances. But, when started
using an alias, it doesn't get the chance to do so, as outlined above.
That recent patch added a test to document this breakage.

Do not check `pager.foo` before launching a builtin as a dashed
external, i.e., if we recognize the name of the external as a builtin.
Change the test to use `test_expect_success`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotag: change default of `pager.tag` to "on"
Martin Ågren [Wed, 2 Aug 2017 19:40:54 +0000 (21:40 +0200)] 
tag: change default of `pager.tag` to "on"

The previous patch taught `git tag` to only respect `pager.tag` in
list-mode. That patch left the default value of `pager.tag` at "off".

After that patch, it makes sense to let the default value be "on"
instead, since it will help with listing many tags, but will not hurt
users of `git tag -a` as it would have before. Make that change. Update
documentation and tests.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotag: respect `pager.tag` in list-mode only
Martin Ågren [Wed, 2 Aug 2017 19:40:53 +0000 (21:40 +0200)] 
tag: respect `pager.tag` in list-mode only

Using, e.g., `git -c pager.tag tag -a new-tag` results in errors such as
"Vim: Warning: Output is not to a terminal" and a garbled terminal.
Someone who makes use of both `git tag -a` and `git tag -l` will
probably not set `pager.tag`, so that `git tag -a` will actually work,
at the cost of not paging output of `git tag -l`.

Use the mechanisms introduced in two earlier patches to ignore
`pager.tag` in git.c and let the `git tag` builtin handle it on its own.
Only respect `pager.tag` when running in list-mode.

There is a window between where the pager is started before and after
this patch. This means that early errors can behave slightly different
before and after this patch. Since operation-parsing has to happen
inside this window, this can be seen with `git -c pager.tag="echo pager
is used" tag -l --unknown-option`. This change in paging-behavior should
be acceptable since it only affects erroneous usages.

Update the documentation and update tests.

If an alias is used to run `git tag -a`, then `pager.tag` will still be
respected. Document this known breakage. It will be fixed in a later
commit. Add a similar test for `-l`, which works.

Noticed-by: Anatoly Borodin <anatoly.borodin@gmail.com>
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7006: add tests for how git tag paginates
Martin Ågren [Wed, 2 Aug 2017 19:40:52 +0000 (21:40 +0200)] 
t7006: add tests for how git tag paginates

Using, e.g., `git -c pager.tag tag -a new-tag` results in errors such as
"Vim: Warning: Output is not to a terminal" and a garbled terminal.
Someone who makes use of both `git tag -a` and `git tag -l` will
probably not set `pager.tag`, so that `git tag -a` will actually work,
at the cost of not paging output of `git tag -l`.

Since we're about to change how `git tag` respects `pager.tag`, add tests
around this, including how the configuration is ignored if --no-pager or
--paginate are used.

Construct tests with a few different subcommands. First, use -l. Second,
use "no arguments" and --contains, since those imply -l. (There are
more arguments which imply -l, but using these two should be enough.)

Third, use -a as a representative for "not -l". Actually, the tests use
`git tag -am` so no editor is launched, but that is irrelevant, since we
just want to see whether the pager is used or not. Make one of the tests
demonstrate the broken behavior mentioned above, where `git tag -a`
respects `pager.tag`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit.c: provide setup_auto_pager()
Martin Ågren [Wed, 2 Aug 2017 19:40:51 +0000 (21:40 +0200)] 
git.c: provide setup_auto_pager()

The previous patch introduced a way for builtins to declare that they
will take responsibility for handling the `pager.foo`-config item. (See
the commit message of that patch for why that could be useful.)

Provide setup_auto_pager(), which builtins can call in order to handle
`pager.<cmd>`, including possibly starting the pager. Make this function
don't do anything if a pager has already been started, as indicated by
use_pager or pager_in_use().

Whenever this function is called from a builtin, git.c will already have
called commit_pager_choice(). Since commit_pager_choice() treats the
special value -1 as "punt" or "not yet decided", it is not a problem
that we might end up calling commit_pager_choice() once in git.c and
once (or more) in the builtin. Make the new function use -1 in the same
way and document it as "punt".

Don't add any users of setup_auto_pager just yet, one will follow in
a later patch.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit.c: let builtins opt for handling `pager.foo` themselves
Martin Ågren [Wed, 2 Aug 2017 19:40:50 +0000 (21:40 +0200)] 
git.c: let builtins opt for handling `pager.foo` themselves

Before launching a builtin git foo and unless mechanisms with precedence
are in use, we check for and handle the `pager.foo` config. This is done
without considering exactly how git foo is being used, and indeed, git.c
cannot (and should not) know what the arguments to git foo are supposed
to achieve.

In practice this means that, e.g., `git -c pager.tag tag -a new-tag`
results in errors such as "Vim: Warning: Output is not to a terminal"
and a garbled terminal. Someone who makes use of both `git tag -a` and
`git tag -l` will probably not set `pager.tag`, so that `git tag -a`
will actually work, at the cost of not paging output of `git tag -l`.

To allow individual builtins to make more informed decisions about when
to respect `pager.foo`, introduce a flag DELAY_PAGER_CONFIG. If the flag
is set, do not check `pager.foo`.

Do not check for DELAY_PAGER_CONFIG in `execv_dashed_external()`. That
call site is arguably wrong, although in a way that is not yet visible,
and will be changed in a slightly different direction in a later patch.

Don't add any users of DELAY_PAGER_CONFIG just yet, one will follow in a
later patch.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin.h: take over documentation from api-builtin.txt
Martin Ågren [Wed, 2 Aug 2017 19:40:49 +0000 (21:40 +0200)] 
builtin.h: take over documentation from api-builtin.txt

Delete Documentation/technical/api-builtin.txt and move its content
into builtin.h. Format it as a comment. Remove a '+' which was needed
when the information was formatted for AsciiDoc. Similarly, change
"::" to ":".

Document SUPPORT_SUPER_PREFIX, thereby bringing the documentation up to
date with the available flags.

While at it, correct '3 more things to do' to '4 more things to do'.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorevision: do not fallback to default when rev_input_given is set
Jeff King [Wed, 2 Aug 2017 22:30:19 +0000 (18:30 -0400)] 
revision: do not fallback to default when rev_input_given is set

If revs->def is set (as it is in "git log") and there are no
pending objects after parsing the user's input, then we show
whatever is in "def". But if the user _did_ ask for some
input that just happened to be empty (e.g., "--glob" that
does not match anything), showing the default revision is
confusing. We should just show nothing, as that is what the
user's request yielded.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorev-list: don't show usage when we see empty ref patterns
Jeff King [Wed, 2 Aug 2017 22:26:06 +0000 (18:26 -0400)] 
rev-list: don't show usage when we see empty ref patterns

If the user gives us no starting point for a traversal, we
want to complain with our normal usage message. But if they
tried to do so with "--all" or "--glob", but that happened
not to match any refs, the usage message isn't helpful. We
should just give them the empty output they asked for
instead.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorevision: add rev_input_given flag
Jeff King [Wed, 2 Aug 2017 22:25:27 +0000 (18:25 -0400)] 
revision: add rev_input_given flag

Normally a caller that invokes setup_revisions() has to
check rev.pending to see if anything was actually queued for
the traversal. But they can't tell the difference between
two cases:

  1. The user gave us no tip from which to start a
     traversal.

  2. The user tried to give us tips via --glob, --all, etc,
     but their patterns ended up being empty.

Let's set a flag in the rev_info struct that callers can use
to tell the difference.  We can set this from the
init_all_refs_cb() function.  That's a little funny because
it's not exactly about initializing the "cb" struct itself.
But that function is the common setup place for doing
pattern traversals that is used by --glob, --all, etc.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot6018: flesh out empty input/output rev-list tests
Jeff King [Wed, 2 Aug 2017 22:24:51 +0000 (18:24 -0400)] 
t6018: flesh out empty input/output rev-list tests

In 751a2ac6e (rev-list --exclude: tests, 2013-11-01), we
added a few tests for handling "empty" inputs with rev-list
(i.e., where the user gave us some pattern but it turned out
not to queue any objects for traversal), all of which were
marked as failing.

In preparation for working on this area of the code, let's
give each test a more descriptive name. Let's also include
one more case which we should cover: feeding a --glob
pattern that doesn't match anything.

We can also drop the explanatory comment; we'll be
converting these to expect_success in the next few patches,
so the discussion isn't necessary.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocherry-pick/revert: reject --rerere-autoupdate when continuing
Phillip Wood [Wed, 2 Aug 2017 10:44:20 +0000 (11:44 +0100)] 
cherry-pick/revert: reject --rerere-autoupdate when continuing

cherry-pick and revert should not accept --[no-]rerere-autoupdate once
they have started.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocherry-pick/revert: remember --rerere-autoupdate
Phillip Wood [Wed, 2 Aug 2017 10:44:19 +0000 (11:44 +0100)] 
cherry-pick/revert: remember --rerere-autoupdate

When continuing after conflicts, cherry-pick forgot if the user had specified
'--rerere-autoupdate'.

Redo the cherry-pick rerere tests to check --rerere-autoupdate works
as expected.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot3504: use test_commit
Phillip Wood [Wed, 2 Aug 2017 10:44:18 +0000 (11:44 +0100)] 
t3504: use test_commit

Using test_commit is simpler than chaining echo && git add &&
test_tick && commit. Also having tags makes it clearer which commit
is being selecting by reset.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase -i: honor --rerere-autoupdate
Phillip Wood [Wed, 2 Aug 2017 10:44:17 +0000 (11:44 +0100)] 
rebase -i: honor --rerere-autoupdate

Interactive rebase was ignoring '--rerere-autoupdate'. Fix this by
reading it appropriate file when restoring the sequencer state for an
interactive rebase and passing '--rerere-autoupdate' to merge and
cherry-pick when rebasing with '--preserve-merges'.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase: honor --rerere-autoupdate
Phillip Wood [Wed, 2 Aug 2017 10:44:16 +0000 (11:44 +0100)] 
rebase: honor --rerere-autoupdate

Rebase accepts '--rerere-autoupdate' as an option but only honors it
if '-m' is also given. Fix it for a non-interactive rebase by passing
on the option to 'git am' and 'git cherry-pick'. Rework the tests so
that they can be used for each rebase flavor and extend them.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoam: remember --rerere-autoupdate setting
Phillip Wood [Wed, 2 Aug 2017 10:44:15 +0000 (11:44 +0100)] 
am: remember --rerere-autoupdate setting

Save the rerere-autoupdate setting so that it is remembered after
stopping for the user to resolve conflicts.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'l10n-2.14.0-rnd2' of git://github.com/git-l10n/git-po
Junio C Hamano [Wed, 2 Aug 2017 17:52:33 +0000 (10:52 -0700)] 
Merge tag 'l10n-2.14.0-rnd2' of git://github.com/git-l10n/git-po

l10n for Git 2.14.0 round 2

* tag 'l10n-2.14.0-rnd2' of git://github.com/git-l10n/git-po:
  l10n: zh_CN: review for git v2.14.0 l10n
  l10n: ko.po: Update Korean translation
  l10n: zh_CN: for git v2.14.0 l10n round 2
  l10n: de.po: various fixes in German translation
  l10n: ru.po: update Russian translation
  l10n: fr.po v2.14.0 rnd 2
  l10n: fr.po Fix some french typos
  l10n: fr.po Fix typo
  l10n: fr.po Fix some translations
  l10n: de.po: update German translation
  l10n: vi.po (3213t): Updated 9 new strings
  l10n: Update Catalan translation
  l10n: bg.po: Updated Bulgarian translation (3213t)

6 years agol10n: zh_CN: review for git v2.14.0 l10n
Jiang Xin [Wed, 2 Aug 2017 00:02:37 +0000 (08:02 +0800)] 
l10n: zh_CN: review for git v2.14.0 l10n

Reviewed-by: 依云 <lilydjwg@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
6 years agoGit 2.13.5 v2.13.5
Junio C Hamano [Tue, 1 Aug 2017 19:30:00 +0000 (12:30 -0700)] 
Git 2.13.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.12.4' into maint
Junio C Hamano [Tue, 1 Aug 2017 19:27:31 +0000 (12:27 -0700)] 
Merge tag 'v2.12.4' into maint

6 years agoSync with v2.13.4
Junio C Hamano [Tue, 1 Aug 2017 18:46:51 +0000 (11:46 -0700)] 
Sync with v2.13.4

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: ko.po: Update Korean translation
Changwoo Ryu [Tue, 1 Aug 2017 03:32:00 +0000 (12:32 +0900)] 
l10n: ko.po: Update Korean translation

Signed-off-by: Changwoo Ryu <cwryu@debian.org>
6 years agol10n: zh_CN: for git v2.14.0 l10n round 2
Jiang Xin [Sun, 11 Jun 2017 03:28:31 +0000 (11:28 +0800)] 
l10n: zh_CN: for git v2.14.0 l10n round 2

Translate new l10n messages for git 2.14.0, and update translations on
"stash".

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
6 years agoSync with maint
Junio C Hamano [Mon, 31 Jul 2017 20:52:53 +0000 (13:52 -0700)] 
Sync with maint

* maint:
  Preparation for 2.13.4 continues

6 years agoPreparation for 2.13.4 continues
Junio C Hamano [Mon, 31 Jul 2017 20:52:40 +0000 (13:52 -0700)] 
Preparation for 2.13.4 continues

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ks/doc-fixes' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:06 +0000 (13:51 -0700)] 
Merge branch 'ks/doc-fixes' into maint

Doc clean-up.

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

6 years agoMerge branch 'jk/test-copy-bytes-fix' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)] 
Merge branch 'jk/test-copy-bytes-fix' into maint

A test fix.

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

6 years agoMerge branch 'pw/unquote-path-in-git-pm' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)] 
Merge branch 'pw/unquote-path-in-git-pm' into maint

Code refactoring.

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

6 years agoMerge branch 'jk/gc-pre-detach-under-hook' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:05 +0000 (13:51 -0700)] 
Merge branch 'jk/gc-pre-detach-under-hook' into maint

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

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

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

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

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

6 years agoMerge branch 'rs/progress-overall-throughput-at-the-end' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:04 +0000 (13:51 -0700)] 
Merge branch 'rs/progress-overall-throughput-at-the-end' into maint

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

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

6 years agoMerge branch 'tb/push-to-cygwin-unc-path' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:04 +0000 (13:51 -0700)] 
Merge branch 'tb/push-to-cygwin-unc-path' into maint

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

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

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

6 years agoMerge branch 'rs/apply-avoid-over-reading' into maint
Junio C Hamano [Mon, 31 Jul 2017 20:51:04 +0000 (13:51 -0700)] 
Merge branch 'rs/apply-avoid-over-reading' into maint

Code cleanup.

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

6 years agoMerge branch 'js/blame-lib'
Junio C Hamano [Mon, 31 Jul 2017 20:05:15 +0000 (13:05 -0700)] 
Merge branch 'js/blame-lib'

A hotfix to a topic already in 'master'.

* js/blame-lib:
  blame: fix memory corruption scrambling revision name in error message

6 years agodiff-options doc: grammar fix
Anthony Sottile [Mon, 31 Jul 2017 14:00:31 +0000 (07:00 -0700)] 
diff-options doc: grammar fix

Signed-off-by: Anthony Sottile <asottile@umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.12.4 v2.12.4
Junio C Hamano [Sun, 30 Jul 2017 22:06:06 +0000 (15:06 -0700)] 
Git 2.12.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.11.3' into maint-2.12
Junio C Hamano [Sun, 30 Jul 2017 22:04:22 +0000 (15:04 -0700)] 
Merge tag 'v2.11.3' into maint-2.12

Git 2.11.3

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

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.10.4' into maint-2.11
Junio C Hamano [Sun, 30 Jul 2017 22:01:31 +0000 (15:01 -0700)] 
Merge tag 'v2.10.4' into maint-2.11

Git 2.10.4

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.9.5' into maint-2.10
Junio C Hamano [Sun, 30 Jul 2017 21:57:33 +0000 (14:57 -0700)] 
Merge tag 'v2.9.5' into maint-2.10

Git 2.9.5

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.8.6' into maint-2.9
Junio C Hamano [Sun, 30 Jul 2017 21:52:14 +0000 (14:52 -0700)] 
Merge tag 'v2.8.6' into maint-2.9

Git 2.8.6

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.7.6' into maint-2.8
Junio C Hamano [Sun, 30 Jul 2017 21:46:43 +0000 (14:46 -0700)] 
Merge tag 'v2.7.6' into maint-2.8

Git 2.7.6

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: de.po: various fixes in German translation
Hartmut Henkel [Thu, 27 Jul 2017 17:24:09 +0000 (19:24 +0200)] 
l10n: de.po: various fixes in German translation

Signed-off-by: Hartmut Henkel <henkel@vh-s.de>
Helped-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Matthias Rüster <matthias.ruester@gmail.com>
6 years agoMerge branch 'russian-l10n' of https://github.com/DJm00n/git-po-ru
Jiang Xin [Sun, 30 Jul 2017 14:47:47 +0000 (22:47 +0800)] 
Merge branch 'russian-l10n' of https://github.com/DJm00n/git-po-ru

* 'russian-l10n' of https://github.com/DJm00n/git-po-ru:
  l10n: ru.po: update Russian translation

6 years agol10n: ru.po: update Russian translation
Dimitriy Ryazantcev [Sun, 30 Jul 2017 09:35:40 +0000 (12:35 +0300)] 
l10n: ru.po: update Russian translation

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
6 years agoMerge branch 'jk/ssh-funny-url' into maint-2.7
Junio C Hamano [Fri, 28 Jul 2017 23:11:54 +0000 (16:11 -0700)] 
Merge branch 'jk/ssh-funny-url' into maint-2.7

6 years agoconnect: reject paths that look like command line options
Jeff King [Fri, 28 Jul 2017 19:28:55 +0000 (15:28 -0400)] 
connect: reject paths that look like command line options

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

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

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: reject dashed arguments for proxy commands
Jeff King [Fri, 28 Jul 2017 19:26:50 +0000 (15:26 -0400)] 
connect: reject dashed arguments for proxy commands

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

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

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

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

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

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

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: factor out "looks like command line option" check
Jeff King [Fri, 28 Jul 2017 19:25:45 +0000 (15:25 -0400)] 
connect: factor out "looks like command line option" check

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

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5813: add test for hostname starting with dash
Jeff King [Fri, 28 Jul 2017 19:23:32 +0000 (15:23 -0400)] 
t5813: add test for hostname starting with dash

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

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: reject ssh hostname that begins with a dash
Junio C Hamano [Wed, 26 Jul 2017 17:24:20 +0000 (10:24 -0700)] 
connect: reject ssh hostname that begins with a dash

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

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

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

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

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

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

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

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

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

Noticed-by: Joern Schneeweisz of Recurity Labs
Reported-by: Brian at GitLab
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot/lib-proto-disable: restore protocol.allow after config tests
Jeff King [Fri, 28 Jul 2017 21:47:48 +0000 (17:47 -0400)] 
t/lib-proto-disable: restore protocol.allow after config tests

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

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

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

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

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

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

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotests: ensure fsck fails on corrupt packfiles
Jonathan Tan [Fri, 28 Jul 2017 20:08:02 +0000 (13:08 -0700)] 
tests: ensure fsck fails on corrupt packfiles

t1450-fsck.sh does not have a test that checks fsck's behavior when a
packfile is invalid. It does have a test for when an object in a
packfile is invalid, but in that test, the packfile itself is valid.

Add such a test.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: remove unsupported parameter from patch-id
Andreas Heiduk [Thu, 27 Jul 2017 22:46:16 +0000 (00:46 +0200)] 
doc: remove unsupported parameter from patch-id

The patch is read from standard input and not from a parameter.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocredential-cache: interpret an ECONNRESET as an EOF
Ramsay Jones [Thu, 27 Jul 2017 01:08:40 +0000 (02:08 +0100)] 
credential-cache: interpret an ECONNRESET as an EOF

Since commit 612c49e94d ("credential-cache: add tests for XDG
functionality", 17-03-2017), the cygwin build has been failing all the
new tests added by that commit. In particular, the 'git credential-cache
exit' command, as part of the test cleanup code, has been die-ing with
the message:

    fatal: read error from cache daemon: Connection reset by peer

As this git command is part of an && chain in a 'test_when_finished'
call, the remaining test cleanup is not happening, so practically all
remaining tests fail due to the unexpected presence of various socket
files and directories.

A simple means of getting the tests to pass, is to simply ignore the
failure of 'git credential-cache exit' command and make sure all test
cleanup is done. For example, the diff for test #12 would look like:

    diff --git a/t/t0301-credential-cache.sh b/t/t0301-credential-cache.sh
    index fd92533ac..87e5001bb 100755
    --- a/t/t0301-credential-cache.sh
    +++ b/t/t0301-credential-cache.sh
    @@ -17,7 +17,7 @@ helper_test cache

     test_expect_success 'socket defaults to ~/.cache/git/credential/socket' '
            test_when_finished "
    -               git credential-cache exit &&
    +               (git credential-cache exit || :) &&
                    rmdir -p .cache/git/credential/
            " &&
            test_path_is_missing "$HOME/.git-credential-cache" &&

... and so on for all remaining tests. While this does indeed make all
tests pass, it is not really a solution.

As an aside, while looking to debug this issue, I added the '--debug'
option to the invocation of the 'git-credential-cache--daemon' child
process (see the spawn_daemon() function). This not only fixed the tests,
but also stopped git-credential-cache exiting with a failure. Since the
only effect of passing '--debug' was to suppress the redirection of stderr
to the bit-bucket (/dev/null), I have no idea why this seems to fix the
protocol interaction between git and git-credential-cache--daemon. (I
did think that maybe it was a timing issue, so I tried sleeping before
reading from the daemon on Linux, but that only slowed down the tests!)

All descriptions of the "Connection reset by peer" error, that I could
find, say that the peer had destroyed the connection before the client
attempted to perform I/O on the connection. Since the daemon does not
respond to an "exit" message from the client, it just closes the socket
and deletes the socket file (via the atexit handler), it seems that the
expected result is for the client to receive an EOF.  Indeed, this is
exactly what seems to be happening on Linux. Also a comment in
credential-cache--daemon.c reads:

    else if (!strcmp(action.buf, "exit")) {
            /*
             * It's important that we clean up our socket first, and then
             * signal the client only once we have finished the cleanup.
             * Calling exit() directly does this, because we clean up in
             * our atexit() handler, and then signal the client when our
             * process actually ends, which closes the socket and gives
             * them EOF.
             */
            exit(0);
    }

On cygwin this is not the case, at least when not passing --debug to the
daemon, and the read following the "exit" gets an error with errno set
to ECONNRESET.

In order to suppress the fatal exit in this case, check the read error
for an ECONNRESET and return as if no data was read from the daemon.
This effectively converts an ECONNRESET into an EOF.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'master' of https://github.com/ralfth/git-po-de
Jiang Xin [Thu, 27 Jul 2017 15:12:11 +0000 (23:12 +0800)] 
Merge branch 'master' of https://github.com/ralfth/git-po-de

* 'master' of https://github.com/ralfth/git-po-de:
  l10n: de.po: update German translation

6 years agoMerge branch 'fr_l10n_v2.14.0rnd2' of git://github.com/jnavila/git
Jiang Xin [Thu, 27 Jul 2017 15:10:13 +0000 (23:10 +0800)] 
Merge branch 'fr_l10n_v2.14.0rnd2' of git://github.com/jnavila/git

* 'fr_l10n_v2.14.0rnd2' of git://github.com/jnavila/git:
  l10n: fr.po v2.14.0 rnd 2
  l10n: fr.po Fix some french typos
  l10n: fr.po Fix typo
  l10n: fr.po Fix some translations

6 years agol10n: fr.po v2.14.0 rnd 2
Jean-Noel Avila [Wed, 26 Jul 2017 13:48:29 +0000 (15:48 +0200)] 
l10n: fr.po v2.14.0 rnd 2

Signed-off-by: Jean-Noel Avila <jean-noel.avila@scantech.fr>
6 years agol10n: fr.po Fix some french typos
Sylvestre Ledru [Thu, 22 Jun 2017 09:22:47 +0000 (11:22 +0200)] 
l10n: fr.po Fix some french typos

Signed-off-by: Sylvestre Ledru <sylvestre@debian.org>
6 years agol10n: fr.po Fix typo
Louis [Thu, 6 Jul 2017 20:21:14 +0000 (22:21 +0200)] 
l10n: fr.po Fix typo

Signed-off-by: Louis <spalax@gresille.org>
6 years agol10n: fr.po Fix some translations
Hugues Peccatte [Wed, 17 May 2017 20:26:19 +0000 (22:26 +0200)] 
l10n: fr.po Fix some translations

Signed-off-by: Hugues Peccatte <hugues.peccatte@aareon.fr>
Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
6 years agot8008: rely on rev-parse'd HEAD instead of sha1 value
Stefan Beller [Wed, 26 Jul 2017 19:06:31 +0000 (12:06 -0700)] 
t8008: rely on rev-parse'd HEAD instead of sha1 value

Remove hard coded sha1 values, obtain the values using
'git rev-parse HEAD' which should be future proof regardless
of the hash function used.

Additionally future-proof the test by hard coding the
abbreviation length of the hash.

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