git
7 years agot1406: new tests for submodule ref store
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:40 +0000 (09:42 +0700)] 
t1406: new tests for submodule ref store

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1405: some basic tests on main ref store
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:39 +0000 (09:42 +0700)] 
t1405: some basic tests on main ref store

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot/helper: add test-ref-store to test ref-store functions
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:38 +0000 (09:42 +0700)] 
t/helper: add test-ref-store to test ref-store functions

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: delete pack_refs() in favor of refs_pack_refs()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:37 +0000 (09:42 +0700)] 
refs: delete pack_refs() in favor of refs_pack_refs()

It only has one caller, not worth keeping just for convenience.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: avoid ref api targeting main ref store
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:36 +0000 (09:42 +0700)] 
files-backend: avoid ref api targeting main ref store

A small step towards making files-backend work as a non-main ref store
using the newly added store-aware API.

For the record, `join` and `nm` on refs.o and files-backend.o tell me
that files-backend no longer uses functions that default to
get_main_ref_store().

I'm not yet comfortable at the idea of removing
files_assert_main_repository() (or converting REF_STORE_MAIN to
REF_STORE_WRITE). More staring and testing is required before that can
happen. Well, except peel_ref(). I'm pretty sure that function is safe.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: new transaction related ref-store api
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:35 +0000 (09:42 +0700)] 
refs: new transaction related ref-store api

The transaction struct now takes a ref store at creation and will
operate on that ref store alone.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: add new ref-store api
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:34 +0000 (09:42 +0700)] 
refs: add new ref-store api

This is not meant to cover all existing API. It adds enough to test ref
stores with the new test program test-ref-store, coming soon and to be
used by files-backend.c.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: rename get_ref_store() to get_submodule_ref_store() and make it public
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:33 +0000 (09:42 +0700)] 
refs: rename get_ref_store() to get_submodule_ref_store() and make it public

This function is intended to replace *_submodule() refs API. It provides
a ref store for a specific submodule, which can be operated on by a new
set of refs API.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: replace submodule_allowed check in files_downcast()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:32 +0000 (09:42 +0700)] 
files-backend: replace submodule_allowed check in files_downcast()

files-backend.c is unlearning submodules. Instead of having a specific
check for submodules to see what operation is allowed, files backend
now takes a set of flags at init. Each operation will check if the
required flags is present before performing.

For now we have four flags: read, write and odb access. Main ref store
has all flags, obviously, while submodule stores are read-only and have
access to odb (*).

The "main" flag stays because many functions in the backend calls
frontend ones without a ref store, so these functions always target the
main ref store. Ideally the flag should be gone after ref-store-aware
api is in place and used by backends.

(*) Submodule code needs for_each_ref. Try take REF_STORE_ODB flag
out. At least t3404 would fail. The "have access to odb" in submodule is
a bit hacky since we don't know from he whether add_submodule_odb() has
been called.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: move submodule code out of files-backend.c
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:31 +0000 (09:42 +0700)] 
refs: move submodule code out of files-backend.c

files-backend is now initialized with a $GIT_DIR. Converting a submodule
path to where real submodule gitdir is located is done in get_ref_store().

This gives a slight performance improvement for submodules since we
don't convert submodule path to gitdir at every backend call like
before. We pay that once at ref-store creation.

More cleanup in files_downcast() and files_assert_main_repository()
follows shortly. It's separate to keep noises from this patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopath.c: move some code out of strbuf_git_path_submodule()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:30 +0000 (09:42 +0700)] 
path.c: move some code out of strbuf_git_path_submodule()

refs is learning to avoid path rewriting that is done by
strbuf_git_path_submodule(). Factor out this code so it could be reused
by refs_* functions.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs.c: make get_main_ref_store() public and use it
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:29 +0000 (09:42 +0700)] 
refs.c: make get_main_ref_store() public and use it

get_ref_store() will soon be renamed to get_submodule_ref_store().
Together with future get_worktree_ref_store(), the three functions
provide an appropriate ref store for different operation modes. New APIs
will be added to operate directly on ref stores.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs.c: kill register_ref_store(), add register_submodule_ref_store()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:28 +0000 (09:42 +0700)] 
refs.c: kill register_ref_store(), add register_submodule_ref_store()

This is the last function in this code (besides public API) that takes
submodule argument and handles both main/submodule cases. Break it down,
move main store registration in get_main_ref_store() and keep the rest
in register_submodule_ref_store().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs.c: flatten get_ref_store() a bit
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:27 +0000 (09:42 +0700)] 
refs.c: flatten get_ref_store() a bit

This helps the future changes in this code. And because get_ref_store()
is destined to become get_submodule_ref_store(), the "get main store"
code path will be removed eventually. After this the patch to delete
that code will be cleaner.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: rename lookup_ref_store() to lookup_submodule_ref_store()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:26 +0000 (09:42 +0700)] 
refs: rename lookup_ref_store() to lookup_submodule_ref_store()

With get_main_ref_store() being used inside get_ref_store(),
lookup_ref_store() is only used for submodule code path. Rename to
reflect that and delete dead code.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs.c: introduce get_main_ref_store()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:25 +0000 (09:42 +0700)] 
refs.c: introduce get_main_ref_store()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: remove the use of git_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:24 +0000 (09:42 +0700)] 
files-backend: remove the use of git_path()

Given $GIT_DIR and $GIT_COMMON_DIR, files-backend is now in charge of
deciding what goes where (*). The end goal is to pass $GIT_DIR only. A
refs "view" of a linked worktree is a logical ref store that combines
two files backends together.

(*) Not entirely true since strbuf_git_path_submodule() still does path
translation underneath. But that's for another patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: add and use files_ref_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:23 +0000 (09:42 +0700)] 
files-backend: add and use files_ref_path()

Keep repo-related path handling in one place. This will make it easier
to add submodule/multiworktree support later.

This automatically adds the "if submodule then use the submodule version
of git_path" to other call sites too. But it does not mean those
operations are submodule-ready. Not yet.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: add and use files_reflog_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:22 +0000 (09:42 +0700)] 
files-backend: add and use files_reflog_path()

Keep repo-related path handling in one place. This will make it easier
to add submodule/multiworktree support later.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: move "logs/" out of TMP_RENAMED_LOG
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:21 +0000 (09:42 +0700)] 
files-backend: move "logs/" out of TMP_RENAMED_LOG

This makes reflog path building consistent, always in the form of

    strbuf_git_path(sb, "logs/%s", refname);

It reduces the mental workload a bit in the next patch when that
function call is converted.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: convert git_path() to strbuf_git_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:20 +0000 (09:42 +0700)] 
files-backend: convert git_path() to strbuf_git_path()

git_path() and friends are going to be killed in files-backend.c in near
future. And because there's a risk with overwriting buffer in
git_path(), let's convert them all to strbuf_git_path(). We'll have
easier time killing/converting strbuf_git_path() then because we won't
have to worry about memory management again.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: make sure files_rename_ref() always reach the end
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:19 +0000 (09:42 +0700)] 
files-backend: make sure files_rename_ref() always reach the end

This is a no-op patch. It prepares the function so that we can release
resources (to be added later in this function) before we return.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: add and use files_packed_refs_path()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:18 +0000 (09:42 +0700)] 
files-backend: add and use files_packed_refs_path()

Keep repo-related path handling in one place. This will make it easier
to add submodule/multiworktree support later.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: delete dead code in files_init_db()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:17 +0000 (09:42 +0700)] 
files-backend: delete dead code in files_init_db()

safe_create_dir() can do adjust_shared_perm() internally, and init-db
has always created 'refs' in shared mode since the beginning,
af6e277c5e (git-init-db: initialize shared repositories with --shared -
2005-12-22). So this code looks like extra adjust_shared_perm calls are
unnecessary.

And they are. But let's see why there are here in the first place.

This code was added in 6fb5acfd8f (refs: add methods to init refs db -
2016-09-04). From the diff alone this looks like a faithful refactored
code from init-db.c. But there is a subtle difference:

Between the safe_create_dir() block and adjust_shared_perm() block in
the old init-db.c, we may copy/recreate directories from the repo
template. So it makes sense that adjust_shared_perm() is re-executed
then to fix potential permission screwups.

After 6fb5acfd8f, refs dirs are created after template is copied. Nobody
will change directory permission again. So the extra adjust_shared_perm()
is redudant. Delete 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 agofiles-backend.c: delete dead code in files_ref_iterator_begin()
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:16 +0000 (09:42 +0700)] 
files-backend.c: delete dead code in files_ref_iterator_begin()

It's not in the diff context, but files_downcast() is called before this
check. If "refs" is NULL, we would have segfaulted before reaching the
check here. And we should never see NULL refs in backend code (frontend
should have caught it).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles-backend: make files_log_ref_write() static
Nguyễn Thái Ngọc Duy [Sun, 26 Mar 2017 02:42:15 +0000 (09:42 +0700)] 
files-backend: make files_log_ref_write() static

Created in 5f3c3a4e6f (files_log_ref_write: new function - 2015-11-10)
but probably never used outside refs-internal.c

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs.h: add forward declaration for structs used in this file
Nguyễn Thái Ngọc Duy [Sat, 18 Mar 2017 02:03:11 +0000 (09:03 +0700)] 
refs.h: add forward declaration for structs used in this file

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoFifth batch for 2.13
Junio C Hamano [Fri, 17 Mar 2017 20:51:58 +0000 (13:51 -0700)] 
Fifth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/cherry-pick-0-mainline'
Junio C Hamano [Fri, 17 Mar 2017 20:50:28 +0000 (13:50 -0700)] 
Merge branch 'jk/cherry-pick-0-mainline'

"git revert -m 0 $merge_commit" complained that reverting a merge
needs to say relative to which parent the reversion needs to
happen, as if "-m 0" weren't given.  The correct diagnosis is that
"-m 0" does not refer to the first parent ("-m 1" does).  This has
been fixed.

* jk/cherry-pick-0-mainline:
  cherry-pick: detect bogus arguments to --mainline

7 years agoMerge branch 'js/early-config'
Junio C Hamano [Fri, 17 Mar 2017 20:50:28 +0000 (13:50 -0700)] 
Merge branch 'js/early-config'

The start-up sequence of "git" needs to figure out some configured
settings before it finds and set itself up in the location of the
repository and was quite messy due to its "chicken-and-egg" nature.
The code has been restructured.

* js/early-config:
  setup.c: mention unresolved problems
  t1309: document cases where we would want early config not to die()
  setup_git_directory_gently_1(): avoid die()ing
  t1309: test read_early_config()
  read_early_config(): really discover .git/
  read_early_config(): avoid .git/config hack when unneeded
  setup: make read_early_config() reusable
  setup: introduce the discover_git_directory() function
  setup_git_directory_1(): avoid changing global state
  setup: prepare setup_discovered_git_dir() for the root directory
  setup_git_directory(): use is_dir_sep() helper
  t7006: replace dubious test

7 years agoMerge branch 'bc/sha1-header-selection-with-cpp-macros'
Junio C Hamano [Fri, 17 Mar 2017 20:50:27 +0000 (13:50 -0700)] 
Merge branch 'bc/sha1-header-selection-with-cpp-macros'

Our source code has used the SHA1_HEADER cpp macro after "#include"
in the C code to switch among the SHA-1 implementations. Instead,
list the exact header file names and switch among implementations
using "#ifdef BLK_SHA1/#include "block-sha1/sha1.h"/.../#endif";
this helps some IDE tools.

* bc/sha1-header-selection-with-cpp-macros:
  hash.h: move SHA-1 implementation selection into a header file

7 years agoMerge branch 'mg/status-porcelain-no-i18n'
Junio C Hamano [Fri, 17 Mar 2017 20:50:27 +0000 (13:50 -0700)] 
Merge branch 'mg/status-porcelain-no-i18n'

"git status --porcelain" is supposed to give a stable output, but a
few strings were left as translatable by mistake.

* mg/status-porcelain-no-i18n:
  git-status: make porcelain more robust

7 years agoMerge branch 'jk/add-i-use-pathspecs'
Junio C Hamano [Fri, 17 Mar 2017 20:50:26 +0000 (13:50 -0700)] 
Merge branch 'jk/add-i-use-pathspecs'

"git add -p <pathspec>" unnecessarily expanded the pathspec to a
list of individual files that matches the pathspec by running "git
ls-files <pathspec>", before feeding it to "git diff-index" to see
which paths have changes, because historically the pathspec
language supported by "diff-index" was weaker.  These days they are
equivalent and there is no reason to internally expand it.  This
helps both performance and avoids command line argument limit on
some platforms.

* jk/add-i-use-pathspecs:
  add--interactive: do not expand pathspecs with ls-files

7 years agoMerge branch 'jk/http-walker-buffer-underflow-fix'
Junio C Hamano [Fri, 17 Mar 2017 20:50:26 +0000 (13:50 -0700)] 
Merge branch 'jk/http-walker-buffer-underflow-fix'

"Dumb http" transport used to misparse a nonsense http-alternates
response, which has been fixed.

* jk/http-walker-buffer-underflow-fix:
  http-walker: fix buffer underflow processing remote alternates

7 years agoMerge branch 'bw/attr-pathspec'
Junio C Hamano [Fri, 17 Mar 2017 20:50:26 +0000 (13:50 -0700)] 
Merge branch 'bw/attr-pathspec'

The pathspec mechanism learned to further limit the paths that
match the pattern to those that have specified attributes attached
via the gitattributes mechanism.

* bw/attr-pathspec:
  pathspec: allow escaped query values
  pathspec: allow querying for attributes

7 years agoMerge branch 'jk/ref-filter-flags-cleanup'
Junio C Hamano [Fri, 17 Mar 2017 20:50:25 +0000 (13:50 -0700)] 
Merge branch 'jk/ref-filter-flags-cleanup'

"git tag --contains" used to (ab)use the object bits to keep track
of the state of object reachability without clearing them after
use; this has been cleaned up and made to use the newer commit-slab
facility.

* jk/ref-filter-flags-cleanup:
  ref-filter: use separate cache for contains_tag_algo
  ref-filter: die on parse_commit errors
  ref-filter: use contains_result enum consistently
  ref-filter: move ref_cbdata definition into ref-filter.c

7 years agoMerge branch 'sb/rev-parse-show-superproject-root'
Junio C Hamano [Fri, 17 Mar 2017 20:50:25 +0000 (13:50 -0700)] 
Merge branch 'sb/rev-parse-show-superproject-root'

From a working tree of a repository, a new option of "rev-parse"
lets you ask if the repository is used as a submodule of another
project, and where the root level of the working tree of that
project (i.e. your superproject) is.

* sb/rev-parse-show-superproject-root:
  rev-parse: add --show-superproject-working-tree

7 years agoMerge branch 'bc/object-id'
Junio C Hamano [Fri, 17 Mar 2017 20:50:24 +0000 (13:50 -0700)] 
Merge branch 'bc/object-id'

"uchar [40]" to "struct object_id" conversion continues.

* bc/object-id:
  wt-status: convert to struct object_id
  builtin/merge-base: convert to struct object_id
  Convert object iteration callbacks to struct object_id
  sha1_file: introduce an nth_packed_object_oid function
  refs: simplify parsing of reflog entries
  refs: convert each_reflog_ent_fn to struct object_id
  reflog-walk: convert struct reflog_info to struct object_id
  builtin/replace: convert to struct object_id
  Convert remaining callers of resolve_refdup to object_id
  builtin/merge: convert to struct object_id
  builtin/clone: convert to struct object_id
  builtin/branch: convert to struct object_id
  builtin/grep: convert to struct object_id
  builtin/fmt-merge-message: convert to struct object_id
  builtin/fast-export: convert to struct object_id
  builtin/describe: convert to struct object_id
  builtin/diff-tree: convert to struct object_id
  builtin/commit: convert to struct object_id
  hex: introduce parse_oid_hex

7 years agoMerge branch 'rs/blame-code-cleanup'
Junio C Hamano [Fri, 17 Mar 2017 20:50:24 +0000 (13:50 -0700)] 
Merge branch 'rs/blame-code-cleanup'

Code clean-up.

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

7 years agoMerge branch 'jk/interop-test'
Junio C Hamano [Fri, 17 Mar 2017 20:50:23 +0000 (13:50 -0700)] 
Merge branch 'jk/interop-test'

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'
Junio C Hamano [Fri, 17 Mar 2017 20:50:23 +0000 (13:50 -0700)] 
Merge branch 'cc/split-index-config'

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 agoSync with 'maint'
Junio C Hamano [Thu, 16 Mar 2017 21:03:11 +0000 (14:03 -0700)] 
Sync with 'maint'

* maint:
  Preparing for 2.12.1

7 years agoPreparing for 2.12.1
Junio C Hamano [Thu, 16 Mar 2017 21:01:00 +0000 (14:01 -0700)] 
Preparing for 2.12.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/realpath-pathdup-fix' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:43 +0000 (13:56 -0700)] 
Merge branch 'js/realpath-pathdup-fix' into maint

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.
... and then to down to 'maint'.

* 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 'mm/two-more-xstrfmt' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:43 +0000 (13:56 -0700)] 
Merge branch 'mm/two-more-xstrfmt' into maint

Code clean-up and a string truncation fix.

* mm/two-more-xstrfmt:
  bisect_next_all: convert xsnprintf to xstrfmt
  stop_progress_msg: convert xsnprintf to xstrfmt

7 years agoMerge branch 'vn/line-log-memcpy-size-fix' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'vn/line-log-memcpy-size-fix' into maint

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 'ax/line-log-range-merge-fix' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'ax/line-log-range-merge-fix' into maint

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 'jk/add-i-patch-do-prompt' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'jk/add-i-patch-do-prompt' into maint

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 'jt/http-base-url-update-upon-redirect' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'jt/http-base-url-update-upon-redirect' into maint

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 'js/travis-32bit-linux' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:41 +0000 (13:56 -0700)] 
Merge branch 'js/travis-32bit-linux' into maint

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 'jh/mingw-openssl-sha1' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:41 +0000 (13:56 -0700)] 
Merge branch 'jh/mingw-openssl-sha1' into maint

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 agoMerge branch 'jk/http-auth' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:41 +0000 (13:56 -0700)] 
Merge branch 'jk/http-auth' into maint

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 agocherry-pick: detect bogus arguments to --mainline
Jeff King [Wed, 15 Mar 2017 16:56:23 +0000 (12:56 -0400)] 
cherry-pick: detect bogus arguments to --mainline

The cherry-pick and revert commands use OPT_INTEGER() to
parse --mainline. The stock parser is smart enough to reject
non-numeric nonsense, but it doesn't know that parent
counting starts at 1.

Worse, the value "0" is indistinguishable from the unset
case, so a user who assumes the counting is 0-based will get
a confusing message:

  $ git cherry-pick -m 0 $merge
  error: commit ... is a merge but no -m option was given.

Let's use a custom callback that enforces our range.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohash.h: move SHA-1 implementation selection into a header file
brian m. carlson [Sat, 11 Mar 2017 22:28:18 +0000 (22:28 +0000)] 
hash.h: move SHA-1 implementation selection into a header file

Many developers use functionality in their editors that allows for quick
syntax checks, including warning about questionable constructs.  This
functionality allows rapid development with fewer errors.  However, such
functionality generally does not allow the specification of
project-specific defines or command-line options.

Since the SHA1_HEADER include is not defined in such a case,
developers see spurious errors when using these tools.  Furthermore,
there are known implementations of "cc" whose '#include' is unhappy
with this construct.

Instead of using SHA1_HEADER, create a hash.h header and use #if
and #elif to select the desired header.  Have the Makefile pass an
appropriate option to help the header select the right implementation to
use.

[jc: make BLK_SHA1 the fallback default as discussed on list,
e.g. <20170314201424.vccij5z2ortq4a4o@sigill.intra.peff.net>; also
remove SHA1_HEADER and SHA1_HEADER_SQ that are no longer used].

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
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>
7 years agoFourth batch after 2.12
Junio C Hamano [Tue, 14 Mar 2017 22:29:40 +0000 (15:29 -0700)] 
Fourth batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'kn/ref-filter-branch-list'
Junio C Hamano [Tue, 14 Mar 2017 22:23:20 +0000 (15:23 -0700)] 
Merge branch 'kn/ref-filter-branch-list'

"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'
Junio C Hamano [Tue, 14 Mar 2017 22:23:20 +0000 (15:23 -0700)] 
Merge branch 'jk/push-deadlock-regression-fix'

"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'
Junio C Hamano [Tue, 14 Mar 2017 22:23:20 +0000 (15:23 -0700)] 
Merge branch 'js/travis-32bit-linux'

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 'ew/http-alternates-as-redirects-warning'
Junio C Hamano [Tue, 14 Mar 2017 22:23:19 +0000 (15:23 -0700)] 
Merge branch 'ew/http-alternates-as-redirects-warning'

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'
Junio C Hamano [Tue, 14 Mar 2017 22:23:19 +0000 (15:23 -0700)] 
Merge branch 'dp/filter-branch-prune-empty'

"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 'jt/perf-updates'
Junio C Hamano [Tue, 14 Mar 2017 22:23:18 +0000 (15:23 -0700)] 
Merge branch 'jt/perf-updates'

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 'mm/fetch-show-error-message-on-unadvertised-object'
Junio C Hamano [Tue, 14 Mar 2017 22:23:18 +0000 (15:23 -0700)] 
Merge branch 'mm/fetch-show-error-message-on-unadvertised-object'

"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 'jk/interpret-branch-name'
Junio C Hamano [Tue, 14 Mar 2017 22:23:18 +0000 (15:23 -0700)] 
Merge branch 'jk/interpret-branch-name'

"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 'ab/cond-skip-tests'
Junio C Hamano [Tue, 14 Mar 2017 22:23:17 +0000 (15:23 -0700)] 
Merge branch 'ab/cond-skip-tests'

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 agosetup.c: mention unresolved problems
Johannes Schindelin [Mon, 13 Mar 2017 20:12:18 +0000 (21:12 +0100)] 
setup.c: mention unresolved problems

During the review of the `early-config` patch series, two issues
have been identified that have been with us forever.  Mark the
identified problems for later so that we do not forget them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1309: document cases where we would want early config not to die()
Johannes Schindelin [Mon, 13 Mar 2017 20:11:26 +0000 (21:11 +0100)] 
t1309: document cases where we would want early config not to die()

Jeff King came up with a couple examples that demonstrate how the new
read_early_config() that looks harder for the current .git/ directory
could die() in an undesirable way.

Let's add those cases to the test script, to document what we would like
to happen when early config encounters problems.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosetup_git_directory_gently_1(): avoid die()ing
Johannes Schindelin [Mon, 13 Mar 2017 20:11:22 +0000 (21:11 +0100)] 
setup_git_directory_gently_1(): avoid die()ing

This function now has a new caller in addition to setup_git_directory():
the newly introduced discover_git_directory(). That function wants to
discover the current .git/ directory, and in case of a corrupted one
simply pretend that there is none to be found.

Example: if a stale .git file exists in the parent directory, and the
user calls `git -p init`, we want Git to simply *not* read any
repository config for the pager (instead of aborting with a message that
the .git file is corrupt).

Let's actually pretend that there was no GIT_DIR to be found in that case
when being called from discover_git_directory(), but keep the previous
behavior (i.e. to die()) for the setup_git_directory() case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1309: test read_early_config()
Johannes Schindelin [Mon, 13 Mar 2017 20:11:17 +0000 (21:11 +0100)] 
t1309: test read_early_config()

So far, we had no explicit tests of that function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread_early_config(): really discover .git/
Johannes Schindelin [Mon, 13 Mar 2017 20:11:12 +0000 (21:11 +0100)] 
read_early_config(): really discover .git/

Earlier, we punted and simply assumed that we are in the top-level
directory of the project, and that there is no .git file but a .git/
directory so that we can read directly from .git/config.

However, that is not necessarily true. We may be in a subdirectory. Or
.git may be a gitfile. Or the environment variable GIT_DIR may be set.

To remedy this situation, we just refactored the way
setup_git_directory() discovers the .git/ directory, to make it
reusable, and more importantly, to leave all global variables and the
current working directory alone.

Let's discover the .git/ directory correctly in read_early_config() by
using that new function.

This fixes 4 known breakages in t7006.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoread_early_config(): avoid .git/config hack when unneeded
Johannes Schindelin [Mon, 13 Mar 2017 20:11:08 +0000 (21:11 +0100)] 
read_early_config(): avoid .git/config hack when unneeded

So far, we only look whether the startup_info claims to have seen a
git_dir.

However, do_git_config_sequence() (and consequently the
git_config_with_options() call used by read_early_config() asks the
have_git_dir() function whether we have a .git/ directory, which in turn
also looks at git_dir and at the environment variable GIT_DIR. And when
this is the case, the repository config is handled already, so we do not
have to do that again explicitly.

Let's just use the same function, have_git_dir(), to determine whether we
have to handle .git/config explicitly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosetup: make read_early_config() reusable
Johannes Schindelin [Mon, 13 Mar 2017 20:11:04 +0000 (21:11 +0100)] 
setup: make read_early_config() reusable

The pager configuration needs to be read early, possibly before
discovering any .git/ directory.

Let's not hide this function in pager.c, but make it available to other
callers.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosetup: introduce the discover_git_directory() function
Johannes Schindelin [Mon, 13 Mar 2017 20:10:45 +0000 (21:10 +0100)] 
setup: introduce the discover_git_directory() function

We modified the setup_git_directory_gently_1() function earlier to make
it possible to discover the GIT_DIR without changing global state.

However, it is still a bit cumbersome to use if you only need to figure
out the (possibly absolute) path of the .git/ directory. Let's just
provide a convenient wrapper function with an easier signature that
*just* discovers the .git/ directory.

We will use it in a subsequent patch to fix the early config.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosetup_git_directory_1(): avoid changing global state
Johannes Schindelin [Mon, 13 Mar 2017 20:10:42 +0000 (21:10 +0100)] 
setup_git_directory_1(): avoid changing global state

For historical reasons, Git searches for the .git/ directory (or the
.git file) by changing the working directory successively to the parent
directory of the current directory, until either anything was found or
until a ceiling or a mount point is hit.

Further global state may be changed in case a .git/ directory was found.

We do have a use case, though, where we would like to find the .git/
directory without having any global state touched, though: when we read
the early config e.g. for the pager or for alias expansion.

Let's just move all of code that changes any global state out of the
function `setup_git_directory_gently_1()` into
`setup_git_directory_gently()`.

In subsequent patches, we will use the _1() function in a new
`discover_git_directory()` function that we will then use for the early
config code.

Note: the new loop is a *little* tricky, as we have to handle the root
directory specially: we cannot simply strip away the last component
including the slash, as the root directory only has that slash. To remedy
that, we introduce the `min_offset` variable that holds the minimal length
of an absolute path, and using that to special-case the root directory,
including an early exit before trying to find the parent of the root
directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosetup: prepare setup_discovered_git_dir() for the root directory
Johannes Schindelin [Mon, 13 Mar 2017 20:09:44 +0000 (21:09 +0100)] 
setup: prepare setup_discovered_git_dir() for the root directory

Currently, the offset parameter (indicating what part of the cwd
parameter corresponds to the current directory after discovering the
.git/ directory) is set to 0 when we are running in the root directory.

However, in the next patches we will avoid changing the current working
directory while searching for the .git/ directory, meaning that the
offset corresponding to the root directory will have to be 1 to reflect
that this directory is characterized by the path "/" (and not "").

So let's make sure that setup_discovered_git_directory() only tries to
append the trailing slash to non-root directories.

Note: the setup_bare_git_directory() does not need a corresponding
change, as it does not want to return a prefix.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoadd--interactive: do not expand pathspecs with ls-files
Jeff King [Tue, 14 Mar 2017 16:30:24 +0000 (12:30 -0400)] 
add--interactive: do not expand pathspecs with ls-files

When we want to get the list of modified files, we first
expand any user-provided pathspecs with "ls-files", and then
feed the resulting list of paths as arguments to
"diff-index" and "diff-files". If your pathspec expands into
a large number of paths, you may run into one of two
problems:

  1. The OS may complain about the size of the argument
     list, and refuse to run. For example:

       $ (ulimit -s 128 && git add -p drivers)
       Can't exec "git": Argument list too long at .../git-add--interactive line 177.
       Died at .../git-add--interactive line 177.

     That's on the linux.git repository, which has about 20K
     files in the "drivers" directory (none of them modified
     in this case). The "ulimit -s" trick is necessary to
     show the problem on Linux even for such a gigantic set
     of paths. Other operating systems have much smaller
     limits (e.g., a real-world case was seen with only 5K
     files on OS X).

  2. Even when it does work, it's really slow. The pathspec
     code is not optimized for huge numbers of paths. Here's
     the same case without the ulimit:

       $ time git add -p drivers
       No changes.

       real 0m16.559s
       user 0m53.140s
       sys 0m0.220s

We can improve this by skipping "ls-files" completely, and
just feeding the original pathspecs to the diff commands.
This solution was discussed in 2010:

  http://public-inbox.org/git/20100105041438.GB12574@coredump.intra.peff.net/

but at the time the diff code's pathspecs were more
primitive than those used by ls-files (e.g., they did not
support globs). Making the change would have caused a
user-visible regression, so we didn't.

Since then, the pathspec code has been unified, and the diff
commands natively understand pathspecs like '*.c'.

This patch implements that solution. That skips the
argument-list limits, and the result runs much faster:

  $ time git add -p drivers
  No changes.

  real 0m0.149s
  user 0m0.116s
  sys 0m0.080s

There are two new tests. The first just exercises the
globbing behavior to confirm that we are not causing a
regression there. The second checks the actual argument
behavior using GIT_TRACE. We _could_ do it with the "ulimit
-s" trick, as above. But that would mean the test could only
run where "ulimit -s" works. And tests of that sort are
expensive, because we have to come up with enough files to
actually bust the limit (we can't just shrink the "128" down
infinitely, since it is also the in-program stack size).

Finally, two caveats and possibilities for future work:

  a. This fixes one argument-list expansion, but there may
     be others. In fact, it's very likely that if you run
     "git add -i" and select a large number of modified
     files that the script would try to feed them all to a
     single git command.

     In practice this is probably fine. The real issue here
     is that the argument list was growing with the _total_
     number of files, not the number of modified or selected
     files.

  b. If the repository contains filenames with literal wildcard
     characters (e.g., "foo*"), the original code expanded
     them via "ls-files" and then fed those wildcard names
     to "diff-index", which would have treated them as
     wildcards. This was a bug, which is now fixed (though
     unless you really go through some contortions with
     ":(literal)", it's likely that your original pathspec
     would match whatever the accidentally-expanded wildcard
     would anyway).

     So this takes us one step closer to working correctly
     with files whose names contain wildcard characters, but
     it's likely that others remain (e.g., if "git add -i"
     feeds the selected paths to "git add").

Reported-by: Wincent Colaiuta <win@wincent.com>
Reported-by: Mislav Marohnić <mislav.marohnic@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-status: make porcelain more robust
Michael J Gruber [Tue, 14 Mar 2017 16:02:02 +0000 (17:02 +0100)] 
git-status: make porcelain more robust

git status provides a porcelain mode for porcelain writers with a
supposedly stable (plumbing) interface.
7a76c28ff2 ("status: disable translation when --porcelain is used", 2014-03-20)
made sure that ahead/behind info is not translated (i.e. is stable).

Make sure that the remaining two strings (initial commit, detached head)
are stable, too.

These changes are for the v1 porcelain interface. While we do have a perfectly
stable v2 porcelain interface now, some tools (such as
powerline-gitstatus) are written against v1 and profit from fixing v1
without any changes on their side.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: allow escaped query values
Brandon Williams [Mon, 13 Mar 2017 18:23:22 +0000 (11:23 -0700)] 
pathspec: allow escaped query values

In our own .gitattributes file we have attributes such as:

    *.[ch] whitespace=indent,trail,space

When querying for attributes we want to be able to ask for the exact
value, i.e.

    git ls-files :(attr:whitespace=indent,trail,space)

should work, but the commas are used in the attr magic to introduce
the next attr, such that this query currently fails with

fatal: Invalid pathspec magic 'trail' in ':(attr:whitespace=indent,trail,space)'

This change allows escaping characters by a backslash, such that the query

    git ls-files :(attr:whitespace=indent\,trail\,space)

will match all path that have the value "indent,trail,space" for the
whitespace attribute. To accomplish this, we need to modify two places.
First `parse_long_magic` needs to not stop early upon seeing a comma or
closing paren that is escaped. As a second step we need to remove any
escaping from the attr value.

Based on a patch by Stefan Beller <sbeller@google.com>

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: allow querying for attributes
Brandon Williams [Mon, 13 Mar 2017 18:23:21 +0000 (11:23 -0700)] 
pathspec: allow querying for attributes

The pathspec mechanism is extended via the new
":(attr:eol=input)pattern/to/match" syntax to filter paths so that it
requires paths to not just match the given pattern but also have the
specified attrs attached for them to be chosen.

Based on a patch by Stefan Beller <sbeller@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp-walker: fix buffer underflow processing remote alternates
Jeff King [Mon, 13 Mar 2017 14:04:45 +0000 (10:04 -0400)] 
http-walker: fix buffer underflow processing remote alternates

If we parse a remote alternates (or http-alternates), we
expect relative lines like:

  ../../foo.git/objects

which we convert into "$URL/../foo.git/" (and then use that
as a base for fetching more objects).

But if the remote feeds us nonsense like just:

  ../

we will try to blindly strip the last 7 characters, assuming
they contain the string "objects". Since we don't _have_ 7
characters at all, this results in feeding a small negative
value to strbuf_add(), which converts it to a size_t,
resulting in a big positive value. This should consistently
fail (since we can't generall allocate the max size_t minus
7 bytes), so there shouldn't be any security implications.

Let's fix this by using strbuf_strip_suffix() to drop the
characters we want. If they're not present, we'll ignore the
alternate (in theory we could use it as-is, but the rest of
the http-walker code unconditionally tacks "objects/" back
on, so it is it not prepared to handle such a case).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 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 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