gitweb.git
repository: enable initialization of submodulesBrandon Williams Thu, 22 Jun 2017 18:43:47 +0000 (11:43 -0700)

repository: enable initialization of submodules

Introduce 'repo_submodule_init()' which performs initialization of a
'struct repository' as a submodule of another 'struct repository'.

The resulting submodule 'struct repository' can be in one of three states:

1. The submodule is initialized and has a worktree.

2. The submodule is initialized but does not have a worktree. This
would occur when the submodule's gitdir is present in the
superproject's 'gitdir/modules/' directory yet the submodule has not
been checked out in superproject's worktree.

3. The submodule remains uninitialized due to an error in the
initialization process or there is no matching submodule at the
provided path in the superproject.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: convert is_submodule_initialized to work... Brandon Williams Thu, 22 Jun 2017 18:43:46 +0000 (11:43 -0700)

submodule: convert is_submodule_initialized to work on a repository

Convert 'is_submodule_initialized()' to take a repository object and
while we're at it, lets rename the function to 'is_submodule_active()'
and remove the NEEDSWORK comment.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: add repo_read_gitmodulesBrandon Williams Thu, 22 Jun 2017 18:43:45 +0000 (11:43 -0700)

submodule: add repo_read_gitmodules

Teach the repo object to be able to populate the submodule_cache by
reading the repository's gitmodules file.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule-config: store the_submodule_cache in the_repo... Brandon Williams Thu, 22 Jun 2017 18:43:44 +0000 (11:43 -0700)

submodule-config: store the_submodule_cache in the_repository

Refactor how 'the_submodule_cache' is handled so that it can be stored
inside of a repository object. Also migrate 'the_submodule_cache' to be
stored in 'the_repository'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

repository: add index_state to struct repoBrandon Williams Thu, 22 Jun 2017 18:43:43 +0000 (11:43 -0700)

repository: add index_state to struct repo

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: read config from a repository objectBrandon Williams Thu, 22 Jun 2017 18:43:42 +0000 (11:43 -0700)

config: read config from a repository object

Teach the config machinery to read config information from a repository
object. This involves storing a 'struct config_set' inside the
repository object and adding a number of functions (repo_config*) to be
able to query a repository's config.

The current config API enables lazy-loading of the config. This means
that when 'git_config_get_int()' is called, if the_config_set hasn't
been populated yet, then it will be populated and properly initialized by
reading the necessary config files (system wide .gitconfig, user's home
.gitconfig, and the repository's config). To maintain this paradigm,
the new API to read from a repository object's config will also perform
this lazy-initialization.

Since both APIs (git_config_get* and repo_config_get*) have the same
semantics we can migrate the default config to be stored within
'the_repository' and just have the 'git_config_get*' family of functions
redirect to the 'repo_config_get*' functions.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: add repo_worktree_path and strbuf_repo_worktree_pathBrandon Williams Thu, 22 Jun 2017 18:43:41 +0000 (11:43 -0700)

path: add repo_worktree_path and strbuf_repo_worktree_path

Introduce 'repo_worktree_path' and 'strbuf_repo_worktree_path' which
take a repository struct and constructs a path relative to the
repository's worktree.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: add repo_git_path and strbuf_repo_git_pathBrandon Williams Thu, 22 Jun 2017 18:43:40 +0000 (11:43 -0700)

path: add repo_git_path and strbuf_repo_git_path

Introduce 'repo_git_path' and 'strbuf_repo_git_path' which take a
repository struct and constructs a path into the repository's git
directory.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: worktree_git_path() should not use file relocationBrandon Williams Thu, 22 Jun 2017 18:43:39 +0000 (11:43 -0700)

path: worktree_git_path() should not use file relocation

git_path is a convenience function that usually produces a string
$GIT_DIR/<path>. Since v2.5.0-rc0~143^2~35 (git_path(): be aware of
file relocation in $GIT_DIR, 2014-11-30), as a side benefit callers
get support for path relocation variables like $GIT_OBJECT_DIRECTORY:

- git_path("index") is $GIT_INDEX_FILE when set
- git_path("info/grafts") is $GIT_GRAFTS_FILE when set
- git_path("objects/<foo>") is $GIT_OBJECT_DIRECTORY/<foo> when set
- git_path("hooks/<foo>") is <foo> under core.hookspath when set
- git_path("refs/<foo>") etc (see path.c::common_list) is relative
to $GIT_COMMON_DIR instead of $GIT_DIR

worktree_git_path, by comparison, is designed to resolve files in a
specific worktree's git dir. Unfortunately, it shares code with
git_path and performs the same relocation. The result is that paths
that are meant to be relative to the specified worktree's git dir end
up replaced by paths from environment variables within the current git
dir.

Luckily, no current callers pass such arguments. The relocation was
noticed when testing the result of merging two patches under review,
one of which introduces a caller:

* The first patch made git prune check the index file in each
worktree's git dir (using worktree_git_path(wt, "index")) for
objects not to prune. This would trigger the unwanted relocation
when GIT_INDEX_FILE is set, causing objects reachable from the
index to be pruned.

* The second patch simplified the relocation logic for index,
info/grafts, objects, and hooks to happen unconditionally instead of
based on whether environment or configuration variables are set.
This caused the relocation to trigger even when GIT_INDEX_FILE is
not set.

[jn: rewrote commit message; skipping all relocation instead of just
GIT_INDEX_FILE]

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: convert do_git_path to take a 'struct repository'Brandon Williams Thu, 22 Jun 2017 18:43:38 +0000 (11:43 -0700)

path: convert do_git_path to take a 'struct repository'

In preparation to adding 'git_path' like functions which operate on a
'struct repository' convert 'do_git_path' to take a 'struct repository'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: convert strbuf_git_common_path to take a 'struct... Brandon Williams Thu, 22 Jun 2017 18:43:37 +0000 (11:43 -0700)

path: convert strbuf_git_common_path to take a 'struct repository'

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: always pass in commondir to update_common_dirBrandon Williams Thu, 22 Jun 2017 18:43:36 +0000 (11:43 -0700)

path: always pass in commondir to update_common_dir

Instead of passing in 'NULL' and having 'update_common_dir()' query for
the commondir, have the callers of 'update_common_dir()' be responsible
for providing the commondir.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: create path.hBrandon Williams Thu, 22 Jun 2017 18:43:35 +0000 (11:43 -0700)

path: create path.h

Move all path related declarations from cache.h to a new path.h header
file. This makes cache.h smaller and makes it easier to add new path
related functions.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

environment: store worktree in the_repositoryBrandon Williams Thu, 22 Jun 2017 18:43:34 +0000 (11:43 -0700)

environment: store worktree in the_repository

Migrate 'work_tree' to be stored in 'the_repository'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

environment: place key repository state in the_repositoryBrandon Williams Thu, 22 Jun 2017 18:43:33 +0000 (11:43 -0700)

environment: place key repository state in the_repository

Migrate 'git_dir', 'git_common_dir', 'git_object_dir', 'git_index_file',
'git_graft_file', and 'namespace' to be stored in 'the_repository'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

repository: introduce the repository objectBrandon Williams Thu, 22 Jun 2017 18:43:32 +0000 (11:43 -0700)

repository: introduce the repository object

Introduce the repository object 'struct repository' which can be used to
hold all state pertaining to a git repository.

Some of the benefits of object-ifying a repository are:

1. Make the code base more readable and easier to reason about.

2. Allow for working on multiple repositories, specifically
submodules, within the same process. Currently the process for
working on a submodule involves setting up an argv_array of options
for a particular command and then launching a child process to
execute the command in the context of the submodule. This is
clunky and can require lots of little hacks in order to ensure
correctness. Ideally it would be nice to simply pass a repository
and an options struct to a command.

3. Eliminating reliance on global state will make it easier to
enable the use of threading to improve performance.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

environment: remove namespace_len variableBrandon Williams Tue, 20 Jun 2017 19:19:34 +0000 (12:19 -0700)

environment: remove namespace_len variable

Use 'skip_prefix' instead of 'starts_with' so that we can drop the need
to keep around 'namespace_len'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

setup: add comment indicating a hackBrandon Williams Tue, 20 Jun 2017 19:19:33 +0000 (12:19 -0700)

setup: add comment indicating a hack

'GIT_TOPLEVEL_PREFIX_ENVIRONMENT' was added in (b58a68c1c setup: allow
for prefix to be passed to git commands) to aid in fixing a bug where
'ls-files' and 'grep' were not able to properly recurse when called from
within a subdirectory. Add a 'NEEDSWORK' comment indicating that this
envvar should be removed once 'ls-files' and 'grep' can recurse
in-process.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

setup: don't perform lazy initialization of repository... Brandon Williams Tue, 20 Jun 2017 19:19:32 +0000 (12:19 -0700)

setup: don't perform lazy initialization of repository state

Under some circumstances (bogus GIT_DIR value or the discovered gitdir
is '.git') 'setup_git_directory()' won't initialize key repository
state. This leads to inconsistent state after running the setup code.
To account for this inconsistent state, lazy initialization is done once
a caller asks for the repository's gitdir or some other piece of
repository state. This is confusing and can be error prone.

Instead let's tighten the expected outcome of 'setup_git_directory()'
and ensure that it initializes repository state in all cases that would
have been handled by lazy initialization.

This also lets us drop the requirement to have 'have_git_dir()' check if
the environment variable GIT_DIR was set as that will be handled by the
end of the setup code.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branches 'bw/ls-files-sans-the-index' and 'bw... Junio C Hamano Wed, 21 Jun 2017 22:20:44 +0000 (15:20 -0700)

Merge branches 'bw/ls-files-sans-the-index' and 'bw/config-h' into bw/repo-object

* bw/ls-files-sans-the-index:
ls-files: factor out tag calculation
ls-files: factor out debug info into a function
ls-files: convert show_files to take an index
ls-files: convert show_ce_entry to take an index
ls-files: convert prune_cache to take an index
ls-files: convert ce_excluded to take an index
ls-files: convert show_ru_info to take an index
ls-files: convert show_other_files to take an index
ls-files: convert show_killed_files to take an index
ls-files: convert write_eolinfo to take an index
ls-files: convert overlay_tree_on_cache to take an index
tree: convert read_tree to take an index parameter
convert: convert renormalize_buffer to take an index
convert: convert convert_to_git to take an index
convert: convert convert_to_git_filter_fd to take an index
convert: convert crlf_to_git to take an index
convert: convert get_cached_convert_stats_ascii to take an index

* bw/config-h:
config: don't implicitly use gitdir or commondir
config: respect commondir
setup: teach discover_git_directory to respect the commondir
config: don't include config.h by default
config: remove git_config_iter
config: create config.h
alias: use the early config machinery to expand aliases
t7006: demonstrate a problem with aliases in subdirectories
t1308: relax the test verifying that empty alias values are disallowed
help: use early config when autocorrecting aliases
config: report correct line number upon error
discover_git_directory(): avoid setting invalid git_dir

Ninth batch for 2.14Junio C Hamano Mon, 19 Jun 2017 19:41:12 +0000 (12:41 -0700)

Ninth batch for 2.14

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

Merge branch 'jk/consistent-h'Junio C Hamano Mon, 19 Jun 2017 19:38:45 +0000 (12:38 -0700)

Merge branch 'jk/consistent-h'

"git $cmd -h" for builtin commands calls the implementation of the
command (i.e. cmd_$cmd() function) without doing any repository
set-up, and the commands that expect RUN_SETUP is done by the Git
potty needs to be prepared to show the help text without barfing.

* jk/consistent-h:
t0012: test "-h" with builtins
git: add hidden --list-builtins option
version: convert to parse-options
diff- and log- family: handle "git cmd -h" early
submodule--helper: show usage for "-h"
remote-{ext,fd}: print usage message on invalid arguments
upload-archive: handle "-h" option early
credential: handle invalid arguments earlier

Merge branch 'ab/perf-remove-index-lock'Junio C Hamano Mon, 19 Jun 2017 19:38:44 +0000 (12:38 -0700)

Merge branch 'ab/perf-remove-index-lock'

When an existing repository is used for t/perf testing, we first
create bit-for-bit copy of it, which may grab a transient state of
the repository and freeze it into the repository used for testing,
which then may cause Git operations to fail. Single out "the index
being locked" case and forcibly drop the lock from the copy.

* ab/perf-remove-index-lock:
perf: work around the tested repo having an index.lock

Merge branch 'bw/object-id'Junio C Hamano Mon, 19 Jun 2017 19:38:44 +0000 (12:38 -0700)

Merge branch 'bw/object-id'

Conversion from uchar[20] to struct object_id continues.

* bw/object-id: (33 commits)
diff: rename diff_fill_sha1_info to diff_fill_oid_info
diffcore-rename: use is_empty_blob_oid
tree-diff: convert path_appendnew to object_id
tree-diff: convert diff_tree_paths to struct object_id
tree-diff: convert try_to_follow_renames to struct object_id
builtin/diff-tree: cleanup references to sha1
diff-tree: convert diff_tree_sha1 to struct object_id
notes-merge: convert write_note_to_worktree to struct object_id
notes-merge: convert verify_notes_filepair to struct object_id
notes-merge: convert find_notes_merge_pair_ps to struct object_id
notes-merge: convert merge_from_diffs to struct object_id
notes-merge: convert notes_merge* to struct object_id
tree-diff: convert diff_root_tree_sha1 to struct object_id
combine-diff: convert find_paths_* to struct object_id
combine-diff: convert diff_tree_combined to struct object_id
diff: convert diff_flush_patch_id to struct object_id
patch-ids: convert to struct object_id
diff: finish conversion for prepare_temp_file to struct object_id
diff: convert reuse_worktree_file to struct object_id
diff: convert fill_filespec to struct object_id
...

Merge branch 'sb/submodule-rm-absorb'Junio C Hamano Mon, 19 Jun 2017 19:38:44 +0000 (12:38 -0700)

Merge branch 'sb/submodule-rm-absorb'

Doc update to a recently graduated topic.

* sb/submodule-rm-absorb:
Documentation/git-rm: correct submodule description

Merge branch 'ab/pcre-v2'Junio C Hamano Mon, 19 Jun 2017 19:38:43 +0000 (12:38 -0700)

Merge branch 'ab/pcre-v2'

Update "perl-compatible regular expression" support to enable JIT
and also allow linking with the newer PCRE v2 library.

* ab/pcre-v2:
grep: add support for PCRE v2
grep: un-break building with PCRE >= 8.32 without --enable-jit
grep: un-break building with PCRE < 8.20
grep: un-break building with PCRE < 8.32
grep: add support for the PCRE v1 JIT API
log: add -P as a synonym for --perl-regexp
grep: skip pthreads overhead when using one thread
grep: don't redundantly compile throwaway patterns under threading

Merge branch 'jk/pathspec-magic-disambiguation'Junio C Hamano Mon, 19 Jun 2017 19:38:42 +0000 (12:38 -0700)

Merge branch 'jk/pathspec-magic-disambiguation'

The convention for a command line is to follow "git cmdname
--options" with revisions followed by an optional "--"
disambiguator and then finally pathspecs. When "--" is not there,
we make sure early ones are all interpretable as revs (and do not
look like paths) and later ones are the other way around. A
pathspec with "magic" (e.g. ":/p/a/t/h" that matches p/a/t/h from
the top-level of the working tree, no matter what subdirectory you
are working from) are conservatively judged as "not a path", which
required disambiguation more often. The command line parser
learned to say "it's a pathspec" a bit more often when the syntax
looks like so.

* jk/pathspec-magic-disambiguation:
verify_filename(): flip order of checks
verify_filename(): treat ":(magic)" as a pathspec
check_filename(): handle ":^" path magic
check_filename(): use skip_prefix
check_filename(): refactor ":/" handling
t4208: add check for ":/" without matching file

sub-process: correct path to API docs in a commentChristian Couder Wed, 14 Jun 2017 15:12:25 +0000 (17:12 +0200)

sub-process: correct path to API docs in a comment

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Ben Peart <peartben@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'svn-doc' of git://bogomips.org/git-svnJunio C Hamano Thu, 15 Jun 2017 21:15:03 +0000 (14:15 -0700)

Merge branch 'svn-doc' of git://bogomips.org/git-svn

* 'svn-doc' of git://bogomips.org/git-svn:
git-svn: document special options for commit-diff

config: don't implicitly use gitdir or commondirBrandon Williams Wed, 14 Jun 2017 18:07:39 +0000 (11:07 -0700)

config: don't implicitly use gitdir or commondir

'git_config_with_options()' takes a 'config_options' struct which
contains feilds for 'git_dir' and 'commondir'. If those feilds happen
to be NULL the config machinery falls back to querying global repository
state. Let's change this and instead use these fields in the
'config_options' struct explicilty all the time. Since the API is
slightly changing to require these two fields to be set if callers want
the config machinery to load the repository's config, let's change the
name to 'config_with_optison()'. This allows the config machinery to
not implicitly rely on any global repository state.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: respect commondirBrandon Williams Wed, 14 Jun 2017 18:07:38 +0000 (11:07 -0700)

config: respect commondir

Worktrees present an interesting problem when it comes to the config.
Historically we could assume that the per-repository config lives at
'gitdir/config', but since worktrees were introduced this isn't the case
anymore. There is currently no way to specify per-worktree
configuration, and as such the repository config is shared with all
worktrees and is located at 'commondir/config'.

Many users of the config machinery correctly set
'config_options.git_dir' with the repository's commondir, allowing the
config to be properly loaded when operating in a worktree. But other's,
like 'read_early_config()', set 'config_options.git_dir' with the
repository's gitdir which can be incorrect when using worktrees.

To fix this issue, and to make things less ambiguous, lets add a
'commondir' field to the 'config_options' struct and have all callers
properly set both the 'git_dir' and 'commondir' fields so that the
config machinery is able to properly find the repository's config.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

setup: teach discover_git_directory to respect the... Brandon Williams Wed, 14 Jun 2017 18:07:37 +0000 (11:07 -0700)

setup: teach discover_git_directory to respect the commondir

Currently 'discover_git_directory' only looks at the gitdir to determine
if a git directory was discovered. This causes a problem in the event
that the gitdir which was discovered was in fact a per-worktree git
directory and not the common git directory. This is because the
repository config, which is checked to verify the repository's format,
is stored in the commondir and not in the per-worktree gitdir. Correct
this behavior by checking the config stored in the commondir.

It will also be of use for callers to have access to the commondir, so
lets also return that upon successfully discovering a git directory.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: don't include config.h by defaultBrandon Williams Wed, 14 Jun 2017 18:07:36 +0000 (11:07 -0700)

config: don't include config.h by default

Stop including config.h by default in cache.h. Instead only include
config.h in those files which require use of the config system.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: remove git_config_iterBrandon Williams Wed, 14 Jun 2017 18:07:35 +0000 (11:07 -0700)

config: remove git_config_iter

Since there is no implementation of the function 'git_config_iter',
let's stop exporting it and remove the prototype from config.h.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: create config.hBrandon Williams Wed, 14 Jun 2017 18:07:34 +0000 (11:07 -0700)

config: create config.h

Move all config related declarations from cache.h to a new config.h
header file. This makes cache.h smaller and allows for the opportunity
in a following patch to only include config.h when needed.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

alias: use the early config machinery to expand aliasesJohannes Schindelin Wed, 14 Jun 2017 11:36:00 +0000 (13:36 +0200)

alias: use the early config machinery to expand aliases

Instead of discovering the .git/ directory, reading the config and then
trying to painstakingly reset all the global state if we did not find a
matching alias, let's use the early config machinery instead.

It may look like unnecessary work to discover the .git/ directory in the
early config machinery and then call setup_git_directory_gently() in the
case of a shell alias, repeating the very same discovery *again*.
However, we have to do this as the early config machinery takes pains
*not* to touch any global state, while shell aliases expect a possibly
changed working directory and at least the GIT_PREFIX and GIT_DIR
variables to be set.

This change also fixes a known issue where Git tried to read the pager
config from an incorrect path in a subdirectory of a Git worktree if an
alias expanded to a shell command.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7006: demonstrate a problem with aliases in subdirectoriesJohannes Schindelin Wed, 14 Jun 2017 11:35:56 +0000 (13:35 +0200)

t7006: demonstrate a problem with aliases in subdirectories

When expanding aliases, the git_dir is set during the alias expansion
(by virtue of running setup_git_directory_gently()).

This git_dir may be relative to the current working directory, and
indeed often is simply ".git/".

When the alias expands to a shell command, we restore the original
working directory, though, yet we do not reset git_dir.

As a consequence, subsequent read_early_config() runs will mistake the
git_dir to be populated properly and not find the correct config.

Demonstrate this problem by adding a test case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1308: relax the test verifying that empty alias values... Johannes Schindelin Wed, 14 Jun 2017 11:35:53 +0000 (13:35 +0200)

t1308: relax the test verifying that empty alias values are disallowed

We are about to change the way aliases are expanded, to use the early
config machinery.

This machinery reports errors in a slightly different manner than the
cached config machinery.

Let's not get hung up by the precise wording of the message mentioning
the line number. It is really sufficient to verify that all the relevant
information is given to the user.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

help: use early config when autocorrecting aliasesJohannes Schindelin Wed, 14 Jun 2017 11:35:50 +0000 (13:35 +0200)

help: use early config when autocorrecting aliases

Git has this feature which suggests similar commands (including aliases)
in case the user specified an unknown command.

This feature currently relies on a side effect of the way we expand
aliases right now: when a command is not a builtin, we use the regular
config machinery (meaning: discovering the .git/ directory and
initializing global state such as the config cache) to see whether the
command refers to an alias.

However, we will change the way aliases are expanded in the next
commits, to use the early config instead. That means that the
autocorrect feature can no longer discover the available aliases by
looking at the config cache (because it has not yet been initialized).

So let's just use the early config machinery instead.

This is slightly less performant than the previous way, as the early
config is used *twice*: once to see whether the command refers to an
alias, and then to see what aliases are most similar. However, this is
hardly a performance-critical code path, so performance is less important
here.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: report correct line number upon errorJohannes Schindelin Wed, 14 Jun 2017 11:35:46 +0000 (13:35 +0200)

config: report correct line number upon error

When get_value() parses a key/value pair, it is possible that the line
number is decreased (because the \n has been consumed already) before the
key/value pair is passed to the callback function, to allow for the
correct line to be attributed in case of an error.

However, when git_parse_source() asks get_value() to parse the key/value
pair, the error reporting is performed *after* get_value() returns.

Which means that we have to be careful not to increase the line number
in get_value() after the callback function returned an error.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

discover_git_directory(): avoid setting invalid git_dirJohannes Schindelin Wed, 14 Jun 2017 11:35:26 +0000 (13:35 +0200)

discover_git_directory(): avoid setting invalid git_dir

When discovering a .git/ directory, we take pains to ensure that its
repository format version matches Git's expectations, and we return NULL
otherwise.

However, we still appended the invalid path to the strbuf passed as
argument.

Let's just reset the strbuf to the state before we appended the .git/
directory that was eventually rejected.

There is another early return path in that function, when
setup_git_directory_gently_1() returns GIT_DIR_NONE or an error. In that
case, the gitdir parameter has not been touched, therefore there is no
need for an equivalent change in that code path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-svn: document special options for commit-diffAndreas Heiduk Wed, 14 Jun 2017 09:31:38 +0000 (11:31 +0200)

git-svn: document special options for commit-diff

Some options specific for `git svn commit-diff` where not documented
so far.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>

Sync with maintJunio C Hamano Tue, 13 Jun 2017 20:52:53 +0000 (13:52 -0700)

Sync with maint

Eighth batch for 2.14Junio C Hamano Tue, 13 Jun 2017 20:52:29 +0000 (13:52 -0700)

Eighth batch for 2.14

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

Merge branch 'jk/pack-idx-corruption-safety'Junio C Hamano Tue, 13 Jun 2017 20:47:10 +0000 (13:47 -0700)

Merge branch 'jk/pack-idx-corruption-safety'

A flaky test has been corrected.

* jk/pack-idx-corruption-safety:
t5313: make extended-table test more deterministic

Merge branch 'nd/fopen-errors'Junio C Hamano Tue, 13 Jun 2017 20:47:09 +0000 (13:47 -0700)

Merge branch 'nd/fopen-errors'

We often try to open a file for reading whose existence is
optional, and silently ignore errors from open/fopen; report such
errors if they are not due to missing files.

* nd/fopen-errors:
mingw_fopen: report ENOENT for invalid file names
mingw: verify that paths are not mistaken for remote nicknames
log: fix memory leak in open_next_file()
rerere.c: move error_errno() closer to the source system call
print errno when reporting a system call error
wrapper.c: make warn_on_inaccessible() static
wrapper.c: add and use fopen_or_warn()
wrapper.c: add and use warn_on_fopen_errors()
config.mak.uname: set FREAD_READS_DIRECTORIES for Darwin, too
config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD
clone: use xfopen() instead of fopen()
use xfopen() in more places
git_fopen: fix a sparse 'not declared' warning

Merge branch 'rf/completion'Junio C Hamano Tue, 13 Jun 2017 20:47:09 +0000 (13:47 -0700)

Merge branch 'rf/completion'

Completion updates.

* rf/completion:
completion: add git config credentialCache.ignoreSIGHUP
completion: add git config credential completions
completion: add git config advice completions
completion: add git config am.threeWay completion
completion: add git config core completions
completion: add git config gc completions

Merge branch 'jc/diff-tree-stale-comment'Junio C Hamano Tue, 13 Jun 2017 20:47:08 +0000 (13:47 -0700)

Merge branch 'jc/diff-tree-stale-comment'

Comment fix.

* jc/diff-tree-stale-comment:
diff-tree: update stale in-code comments

Merge branch 'sb/submodule-blanket-recursive'Junio C Hamano Tue, 13 Jun 2017 20:47:07 +0000 (13:47 -0700)

Merge branch 'sb/submodule-blanket-recursive'

Many commands learned to pay attention to submodule.recurse
configuration.

* sb/submodule-blanket-recursive:
builtin/fetch.c: respect 'submodule.recurse' option
builtin/push.c: respect 'submodule.recurse' option
builtin/grep.c: respect 'submodule.recurse' option
Introduce 'submodule.recurse' option for worktree manipulators
submodule loading: separate code path for .gitmodules and config overlay
reset/checkout/read-tree: unify config callback for submodule recursion
submodule test invocation: only pass additional arguments
submodule recursing: do not write a config variable twice

Merge branch 'jc/noent-notdir'Junio C Hamano Tue, 13 Jun 2017 20:47:06 +0000 (13:47 -0700)

Merge branch 'jc/noent-notdir'

Our code often opens a path to an optional file, to work on its
contents when we can successfully open it. We can ignore a failure
to open if such an optional file does not exist, but we do want to
report a failure in opening for other reasons (e.g. we got an I/O
error, or the file is there, but we lack the permission to open).

The exact errors we need to ignore are ENOENT (obviously) and
ENOTDIR (less obvious). Instead of repeating comparison of errno
with these two constants, introduce a helper function to do so.

* jc/noent-notdir:
treewide: use is_missing_file_error() where ENOENT and ENOTDIR are checked
compat-util: is_missing_file_error()

Prepare for 2.13.2Junio C Hamano Tue, 13 Jun 2017 20:30:16 +0000 (13:30 -0700)

Prepare for 2.13.2

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

Merge branch 'ad/pull-remote-doc' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:06 +0000 (13:27 -0700)

Merge branch 'ad/pull-remote-doc' into maint

Docfix.

* ad/pull-remote-doc:
docs: fix formatting and grammar

Merge branch 'jk/drop-free-refspecs' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:06 +0000 (13:27 -0700)

Merge branch 'jk/drop-free-refspecs' into maint

Code clean-up.

* jk/drop-free-refspecs:
remote: drop free_refspecs() function

Merge branch 'jk/connect-symref-info-leak-fix' into... Junio C Hamano Tue, 13 Jun 2017 20:27:05 +0000 (13:27 -0700)

Merge branch 'jk/connect-symref-info-leak-fix' into maint

Leakfix.

* jk/connect-symref-info-leak-fix:
connect.c: fix leak in parse_one_symref_info()

Merge branch 'rf/completion-config-commit' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:05 +0000 (13:27 -0700)

Merge branch 'rf/completion-config-commit' into maint

Completion update.

* rf/completion-config-commit:
completion: add completions for git config commit

Merge branch 'ab/t3070-test-dedup' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:04 +0000 (13:27 -0700)

Merge branch 'ab/t3070-test-dedup' into maint

Test cleanup.

* ab/t3070-test-dedup:
wildmatch test: remove redundant duplicate test

Merge branch 'jh/memihash-opt' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:03 +0000 (13:27 -0700)

Merge branch 'jh/memihash-opt' into maint

perf-test update.

* jh/memihash-opt:
p0004: don't error out if test repo is too small
p0004: don't abort if multi-threaded is too slow
p0004: use test_perf
p0004: avoid using pipes
p0004: simplify calls of test-lazy-init-name-hash

Merge branch 'tb/pull-ff-rebase-autostash' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:03 +0000 (13:27 -0700)

Merge branch 'tb/pull-ff-rebase-autostash' into maint

"git pull --rebase --autostash" didn't auto-stash when the local history
fast-forwards to the upstream.

* tb/pull-ff-rebase-autostash:
pull: ff --rebase --autostash works in dirty repo

Merge branch 'jh/close-index-before-stat' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:02 +0000 (13:27 -0700)

Merge branch 'jh/close-index-before-stat' into maint

The timestamp of the index file is now taken after the file is
closed, to help Windows, on which a stale timestamp is reported by
fstat() on a file that is opened for writing and data was written
but not yet closed.

* jh/close-index-before-stat:
read-cache: close index.lock in do_write_index

Merge branch 'sl/clean-d-ignored-fix' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:01 +0000 (13:27 -0700)

Merge branch 'sl/clean-d-ignored-fix' into maint

"git clean -d" used to clean directories that has ignored files,
even though the command should not lose ignored ones without "-x".
"git status --ignored" did not list ignored and untracked files
without "-uall". These have been corrected.

* sl/clean-d-ignored-fix:
clean: teach clean -d to preserve ignored paths
dir: expose cmp_name() and check_contains()
dir: hide untracked contents of untracked dirs
dir: recurse into untracked dirs for ignored files
t7061: status --ignored should search untracked dirs
t7300: clean -d should skip dirs with ignored files

Merge branch 'dk/send-email-avoid-net-smtp-ssl-when... Junio C Hamano Tue, 13 Jun 2017 20:27:01 +0000 (13:27 -0700)

Merge branch 'dk/send-email-avoid-net-smtp-ssl-when-able' into maint

A hotfix to a topic in 'master'.

* dk/send-email-avoid-net-smtp-ssl-when-able:
send-email: Net::SMTP::starttls was introduced in v2.34
send-email: Net::SMTP::SSL is obsolete, use only when necessary

Merge branch 'jc/skip-test-in-the-middle' into maintJunio C Hamano Tue, 13 Jun 2017 20:27:00 +0000 (13:27 -0700)

Merge branch 'jc/skip-test-in-the-middle' into maint

A recent update to t5545-push-options.sh started skipping all the
tests in the script when a web server testing is disabled or
unavailable, not just the ones that require a web server. Non HTTP
tests have been salvaged to always run in this script.

* jc/skip-test-in-the-middle:
t5545: enhance test coverage when no http server is installed
test: allow skipping the remainder

Merge branch 'bw/forking-and-threading' into maintJunio C Hamano Tue, 13 Jun 2017 20:26:59 +0000 (13:26 -0700)

Merge branch 'bw/forking-and-threading' into maint

The "run-command" API implementation has been made more robust
against dead-locking in a threaded environment.

* bw/forking-and-threading:
usage.c: drop set_error_handle()
run-command: restrict PATH search to executable files
run-command: expose is_executable function
run-command: block signals between fork and execve
run-command: add note about forking and threading
run-command: handle dup2 and close errors in child
run-command: eliminate calls to error handling functions in child
run-command: don't die in child when duping /dev/null
run-command: prepare child environment before forking
string-list: add string_list_remove function
run-command: use the async-signal-safe execv instead of execvp
run-command: prepare command before forking
t0061: run_command executes scripts without a #! line
t5550: use write_script to generate post-update hook

Merge branch 'jk/bug-to-abort' into maintJunio C Hamano Tue, 13 Jun 2017 20:26:59 +0000 (13:26 -0700)

Merge branch 'jk/bug-to-abort' into maint

Introduce the BUG() macro to improve die("BUG: ...").

* jk/bug-to-abort:
usage: add NORETURN to BUG() function definitions
config: complain about --local outside of a git repo
setup_git_env: convert die("BUG") to BUG()
usage.c: add BUG() function

Merge branch 'sb/checkout-recurse-submodules' into... Junio C Hamano Tue, 13 Jun 2017 20:26:59 +0000 (13:26 -0700)

Merge branch 'sb/checkout-recurse-submodules' into maint

"git checkout --recurse-submodules" did not quite work with a
submodule that itself has submodules.

* sb/checkout-recurse-submodules:
submodule: properly recurse for read-tree and checkout
submodule: avoid auto-discovery in new working tree manipulator code
submodule_move_head: reuse child_process structure for futher commands

ls-files: factor out tag calculationBrandon Williams Mon, 12 Jun 2017 22:14:08 +0000 (15:14 -0700)

ls-files: factor out tag calculation

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: factor out debug info into a functionBrandon Williams Mon, 12 Jun 2017 22:14:07 +0000 (15:14 -0700)

ls-files: factor out debug info into a function

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert show_files to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:06 +0000 (15:14 -0700)

ls-files: convert show_files to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert show_ce_entry to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:05 +0000 (15:14 -0700)

ls-files: convert show_ce_entry to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert prune_cache to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:04 +0000 (15:14 -0700)

ls-files: convert prune_cache to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert ce_excluded to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:03 +0000 (15:14 -0700)

ls-files: convert ce_excluded to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert show_ru_info to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:02 +0000 (15:14 -0700)

ls-files: convert show_ru_info to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert show_other_files to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:01 +0000 (15:14 -0700)

ls-files: convert show_other_files to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert show_killed_files to take an indexBrandon Williams Mon, 12 Jun 2017 22:14:00 +0000 (15:14 -0700)

ls-files: convert show_killed_files to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert write_eolinfo to take an indexBrandon Williams Mon, 12 Jun 2017 22:13:59 +0000 (15:13 -0700)

ls-files: convert write_eolinfo to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: convert overlay_tree_on_cache to take an... Brandon Williams Mon, 12 Jun 2017 22:13:58 +0000 (15:13 -0700)

ls-files: convert overlay_tree_on_cache to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree: convert read_tree to take an index parameterBrandon Williams Mon, 12 Jun 2017 22:13:57 +0000 (15:13 -0700)

tree: convert read_tree to take an index parameter

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: convert renormalize_buffer to take an indexBrandon Williams Mon, 12 Jun 2017 22:13:56 +0000 (15:13 -0700)

convert: convert renormalize_buffer to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: convert convert_to_git to take an indexBrandon Williams Mon, 12 Jun 2017 22:13:55 +0000 (15:13 -0700)

convert: convert convert_to_git to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: convert convert_to_git_filter_fd to take an... Brandon Williams Mon, 12 Jun 2017 22:13:54 +0000 (15:13 -0700)

convert: convert convert_to_git_filter_fd to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: convert crlf_to_git to take an indexBrandon Williams Mon, 12 Jun 2017 22:13:53 +0000 (15:13 -0700)

convert: convert crlf_to_git to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: convert get_cached_convert_stats_ascii to... Brandon Williams Mon, 12 Jun 2017 22:13:52 +0000 (15:13 -0700)

convert: convert get_cached_convert_stats_ascii to take an index

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'master' of git://bogomips.org/git-svnJunio C Hamano Sat, 10 Jun 2017 05:29:26 +0000 (14:29 +0900)

Merge branch 'master' of git://bogomips.org/git-svn

* 'master' of git://bogomips.org/git-svn:
doc: describe git svn init --ignore-refs

doc: describe git svn init --ignore-refsAndreas Heiduk Wed, 7 Jun 2017 18:32:14 +0000 (20:32 +0200)

doc: describe git svn init --ignore-refs

Add the missing documentation for `git svn init --ignore-refs`.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>

Sync with maintJunio C Hamano Wed, 7 Jun 2017 00:32:04 +0000 (09:32 +0900)

Sync with maint

* maint:
sha1dc: update from upstream
sha1dc: ignore indent-with-non-tab whitespace violations

Merge branch 'ab/sha1dc-maint' into maintJunio C Hamano Wed, 7 Jun 2017 00:31:53 +0000 (09:31 +0900)

Merge branch 'ab/sha1dc-maint' into maint

* ab/sha1dc-maint:
sha1dc: update from upstream
sha1dc: ignore indent-with-non-tab whitespace violations

sha1dc: update from upstreamÆvar Arnfjörð Bjarmason Tue, 6 Jun 2017 15:12:29 +0000 (15:12 +0000)

sha1dc: update from upstream

Update sha1dc from the latest version by the upstream
maintainer[1].

See commit a0103914c2 ("sha1dc: update from upstream", 2017-05-20) for
the latest update. That update was done sans some whitespace changes
by upstream, which is why the diff here isn't the same as the upstream
cc46554..e139984.

It also brings in a change[2] upstream made which should hopefully
address the breakage in 2.13.1 on Cygwin, see [3]. Cygwin defines both
_BIG_ENDIAN and _LITTLE_ENDIAN.

Adam Dinwoodie reports on the mailing list that that upstream commit
fixes the issue on Cygwin[4].

1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/e1399840b501a68ac6c8d7ed9a5cb1455480200e
2. https://github.com/cr-marcstevens/sha1collisiondetection/commit/a24eef58c0684078405f8c7a89f9b78271432005
3. <20170606100355.GC25777@dinwoodie.org> (https://public-inbox.org/git/20170606100355.GC25777@dinwoodie.org/)
4. <20170606124323.GD25777@dinwoodie.org> (https://public-inbox.org/git/20170606124323.GD25777@dinwoodie.org/)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1dc: ignore indent-with-non-tab whitespace violationsJeff King Tue, 6 Jun 2017 19:01:11 +0000 (15:01 -0400)

sha1dc: ignore indent-with-non-tab whitespace violations

The upstream sha1dc code indents some lines with spaces.
While this doesn't match Git's coding guidelines, it's better
to leave this imported code untouched than to try to make it
match our style. However, we can use .gitattributes to tell
"diff --check" and "git am" not to bother us about it.

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

t5313: make extended-table test more deterministicJeff King Mon, 5 Jun 2017 19:15:25 +0000 (15:15 -0400)

t5313: make extended-table test more deterministic

Commit a1283866b (t5313: test bounds-checks of
corrupted/malicious pack/idx files, 2016-02-25) added a test
that requires our corrupted pack index to have two objects.
The entry for the first one remains untouched, but we
corrupt the entry for second one. Since the index stores the
entries in sha1-sorted order, this means that the test must
make sure that the sha1 of the object we expect to be
corrupted ("$object") sorts after the other placeholder
object.

That commit used the HEAD commit as the placeholder, but the
script never calls test_tick. That means that the commit
object (and thus its sha1) depends on the timestamp when the
test script is run. This usually works in practice, because
the sha1 of $object starts with "fff". The commit object
will sort after that only 1 in 4096 times, but when it does
the test will fail.

One obvious solution is to add the test_tick call to get a
deterministic commit sha1. But since we're relying on the
sort order for the test to function, let's make that very
explicit by just generating a second blob with a known sha1.

Reported-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t0012: test "-h" with builtinsJeff King Tue, 30 May 2017 05:19:30 +0000 (01:19 -0400)

t0012: test "-h" with builtins

Since commit 99caeed05 (Let 'git <command> -h' show usage
without a git dir, 2009-11-09), the git wrapper handles "-h"
specially, skipping any repository setup but still calling
the builtin's cmd_foo() function. This means that every
cmd_foo() must be ready to handle this case, but we don't
have any systematic tests. This led to "git am -h" being
broken for some time without anybody noticing.

This patch just tests that "git foo -h" works for every
builtin, where we see a 129 exit code (the normal code for
our usage() helper), and that the word "usage" appears in
the output.

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

git: add hidden --list-builtins optionJeff King Tue, 30 May 2017 05:18:43 +0000 (01:18 -0400)

git: add hidden --list-builtins option

It can be useful in the test suite to be able to iterate
over the list of builtins. We could do this with some
Makefile magic. But since the authoritative list is in the
commands array inside git.c, and since this could also be
handy for debugging, let's add a hidden command-line option
to dump that list.

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

version: convert to parse-optionsJeff King Tue, 30 May 2017 05:17:42 +0000 (01:17 -0400)

version: convert to parse-options

The "git version" command didn't traditionally accept any
options, and in fact ignores any you give it. When we added
simple option parsing for "--build-options" in 6b9c38e14, we
didn't improve this; we just loop over the arguments and
pick out the one we recognize.

Instead, let's move to a real parsing loop, complain about
nonsense options, and recognize conventions like "-h".

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

diff- and log- family: handle "git cmd -h" earlyJunio C Hamano Thu, 1 Jun 2017 04:38:16 +0000 (13:38 +0900)

diff- and log- family: handle "git cmd -h" early

"git $builtin -h" bypasses the usual repository setup and calls the
cmd_$builtin() function, expecting it to show the help text.

Unfortunately the commands in the log- and the diff- family want to
call into the revisions machinery, which by definition needs to have
a repository already discovered. Strictly speaking, they may not
need a repository only for parsing "-h", but it is a good discipline
to future-proof codepath to ensure that setup_revisions() is called
after we know that a repository is there.

Handle the "git $builtin -h" special case very early in these
commands to work around potential issues.

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

diff: rename diff_fill_sha1_info to diff_fill_oid_infoBrandon Williams Tue, 30 May 2017 17:31:09 +0000 (10:31 -0700)

diff: rename diff_fill_sha1_info to diff_fill_oid_info

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diffcore-rename: use is_empty_blob_oidBrandon Williams Tue, 30 May 2017 17:31:08 +0000 (10:31 -0700)

diffcore-rename: use is_empty_blob_oid

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-diff: convert path_appendnew to object_idBrandon Williams Tue, 30 May 2017 17:31:07 +0000 (10:31 -0700)

tree-diff: convert path_appendnew to object_id

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-diff: convert diff_tree_paths to struct object_idBrandon Williams Tue, 30 May 2017 17:31:06 +0000 (10:31 -0700)

tree-diff: convert diff_tree_paths to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tree-diff: convert try_to_follow_renames to struct... Brandon Williams Tue, 30 May 2017 17:31:05 +0000 (10:31 -0700)

tree-diff: convert try_to_follow_renames to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/diff-tree: cleanup references to sha1Brandon Williams Tue, 30 May 2017 17:31:04 +0000 (10:31 -0700)

builtin/diff-tree: cleanup references to sha1

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff-tree: convert diff_tree_sha1 to struct object_idBrandon Williams Tue, 30 May 2017 17:31:03 +0000 (10:31 -0700)

diff-tree: convert diff_tree_sha1 to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>