git
5 years agoMerge branch 'dl/difftool-mergetool'
Junio C Hamano [Sun, 19 May 2019 07:45:30 +0000 (16:45 +0900)] 
Merge branch 'dl/difftool-mergetool'

Update "git difftool" and "git mergetool" so that the combinations
of {diff,merge}.{tool,guitool} configuration variables serve as
fallback settings of each other in a sensible order.

* dl/difftool-mergetool:
  difftool: fallback on merge.guitool
  difftool: make --gui, --tool and --extcmd mutually exclusive
  mergetool: fallback to tool when guitool unavailable
  mergetool--lib: create gui_mode function
  mergetool: use get_merge_tool function
  t7610: add mergetool --gui tests
  t7610: unsuppress output

5 years agoMerge branch 'mh/http-fread-api-fix'
Junio C Hamano [Sun, 19 May 2019 07:45:29 +0000 (16:45 +0900)] 
Merge branch 'mh/http-fread-api-fix'

A pair of private functions in http.c that had names similar to
fread/fwrite did not return the number of elements, which was found
to be confusing.

* mh/http-fread-api-fix:
  Make fread/fwrite-like functions in http.c more like fread/fwrite.

5 years agoMerge branch 'js/t6500-use-windows-pid-on-mingw'
Junio C Hamano [Sun, 19 May 2019 07:45:29 +0000 (16:45 +0900)] 
Merge branch 'js/t6500-use-windows-pid-on-mingw'

Future-proof a test against an update to MSYS2 runtime v3.x series.

* js/t6500-use-windows-pid-on-mingw:
  t6500(mingw): use the Windows PID of the shell

5 years agoMerge branch 'jk/apache-lsan'
Junio C Hamano [Sun, 19 May 2019 07:45:29 +0000 (16:45 +0900)] 
Merge branch 'jk/apache-lsan'

Allow tests that involve httpd to be run under leak sanitizer, just
like we can already do so under address sanitizer.

* jk/apache-lsan:
  t/lib-httpd: pass LSAN_OPTIONS through apache

5 years agoMerge branch 'nd/parse-options-aliases'
Junio C Hamano [Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)] 
Merge branch 'nd/parse-options-aliases'

Attempt to use an abbreviated option in "git clone --recurs" is
responded by a request to disambiguate between --recursive and
--recurse-submodules, which is bad because these two are synonyms.
The parse-options API has been extended to define such synonyms
more easily and not produce an unnecessary failure.

* nd/parse-options-aliases:
  parse-options: don't emit "ambiguous option" for aliases

5 years agoMerge branch 'dl/branch-from-3dot-merge-base'
Junio C Hamano [Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)] 
Merge branch 'dl/branch-from-3dot-merge-base'

"git branch new A...B" and "git checkout -b new A...B" have been
taught that in their contexts, the notation A...B means "the merge
base between these two commits", just like "git checkout A...B"
detaches HEAD at that commit.

* dl/branch-from-3dot-merge-base:
  branch: make create_branch accept a merge base rev
  t2018: cleanup in current test

5 years agoMerge branch 'js/commit-graph-parse-leakfix'
Junio C Hamano [Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)] 
Merge branch 'js/commit-graph-parse-leakfix'

Leakfix.

* js/commit-graph-parse-leakfix:
  commit-graph: fix memory leak

5 years agoMerge branch 'jk/cocci-batch'
Junio C Hamano [Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)] 
Merge branch 'jk/cocci-batch'

Optionally "make coccicheck" can feed multiple source files to
spatch, gaining performance while spending more memory.

* jk/cocci-batch:
  coccicheck: make batch size of 0 mean "unlimited"
  coccicheck: optionally batch spatch invocations

5 years agoMerge branch 'ab/perf-installed-fix'
Junio C Hamano [Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)] 
Merge branch 'ab/perf-installed-fix'

Performance test framework has been broken and measured the version
of Git that happens to be on $PATH, not the specified one to
measure, for a while, which has been corrected.

* ab/perf-installed-fix:
  perf-lib.sh: forbid the use of GIT_TEST_INSTALLED
  perf tests: add "bindir" prefix to git tree test results
  perf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh
  perf-lib.sh: make "./run <revisions>" use the correct gits
  perf aggregate: remove GIT_TEST_INSTALLED from --codespeed
  perf README: correct docs for 3c8f12c96c regression

5 years agoMerge branch 'id/windows-dep-aslr'
Junio C Hamano [Sun, 19 May 2019 07:45:27 +0000 (16:45 +0900)] 
Merge branch 'id/windows-dep-aslr'

Allow DEP and ASLR for Windows build to for security hardening.

* id/windows-dep-aslr:
  mingw: enable DEP and ASLR
  mingw: do not let ld strip relocations

5 years agoMerge branch 'ab/trace2-typofix'
Junio C Hamano [Sun, 19 May 2019 07:45:27 +0000 (16:45 +0900)] 
Merge branch 'ab/trace2-typofix'

Typofix.

* ab/trace2-typofix:
  trace2: fix up a missing "leave" entry point

5 years agoMerge branch 'nd/submodule-helper-incomplete-line-fix'
Junio C Hamano [Sun, 19 May 2019 07:45:27 +0000 (16:45 +0900)] 
Merge branch 'nd/submodule-helper-incomplete-line-fix'

Typofix.

* nd/submodule-helper-incomplete-line-fix:
  submodule--helper: add a missing \n

5 years agoMerge branch 'cw/diff-highlight'
Junio C Hamano [Sun, 19 May 2019 07:45:26 +0000 (16:45 +0900)] 
Merge branch 'cw/diff-highlight'

Portability fix for a diff-highlight tool (in contrib/).

* cw/diff-highlight:
  diff-highlight: use correct /dev/null for UNIX and Windows

5 years agoMerge branch 'dl/warn-tagging-a-tag'
Junio C Hamano [Sun, 19 May 2019 07:45:26 +0000 (16:45 +0900)] 
Merge branch 'dl/warn-tagging-a-tag'

Typofix.

* dl/warn-tagging-a-tag:
  tag: fix typo in nested tagging hint

5 years agoGit 2.22-rc0 v2.22.0-rc0
Junio C Hamano [Mon, 13 May 2019 14:40:13 +0000 (23:40 +0900)] 
Git 2.22-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'jh/trace2'
Junio C Hamano [Mon, 13 May 2019 14:50:35 +0000 (23:50 +0900)] 
Merge branch 'jh/trace2'

A few embarrassing bugfixes.

* jh/trace2:
  trace2: fix up a missing "leave" entry point
  trace2: fix incorrect function pointer check

5 years agoMerge branch 'cc/access-on-aix-workaround'
Junio C Hamano [Mon, 13 May 2019 14:50:35 +0000 (23:50 +0900)] 
Merge branch 'cc/access-on-aix-workaround'

Workaround for standard-compliant but less-than-useful behaviour of
access(2) for the root user.

* cc/access-on-aix-workaround:
  git-compat-util: work around for access(X_OK) under root

5 years agoMerge branch 'pw/clean-sequencer-state-upon-final-commit'
Junio C Hamano [Mon, 13 May 2019 14:50:35 +0000 (23:50 +0900)] 
Merge branch 'pw/clean-sequencer-state-upon-final-commit'

"git chery-pick" (and "revert" that shares the same runtime engine)
that deals with multiple commits got confused when the final step
gets stopped with a conflict and the user concluded the sequence
with "git commit".  Attempt to fix it by cleaning up the state
files used by these commands in such a situation.

* pw/clean-sequencer-state-upon-final-commit:
  fix cherry-pick/revert status after commit
  commit/reset: try to clean up sequencer state

5 years agoMerge branch 'pw/rebase-i-internal'
Junio C Hamano [Mon, 13 May 2019 14:50:34 +0000 (23:50 +0900)] 
Merge branch 'pw/rebase-i-internal'

The internal implementation of "git rebase -i" has been updated to
avoid forking a separate "rebase--interactive" process.

* pw/rebase-i-internal:
  rebase -i: run without forking rebase--interactive
  rebase: use a common action enum
  rebase -i: use struct rebase_options in do_interactive_rebase()
  rebase -i: use struct rebase_options to parse args
  rebase -i: use struct object_id for squash_onto
  rebase -i: use struct commit when parsing options
  rebase -i: remove duplication
  rebase -i: combine rebase--interactive.c with rebase.c
  rebase: use OPT_RERERE_AUTOUPDATE()
  rebase: rename write_basic_state()
  rebase: don't translate trace strings
  sequencer: always discard index after checkout

5 years agoMerge branch 'jk/perf-aggregate-wo-libjson'
Junio C Hamano [Mon, 13 May 2019 14:50:34 +0000 (23:50 +0900)] 
Merge branch 'jk/perf-aggregate-wo-libjson'

The script to aggregate perf result unconditionally depended on
libjson-perl even though it did not have to, which has been
corrected.

* jk/perf-aggregate-wo-libjson:
  t/perf: depend on perl JSON only when using --codespeed

5 years agoMerge branch 'dl/rev-tilde-doc-clarify'
Junio C Hamano [Mon, 13 May 2019 14:50:33 +0000 (23:50 +0900)] 
Merge branch 'dl/rev-tilde-doc-clarify'

Docfix.

* dl/rev-tilde-doc-clarify:
  revisions.txt: remove ambibuity between <rev>:<path> and :<path>
  revisions.txt: mention <rev>~ form
  revisions.txt: mark optional rev arguments with []
  revisions.txt: change "rev" to "<rev>"

5 years agoMerge branch 'jc/make-dedup-ls-files-output'
Junio C Hamano [Mon, 13 May 2019 14:50:33 +0000 (23:50 +0900)] 
Merge branch 'jc/make-dedup-ls-files-output'

A "ls-files" that emulates "find" to enumerate files in the working
tree resulted in duplicated Makefile rules that caused the build to
issue an unnecessary warning during a trial build after merge
conflicts are resolved in working tree *.h files but before the
resolved results are added to the index.  This has been corrected.

* jc/make-dedup-ls-files-output:
  Makefile: dedup list of files obtained from ls-files

5 years agoMerge branch 'jk/ls-files-doc-markup-fix'
Junio C Hamano [Mon, 13 May 2019 14:50:33 +0000 (23:50 +0900)] 
Merge branch 'jk/ls-files-doc-markup-fix'

Docfix.

* jk/ls-files-doc-markup-fix:
  doc/ls-files: put nested list for "-t" option into block

5 years agoMerge branch 'jk/p5302-avoid-collision-check-cost'
Junio C Hamano [Mon, 13 May 2019 14:50:32 +0000 (23:50 +0900)] 
Merge branch 'jk/p5302-avoid-collision-check-cost'

Fix index-pack perf test so that the repeated invocations always
run in an empty repository, which emulates the initial clone
situation better.

* jk/p5302-avoid-collision-check-cost:
  p5302: create the repo in each index-pack test

5 years agoMerge branch 'dl/no-extern-in-func-decl'
Junio C Hamano [Mon, 13 May 2019 14:50:32 +0000 (23:50 +0900)] 
Merge branch 'dl/no-extern-in-func-decl'

Mechanically and systematically drop "extern" from function
declarlation.

* dl/no-extern-in-func-decl:
  *.[ch]: manually align parameter lists
  *.[ch]: remove extern from function declarations using sed
  *.[ch]: remove extern from function declarations using spatch

5 years agoMerge branch 'ew/repack-with-bitmaps-by-default'
Junio C Hamano [Mon, 13 May 2019 14:50:32 +0000 (23:50 +0900)] 
Merge branch 'ew/repack-with-bitmaps-by-default'

The connectivity bitmaps are created by default in bare
repositories now; also the pathname hash-cache is created by
default to avoid making crappy deltas when repacking.

* ew/repack-with-bitmaps-by-default:
  pack-objects: default to writing bitmap hash-cache
  t5310: correctly remove bitmaps for jgit test
  repack: enable bitmaps by default on bare repos

5 years agoMerge branch 'js/partial-clone-connectivity-check'
Junio C Hamano [Mon, 13 May 2019 14:50:31 +0000 (23:50 +0900)] 
Merge branch 'js/partial-clone-connectivity-check'

During an initial "git clone --depth=..." partial clone, it is
pointless to spend cycles for a large portion of the connectivity
check that enumerates and skips promisor objects (which by
definition is all objects fetched from the other side).  This has
been optimized out.

* js/partial-clone-connectivity-check:
  t/perf: add perf script for partial clones
  clone: do faster object check for partial clones

5 years agoMerge branch 'jh/trace2-sid-fix'
Junio C Hamano [Mon, 13 May 2019 14:50:31 +0000 (23:50 +0900)] 
Merge branch 'jh/trace2-sid-fix'

Polishing of the new trace2 facility continues.  The system-level
configuration can specify site-wide trace2 settings, which can be
overridden with per-user configuration and environment variables.

* jh/trace2-sid-fix:
  trace2: fixup access problem on /etc/gitconfig in read_very_early_config
  trace2: update docs to describe system/global config settings
  trace2: make SIDs more unique
  trace2: clarify UTC datetime formatting
  trace2: report peak memory usage of the process
  trace2: use system/global config for default trace2 settings
  config: add read_very_early_config()
  trace2: find exec-dir before trace2 initialization
  trace2: add absolute elapsed time to start event
  trace2: refactor setting process starting time
  config: initialize opts structure in repo_read_config()

5 years agodifftool: fallback on merge.guitool
Denton Liu [Mon, 29 Apr 2019 06:21:20 +0000 (02:21 -0400)] 
difftool: fallback on merge.guitool

In git-difftool.txt, it says

'git difftool' falls back to 'git mergetool' config variables when the
difftool equivalents have not been defined.

However, when `diff.guitool` is missing, it doesn't fallback to
anything. Make git-difftool fallback to `merge.guitool` when `diff.guitool` is
missing.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodifftool: make --gui, --tool and --extcmd mutually exclusive
Denton Liu [Mon, 29 Apr 2019 06:21:17 +0000 (02:21 -0400)] 
difftool: make --gui, --tool and --extcmd mutually exclusive

In git-difftool, these options specify which tool to ultimately run. As
a result, they are logically conflicting. Explicitly disallow these
options from being used together.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agomergetool: fallback to tool when guitool unavailable
Denton Liu [Mon, 29 Apr 2019 06:21:14 +0000 (02:21 -0400)] 
mergetool: fallback to tool when guitool unavailable

In git-difftool, if the tool is called with --gui but `diff.guitool` is
not set, it falls back to `diff.tool`. Make git-mergetool also fallback
from `merge.guitool` to `merge.tool` if the former is undefined.

If git-difftool, when called with `--gui`, were to use
`get_configured_mergetool` in a future patch, it would also get the
fallback behavior in the following precedence:

1. diff.guitool
2. merge.guitool
3. diff.tool
4. merge.tool

The behavior for when difftool or mergetool are called without `--gui`
should be identical with or without this patch.

Note that the search loop could be written as

sections="merge"
keys="tool"
if diff_mode
then
sections="diff $sections"
fi
if gui_mode
then
keys="guitool $keys"
fi

merge_tool=$(
IFS=' '
for key in $keys
do
for section in $sections
do
selected=$(git config $section.$key)
if test -n "$selected"
then
echo "$selected"
return
fi
done
done)

which would make adding a mode in the future much easier. However,
adding a new mode will likely never happen as it is highly discouraged
so, as a result, it is written in its current form so that it is more
readable for future readers.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agomergetool--lib: create gui_mode function
Denton Liu [Mon, 29 Apr 2019 06:21:11 +0000 (02:21 -0400)] 
mergetool--lib: create gui_mode function

Before, in `get_configured_merge_tool`, we would test the value of the
first argument directly, which corresponded to whether we were using
guitool. However, since `$GIT_MERGETOOL_GUI` is available as an
environment variable, create the `gui_mode` function which increases the
clarify of functions which use it.

While we're at it, add a space before `()` in function definitions to
fix the style.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agomergetool: use get_merge_tool function
Denton Liu [Mon, 29 Apr 2019 06:21:08 +0000 (02:21 -0400)] 
mergetool: use get_merge_tool function

In git-mergetool, the logic for getting which merge tool to use is
duplicated in git-mergetool--lib, except for the fact that it needs to
know whether the tool was guessed or not.

Rewrite `get_merge_tool` to return whether or not the tool was guessed
through the return code and make git-mergetool call this function
instead of duplicating the logic. Note that 1 was chosen to be the
return code of when a tool is guessed because it seems like a slightly
more abnormal condition than getting a tool that's explicitly specified
but this is completely arbitrary.

Also, let `$GIT_MERGETOOL_GUI` be set to determine whether or not the
guitool will be selected.

This change is not completely backwards compatible as there may be
external users of git-mergetool--lib. However, only one user,
git-diffall[1], was found from searching GitHub and Google, and this
tool is superseded by `git difftool --dir-diff` anyway. It seems very
unlikely that there exists an external caller that would take into
account the return code of `get_merge_tool` as it would always return 0
before this change so this change probably does not affect any external
users.

[1]: https://github.com/thenigan/git-diffall

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotrace2: fix up a missing "leave" entry point
Ævar Arnfjörð Bjarmason [Fri, 10 May 2019 13:37:38 +0000 (15:37 +0200)] 
trace2: fix up a missing "leave" entry point

Fix a trivial bug that's been here since the shared/do_write_index
tracing was added in 42fee7a388 ("trace2:data: add trace2
instrumentation to index read/write", 2019-02-22). We should have
enter/leave points, not two enter/enter points. This resulted in an
"enter" event without a corresponding "leave" event.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agomingw: enable DEP and ASLR
İsmail Dönmez [Wed, 8 May 2019 11:30:59 +0000 (04:30 -0700)] 
mingw: enable DEP and ASLR

Enable DEP (Data Execution Prevention) and ASLR (Address Space Layout
Randomization) support. This applies to both 32bit and 64bit builds
and makes it substantially harder to exploit security holes in Git by
offering a much more unpredictable attack surface.

ASLR interferes with GDB's ability to set breakpoints. A similar issue
holds true when compiling with -O2 (in which case single-stepping is
messed up because GDB cannot map the code back to the original source
code properly). Therefore we simply enable ASLR only when an
optimization flag is present in the CFLAGS, using it as an indicator
that the developer does not want to debug in GDB anyway.

Signed-off-by: İsmail Dönmez <ismail@i10z.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agomingw: do not let ld strip relocations
İsmail Dönmez [Wed, 8 May 2019 11:30:58 +0000 (04:30 -0700)] 
mingw: do not let ld strip relocations

This is the first step for enabling ASLR (Address Space Layout
Randomization) support. We want to enable ASLR for better protection
against exploiting security holes in Git: it makes it harder to attack
software by making code addresses unpredictable.

The problem fixed by this commit is that `ld.exe` seems to be stripping
relocations which in turn will break ASLR support. We just make sure
it's not stripping the main executable entry.

Signed-off-by: İsmail Dönmez <ismail@i10z.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotrace2: fix up a missing "leave" entry point
Ævar Arnfjörð Bjarmason [Fri, 10 May 2019 13:37:38 +0000 (15:37 +0200)] 
trace2: fix up a missing "leave" entry point

Fix a trivial bug that's been here since the shared/do_write_index
tracing was added in 42fee7a388 ("trace2:data: add trace2
instrumentation to index read/write", 2019-02-22). We should have
enter/leave points, not two enter/enter points. This resulted in an
"enter" event without a corresponding "leave" event.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotag: fix typo in nested tagging hint
Denton Liu [Wed, 8 May 2019 19:16:41 +0000 (15:16 -0400)] 
tag: fix typo in nested tagging hint

In eea9c1e78f (tag: advise on nested tags, 2019-04-04), tag was taught
to hint at the user if a nested tag is made. However, this message had a
typo and it said "The object referred to by your new is...", which was
missing a "tag" after "new". Fix this message by adding the "tag".

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodiff-highlight: use correct /dev/null for UNIX and Windows
Chris. Webster [Wed, 31 Oct 2018 14:58:00 +0000 (23:58 +0900)] 
diff-highlight: use correct /dev/null for UNIX and Windows

Use File::Spec->devnull() for output redirection to avoid messages
when Windows version of Perl is first in path.  The message 'The
system cannot find the path specified.' is displayed each time git is
run to get colors.

Signed-off-by: Chris. Webster <chris@webstech.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoThe eighth batch
Junio C Hamano [Wed, 8 May 2019 15:37:54 +0000 (00:37 +0900)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'vk/autoconf-gettext'
Junio C Hamano [Wed, 8 May 2019 15:37:29 +0000 (00:37 +0900)] 
Merge branch 'vk/autoconf-gettext'

The autoconf generated configure script failed to use the right
gettext() implementations from -libintl by ignoring useless stub
implementations shipped in some C library, which has been
corrected.

* vk/autoconf-gettext:
  autoconf: #include <libintl.h> when checking for gettext()

5 years agoMerge branch 'cc/aix-has-fileno-as-a-macro'
Junio C Hamano [Wed, 8 May 2019 15:37:28 +0000 (00:37 +0900)] 
Merge branch 'cc/aix-has-fileno-as-a-macro'

AIX shared the same build issues with other BSDs around fileno(fp),
which has been corrected.

* cc/aix-has-fileno-as-a-macro:
  Makefile: use fileno macro work around on AIX

5 years agoMerge branch 'jt/submodule-repo-is-with-worktree'
Junio C Hamano [Wed, 8 May 2019 15:37:28 +0000 (00:37 +0900)] 
Merge branch 'jt/submodule-repo-is-with-worktree'

The logic to tell if a Git repository has a working tree protects
"git branch -D" from removing the branch that is currently checked
out by mistake.  The implementation of this logic was broken for
repositories with unusual name, which unfortunately is the norm for
submodules these days.  This has been fixed.

* jt/submodule-repo-is-with-worktree:
  worktree: update is_bare heuristics

5 years agoMerge branch 'jk/untracked-cache-more-fixes'
Junio C Hamano [Wed, 8 May 2019 15:37:28 +0000 (00:37 +0900)] 
Merge branch 'jk/untracked-cache-more-fixes'

Code clean-up.

* jk/untracked-cache-more-fixes:
  untracked-cache: simplify parsing by dropping "len"
  untracked-cache: simplify parsing by dropping "next"
  untracked-cache: be defensive about missing NULs in index

5 years agoMerge branch 'jk/prune-optim'
Junio C Hamano [Wed, 8 May 2019 15:37:27 +0000 (00:37 +0900)] 
Merge branch 'jk/prune-optim'

A follow-up test for an earlier "git prune" improvements.

* jk/prune-optim:
  t5304: add a test for pruning with bitmaps

5 years agoMerge branch 'js/misc-doc-fixes'
Junio C Hamano [Wed, 8 May 2019 15:37:27 +0000 (00:37 +0900)] 
Merge branch 'js/misc-doc-fixes'

"make check-docs", "git help -a", etc. did not account for cases
where a particular build may deliberately omit some subcommands,
which has been corrected.

* js/misc-doc-fixes:
  Turn `git serve` into a test helper
  test-tool: handle the `-C <directory>` option just like `git`
  check-docs: do not bother checking for legacy scripts' documentation
  docs: exclude documentation for commands that have been excluded
  check-docs: allow command-list.txt to contain excluded commands
  help -a: do not list commands that are excluded from the build
  Makefile: drop the NO_INSTALL variable
  remote-testgit: move it into the support directory for t5801

5 years agoMerge branch 'dr/ref-filter-push-track-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:26 +0000 (00:37 +0900)] 
Merge branch 'dr/ref-filter-push-track-fix'

%(push:track) token used in the --format option to "git
for-each-ref" and friends was not showing the right branch, which
has been fixed.

* dr/ref-filter-push-track-fix:
  ref-filter: use correct branch for %(push:track)

5 years agoMerge branch 'ss/msvc-path-utils-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:26 +0000 (00:37 +0900)] 
Merge branch 'ss/msvc-path-utils-fix'

An earlier update for MinGW and Cygwin accidentally broke MSVC build,
which has been fixed.

* ss/msvc-path-utils-fix:
  MSVC: include compat/win32/path-utils.h for MSVC, too, for real_path()

5 years agoMerge branch 'jt/clone-server-option'
Junio C Hamano [Wed, 8 May 2019 15:37:25 +0000 (00:37 +0900)] 
Merge branch 'jt/clone-server-option'

"git clone" learned a new --server-option option when talking over
the protocol version 2.

* jt/clone-server-option:
  clone: send server options when using protocol v2
  transport: die if server options are unsupported

5 years agoMerge branch 'tb/unexpected'
Junio C Hamano [Wed, 8 May 2019 15:37:25 +0000 (00:37 +0900)] 
Merge branch 'tb/unexpected'

Code tightening against a "wrong" object appearing where an object
of a different type is expected, instead of blindly assuming that
the connection between objects are correctly made.

* tb/unexpected:
  rev-list: detect broken root trees
  rev-list: let traversal die when --missing is not in use
  get_commit_tree(): return NULL for broken tree
  list-objects.c: handle unexpected non-tree entries
  list-objects.c: handle unexpected non-blob entries
  t: introduce tests for unexpected object types
  t: move 'hex2oct' into test-lib-functions.sh

5 years agoMerge branch 'nd/sha1-name-c-wo-the-repository'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)] 
Merge branch 'nd/sha1-name-c-wo-the-repository'

Further code clean-up to allow the lowest level of name-to-object
mapping layer to work with a passed-in repository other than the
default one.

* nd/sha1-name-c-wo-the-repository: (34 commits)
  sha1-name.c: remove the_repo from get_oid_mb()
  sha1-name.c: remove the_repo from other get_oid_*
  sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name
  submodule-config.c: use repo_get_oid for reading .gitmodules
  sha1-name.c: add repo_get_oid()
  sha1-name.c: remove the_repo from get_oid_with_context_1()
  sha1-name.c: remove the_repo from resolve_relative_path()
  sha1-name.c: remove the_repo from diagnose_invalid_index_path()
  sha1-name.c: remove the_repo from handle_one_ref()
  sha1-name.c: remove the_repo from get_oid_1()
  sha1-name.c: remove the_repo from get_oid_basic()
  sha1-name.c: remove the_repo from get_describe_name()
  sha1-name.c: remove the_repo from get_oid_oneline()
  sha1-name.c: add repo_interpret_branch_name()
  sha1-name.c: remove the_repo from interpret_branch_mark()
  sha1-name.c: remove the_repo from interpret_nth_prior_checkout()
  sha1-name.c: remove the_repo from get_short_oid()
  sha1-name.c: add repo_for_each_abbrev()
  sha1-name.c: store and use repo in struct disambiguate_state
  sha1-name.c: add repo_find_unique_abbrev_r()
  ...

5 years agoMerge branch 'cc/replace-graft-peel-tags'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)] 
Merge branch 'cc/replace-graft-peel-tags'

When given a tag that points at a commit-ish, "git replace --graft"
failed to peel the tag before writing a replace ref, which did not
make sense because the old graft mechanism the feature wants to
mimick only allowed to replace one commit object with another.
This has been fixed.

* cc/replace-graft-peel-tags:
  replace: peel tag when passing a tag first to --graft
  replace: peel tag when passing a tag as parent to --graft
  t6050: redirect expected error output to a file
  t6050: use test_line_count instead of wc -l

5 years agoMerge branch 'js/trace2-to-directory'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)] 
Merge branch 'js/trace2-to-directory'

The trace2 tracing facility learned to auto-generate a filename
when told to log to a directory.

* js/trace2-to-directory:
  trace2: write to directory targets

5 years agoMerge branch 'dl/merge-cleanup-scissors-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)] 
Merge branch 'dl/merge-cleanup-scissors-fix'

The list of conflicted paths shown in the editor while concluding a
conflicted merge was shown above the scissors line when the
clean-up mode is set to "scissors", even though it was commented
out just like the list of updated paths and other information to
help the user explain the merge better.

* dl/merge-cleanup-scissors-fix:
  cherry-pick/revert: add scissors line on merge conflict
  sequencer.c: save and restore cleanup mode
  merge: add scissors line on merge conflict
  merge: cleanup messages like commit
  parse-options.h: extract common --cleanup option
  commit: extract cleanup_mode functions to sequencer
  t7502: clean up style
  t7604: clean up style
  t3507: clean up style
  t7600: clean up style

5 years agoMerge branch 'pw/sequencer-cleanup-with-signoff-x-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)] 
Merge branch 'pw/sequencer-cleanup-with-signoff-x-fix'

"git cherry-pick" run with the "-x" or the "--signoff" option used
to (and more importantly, ought to) clean up the commit log message
with the --cleanup=space option by default, but this has been
broken since late 2017.  This has been fixed.

* pw/sequencer-cleanup-with-signoff-x-fix:
  sequencer: fix cleanup with --signoff and -x

5 years agoMerge branch 'jk/pack-objects-reports-num-objects-to-trace2'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)] 
Merge branch 'jk/pack-objects-reports-num-objects-to-trace2'

The "git pack-objects" command learned to report the number of
objects it packed via the trace2 mechanism.

* jk/pack-objects-reports-num-objects-to-trace2:
  pack-objects: write objects packed to trace2

5 years agoMerge branch 'tz/git-svn-doc-markup-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)] 
Merge branch 'tz/git-svn-doc-markup-fix'

Doc formatting fix.

* tz/git-svn-doc-markup-fix:
  Documentation/git-svn: improve asciidoctor compatibility

5 years agoMerge branch 'km/empty-repo-is-still-a-repo'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)] 
Merge branch 'km/empty-repo-is-still-a-repo'

Running "git add" on a repository created inside the current
repository is an explicit indication that the user wants to add it
as a submodule, but when the HEAD of the inner repository is on an
unborn branch, it cannot be added as a submodule.  Worse, the files
in its working tree can be added as if they are a part of the outer
repository, which is not what the user wants.  These problems are
being addressed.

* km/empty-repo-is-still-a-repo:
  add: error appropriately on repository with no commits
  dir: do not traverse repositories with no commits
  submodule: refuse to add repository with no commits

5 years agoMerge branch 'dl/warn-tagging-a-tag'
Junio C Hamano [Wed, 8 May 2019 15:37:22 +0000 (00:37 +0900)] 
Merge branch 'dl/warn-tagging-a-tag'

"git tag" learned to give an advice suggesting it might be a
mistake when creating an annotated or signed tag that points at
another tag.

* dl/warn-tagging-a-tag:
  tag: advise on nested tags
  tag: fix formatting

5 years agoMerge branch 'en/merge-directory-renames'
Junio C Hamano [Wed, 8 May 2019 15:37:22 +0000 (00:37 +0900)] 
Merge branch 'en/merge-directory-renames'

"git merge-recursive" backend recently learned a new heuristics to
infer file movement based on how other files in the same directory
moved.  As this is inherently less robust heuristics than the one
based on the content similarity of the file itself (rather than
based on what its neighbours are doing), it sometimes gives an
outcome unexpected by the end users.  This has been toned down to
leave the renamed paths in higher/conflicted stages in the index so
that the user can examine and confirm the result.

* en/merge-directory-renames:
  merge-recursive: switch directory rename detection default
  merge-recursive: give callers of handle_content_merge() access to contents
  merge-recursive: track information associated with directory renames
  t6043: fix copied test description to match its purpose
  merge-recursive: switch from (oid,mode) pairs to a diff_filespec
  merge-recursive: cleanup handle_rename_* function signatures
  merge-recursive: track branch where rename occurred in rename struct
  merge-recursive: remove ren[12]_other fields from rename_conflict_info
  merge-recursive: shrink rename_conflict_info
  merge-recursive: move some struct declarations together
  merge-recursive: use 'ci' for rename_conflict_info variable name
  merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf'
  merge-recursive: rename diff_filespec 'one' to 'o'
  merge-recursive: rename merge_options argument from 'o' to 'opt'
  Use 'unsigned short' for mode, like diff_filespec does

5 years agosubmodule--helper: add a missing \n
Nguyễn Thái Ngọc Duy [Tue, 7 May 2019 09:50:37 +0000 (16:50 +0700)] 
submodule--helper: add a missing \n

This is a complete line. We're not expecting the next function to add
anything to the same line.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agococcicheck: make batch size of 0 mean "unlimited"
Jeff King [Wed, 8 May 2019 07:07:54 +0000 (03:07 -0400)] 
coccicheck: make batch size of 0 mean "unlimited"

If you have the memory to handle it, the ideal case is to run a single
spatch invocation with all of the source files. But the only way to do
so now is to pick an arbitrarily large batch size. Let's make "0" do
this, which is a little friendlier (and doesn't otherwise have a useful
meaning).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot6500(mingw): use the Windows PID of the shell
Johannes Schindelin [Tue, 7 May 2019 21:51:30 +0000 (14:51 -0700)] 
t6500(mingw): use the Windows PID of the shell

In Git for Windows, we use the MSYS2 Bash which inherits a non-standard
PID model from Cygwin's POSIX emulation layer: every MSYS2 process has a
regular Windows PID, and in addition it has an MSYS2 PID (which
corresponds to a shadow process that emulates Unix-style signal
handling).

With the upgrade to the MSYS2 runtime v3.x, this shadow process cannot
be accessed via `OpenProcess()` any longer, and therefore t6500 thought
incorrectly that the process referenced in `gc.pid` (which is not
actually a real `gc` process in this context, but the current shell) no
longer exists.

Let's fix this by making sure that the Windows PID is written into
`gc.pid` in this test script so that `git.exe` is able to understand
that that process does indeed still exist.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot/lib-httpd: pass LSAN_OPTIONS through apache
Jeff King [Tue, 7 May 2019 22:30:46 +0000 (18:30 -0400)] 
t/lib-httpd: pass LSAN_OPTIONS through apache

Just as we instruct Apache to pass through ASAN_OPTIONS (so that
server-side Git programs it spawns will respect our options while
running the tests), we should do the same with LSAN_OPTIONS. Otherwise
trying to collect a list of leaks like:

    export LSAN_OPTIONS=exitcode=0:log_path=/tmp/lsan
    make SANITIZE=leak test

won't work for http tests (the server-side programs won't log their
leaks to the right place, and they'll prematurely die, producing a
spurious test failure).

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMake fread/fwrite-like functions in http.c more like fread/fwrite.
Mike Hommey [Tue, 7 May 2019 23:03:54 +0000 (08:03 +0900)] 
Make fread/fwrite-like functions in http.c more like fread/fwrite.

The fread/fwrite-like functions in http.c, namely fread_buffer,
fwrite_buffer, fwrite_null, fwrite_sha1_file all return the
multiplication of the size and number of items they are being given.

Practically speaking, it doesn't matter, because in all contexts where
those functions are used, size is 1.

But those functions being similar to fread and fwrite (the curl API is
designed around being able to use fread and fwrite directly), it might
be preferable to make them behave like fread and fwrite, which, from
the fread/fwrite manual page, is:
   On  success, fread() and fwrite() return the number of items read
   or written.  This number equals the number of bytes transferred
   only when size is 1.  If an error occurs, or the end of the file
   is reached, the return value is a short item count (or zero).

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoperf-lib.sh: forbid the use of GIT_TEST_INSTALLED
Ævar Arnfjörð Bjarmason [Tue, 7 May 2019 10:54:34 +0000 (12:54 +0200)] 
perf-lib.sh: forbid the use of GIT_TEST_INSTALLED

As noted in preceding commits setting GIT_TEST_INSTALLED has never
been supported or documented, and as noted in an earlier t/perf/README
change to the extent that it's been documented nobody's notices that
the example hasn't worked since 3c8f12c96c ("test-lib: reorder and
include GIT-BUILD-OPTIONS a lot earlier", 2012-06-24).

We could directly support GIT_TEST_INSTALLED for invocations without
the "run" script, such as:

    GIT_TEST_INSTALLED=../../ ./p0000-perf-lib-sanity.sh
    GIT_TEST_INSTALLED=/home/avar/g/git ./p0000-perf-lib-sanity.sh

But while not having this "error" will "work", it won't write the the
resulting "test-results/*" files to the right place, and thus a
subsequent call to aggregate.perl won't work as expected.

Let's just tell the user that they need to use the "run" script,
which'll correctly deal with this and set the right
PERF_RESULTS_PREFIX.

If someone's in desperate need of bypassing "run" for whatever reason
they can trivially do so by setting "PERF_SET_GIT_TEST_INSTALLED", but
not we won't have people who expect GIT_TEST_INSTALLED to just work
wondering why their aggregation doesn't work, even though they're
running the right "git".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
5 years agoperf tests: add "bindir" prefix to git tree test results
Ævar Arnfjörð Bjarmason [Tue, 7 May 2019 10:54:33 +0000 (12:54 +0200)] 
perf tests: add "bindir" prefix to git tree test results

Change the output file names in test-results/ to be
"test-results/bindir_<munged dir>" rather than just
"test-results/<munged dir>".

This is for consistency with the "build_" directories we have for
built revisions, i.e. "test-results/build_<SHA-1>".

There's no user-visible functional changes here, it just makes it
easier to see at a glance what "test-results" files are of what "type"
as they're all explicitly grouped together now, and to grep this code
to find both the run_dirs_helper() implementation and its
corresponding aggregate.perl code.

Note that we already guarantee that the rest of the
PERF_RESULTS_PREFIX is an absolute path, and since it'll start with
e.g. "/" which we munge to "_" we'll up with a readable string like
"bindir_home_avar[...]".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
5 years agoperf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh
Ævar Arnfjörð Bjarmason [Tue, 7 May 2019 10:54:32 +0000 (12:54 +0200)] 
perf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh

Follow-up my preceding change which fixed the immediate "./run
<revisions>" regression in 0baf78e7bc ("perf-lib.sh: rely on
test-lib.sh for --tee handling", 2019-03-15) and entirely get rid of
GIT_TEST_INSTALLED from perf-lib.sh (and aggregate.perl).

As noted in that change the dance we're doing with GIT_TEST_INSTALLED
perf-lib.sh isn't necessary, but there I was doing the most minimal
set of changes to quickly fix a regression.

But it's much simpler to never deal with the "GIT_TEST_INSTALLED" we
were setting in perf-lib.sh at all. Instead the run_dirs_helper() sets
the previously inferred $PERF_RESULTS_PREFIX directly.

Setting this at the callsite that's already best positioned to
exhaustively know about all the different cases we need to handle
where PERF_RESULTS_PREFIX isn't what we want already (the empty
string) makes the most sense. In one-off cases like:

    ./run ./p0000-perf-lib-sanity.sh
    ./p0000-perf-lib-sanity.sh

We'll just do the right thing because PERF_RESULTS_PREFIX will be
empty, and test-lib.sh takes care of finding where our git is.

Any refactoring of this code needs to change both the shell code and
the Perl code in aggregate.perl, because when running e.g.:

    ./run ../../ -- <test>

The "../../" path to a relative bindir needs to be munged to a
filename containing the results, and critically aggregate.perl does
not get passed the path to those aggregations, just "../..".

Let's fix cases where aggregate.perl would print e.g. ".." in its
report output for this, and "git" for "/home/avar/g/git", i.e. it
would always pick the last element. Now'll always print the full path
instead.

This also makes the code sturdier, e.g. you can feed "../.."  to
"./run" and then an absolute path to the aggregate.perl script, as
long as the absolute path and "../.." resolved to the same directory
printing the aggregation will work.

Also simplify the "[_*]" on the RHS of "tr -c", we're trimming
everything to "_", so we don't need that.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
5 years agoperf-lib.sh: make "./run <revisions>" use the correct gits
Ævar Arnfjörð Bjarmason [Tue, 7 May 2019 10:54:31 +0000 (12:54 +0200)] 
perf-lib.sh: make "./run <revisions>" use the correct gits

Fix a really bad regression in 0baf78e7bc ("perf-lib.sh: rely on
test-lib.sh for --tee handling", 2019-03-15). Since that change all
runs of different <revisions> of git have used the git found in the
user's $PATH, e.g. /usr/bin/git instead of the <revision> we just
built and wanted to performance test.

The problem starts with GIT_TEST_INSTALLED not working like our
non-perf tests with the "run" script. I.e. you can't run performance
tests against a given installed git. Instead we expect to use it
ourselves to point GIT_TEST_INSTALLED to the <revision> we just built.

However, we had been relying on '$(cd "$GIT_TEST_INSTALLED" && pwd)'
to resolve that relative $GIT_TEST_INSTALLED to an absolute
path *before* test-lib.sh was loaded, in cases where it was
e.g. "build/<rev>/bin-wrappers" and we wanted "<abs_path>build/...".

This change post-dates another proposed solution by a few days[1], I
didn't notice that version when I initially wrote this. I'm doing the
most minimal thing to solve the regression here, a follow-up change
will move this result prefix selection logic entirely into the "run"
script.

This makes e.g. these cases all work:

    ./run . $PWD/../../ origin/master origin/next HEAD -- <tests>

As well as just a plain one-off:

    ./run <tests>

And, since we're passing down the new GIT_PERF_DIR_MYDIR_REL we make
sure the bug relating to aggregate.perl not finding our files as
described in 0baf78e7bc doesn't happen again.

What *doesn't* work is setting GIT_TEST_INSTALLED to a relative path,
this will subtly fail in test-lib.sh. This has always been the case
even before 0baf78e7bc, and as documented in t/README the
GIT_TEST_INSTALLED variable should be set to an absolute path (needs
to be set "to the bindir", which is always absolute), and the "perf"
framework expects to munge it itself.

Perhaps that should be dealt with in the future to allow manually
setting GIT_TEST_INSTALLED, but as a preceding commit showed the user
can just use the "run" script, which'll also pick the right output
directory for the test results as expected by aggregate.perl.

1. https://public-inbox.org/git/20190502222409.GA15631@sigill.intra.peff.net/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
5 years agoperf aggregate: remove GIT_TEST_INSTALLED from --codespeed
Ævar Arnfjörð Bjarmason [Tue, 7 May 2019 10:54:30 +0000 (12:54 +0200)] 
perf aggregate: remove GIT_TEST_INSTALLED from --codespeed

Remove the setting of the "environment" from the --codespeed output. I
don't think this is useful, and it helps with a later refactoring
where we GIT_TEST_INSTALLED stop munging/reading GIT_TEST_INSTALLED in
the perf tests in so many places.

This was added in 05eb1c37ed ("perf/aggregate: implement codespeed
JSON output", 2018-01-05), but since the "run" scripts uses
"GIT_TEST_INSTALLED" internally this was only ever useful for one-off
runs of a single revision as all the "environment" values would be
ones for whatever directory the "run" script ran last.

Let's instead fall back on the "uname -r" case, which is the sort of
thing the environment should be set to, not something that duplicates
other parts of the codpseed output. For setting the "environment" to
something custom the perf.repoName variable can be used. See
19cf57a92e ("perf/run: read GIT_PERF_REPO_NAME from perf.repoName",
2018-01-05).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
5 years agoperf README: correct docs for 3c8f12c96c regression
Ævar Arnfjörð Bjarmason [Tue, 7 May 2019 10:54:29 +0000 (12:54 +0200)] 
perf README: correct docs for 3c8f12c96c regression

Since 3c8f12c96c ("test-lib: reorder and include GIT-BUILD-OPTIONS a
lot earlier", 2012-06-24) the suggested advice of overriding
GIT_BUILD_DIR has not worked. We've printed a hard error like this
given e.g. GIT_BUILD_DIR=/home/avar/g/git:

    /bin-wrappers/git is not executable; using GIT_EXEC_PATH
    error: You haven't built things yet, have you?

Let's just suggest that the user run other gits via the "run"
script. That'll do the right thing for setting the path to the other
git, and running the "aggregate.perl" scripts afterwards will work.

As an aside, if setting GIT_BUILD_DIR had still worked, then the
MODERN_GIT feature/fix added in 1a0962dee5 ("t/perf: fix regression in
testing older versions of git", 2016-06-22) would have broke.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
5 years agorevisions.txt: remove ambibuity between <rev>:<path> and :<path>
Andreas Heiduk [Sun, 5 May 2019 16:07:10 +0000 (12:07 -0400)] 
revisions.txt: remove ambibuity between <rev>:<path> and :<path>

The revision ':README' is mentioned as an example for '<rev>:<path>'
but the explanation forwards to the ':<n>:<path>' syntax. At the same
time ':<n>:<path>' did not mark the '<n>:' as optional.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agorevisions.txt: mention <rev>~ form
Denton Liu [Sun, 5 May 2019 16:07:07 +0000 (12:07 -0400)] 
revisions.txt: mention <rev>~ form

In revisions.txt, the '<rev>^' form is mentioned but the '<rev>~' form
is missing. Although both forms are essentially equivalent (they each
get the first parent of the specified revision), we should mention the
latter for completeness. Make this change.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agorevisions.txt: mark optional rev arguments with []
Denton Liu [Sun, 5 May 2019 16:07:03 +0000 (12:07 -0400)] 
revisions.txt: mark optional rev arguments with []

In revisions.txt, an optional rev argument was not distinguised.
Instead, a user had to continue and read the description in order to
learn that the argument was optional.

Since the [] notation for an optional argument is common-knowledge in
the Git documentation, mark optional arguments with [] so that it's more
obvious for the reader.

Helped-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agorevisions.txt: change "rev" to "<rev>"
Denton Liu [Sun, 5 May 2019 16:06:59 +0000 (12:06 -0400)] 
revisions.txt: change "rev" to "<rev>"

In revisions.txt, there were some instances of a rev argument being
written as "rev". However, since they didn't mean the string literal,
write "<rev>", instead.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocommit-graph: fix memory leak
Josh Steadmon [Mon, 6 May 2019 21:36:58 +0000 (14:36 -0700)] 
commit-graph: fix memory leak

Free the commit graph when verify_commit_graph_lite() reports an error.
Credit to OSS-Fuzz for finding this leak.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agobranch: make create_branch accept a merge base rev
Denton Liu [Sat, 27 Apr 2019 12:02:22 +0000 (05:02 -0700)] 
branch: make create_branch accept a merge base rev

When we ran something like

    $ git checkout -b test master...

it would fail with the message

    fatal: Not a valid object name: 'master...'.

This was caused by the call to `create_branch` where `start_name` is
expected to be a valid rev. However, git-checkout allows the branch to
be a valid _merge base_ rev (i.e. with a "...") so it was possible for
an invalid rev to be passed in.

Make `create_branch` accept a merge base rev so that this case does not
error out.

As a side-effect, teach git-branch how to handle merge base revs as
well.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot2018: cleanup in current test
Denton Liu [Sat, 27 Apr 2019 12:02:19 +0000 (05:02 -0700)] 
t2018: cleanup in current test

Before, in t2018, if do_checkout failed to create `branch2`, the next
test-case would run `git branch -D branch2` but then fail because it was
expecting `branch2` to exist, even though it doesn't. As a result, an
early failure could cause a cascading failure of tests.

Make test-case responsible for cleaning up their own branches so that
future tests can start with a sane environment.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoparse-options: don't emit "ambiguous option" for aliases
Nguyễn Thái Ngọc Duy [Mon, 29 Apr 2019 10:05:25 +0000 (17:05 +0700)] 
parse-options: don't emit "ambiguous option" for aliases

Change the option parsing machinery so that e.g. "clone --recurs ..."
doesn't error out because "clone" understands both "--recursive" and
"--recurse-submodules" to mean the same thing.

Initially "clone" just understood --recursive until the
--recurses-submodules alias was added in ccdd3da652 ("clone: Add the
--recurse-submodules option as alias for --recursive",
2010-11-04). Since bb62e0a99f ("clone: teach --recurse-submodules to
optionally take a pathspec", 2017-03-17) the longer form has been
promoted to the default.

But due to the way the options parsing machinery works this resulted
in the rather absurd situation of:

    $ git clone --recurs [...]
    error: ambiguous option: recurs (could be --recursive or --recurse-submodules)

Add OPT_ALIAS() to express this link between two or more options and use
it in git-clone. Multiple aliases of an option could be written as

    OPT_ALIAS(0, "alias1", "original-name"),
    OPT_ALIAS(0, "alias2", "original-name"),
    ...

The current implementation is not exactly optimal in this case. But we
can optimize it when it becomes a problem. So far we don't even have two
aliases of any option.

A big chunk of code is actually from Junio C Hamano.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agococcicheck: optionally batch spatch invocations
Jeff King [Mon, 6 May 2019 23:43:34 +0000 (19:43 -0400)] 
coccicheck: optionally batch spatch invocations

In our "make coccicheck" rule, we currently feed each source file to its
own individual invocation of spatch. This has a few downsides:

  - it repeats any overhead spatch has for starting up and reading the
    patch file

  - any included header files may get processed from multiple
    invocations. This is slow (we see the same header files multiple
    times) and may produce a resulting patch with repeated hunks (which
    cannot be applied without further cleanup)

Ideally we'd just invoke a single instance of spatch per rule-file and
feed it all source files. But spatch can be rather memory hungry when
run in this way. I measured the peak RSS going from ~90MB for a single
file to ~1900MB for all files. Multiplied by multiple rule files being
processed at the same time (for "make -j"), this can make things slower
or even cause them to fail (e.g., this is reported to happen on our
Travis builds).

Instead, let's provide a tunable knob. We'll leave the default at "1",
but it can be cranked up to "999" for maximum CPU/memory tradeoff, or
people can find points in between that serve their particular machines.

Here are a few numbers running a single rule via:

  SIZES='1 4 16 999'
  RULE=contrib/coccinelle/object_id.cocci
  for i in $SIZES; do
    make clean
    /usr/bin/time -o $i.out --format='%e | %U | %S | %M' \
      make $RULE.patch SPATCH_BATCH_SIZE=$i
  done
  for i in $SIZES; do
    printf '%4d | %s\n' $i "$(cat $i.out)"
  done

which yields:

     1 | 97.73 | 93.38 | 4.33 | 100128
     4 | 52.80 | 51.14 | 1.69 | 135204
    16 | 35.82 | 35.09 | 0.76 | 284124
   999 | 23.30 | 23.13 | 0.20 | 1903852

The implementation is done with xargs, which should be widely available;
it's in POSIX, we rely on it already in the test suite. And "coccicheck"
is really a developer-only tool anyway, so it's not a big deal if
obscure systems can't run it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotrace2: fixup access problem on /etc/gitconfig in read_very_early_config
Jeff Hostetler [Mon, 29 Apr 2019 20:14:22 +0000 (13:14 -0700)] 
trace2: fixup access problem on /etc/gitconfig in read_very_early_config

Teach do_git_config_sequence() to optionally gently check for access to
the system config.  Use this option in read_very_early_config() when
initializing trace2.

In [1] SZEDER Gábor reported that my changes in [2] introduced a
regression when the user does not have permission to read the system
config.

This commit addresses that problem by optionally ignoring that error.

[1] https://public-inbox.org/git/285beb2b2d740ce20fdd8af1becf371ab39703db.1554995916.git.gitgitgadget@gmail.com/T/#m342e839289aec515523a98b5e34d7f42d3f1fd79
[2] https://public-inbox.org/git/285beb2b2d740ce20fdd8af1becf371ab39703db.1554995916.git.gitgitgadget@gmail.com/T/#m11b59c9228c698442f750ee8f9b10c629399ae48

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years ago*.[ch]: manually align parameter lists
Denton Liu [Mon, 29 Apr 2019 08:28:23 +0000 (04:28 -0400)] 
*.[ch]: manually align parameter lists

In previous patches, extern was mechanically removed from function
declarations without care to formatting, causing parameter lists to be
misaligned. Manually format changed sections such that the parameter
lists should be realigned.

Viewing this patch with 'git diff -w' should produce no output.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years ago*.[ch]: remove extern from function declarations using sed
Denton Liu [Mon, 29 Apr 2019 08:28:20 +0000 (04:28 -0400)] 
*.[ch]: remove extern from function declarations using sed

There has been a push to remove extern from function declarations.
Finish the job by removing all instances of "extern" for function
declarations in headers using sed.

This was done by running the following on my system with sed 4.2.2:

    $ git ls-files \*.{c,h} |
        grep -v ^compat/ |
        xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/'

Files under `compat/` are intentionally excluded as some are directly
copied from external sources and we should avoid churning them as much
as possible.

Then, leftover instances of extern were found by running

    $ git grep -w -C3 extern \*.{c,h}

and manually checking the output. No other instances were found.

Note that the regex used specifically excludes function variables which
_should_ be left as extern.

Not the most elegant way to do it but it gets the job done.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years ago*.[ch]: remove extern from function declarations using spatch
Denton Liu [Mon, 29 Apr 2019 08:28:14 +0000 (04:28 -0400)] 
*.[ch]: remove extern from function declarations using spatch

There has been a push to remove extern from function declarations.
Remove some instances of "extern" for function declarations which are
caught by Coccinelle. Note that Coccinelle has some difficulty with
processing functions with `__attribute__` or varargs so some `extern`
declarations are left behind to be dealt with in a future patch.

This was the Coccinelle patch used:

@@
type T;
identifier f;
@@
- extern
  T f(...);

and it was run with:

$ git ls-files \*.{c,h} |
grep -v ^compat/ |
xargs spatch --sp-file contrib/coccinelle/noextern.cocci --in-place

Files under `compat/` are intentionally excluded as some are directly
copied from external sources and we should avoid churning them as much
as possible.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot/perf: add perf script for partial clones
Jeff King [Thu, 2 May 2019 21:45:09 +0000 (17:45 -0400)] 
t/perf: add perf script for partial clones

We don't cover the partial clone feature at all in t/perf. Let's at
least run a few basic tests so that we'll notice any regressions.

We'll do a no-blob clone, and split it into two parts: the actual object
transfer, and the subsequent checkout (which will of course require
another transfer to get the blobs). That will help us more clearly
assess the performance of each.

There are obviously a lot more possibilities besides just a no-blob
partial clone, but this should serve as a canary that alerts us to any
generic slow-downs (and we can add more tests later for cases that
aren't exercised here).

There are a few non-ideal things here that make this not an entirely
accurate test, but are probably OK for our purposes:

  1. We have to do some extra prep/cleanup work inside the timing tests,
     since they impact the on-disk state and the perf harness may run
     each one multiple times.

     In practice this is probably OK, since these bits should be much
     less expensive than the operations we are measuring.

  2. The clone time is likely to be dominated by the server's object
     enumeration. In the real world, a repo large enough to drive people
     to partial clones is likely to have reachability bitmaps enabled.

     And in the opposite direction, our object transfer is happening at
     the speed of a local pipe, whereas in the real world it would
     bottle-neck on the network.

     So any percentage speedups should be taken with a grain of salt.
     But hopefully any regressions will produce enough of an effect to
     be noticeable.

This script also demonstrates the recent improvement from dfa33a298d
(clone: do faster object check for partial clones, 2019-04-19):

  Test                          dfa33a298d^         dfa33a298d
  -------------------------------------------------------------------------
  5600.2: clone without blobs   18.41(22.72+1.09)   6.83(11.65+0.50) -62.9%
  5600.3: checkout of result    1.82(3.24+0.26)     1.84(3.24+0.26) +1.1%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotrace2: fix incorrect function pointer check
Josh Steadmon [Thu, 25 Apr 2019 17:08:53 +0000 (10:08 -0700)] 
trace2: fix incorrect function pointer check

Fix trace2_data_json_fl() to check for the presence of pfn_data_json_fl
in its targets, rather than pfn_data_fl, which is not actually called.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agogit-compat-util: work around for access(X_OK) under root
Clément Chigot [Thu, 25 Apr 2019 07:01:56 +0000 (07:01 +0000)] 
git-compat-util: work around for access(X_OK) under root

On AIX, access(X_OK) may succeed when run as root even if the
execution isn't possible. This behavior is allowed by POSIX
which says:

  ... for a process with appropriate privileges, an implementation
  may indicate success for X_OK even if execute permission is not
  granted to any user.

It can lead hook programs to have their execution refused:

   git commit -m content
   fatal: cannot exec '.git/hooks/pre-commit': Permission denied

Add NEED_ACCESS_ROOT_HANDLER in order to use an access helper function.
It checks with stat if any executable flags is set when the current user
is root.

Signed-off-by: Clément Chigot <clement.chigot@atos.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMakefile: use fileno macro work around on AIX
Clément Chigot [Thu, 18 Apr 2019 08:55:09 +0000 (08:55 +0000)] 
Makefile: use fileno macro work around on AIX

Declare FILENO_IS_A_MACRO on AIX

On AIX, fileno(fp) is a macro and need to use the work around already made for BSD's.

Signed-off-by: Clément Chigot <clement.chigot@atos.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoThe seventh batch
Junio C Hamano [Thu, 25 Apr 2019 07:03:52 +0000 (16:03 +0900)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'js/macos-gettext-build'
Junio C Hamano [Thu, 25 Apr 2019 07:41:25 +0000 (16:41 +0900)] 
Merge branch 'js/macos-gettext-build'

Build with gettext breaks on recent macOS w/ Homebrew when
/usr/local/bin is not on PATH, which has been corrected.

* js/macos-gettext-build:
  macOS: make sure that gettext is found

5 years agoMerge branch 'bs/sendemail-tighten-anything-by'
Junio C Hamano [Thu, 25 Apr 2019 07:41:25 +0000 (16:41 +0900)] 
Merge branch 'bs/sendemail-tighten-anything-by'

The recently added feature to add addresses that are on
anything-by: trailers in 'git send-email' was found to be way too
eager and considered nonsense strings as if they can be legitimate
beginning of *-by: trailer.  This has been tightened.

* bs/sendemail-tighten-anything-by:
  send-email: don't cc *-by lines with '-' prefix

5 years agoMerge branch 'bc/send-email-qp-cr'
Junio C Hamano [Thu, 25 Apr 2019 07:41:25 +0000 (16:41 +0900)] 
Merge branch 'bc/send-email-qp-cr'

"git send-email" has been taught to use quoted-printable when the
payload contains carriage-return.  The use of the mechanism is in
line with the design originally added the codepath that chooses QP
when the payload has overly long lines.

* bc/send-email-qp-cr:
  send-email: default to quoted-printable when CR is present

5 years agoMerge branch 'nd/submodule-foreach-quiet'
Junio C Hamano [Thu, 25 Apr 2019 07:41:24 +0000 (16:41 +0900)] 
Merge branch 'nd/submodule-foreach-quiet'

"git submodule foreach <command> --quiet" did not pass the option
down correctly, which has been corrected.

* nd/submodule-foreach-quiet:
  submodule foreach: fix "<command> --quiet" not being respected

5 years agoMerge branch 'js/iso8895-test-on-apfs'
Junio C Hamano [Thu, 25 Apr 2019 07:41:24 +0000 (16:41 +0900)] 
Merge branch 'js/iso8895-test-on-apfs'

Test fix on APFS that is incapable of store paths in Latin-1.

* js/iso8895-test-on-apfs:
  t9822: skip tests if file names cannot be ISO-8859-1 encoded

5 years agoMerge branch 'jc/gettext-test-fix'
Junio C Hamano [Thu, 25 Apr 2019 07:41:23 +0000 (16:41 +0900)] 
Merge branch 'jc/gettext-test-fix'

The GETTEXT_POISON test option has been quite broken ever since it
was made runtime-tunable, which has been fixed.

* jc/gettext-test-fix:
  gettext tests: export the restored GIT_TEST_GETTEXT_POISON

5 years agoMerge branch 'jk/fetch-reachability-error-fix'
Junio C Hamano [Thu, 25 Apr 2019 07:41:23 +0000 (16:41 +0900)] 
Merge branch 'jk/fetch-reachability-error-fix'

Code clean-up and a fix for "git fetch" by an explicit object name
(as opposed to fetching refs by name).

* jk/fetch-reachability-error-fix:
  fetch: do not consider peeled tags as advertised tips
  remote.c: make singular free_ref() public
  fetch: use free_refs()
  pkt-line: prepare buffer before handling ERR packets
  upload-pack: send ERR packet for non-tip objects
  t5530: check protocol response for "not our ref"
  t5516: drop ok=sigpipe from unreachable-want tests

5 years agoMerge branch 'jk/xmalloc'
Junio C Hamano [Thu, 25 Apr 2019 07:41:23 +0000 (16:41 +0900)] 
Merge branch 'jk/xmalloc'

The code is updated to check the result of memory allocation before
it is used in more places, by using xmalloc and/or xcalloc calls.

* jk/xmalloc:
  progress: use xmalloc/xcalloc
  xdiff: use xmalloc/xrealloc
  xdiff: use git-compat-util
  test-prio-queue: use xmalloc

5 years agoMerge branch 'km/t3000-retitle'
Junio C Hamano [Thu, 25 Apr 2019 07:41:22 +0000 (16:41 +0900)] 
Merge branch 'km/t3000-retitle'

A test update.

* km/t3000-retitle:
  t3000 (ls-files -o): widen description to reflect current tests

5 years agoMerge branch 'js/untracked-cache-allocfix'
Junio C Hamano [Thu, 25 Apr 2019 07:41:22 +0000 (16:41 +0900)] 
Merge branch 'js/untracked-cache-allocfix'

An underallocation in the code to read the untracked cache
extension has been corrected.

* js/untracked-cache-allocfix:
  untracked cache: fix off-by-one

5 years agoMerge branch 'js/t3301-unbreak-notes-test'
Junio C Hamano [Thu, 25 Apr 2019 07:41:21 +0000 (16:41 +0900)] 
Merge branch 'js/t3301-unbreak-notes-test'

Test fix.

* js/t3301-unbreak-notes-test:
  t3301: fix false negative