git
7 years agoMerge branch 'rs/blame-code-cleanup' into next
Junio C Hamano [Mon, 13 Mar 2017 06:25:30 +0000 (23:25 -0700)] 
Merge branch 'rs/blame-code-cleanup' into next

Code clean-up.

* rs/blame-code-cleanup:
  blame: move blame_entry duplication to add_blame_entry()

7 years agoMerge branch 'jk/interop-test' into next
Junio C Hamano [Mon, 13 Mar 2017 06:25:29 +0000 (23:25 -0700)] 
Merge branch 'jk/interop-test' into next

Picking two versions of Git and running tests to make sure the
older one and the newer one interoperate happily has now become
possible.

* jk/interop-test:
  t/interop: add test of old clients against modern git-daemon
  t: add an interoperability test harness

7 years agoMerge branch 'cc/split-index-config' into next
Junio C Hamano [Mon, 13 Mar 2017 06:25:29 +0000 (23:25 -0700)] 
Merge branch 'cc/split-index-config' into next

The experimental "split index" feature has gained a few
configuration variables to make it easier to use.

* cc/split-index-config: (22 commits)
  Documentation/git-update-index: explain splitIndex.*
  Documentation/config: add splitIndex.sharedIndexExpire
  read-cache: use freshen_shared_index() in read_index_from()
  read-cache: refactor read_index_from()
  t1700: test shared index file expiration
  read-cache: unlink old sharedindex files
  config: add git_config_get_expiry() from gc.c
  read-cache: touch shared index files when used
  sha1_file: make check_and_freshen_file() non static
  Documentation/config: add splitIndex.maxPercentChange
  t1700: add tests for splitIndex.maxPercentChange
  read-cache: regenerate shared index if necessary
  config: add git_config_get_max_percent_split_change()
  Documentation/git-update-index: talk about core.splitIndex config var
  Documentation/config: add information for core.splitIndex
  t1700: add tests for core.splitIndex
  update-index: warn in case of split-index incoherency
  read-cache: add and then use tweak_split_index()
  split-index: add {add,remove}_split_index() functions
  config: add git_config_get_split_index()
  ...

7 years agoThird batch after 2.12
Junio C Hamano [Mon, 13 Mar 2017 06:24:14 +0000 (23:24 -0700)] 
Third batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ah/doc-ls-files-quotepath'
Junio C Hamano [Mon, 13 Mar 2017 06:21:36 +0000 (23:21 -0700)] 
Merge branch 'ah/doc-ls-files-quotepath'

Documentation for "git ls-files" did not refer to core.quotePath

* ah/doc-ls-files-quotepath:
  Documentation: improve description for core.quotePath

7 years agoMerge branch 'jc/diff-populate-filespec-size-only-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:36 +0000 (23:21 -0700)] 
Merge branch 'jc/diff-populate-filespec-size-only-fix'

"git diff --quiet" relies on the size field in diff_filespec to be
correctly populated, but diff_populate_filespec() helper function
made an incorrect short-cut when asked only to populate the size
field for paths that need to go through convert_to_git() (e.g. CRLF
conversion).

* jc/diff-populate-filespec-size-only-fix:
  diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

7 years agoMerge branch 'vn/line-log-memcpy-size-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:35 +0000 (23:21 -0700)] 
Merge branch 'vn/line-log-memcpy-size-fix'

The command-line parsing of "git log -L" copied internal data
structures using incorrect size on ILP32 systems.

* vn/line-log-memcpy-size-fix:
  line-log: use COPY_ARRAY to fix mis-sized memcpy

7 years agoMerge branch 'jk/ewah-use-right-type-in-sizeof'
Junio C Hamano [Mon, 13 Mar 2017 06:21:35 +0000 (23:21 -0700)] 
Merge branch 'jk/ewah-use-right-type-in-sizeof'

Code clean-up.

* jk/ewah-use-right-type-in-sizeof:
  ewah: fix eword_t/uint64_t confusion

7 years agoMerge branch 'ax/line-log-range-merge-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:34 +0000 (23:21 -0700)] 
Merge branch 'ax/line-log-range-merge-fix'

The code to parse "git log -L..." command line was buggy when there
are many ranges specified with -L; overrun of the allocated buffer
has been fixed.

* ax/line-log-range-merge-fix:
  line-log.c: prevent crash during union of too many ranges

7 years agoMerge branch 'ss/remote-bzr-hg-placeholder-wo-python'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)] 
Merge branch 'ss/remote-bzr-hg-placeholder-wo-python'

There is no need for Python only to give a few messages to the
standard error stream, but we somehow did.

* ss/remote-bzr-hg-placeholder-wo-python:
  contrib: git-remote-{bzr,hg} placeholders don't need Python

7 years agoMerge branch 'js/realpath-pathdup-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)] 
Merge branch 'js/realpath-pathdup-fix'

Git v2.12 was shipped with an embarrassing breakage where various
operations that verify paths given from the user stopped dying when
seeing an issue, and instead later triggering segfault.

* js/realpath-pathdup-fix:
  real_pathdup(): fix callsites that wanted it to die on error
  t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

7 years agoMerge branch 'jk/add-i-patch-do-prompt'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)] 
Merge branch 'jk/add-i-patch-do-prompt'

The patch subcommand of "git add -i" was meant to have paths
selection prompt just like other subcommand, unlike "git add -p"
directly jumps to hunk selection.  Recently, this was broken and
"add -i" lost the paths selection dialog, but it now has been
fixed.

* jk/add-i-patch-do-prompt:
  add--interactive: fix missing file prompt for patch mode with "-i"

7 years agoMerge branch 'jh/mingw-openssl-sha1'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)] 
Merge branch 'jh/mingw-openssl-sha1'

Windows port wants to use OpenSSL's implementation of SHA-1
routines, so let them.

* jh/mingw-openssl-sha1:
  mingw: use OpenSSL's SHA-1 routines

7 years agoblame: move blame_entry duplication to add_blame_entry()
René Scharfe [Fri, 10 Mar 2017 00:12:59 +0000 (01:12 +0100)] 
blame: move blame_entry duplication to add_blame_entry()

All callers of add_blame_entry() allocate and copy the second argument.
Let the function do it for them, reducing code duplication.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig: add conditional include
Nguyễn Thái Ngọc Duy [Wed, 1 Mar 2017 11:26:31 +0000 (18:26 +0700)] 
config: add conditional include

Sometimes a set of repositories want to share configuration settings
among themselves that are distinct from other such sets of repositories.
A user may work on two projects, each of which have multiple
repositories, and use one user.email for one project while using another
for the other.

Setting $GIT_DIR/.config works, but if the penalty of forgetting to
update $GIT_DIR/.config is high (especially when you end up cloning
often), it may not be the best way to go. Having the settings in
~/.gitconfig, which would work for just one set of repositories, would
not well in such a situation. Having separate ${HOME}s may add more
problems than it solves.

Extend the include.path mechanism that lets a config file include
another config file, so that the inclusion can be done only when some
conditions hold. Then ~/.gitconfig can say "include config-project-A
only when working on project-A" for each project A the user works on.

In this patch, the only supported grouping is based on $GIT_DIR (in
absolute path), so you would need to group repositories by directory, or
something like that to take advantage of it.

We already have include.path for unconditional includes. This patch goes
with includeIf.<condition>.path to make it clearer that a condition is
required. The new config has the same backward compatibility approach as
include.path: older git versions that don't understand includeIf will
simply ignore them.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig.txt: reflow the second include.path paragraph
Nguyễn Thái Ngọc Duy [Wed, 1 Mar 2017 11:26:30 +0000 (18:26 +0700)] 
config.txt: reflow the second include.path paragraph

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig.txt: clarify multiple key values in include.path
Nguyễn Thái Ngọc Duy [Wed, 1 Mar 2017 11:26:29 +0000 (18:26 +0700)] 
config.txt: clarify multiple key values in include.path

The phrasing in this paragraph may give an impression that you can only
use it once. Rephrase it a bit.

Helped-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with master
Junio C Hamano [Fri, 10 Mar 2017 22:36:19 +0000 (14:36 -0800)] 
Sync with master

* master:
  Second batch after 2.12

7 years agoMerge branch 'js/realpath-pathdup-fix' into next
Junio C Hamano [Fri, 10 Mar 2017 22:34:48 +0000 (14:34 -0800)] 
Merge branch 'js/realpath-pathdup-fix' into next

Git v2.12 was shipped with an embarrassing breakage where various
operations that verify paths given from the user stopped dying when
seeing an issue, and instead later triggering segfault.

* js/realpath-pathdup-fix:
  real_pathdup(): fix callsites that wanted it to die on error
  t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

7 years agot/interop: add test of old clients against modern git-daemon
Jeff King [Sat, 25 Feb 2017 09:37:30 +0000 (04:37 -0500)] 
t/interop: add test of old clients against modern git-daemon

This test just checks that old clients can clone and fetch
from a newer git-daemon. The opposite should also be true,
but it's hard to test ancient versions of git-daemon because
they lack basic options like "--listen".

Note that we have to make a slight tweak to the
lib-git-daemon helper from the regular tests, so that it
starts the daemon with our correct git.a version.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot: add an interoperability test harness
Jeff King [Sat, 25 Feb 2017 09:37:07 +0000 (04:37 -0500)] 
t: add an interoperability test harness

The current test suite is good at letting you test a
particular version of Git. But it's not very good at letting
you test _two_ versions and seeing how they interact (e.g.,
one cloning from the other).

This commit adds a test harness that will build two
arbitrary versions of git and make it easy to call them from
inside your tests. See the README and the example script for
details.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'kn/ref-filter-branch-list' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:35 +0000 (13:35 -0800)] 
Merge branch 'kn/ref-filter-branch-list' into next

"git branch --list" takes the "--abbrev" and "--no-abbrev" options
to control the output of the object name in its "-v"(erbose)
output, but a recent update started ignoring them; this fixes it
before the breakage reaches to any released version.

* kn/ref-filter-branch-list:
  branch: honor --abbrev/--no-abbrev in --list mode

7 years agoMerge branch 'jk/push-deadlock-regression-fix' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:34 +0000 (13:35 -0800)] 
Merge branch 'jk/push-deadlock-regression-fix' into next

"git push" had a handful of codepaths that could lead to a deadlock
when unexpected error happened, which has been fixed.

* jk/push-deadlock-regression-fix:
  send-pack: report signal death of pack-objects
  send-pack: read "unpack" status even on pack-objects failure
  send-pack: improve unpack-status error messages
  send-pack: use skip_prefix for parsing unpack status
  send-pack: extract parsing of "unpack" response
  receive-pack: fix deadlock when we cannot create tmpdir

7 years agoMerge branch 'js/travis-32bit-linux' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:34 +0000 (13:35 -0800)] 
Merge branch 'js/travis-32bit-linux' into next

Add 32-bit Linux variant to the set of platforms to be tested with
Travis CI.

* js/travis-32bit-linux:
  Travis: also test on 32-bit Linux

7 years agoMerge branch 'vn/line-log-memcpy-size-fix' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:33 +0000 (13:35 -0800)] 
Merge branch 'vn/line-log-memcpy-size-fix' into next

The command-line parsing of "git log -L" copied internal data
structures using incorrect size on ILP32 systems.

* vn/line-log-memcpy-size-fix:
  line-log: use COPY_ARRAY to fix mis-sized memcpy

7 years agoMerge branch 'jk/ewah-use-right-type-in-sizeof' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:33 +0000 (13:35 -0800)] 
Merge branch 'jk/ewah-use-right-type-in-sizeof' into next

Code clean-up.

* jk/ewah-use-right-type-in-sizeof:
  ewah: fix eword_t/uint64_t confusion

7 years agoMerge branch 'ew/http-alternates-as-redirects-warning' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:32 +0000 (13:35 -0800)] 
Merge branch 'ew/http-alternates-as-redirects-warning' into next

Recent versions of Git treats http alternates (used in dumb http
transport) just like HTTP redirects and requires the client to
enable following it, due to security concerns.  But we forgot to
give a warning when we decide not to honor the alternates.

* ew/http-alternates-as-redirects-warning:
  http: release strbuf on disabled alternates
  http: inform about alternates-as-redirects behavior

7 years agoMerge branch 'dp/filter-branch-prune-empty' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:32 +0000 (13:35 -0800)] 
Merge branch 'dp/filter-branch-prune-empty' into next

"git filter-branch --prune-empty" drops a single-parent commit that
becomes a no-op, but did not drop a root commit whose tree is empty.

* dp/filter-branch-prune-empty:
  p7000: add test for filter-branch with --prune-empty
  filter-branch: fix --prune-empty on parentless commits
  t7003: ensure --prune-empty removes entire branch when applicable
  t7003: ensure --prune-empty can prune root commit

7 years agoMerge branch 'ss/remote-bzr-hg-placeholder-wo-python' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:31 +0000 (13:35 -0800)] 
Merge branch 'ss/remote-bzr-hg-placeholder-wo-python' into next

There is no need for Python only to give a few messages to the
standard error stream, but we somehow did.

* ss/remote-bzr-hg-placeholder-wo-python:
  contrib: git-remote-{bzr,hg} placeholders don't need Python

7 years agoMerge branch 'jt/perf-updates' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:31 +0000 (13:35 -0800)] 
Merge branch 'jt/perf-updates' into next

The t/perf performance test suite was not prepared to test not so
old versions of Git, but now it covers versions of Git that are not
so ancient.

* jt/perf-updates:
  t/perf: add fallback for pre-bin-wrappers versions of git
  t/perf: use $MODERN_GIT for all repo-copying steps
  t/perf: export variable used in other blocks

7 years agoMerge branch 'ax/line-log-range-merge-fix' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:31 +0000 (13:35 -0800)] 
Merge branch 'ax/line-log-range-merge-fix' into next

The code to parse "git log -L..." command line was buggy when there
are many ranges specified with -L; overrun of the allocated buffer
has been fixed.

* ax/line-log-range-merge-fix:
  line-log.c: prevent crash during union of too many ranges

7 years agoMerge branch 'mm/fetch-show-error-message-on-unadvertised-object' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:31 +0000 (13:35 -0800)] 
Merge branch 'mm/fetch-show-error-message-on-unadvertised-object' into next

"git fetch" that requests a commit by object name, when the other
side does not allow such an request, failed without much
explanation.

* mm/fetch-show-error-message-on-unadvertised-object:
  fetch-pack: add specific error for fetching an unadvertised object
  fetch_refs_via_pack: call report_unmatched_refs
  fetch-pack: move code to report unmatched refs to a function

7 years agoMerge branch 'ah/doc-ls-files-quotepath' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:30 +0000 (13:35 -0800)] 
Merge branch 'ah/doc-ls-files-quotepath' into next

Documentation for "git ls-files" did not refer to core.quotePath

* ah/doc-ls-files-quotepath:
  Documentation: improve description for core.quotePath

7 years agoMerge branch 'jc/diff-populate-filespec-size-only-fix' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:30 +0000 (13:35 -0800)] 
Merge branch 'jc/diff-populate-filespec-size-only-fix' into next

"git diff --quiet" relies on the size field in diff_filespec to be
correctly populated, but diff_populate_filespec() helper function
made an incorrect short-cut when asked only to populate the size
field for paths that need to go through convert_to_git() (e.g. CRLF
conversion).

* jc/diff-populate-filespec-size-only-fix:
  diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

7 years agoMerge branch 'jk/interpret-branch-name' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:29 +0000 (13:35 -0800)] 
Merge branch 'jk/interpret-branch-name' into next

"git branch @" created refs/heads/@ as a branch, and in general the
code that handled @{-1} and @{upstream} was a bit too loose in
disambiguating.

* jk/interpret-branch-name:
  checkout: restrict @-expansions when finding branch
  strbuf_check_ref_format(): expand only local branches
  branch: restrict @-expansions when deleting
  t3204: test git-branch @-expansion corner cases
  interpret_branch_name: allow callers to restrict expansions
  strbuf_branchname: add docstring
  strbuf_branchname: drop return value
  interpret_branch_name: move docstring to header file
  interpret_branch_name(): handle auto-namelen for @{-1}

7 years agoMerge branch 'jk/add-i-patch-do-prompt' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:29 +0000 (13:35 -0800)] 
Merge branch 'jk/add-i-patch-do-prompt' into next

The patch subcommand of "git add -i" was meant to have paths
selection prompt just like other subcommand, unlike "git add -p"
directly jumps to hunk selection.  Recently, this was broken and
"add -i" lost the paths selection dialog, but it now has been
fixed.

* jk/add-i-patch-do-prompt:
  add--interactive: fix missing file prompt for patch mode with "-i"

7 years agoMerge branch 'ab/cond-skip-tests' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:29 +0000 (13:35 -0800)] 
Merge branch 'ab/cond-skip-tests' into next

A few tests were run conditionally under (rare) conditions where
they cannot be run (like running cvs tests under 'root' account).

* ab/cond-skip-tests:
  gitweb tests: skip tests when we don't have Time::HiRes
  gitweb tests: change confusing "skip_all" phrasing
  cvs tests: skip tests that call "cvs commit" when running as root

7 years agoMerge branch 'jh/mingw-openssl-sha1' into next
Junio C Hamano [Fri, 10 Mar 2017 21:35:28 +0000 (13:35 -0800)] 
Merge branch 'jh/mingw-openssl-sha1' into next

Windows port wants to use OpenSSL's implementation of SHA-1
routines, so let them.

* jh/mingw-openssl-sha1:
  mingw: use OpenSSL's SHA-1 routines

7 years agoSecond batch after 2.12
Junio C Hamano [Fri, 10 Mar 2017 21:24:59 +0000 (13:24 -0800)] 
Second batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'rs/log-email-subject'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)] 
Merge branch 'rs/log-email-subject'

Code clean-up.

* rs/log-email-subject:
  pretty: use fmt_output_email_subject()
  log-tree: factor out fmt_output_email_subject()

7 years agoMerge branch 'tg/stash-push'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)] 
Merge branch 'tg/stash-push'

"git stash save" takes a pathspec so that the local changes can be
stashed away only partially.

* tg/stash-push:
  stash: allow pathspecs in the no verb form
  stash: use stash_push for no verb form
  stash: teach 'push' (and 'create_stash') to honor pathspec
  stash: refactor stash_create
  stash: add test for the create command line arguments
  stash: introduce push verb

7 years agoMerge branch 'sb/submodule-init-url-selection'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)] 
Merge branch 'sb/submodule-init-url-selection'

When "git submodule init" decides that the submodule in the working
tree is its upstream, it now gives a warning as it is not a very
common setup.

* sb/submodule-init-url-selection:
  submodule init: warn about falling back to a local path

7 years agoMerge branch 'rj/remove-unused-mktemp'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)] 
Merge branch 'rj/remove-unused-mktemp'

Code cleanup.

* rj/remove-unused-mktemp:
  wrapper.c: remove unused gitmkstemps() function
  wrapper.c: remove unused git_mkstemp() function

7 years agoMerge branch 'ew/markdown-url-in-readme'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)] 
Merge branch 'ew/markdown-url-in-readme'

Doc update.

* ew/markdown-url-in-readme:
  README: create HTTP/HTTPS links from URLs in Markdown

7 years agoMerge branch 'ps/docs-diffcore'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)] 
Merge branch 'ps/docs-diffcore'

Doc update.

* ps/docs-diffcore:
  docs/diffcore: unquote "Complete Rewrites" in headers
  docs/diffcore: fix grammar in diffcore-rename header

7 years agoMerge branch 'jt/http-base-url-update-upon-redirect'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)] 
Merge branch 'jt/http-base-url-update-upon-redirect'

When a redirected http transport gets an error during the
redirected request, we ignored the error we got from the server,
and ended up giving a not-so-useful error message.

* jt/http-base-url-update-upon-redirect:
  http: attempt updating base URL only if no error

7 years agoMerge branch 'jk/http-auth'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)] 
Merge branch 'jk/http-auth'

Reduce authentication round-trip over HTTP when the server supports
just a single authentication method.

* jk/http-auth:
  http: add an "auto" mode for http.emptyauth
  http: restrict auth methods to what the server advertises

7 years agoMerge branch 'jh/send-email-one-cc'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)] 
Merge branch 'jh/send-email-one-cc'

"Cc:" on the trailer part does not have to conform to RFC strictly,
unlike in the e-mail header.  "git send-email" has been updated to
ignore anything after '>' when picking addresses, to allow non-address
cruft like " # stable 4.4" after the address.

* jh/send-email-one-cc:
  send-email: only allow one address per body tag

7 years agoMerge branch 'rs/strbuf-add-real-path'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)] 
Merge branch 'rs/strbuf-add-real-path'

An helper function to make it easier to append the result from
real_path() to a strbuf has been added.

* rs/strbuf-add-real-path:
  strbuf: add strbuf_add_real_path()
  cocci: use ALLOC_ARRAY

7 years agoMerge branch 'rs/sha1-file-plug-fallback-base-leak'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)] 
Merge branch 'rs/sha1-file-plug-fallback-base-leak'

A leak in a codepath to read from a packed object in (rare) cases
has been plugged.

* rs/sha1-file-plug-fallback-base-leak:
  sha1_file: release fallback base's memory in unpack_entry()

7 years agoMerge branch 'rs/commit-parsing-optim'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)] 
Merge branch 'rs/commit-parsing-optim'

The code that parses header fields in the commit object has been
updated for (micro)performance and code hygiene.

* rs/commit-parsing-optim:
  commit: don't check for space twice when looking for header
  commit: be more precise when searching for headers

7 years agoMerge branch 'jk/t6300-cleanup'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)] 
Merge branch 'jk/t6300-cleanup'

A test that creates a confusing branch whose name is HEAD has been
corrected not to do so.

* jk/t6300-cleanup:
  t6300: avoid creating refs/heads/HEAD

7 years agoMerge branch 'jk/parse-config-key-cleanup'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)] 
Merge branch 'jk/parse-config-key-cleanup'

The "parse_config_key()" API function has been cleaned up.

* jk/parse-config-key-cleanup:
  parse_hide_refs_config: tell parse_config_key we don't want a subsection
  parse_config_key: allow matching single-level config
  parse_config_key: use skip_prefix instead of starts_with

7 years agoMerge branch 'sb/parse-hide-refs-config-cleanup'
Junio C Hamano [Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)] 
Merge branch 'sb/parse-hide-refs-config-cleanup'

Code clean-up.

* sb/parse-hide-refs-config-cleanup:
  refs: parse_hide_refs_config to use parse_config_key

7 years agoMerge branch 'jt/upload-pack-error-report'
Junio C Hamano [Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)] 
Merge branch 'jt/upload-pack-error-report'

"git upload-pack", which is a counter-part of "git fetch", did not
report a request for a ref that was not advertised as invalid.
This is generally not a problem (because "git fetch" will stop
before making such a request), but is the right thing to do.

* jt/upload-pack-error-report:
  upload-pack: report "not our ref" to client

7 years agoMerge branch 'jk/ident-empty'
Junio C Hamano [Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)] 
Merge branch 'jk/ident-empty'

user.email that consists of only cruft chars should consistently
error out, but didn't.

* jk/ident-empty:
  ident: do not ignore empty config name/email
  ident: reject all-crud ident name
  ident: handle NULL email when complaining of empty name
  ident: mark error messages for translation

7 years agoMerge branch 'jc/config-case-cmdline-take-2'
Junio C Hamano [Fri, 10 Mar 2017 21:24:20 +0000 (13:24 -0800)] 
Merge branch 'jc/config-case-cmdline-take-2'

The code to parse "git -c VAR=VAL cmd" and set configuration
variable for the duration of cmd had two small bugs, which have
been fixed.

* jc/config-case-cmdline-take-2:
  config: use git_config_parse_key() in git_config_parse_parameter()
  config: move a few helper functions up

7 years agoref-filter: use separate cache for contains_tag_algo
Jeff King [Thu, 9 Mar 2017 13:29:49 +0000 (08:29 -0500)] 
ref-filter: use separate cache for contains_tag_algo

The algorithm which powers "tag --contains" uses the
TMP_MARK and UNINTERESTING bits, but never cleans up after
itself. As a result, stale UNINTERESTING bits may impact
later traversals (like "--merged").

We could fix this by clearing the bits after we're done with
the --contains traversal. That would be enough to fix the
existing problem, but it leaves future developers in a bad
spot: they cannot add other traversals that operate
simultaneously with --contains (e.g., if you wanted to add
"--no-contains" and use both filters at the same time).

Instead, we can use a commit slab to store our cached
results, which will store the bits outside of the commit
structs entirely. This adds an extra level of indirection,
but in my tests (running "git tag --contains HEAD" on
linux.git), there was no measurable slowdown.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref-filter: die on parse_commit errors
Jeff King [Thu, 9 Mar 2017 13:29:04 +0000 (08:29 -0500)] 
ref-filter: die on parse_commit errors

The tag-contains algorithm quietly returns "does not
contain" when parse_commit() fails. But a parse failure is
an indication that the repository is corrupt. We should die
loudly rather than producing a bogus result.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref-filter: use contains_result enum consistently
Jeff King [Thu, 9 Mar 2017 13:28:48 +0000 (08:28 -0500)] 
ref-filter: use contains_result enum consistently

Commit cbc60b672 (git tag --contains: avoid stack overflow,
2014-04-24) adapted the -1/0/1 contains status into a
tri-state enum. However, some of the code still used the
numeric values, or assumed that no/yes correspond to C's
boolean true/false.

Let's switch to using the symbolic values everywhere, which
will make it easier to change them.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoref-filter: move ref_cbdata definition into ref-filter.c
Jeff King [Thu, 9 Mar 2017 13:27:55 +0000 (08:27 -0500)] 
ref-filter: move ref_cbdata definition into ref-filter.c

This is an implementation detail of how filter_refs() works,
and does not need to be exposed to the outside world. This
will become more important in future patches as we add new
private data types to it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobranch: honor --abbrev/--no-abbrev in --list mode
Junio C Hamano [Wed, 8 Mar 2017 22:13:09 +0000 (14:13 -0800)] 
branch: honor --abbrev/--no-abbrev in --list mode

When the "branch --list" command was converted to use the --format
facility from the ref-filter API, we forgot to honor the --abbrev
setting in the default output format and instead used a hardcoded
"7".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorev-parse: add --show-superproject-working-tree
Stefan Beller [Wed, 8 Mar 2017 23:07:42 +0000 (15:07 -0800)] 
rev-parse: add --show-superproject-working-tree

In some situations it is useful to know if the given repository
is a submodule of another repository.

Add the flag --show-superproject-working-tree to git-rev-parse
to make it easy to find out if there is a superproject. When no
superproject exists, the output will be empty.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreal_pathdup(): fix callsites that wanted it to die on error
Johannes Schindelin [Wed, 8 Mar 2017 15:43:40 +0000 (16:43 +0100)] 
real_pathdup(): fix callsites that wanted it to die on error

In 4ac9006f832 (real_path: have callers use real_pathdup and
strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path())
pattern to use real_pathdup() directly.

The problem with this change is that real_path() calls
strbuf_realpath() with die_on_error = 1 while real_pathdup() calls
it with die_on_error = 0. Meaning that in cases where real_path()
causes Git to die() with an error message, real_pathdup() is silent
and returns NULL instead.

The callers, however, are ill-prepared for that change, as they expect
the return value to be non-NULL (and otherwise the function died
with an appropriate error message).

Fix this by extending real_pathdup()'s signature to accept the
die_on_error flag and simply pass it through to strbuf_realpath(),
and then adjust all callers after a careful audit whether they would
handle NULLs well.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE
Johannes Schindelin [Wed, 8 Mar 2017 15:43:34 +0000 (16:43 +0100)] 
t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

When GIT_WORK_TREE does not specify a valid path, we should error
out, instead of crashing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosetup_git_directory(): use is_dir_sep() helper
Johannes Schindelin [Tue, 7 Mar 2017 14:32:32 +0000 (15:32 +0100)] 
setup_git_directory(): use is_dir_sep() helper

It is okay in practice to test for forward slashes in the output of
getcwd(), because we go out of our way to convert backslashes to forward
slashes in getcwd()'s output on Windows.

Still, the correct way to test for a dir separator is by using the
helper function we introduced for that very purpose. It also serves as a
good documentation what the code tries to do (not "how").

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with master
Junio C Hamano [Tue, 7 Mar 2017 23:13:35 +0000 (15:13 -0800)] 
Sync with master

* master:
  git svn: fix authentication with 'branch'

7 years agosend-pack: report signal death of pack-objects
Jeff King [Tue, 7 Mar 2017 13:39:48 +0000 (08:39 -0500)] 
send-pack: report signal death of pack-objects

If our pack-objects sub-process dies of a signal, then it
likely didn't have a chance to write anything useful to
stderr. The user may be left scratching their head why the
push failed. Let's detect this situation and write something
to stderr.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosend-pack: read "unpack" status even on pack-objects failure
Jeff King [Tue, 7 Mar 2017 13:38:51 +0000 (08:38 -0500)] 
send-pack: read "unpack" status even on pack-objects failure

If the local pack-objects of a push fails, we'll tell the
user about it. But one likely cause is that the remote
index-pack stopped reading for some reason (because it
didn't like our input, or encountered another error). In
that case we'd expect the remote to report more details to
us via the "unpack ..." status line. However, the current
code just hangs up completely, and the user never sees it.

Instead, let's call receive_unpack_status(), which will
complain on stderr with whatever reason the remote told us.
Note that if our pack-objects fails because the connection
was severed or the remote just crashed entirely, then our
packet_read_line() call may fail with "the remote end hung
up unexpectedly". That's OK. It's a more accurate
description than what we get now (which is just "some refs
failed to push").

This should be safe from any deadlocks. At the point we make
this call we'll have closed the writing end of the
connection to the server (either by handing it off to
a pack-objects which exited, explicitly in the stateless_rpc
case, or by doing a half-duplex shutdown for a socket). So
there should be no chance that the other side is waiting
for the rest of our pack-objects input.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosend-pack: improve unpack-status error messages
Jeff King [Tue, 7 Mar 2017 13:37:36 +0000 (08:37 -0500)] 
send-pack: improve unpack-status error messages

When the remote tells us that the "unpack" step failed, we
show an error message. However, unless you are familiar with
the internals of send-pack and receive-pack, it was not
clear that this represented an error on the remote side.
Let's re-word to make that more obvious.

Likewise, when we got an unexpected packet from the other
end, we complained with a vague message but did not actually
show the packet.  Let's fix that.

And finally, neither message was marked for translation. The
message from the remote probably won't be translated, but
there's no reason we can't do better for the local half.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosend-pack: use skip_prefix for parsing unpack status
Jeff King [Tue, 7 Mar 2017 13:36:19 +0000 (08:36 -0500)] 
send-pack: use skip_prefix for parsing unpack status

This avoids repeating ourselves, and the use of magic
numbers.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosend-pack: extract parsing of "unpack" response
Jeff King [Tue, 7 Mar 2017 13:35:57 +0000 (08:35 -0500)] 
send-pack: extract parsing of "unpack" response

After sending the pack, we call receive_status() which gets
both the "unpack" line and the ref status. Let's break these
into two functions so we can call the first part
independently.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreceive-pack: fix deadlock when we cannot create tmpdir
Jeff King [Tue, 7 Mar 2017 13:35:34 +0000 (08:35 -0500)] 
receive-pack: fix deadlock when we cannot create tmpdir

The err_fd descriptor passed to the unpack() function is
intended to be handed off to the child index-pack, and our
async muxer will read until it gets EOF. However, if we
encounter an error before handing off the descriptor, we
must manually close(err_fd). Otherwise we will be waiting
for our muxer to finish, while the muxer is waiting for EOF
on err_fd.

We fixed an identical deadlock already in 49ecfa13f
(receive-pack: close sideband fd on early pack errors,
2013-04-19). But since then, the function grew a new
early-return in 722ff7f87 (receive-pack: quarantine objects
until pre-receive accepts, 2016-10-03), when we fail to
create a temporary directory. This return needs the same
treatment.

Reported-by: Horst Schirmeier <horst@schirmeier.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit svn: fix authentication with 'branch'
Hiroshi Shirosaki [Mon, 6 Mar 2017 05:59:07 +0000 (14:59 +0900)] 
git svn: fix authentication with 'branch'

Authentication fails with svn branch while svn rebase and
svn dcommit work fine without authentication failures.

$ git svn branch v7_3
Copying https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at r27519
to https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/v7_3...
Can't create session: Unable to connect to a repository at URL
'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': No more
credentials or we tried too many times.
Authentication failed at
C:\Program Files\Git\mingw64/libexec/git-core\git-svn line 1200.

We add auth configuration to SVN::Client->new() to fix the issue.

Signed-off-by: Hiroshi Shirosaki <h.shirosaki@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>
7 years agoDocumentation/git-update-index: explain splitIndex.*
Christian Couder [Mon, 6 Mar 2017 09:42:03 +0000 (10:42 +0100)] 
Documentation/git-update-index: explain splitIndex.*

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoDocumentation/config: add splitIndex.sharedIndexExpire
Christian Couder [Mon, 6 Mar 2017 09:42:02 +0000 (10:42 +0100)] 
Documentation/config: add splitIndex.sharedIndexExpire

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread-cache: use freshen_shared_index() in read_index_from()
Christian Couder [Mon, 6 Mar 2017 09:42:01 +0000 (10:42 +0100)] 
read-cache: use freshen_shared_index() in read_index_from()

This way a share index file will not be garbage collected if
we still read from an index it is based from.

As we need to read the current index before creating a new
one, the tests have to be adjusted, so that we don't expect
an old shared index file to be deleted right away when we
create a new one.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread-cache: refactor read_index_from()
Christian Couder [Mon, 6 Mar 2017 09:42:00 +0000 (10:42 +0100)] 
read-cache: refactor read_index_from()

It looks better and is simpler to review when we don't compute
the same things many times in the function.

It will also help make the following commit simpler.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1700: test shared index file expiration
Christian Couder [Mon, 6 Mar 2017 09:41:59 +0000 (10:41 +0100)] 
t1700: test shared index file expiration

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread-cache: unlink old sharedindex files
Christian Couder [Mon, 6 Mar 2017 09:41:58 +0000 (10:41 +0100)] 
read-cache: unlink old sharedindex files

Everytime split index is turned on, it creates a "sharedindex.XXXX"
file in the git directory. This change makes sure that shared index
files that haven't been used for a long time are removed when a new
shared index file is created.

The new "splitIndex.sharedIndexExpire" config variable is created
to tell the delay after which an unused shared index file can be
deleted. It defaults to "2.weeks.ago".

A previous commit made sure that each time a split index file is
created the mtime of the shared index file it references is updated.
This makes sure that recently used shared index file will not be
deleted.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoewah: fix eword_t/uint64_t confusion
Jeff King [Sun, 5 Mar 2017 11:46:38 +0000 (06:46 -0500)] 
ewah: fix eword_t/uint64_t confusion

The ewah subsystem typedefs eword_t to be uint64_t, but some
code uses a bare uint64_t. This isn't a bug now, but it's a
potential maintenance problem if the definition of eword_t
ever changes. Let's use the correct type.

Note that we can't use COPY_ARRAY() here because the source
and destination point to objects of different sizes. For
that reason we'll also skip the usual "sizeof(*dst)" and use
the real type, which should make it more clear that there's
something tricky going on.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoline-log: use COPY_ARRAY to fix mis-sized memcpy
Vegard Nossum [Sun, 5 Mar 2017 11:44:46 +0000 (06:44 -0500)] 
line-log: use COPY_ARRAY to fix mis-sized memcpy

This memcpy meant to get the sizeof a "struct range", not a
"range_set", as the former is what our array holds. Rather
than swap out the types, let's convert this site to
COPY_ARRAY, which avoids the problem entirely (and confirms
that the src and dst types match).

Note for curiosity's sake that this bug doesn't trigger on
I32LP64 systems, but does on ILP32 systems. The mistaken
"struct range_set" has two ints and a pointer. That's 16
bytes on LP64, or 12 on ILP32. The correct "struct range"
type has two longs, which is also 16 on LP64, but only 8 on
ILP32.

Likewise an IL32P64 system would experience the bug.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoTravis: also test on 32-bit Linux
Johannes Schindelin [Sun, 5 Mar 2017 18:25:19 +0000 (19:25 +0100)] 
Travis: also test on 32-bit Linux

When Git v2.9.1 was released, it had a bug that showed only on Windows
and on 32-bit systems: our assumption that `unsigned long` can hold
64-bit values turned out to be wrong.

This could have been caught earlier if we had a Continuous Testing
set up that includes a build and test run on 32-bit Linux.

Let's do this (and take care of the Windows build later). This patch
asks Travis CI to install a Docker image with 32-bit libraries and then
goes on to build and test Git using this 32-bit setup.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp: release strbuf on disabled alternates
Eric Wong [Sat, 4 Mar 2017 01:50:16 +0000 (01:50 +0000)] 
http: release strbuf on disabled alternates

This likely has no real-world impact on memory usage,
but it is cleaner for future readers.

Fixes: abcbdc03895f ("http: respect protocol.*.allow=user for http-alternates")
Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp: inform about alternates-as-redirects behavior
Eric Wong [Sat, 4 Mar 2017 08:36:45 +0000 (08:36 +0000)] 
http: inform about alternates-as-redirects behavior

It is disconcerting for users to not notice the behavior
change in handling alternates from commit cb4d2d35c4622ec2
("http: treat http-alternates like redirects")

Give the user a hint about the config option so they can
see the URL and decide whether or not they want to enable
http.followRedirects in their config.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'rs/log-email-subject' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:16 +0000 (13:48 -0800)] 
Merge branch 'rs/log-email-subject' into next

Code clean-up.

* rs/log-email-subject:
  pretty: use fmt_output_email_subject()
  log-tree: factor out fmt_output_email_subject()

7 years agoMerge branch 'tg/stash-push' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:16 +0000 (13:48 -0800)] 
Merge branch 'tg/stash-push' into next

Allow "git stash" to take pathspec so that the local changes can be
stashed away only partially.

* tg/stash-push:
  stash: allow pathspecs in the no verb form
  stash: use stash_push for no verb form
  stash: teach 'push' (and 'create_stash') to honor pathspec
  stash: refactor stash_create
  stash: add test for the create command line arguments
  stash: introduce push verb

7 years agoMerge branch 'sb/submodule-init-url-selection' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:16 +0000 (13:48 -0800)] 
Merge branch 'sb/submodule-init-url-selection' into next

Give a warning when "git submodule init" decides that the submodule
in the working tree is its upstream, as it is not a very common
setup.

* sb/submodule-init-url-selection:
  submodule init: warn about falling back to a local path

7 years agoMerge branch 'rj/remove-unused-mktemp' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:15 +0000 (13:48 -0800)] 
Merge branch 'rj/remove-unused-mktemp' into next

Code cleanup.

* rj/remove-unused-mktemp:
  wrapper.c: remove unused gitmkstemps() function
  wrapper.c: remove unused git_mkstemp() function

7 years agoMerge branch 'ew/markdown-url-in-readme' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:15 +0000 (13:48 -0800)] 
Merge branch 'ew/markdown-url-in-readme' into next

Doc update.

* ew/markdown-url-in-readme:
  README: create HTTP/HTTPS links from URLs in Markdown

7 years agoMerge branch 'ps/docs-diffcore' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:15 +0000 (13:48 -0800)] 
Merge branch 'ps/docs-diffcore' into next

Doc update.

* ps/docs-diffcore:
  docs/diffcore: unquote "Complete Rewrites" in headers
  docs/diffcore: fix grammar in diffcore-rename header

7 years agoMerge branch 'jt/http-base-url-update-upon-redirect' into next
Junio C Hamano [Fri, 3 Mar 2017 21:48:14 +0000 (13:48 -0800)] 
Merge branch 'jt/http-base-url-update-upon-redirect' into next

When a redirected http transport gets an error during the
redirected request, we ignored the error we got from the server,
and ended up giving a not-so-useful error message.

* jt/http-base-url-update-upon-redirect:
  http: attempt updating base URL only if no error

7 years agot7006: replace dubious test
Johannes Schindelin [Fri, 3 Mar 2017 17:32:01 +0000 (18:32 +0100)] 
t7006: replace dubious test

The idea of the test case "git -p - core.pager is not used from
subdirectory" was to verify that the setup_git_directory() function had
not been called just to obtain the core.pager setting.

However, we are about to fix the early config machinery so that it
*does* work, without messing up the global state.

Once that is done, the core.pager setting *will* be used, even when
running from a subdirectory, and that is a Good Thing.

The intention of that test case, however, was to verify that the
setup_git_directory() function has not run, because it changes global
state such as the current working directory.

To keep that spirit, but fix the incorrect assumption, this patch
replaces that test case by a new one that verifies that the pager is
run in the subdirectory, i.e. that the current working directory has
not been changed at the time the pager is configured and launched, even
if the `rev-parse` command requires a .git/ directory and *will* change
the working directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop7000: add test for filter-branch with --prune-empty
Devin J. Pohly [Thu, 23 Feb 2017 08:27:36 +0000 (02:27 -0600)] 
p7000: add test for filter-branch with --prune-empty

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofilter-branch: fix --prune-empty on parentless commits
Devin J. Pohly [Thu, 23 Feb 2017 08:27:35 +0000 (02:27 -0600)] 
filter-branch: fix --prune-empty on parentless commits

Previously, the git_commit_non_empty_tree function would always pass any
commit with no parents to git-commit-tree, regardless of whether the
tree was nonempty.  The new commit would then be recorded in the
filter-branch revision map, and subsequent commits which leave the tree
untouched would be correctly filtered.

With this change, parentless commits with an empty tree are correctly
pruned, and an empty file is recorded in the revision map, signifying
that it was rewritten to "no commits."  This works naturally with the
parent mapping for subsequent commits.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7003: ensure --prune-empty removes entire branch when applicable
Devin J. Pohly [Thu, 23 Feb 2017 08:27:34 +0000 (02:27 -0600)] 
t7003: ensure --prune-empty removes entire branch when applicable

Sanity check before changing the logic in git_commit_non_empty_tree.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7003: ensure --prune-empty can prune root commit
Devin J. Pohly [Thu, 23 Feb 2017 08:27:33 +0000 (02:27 -0600)] 
t7003: ensure --prune-empty can prune root commit

New test to expose a bug in filter-branch whereby the root commit is
never pruned, even though its tree is empty and --prune-empty is given.

The setup isn't exactly pretty, but I couldn't think of a simpler way to
create a parallel commit graph sans the first commit.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoline-log.c: prevent crash during union of too many ranges
Allan Xavier [Thu, 2 Mar 2017 17:29:02 +0000 (17:29 +0000)] 
line-log.c: prevent crash during union of too many ranges

The existing implementation of range_set_union does not correctly
reallocate memory, leading to a heap overflow when it attempts to union
more than 24 separate line ranges.

For struct range_set *out to grow correctly it must have out->nr set to
the current size of the buffer when it is passed to range_set_grow.
However, the existing implementation of range_set_union only updates
out->nr at the end of the function, meaning that it is always zero
before this. This results in range_set_grow never growing the buffer, as
well as some of the union logic itself being incorrect as !out->nr is
always true.

The reason why 24 is the limit is that the first allocation of size 1
ends up allocating a buffer of size 24 (due to the call to alloc_nr in
ALLOC_GROW). This goes some way to explain why this hasn't been
caught before.

Fix the problem by correctly updating out->nr after reallocating the
range_set. As this results in out->nr containing the same value as the
variable o, replace o with out->nr as well.

Finally, add a new test to help prevent the problem reoccurring in the
future. Thanks to Vegard Nossum for writing the test.

Signed-off-by: Allan Xavier <allan.x.xavier@oracle.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocontrib: git-remote-{bzr,hg} placeholders don't need Python
Sebastian Schuberth [Fri, 3 Mar 2017 10:57:46 +0000 (10:57 +0000)] 
contrib: git-remote-{bzr,hg} placeholders don't need Python

It does not make sense for these placeholder scripts to depend on Python
just because the real scripts do. At the example of Git for Windows, we
would not even be able to see those warnings as it does not ship with
Python. So just use plain shell scripts instead.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot/perf: add fallback for pre-bin-wrappers versions of git
Jeff King [Fri, 3 Mar 2017 07:36:33 +0000 (02:36 -0500)] 
t/perf: add fallback for pre-bin-wrappers versions of git

It's tempting to say:

  ./run v1.0.0 HEAD

to see how we've sped up Git over the years. Unfortunately,
this doesn't quite work because versions of Git prior to
v1.7.0 lack bin-wrappers, so our "run" script doesn't
correctly put them in the PATH.

Worse, it means we silently find whatever other "git" is in
the PATH, and produce test results that have no bearing on
what we asked for.

Let's fallback to the main git directory when bin-wrappers
isn't present. Many modern perf scripts won't run with such
an antique version of Git, of course, but at least those
failures are detected and reported (and you're free to write
a limited perf script that works across many versions).

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