git
4 years agoMerge branch 'qn/clone-doc-use-long-form'
Junio C Hamano [Thu, 11 Jul 2019 22:16:48 +0000 (15:16 -0700)] 
Merge branch 'qn/clone-doc-use-long-form'

The "git clone" documentation refers to command line options in its
description in the short form; they have been replaced with long
forms to make them more recognisable.

* qn/clone-doc-use-long-form:
  docs: git-clone: list short form of options first
  docs: git-clone: refer to long form of options

4 years agoMerge branch 'js/rebase-reschedule-applies-only-to-interactive'
Junio C Hamano [Thu, 11 Jul 2019 22:16:48 +0000 (15:16 -0700)] 
Merge branch 'js/rebase-reschedule-applies-only-to-interactive'

The configuration variable rebase.rescheduleFailedExec should be
effective only while running an interactive rebase and should not
affect anything when running an non-interactive one, which was not
the case.  This has been corrected.

* js/rebase-reschedule-applies-only-to-interactive:
  rebase --am: ignore rebase.rescheduleFailedExec

4 years agoMerge branch 'sg/git-C-empty-doc'
Junio C Hamano [Thu, 11 Jul 2019 22:16:48 +0000 (15:16 -0700)] 
Merge branch 'sg/git-C-empty-doc'

Doc update.

* sg/git-C-empty-doc:
  Document that 'git -C ""' works and doesn't change directory

4 years agoMerge branch 'jt/t5551-test-chunked'
Junio C Hamano [Thu, 11 Jul 2019 22:16:47 +0000 (15:16 -0700)] 
Merge branch 'jt/t5551-test-chunked'

Update smart-http test.

* jt/t5551-test-chunked:
  t5551: test usage of chunked encoding explicitly

4 years agoMerge branch 'js/mingw-gcc-stack-protect'
Junio C Hamano [Thu, 11 Jul 2019 22:16:47 +0000 (15:16 -0700)] 
Merge branch 'js/mingw-gcc-stack-protect'

Windows update.

* js/mingw-gcc-stack-protect:
  mingw: enable stack smashing protector

4 years agoMerge branch 'cb/windows-manifest'
Junio C Hamano [Thu, 11 Jul 2019 22:16:47 +0000 (15:16 -0700)] 
Merge branch 'cb/windows-manifest'

Windows update.

* cb/windows-manifest:
  mingw: embed a manifest to trick UAC into Doing The Right Thing

4 years agoenv--helper: mark a file-local symbol as static
Ramsay Jones [Thu, 11 Jul 2019 17:06:13 +0000 (18:06 +0100)] 
env--helper: mark a file-local symbol as static

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: add headers to the outer hunk header
Thomas Gummerer [Thu, 11 Jul 2019 16:08:51 +0000 (17:08 +0100)] 
range-diff: add headers to the outer hunk header

Add the section headers/hunk headers we introduced in the previous
commits to the outer diff's hunk headers.  This makes it easier to
understand which change we are actually looking at.  For example an
outer hunk header might now look like:

    @@  Documentation/config/interactive.txt

while previously it would have only been

    @@

which doesn't give a lot of context for the change that follows.

For completeness also add section headers for the commit metadata and
the commit message, although they are arguably less important.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: add filename to inner diff
Thomas Gummerer [Thu, 11 Jul 2019 16:08:50 +0000 (17:08 +0100)] 
range-diff: add filename to inner diff

In a range-diff it's not always clear which file a certain funcname of
the inner diff belongs to, because the diff header (or section header
as added in a previous commit) is not always visible in the
range-diff.

Add the filename to the inner diffs header, so it's always visible to
users.

This also allows us to add the filename + the funcname to the outer
diffs hunk headers using a custom userdiff pattern, which will be done
in the next commit.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: add section header instead of diff header
Thomas Gummerer [Thu, 11 Jul 2019 16:08:49 +0000 (17:08 +0100)] 
range-diff: add section header instead of diff header

Currently range-diff keeps the diff header of the inner diff
intact (apart from stripping lines starting with index).  This diff
header is somewhat useful, especially when files get different
names in different ranges.

However there is no real need to keep the whole diff header for that.
The main reason we currently do that is probably because it is easy to
do.

Introduce a new range diff hunk header, that's enclosed by "##",
similar to how line numbers in diff hunks are enclosed by "@@", and
give human readable information of what exactly happened to the file,
including the file name.

This improves the readability of the range-diff by giving more concise
information to the users.  For example if a file was renamed in one
iteration, but not in another, the diff of the headers would be quite
noisy.  However the diff of a single line is concise and should be
easier to understand.

Additionally, this allows us to add these range diff section headers to
the outer diffs hunk headers using a custom userdiff pattern, which
should help making the range-diff more readable.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: suppress line count in outer diff
Thomas Gummerer [Thu, 11 Jul 2019 16:08:48 +0000 (17:08 +0100)] 
range-diff: suppress line count in outer diff

The line count in the outer diff's hunk headers of a range diff is not
all that interesting.  It merely shows how far along the inner diff
are on both sides.  That number is of no use for human readers, and
range-diffs are not meant to be machine readable.

In a subsequent commit we're going to add some more contextual
information such as the filename corresponding to the diff to the hunk
headers.  Remove the unnecessary information, and just keep the "@@"
to indicate that a new hunk of the outer diff is starting.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: don't remove funcname from inner diff
Thomas Gummerer [Thu, 11 Jul 2019 16:08:47 +0000 (17:08 +0100)] 
range-diff: don't remove funcname from inner diff

When postprocessing the inner diff in range-diff, we currently replace
the whole hunk header line with just "@@".  This matches how 'git
tbdiff' used to handle hunk headers as well.

Most likely this is being done because line numbers in the hunk header
are not relevant without other changes.  They can for example easily
change if a range is rebased, and lines are added/removed before a
change that we actually care about in our ranges.

However it can still be useful to have the function name that 'git
diff' extracts as additional context for the change.

Note that it is not guaranteed that the hunk header actually shows up
in the range-diff, and this change only aims to improve the case where
a hunk header would already be included in the final output.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: split lines manually
Thomas Gummerer [Thu, 11 Jul 2019 16:08:46 +0000 (17:08 +0100)] 
range-diff: split lines manually

Currently range-diff uses the 'strbuf_getline()' function for doing
its line by line processing.  In a future patch we want to do parts of
that parsing using the 'parse_git_diff_header()' function.  That
function does its own line by line reading of the input, and doesn't
use strbufs.  This doesn't match with how we do the line-by-line
processing in range-diff currently.

Switch range-diff to do our own line by line parsing, so we can re-use
the 'parse_git_diff_header()' function later.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: fix function parameter indentation
Thomas Gummerer [Thu, 11 Jul 2019 16:08:45 +0000 (17:08 +0100)] 
range-diff: fix function parameter indentation

Fix the indentation of the function parameters for a couple of
functions, to match the style in the rest of the file.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: make parse_git_diff_header public
Thomas Gummerer [Thu, 11 Jul 2019 16:08:44 +0000 (17:08 +0100)] 
apply: make parse_git_diff_header public

Make 'parse_git_header()' (renamed to 'parse_git_diff_header()') a
"public" function in apply.h, so we can re-use it in range-diff in a
subsequent commit.  We're renaming the function to make it clearer in
other parts of the codebase that we're talking about a diff header and
not just any header.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: only pass required data to gitdiff_* functions
Thomas Gummerer [Thu, 11 Jul 2019 16:08:43 +0000 (17:08 +0100)] 
apply: only pass required data to gitdiff_* functions

Currently the 'gitdiff_*()' functions take 'struct apply_state' as
parameter, even though they only needs the root, linenr and p_value
from that struct.

These functions are in the callchain of 'parse_git_header()', which we
want to make more generally useful in a subsequent commit.  To make
that happen we only want to pass in the required data to
'parse_git_header()', and not the whole 'struct apply_state', and thus
we want functions in the callchain of 'parse_git_header()' to only
take arguments they really need.

As these functions are called in a loop using their function pointers,
each function needs to be passed all the parameters even if only one
of the functions actually needs it.  We therefore pass this data along
in a struct to avoid adding too many unused parameters to each
function and making the code very verbose in the process.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: replace strcmp by fspathcmp
Matheus Tavares [Wed, 10 Jul 2019 23:59:04 +0000 (20:59 -0300)] 
clone: replace strcmp by fspathcmp

Replace the use of strcmp by fspathcmp at copy_or_link_directory, which
is more permissive/friendly to case-insensitive file systems.

Suggested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: use dir-iterator to avoid explicit dir traversal
Matheus Tavares [Wed, 10 Jul 2019 23:59:03 +0000 (20:59 -0300)] 
clone: use dir-iterator to avoid explicit dir traversal

Replace usage of opendir/readdir/closedir API to traverse directories
recursively, at copy_or_link_directory function, by the dir-iterator
API. This simplifies the code and avoids recursive calls to
copy_or_link_directory.

This process also makes copy_or_link_directory call die() in case of an
error on readdir or stat inside dir_iterator_advance. Previously it
would just print a warning for errors on stat and ignore errors on
readdir, which isn't nice because a local git clone could succeed even
though the .git/objects copy didn't fully succeed.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: extract function from copy_or_link_directory
Matheus Tavares [Wed, 10 Jul 2019 23:59:02 +0000 (20:59 -0300)] 
clone: extract function from copy_or_link_directory

Extract dir creation code snippet from copy_or_link_directory to its own
function named mkdir_if_missing. This change will help to remove
copy_or_link_directory's explicit recursion, which will be done in a
following patch. Also makes the code more readable.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: copy hidden paths at local clone
Matheus Tavares [Wed, 10 Jul 2019 23:59:01 +0000 (20:59 -0300)] 
clone: copy hidden paths at local clone

Make the copy_or_link_directory function no longer skip hidden
directories. This function, used to copy .git/objects, currently skips
all hidden directories but not hidden files, which is an odd behaviour.
The reason for that could be unintentional: probably the intention was
to skip '.' and '..' only but it ended up accidentally skipping all
directories starting with '.'. Besides being more natural, the new
behaviour is more permissive to the user.

Also adjust tests to reflect this behaviour change.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodir-iterator: add flags parameter to dir_iterator_begin
Matheus Tavares [Wed, 10 Jul 2019 23:59:00 +0000 (20:59 -0300)] 
dir-iterator: add flags parameter to dir_iterator_begin

Add the possibility of giving flags to dir_iterator_begin to initialize
a dir-iterator with special options.

Currently possible flags are:
- DIR_ITERATOR_PEDANTIC, which makes dir_iterator_advance abort
immediately in the case of an error, instead of keep looking for the
next valid entry;
- DIR_ITERATOR_FOLLOW_SYMLINKS, which makes the iterator follow
symlinks and include linked directories' contents in the iteration.

These new flags will be used in a subsequent patch.

Also add tests for the flags' usage and adjust refs/files-backend.c to
the new dir_iterator_begin signature.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodir-iterator: refactor state machine model
Matheus Tavares [Wed, 10 Jul 2019 23:58:59 +0000 (20:58 -0300)] 
dir-iterator: refactor state machine model

dir_iterator_advance() is a large function with two nested loops. Let's
improve its readability factoring out three functions and simplifying
its mechanics. The refactored model will no longer depend on
level.initialized and level.dir_state to keep track of the iteration
state and will perform on a single loop.

Also, dir_iterator_begin() currently does not check if the given string
represents a valid directory path. Since the refactored model will have
to stat() the given path at initialization, let's also check for this
kind of error and make dir_iterator_begin() return NULL, on failures,
with errno appropriately set. And add tests for this new behavior.

Improve documentation at dir-iteration.h and code comments at
dir-iterator.c to reflect the changes and eliminate possible
ambiguities.

Finally, adjust refs/files-backend.c to check for now possible
dir_iterator_begin() failures.

Original-patch-by: Daniel Ferreira <bnmvco@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodir-iterator: use warning_errno when possible
Matheus Tavares [Wed, 10 Jul 2019 23:58:58 +0000 (20:58 -0300)] 
dir-iterator: use warning_errno when possible

Change warning(..., strerror(errno)) by warning_errno(...). This helps
to unify warning display besides simplifying a bit the code. Also,
improve warning messages by surrounding paths with quotation marks and
using more meaningful statements.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodir-iterator: add tests for dir-iterator API
Daniel Ferreira [Wed, 10 Jul 2019 23:58:57 +0000 (20:58 -0300)] 
dir-iterator: add tests for dir-iterator API

Create t/helper/test-dir-iterator.c, which prints relevant information
about a directory tree iterated over with dir-iterator.

Create t/t0066-dir-iterator.sh, which tests that dir-iterator does
iterate through a whole directory tree as expected.

Signed-off-by: Daniel Ferreira <bnmvco@gmail.com>
[matheus.bernardino: update to use test-tool and some minor aesthetics]
Helped-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: better handle symlinked files at .git/objects/
Matheus Tavares [Wed, 10 Jul 2019 23:58:56 +0000 (20:58 -0300)] 
clone: better handle symlinked files at .git/objects/

There is currently an odd behaviour when locally cloning a repository
with symlinks at .git/objects: using --no-hardlinks all symlinks are
dereferenced but without it, Git will try to hardlink the files with the
link() function, which has an OS-specific behaviour on symlinks. On OSX
and NetBSD, it creates a hardlink to the file pointed by the symlink
whilst on GNU/Linux, it creates a hardlink to the symlink itself.

On Manjaro GNU/Linux:
    $ touch a
    $ ln -s a b
    $ link b c
    $ ls -li a b c
    155 [...] a
    156 [...] b -> a
    156 [...] c -> a

But on NetBSD:
    $ ls -li a b c
    2609160 [...] a
    2609164 [...] b -> a
    2609160 [...] c

It's not good to have the result of a local clone to be OS-dependent and
besides that, the current behaviour on GNU/Linux may result in broken
symlinks. So let's standardize this by making the hardlinks always point
to dereferenced paths, instead of the symlinks themselves. Also, add
tests for symlinked files at .git/objects/.

Note: Git won't create symlinks at .git/objects itself, but it's better
to handle this case and be friendly with users who manually create them.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: test for our behavior on odd objects/* content
Ævar Arnfjörð Bjarmason [Wed, 10 Jul 2019 23:58:55 +0000 (20:58 -0300)] 
clone: test for our behavior on odd objects/* content

Add tests for what happens when we perform a local clone on a repo
containing odd files at .git/object directory, such as symlinks to other
dirs, or unknown files.

I'm bending over backwards here to avoid a SHA-1 dependency. See [1]
for an earlier and simpler version that hardcoded SHA-1s.

This behavior has been the same for a *long* time, but hasn't been
tested for.

There's a good post-hoc argument to be made for copying over unknown
things, e.g. I'd like a git version that doesn't know about the
commit-graph to copy it under "clone --local" so a newer git version
can make use of it.

In follow-up commits we'll look at changing some of this behavior, but
for now, let's just assert it as-is so we'll notice what we'll change
later.

1. https://public-inbox.org/git/20190226002625.13022-5-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
[matheus.bernardino: improved and split tests in more than one patch]
Helped-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodiff: munmap() file contents before running external diff
Johannes Schindelin [Thu, 11 Jul 2019 08:23:41 +0000 (01:23 -0700)] 
diff: munmap() file contents before running external diff

When running an external diff from, say, a diff tool, it is safe to
assume that we want to write the files in question. On Windows, that
means that there cannot be any other process holding an open handle to
said files, or even just a mapped region.

So let's make sure that `git diff` itself is not holding any open handle
to the files in question.

In fact, we will just release the file pair right away, as the external
diff uses the files we just wrote, so we do not need to hold the file
contents in memory anymore.

This fixes https://github.com/git-for-windows/git/issues/1315

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoref-filter: fix memory leak in `free_array_item()`
Martin Ågren [Wed, 10 Jul 2019 18:36:39 +0000 (20:36 +0200)] 
ref-filter: fix memory leak in `free_array_item()`

We treat the `value` pointer as a pointer to a struct and free its `s`
field. But `value` is in fact an array of structs. As a result, we only
free the first `s` out of `used_atom_cnt`-many and leak the rest. Make
sure we free all items in `value`.

In the caller, `ref_array_clear()`, this means we need to be careful not
to zero `used_atom_cnt` until after we've called `free_array_item()`. We
could move just a single line, but let's keep related things close
together instead, by first handling `array`, then `used_atom`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotrace2: correct trace2 field name documentation
Josh Steadmon [Tue, 9 Jul 2019 23:09:01 +0000 (16:09 -0700)] 
trace2: correct trace2 field name documentation

Correct the api-trace2 documentation, which lists "signal" as an
expected field for the signal event type, but which actually outputs
"signo" as the field name.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoThe fourth batch
Junio C Hamano [Tue, 9 Jul 2019 22:48:36 +0000 (15:48 -0700)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ds/fetch-disable-force-notice'
Junio C Hamano [Tue, 9 Jul 2019 22:25:46 +0000 (15:25 -0700)] 
Merge branch 'ds/fetch-disable-force-notice'

"git fetch" and "git pull" reports when a fetch results in
non-fast-forward updates to let the user notice unusual situation.
The commands learned "--no-shown-forced-updates" option to disable
this safety feature.

* ds/fetch-disable-force-notice:
  pull: add --[no-]show-forced-updates passthrough
  fetch: warn about forced updates in branch listing
  fetch: add --[no-]show-forced-updates argument

4 years agoMerge branch 'jh/status-aheadbehind'
Junio C Hamano [Tue, 9 Jul 2019 22:25:46 +0000 (15:25 -0700)] 
Merge branch 'jh/status-aheadbehind'

"git status" can be told a non-standard default value for the
"--[no-]ahead-behind" option with a new configuration variable
status.aheadBehind.

* jh/status-aheadbehind:
  status: ignore status.aheadbehind in porcelain formats
  status: warn when a/b calculation takes too long
  status: add status.aheadbehind setting

4 years agoMerge branch 'sg/t5551-fetch-smart-error-is-translated'
Junio C Hamano [Tue, 9 Jul 2019 22:25:46 +0000 (15:25 -0700)] 
Merge branch 'sg/t5551-fetch-smart-error-is-translated'

Test update.

* sg/t5551-fetch-smart-error-is-translated:
  t5551: use 'test_i18ngrep' to check translated output

4 years agoMerge branch 'ms/submodule-foreach-fix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:46 +0000 (15:25 -0700)] 
Merge branch 'ms/submodule-foreach-fix'

"git submodule foreach" did not protect command line options passed
to the command to be run in each submodule correctly, when the
"--recursive" option was in use.

* ms/submodule-foreach-fix:
  submodule foreach: fix recursion of options

4 years agoMerge branch 'jh/msvc'
Junio C Hamano [Tue, 9 Jul 2019 22:25:45 +0000 (15:25 -0700)] 
Merge branch 'jh/msvc'

Support to build with MSVC has been updated.

* jh/msvc:
  msvc: ignore .dll and incremental compile output
  msvc: avoid debug assertion windows in Debug Mode
  msvc: do not pretend to support all signals
  msvc: add pragmas for common warnings
  msvc: add a compile-time flag to allow detailed heap debugging
  msvc: support building Git using MS Visual C++
  msvc: update Makefile to allow for spaces in the compiler path
  msvc: fix detect_msys_tty()
  msvc: define ftello()
  msvc: do not re-declare the timespec struct
  msvc: mark a variable as non-const
  msvc: define O_ACCMODE
  msvc: include sigset_t definition
  msvc: fix dependencies of compat/msvc.c
  mingw: replace mingw_startup() hack
  obstack: fix compiler warning
  cache-tree/blame: avoid reusing the DEBUG constant
  t0001 (mingw): do not expect a specific order of stdout/stderr
  Mark .bat files as requiring CR/LF endings
  mingw: fix a typo in the msysGit-specific section

4 years agoMerge branch 'sg/rebase-progress'
Junio C Hamano [Tue, 9 Jul 2019 22:25:45 +0000 (15:25 -0700)] 
Merge branch 'sg/rebase-progress'

Use "Erase in Line" CSI sequence that is already used in the editor
support to clear cruft in the progress output.

* sg/rebase-progress:
  progress: use term_clear_line()
  rebase: fix garbled progress display with '-x'
  pager: add a helper function to clear the last line in the terminal
  t3404: make the 'rebase.missingCommitsCheck=ignore' test more focused
  t3404: modernize here doc style

4 years agoMerge branch 'jw/gitweb-sample-update'
Junio C Hamano [Tue, 9 Jul 2019 22:25:45 +0000 (15:25 -0700)] 
Merge branch 'jw/gitweb-sample-update'

Doc update.

* jw/gitweb-sample-update:
  doc: don't use git.kernel.org as example gitweb URL

4 years agoMerge branch 'js/t0001-case-insensitive'
Junio C Hamano [Tue, 9 Jul 2019 22:25:44 +0000 (15:25 -0700)] 
Merge branch 'js/t0001-case-insensitive'

Test update.

* js/t0001-case-insensitive:
  t0001: fix on case-insensitive filesystems

4 years agoMerge branch 'cc/first-contrib-tutorial'
Junio C Hamano [Tue, 9 Jul 2019 22:25:44 +0000 (15:25 -0700)] 
Merge branch 'cc/first-contrib-tutorial'

Update docs used in a tutorial.

* cc/first-contrib-tutorial:
  doc: improve usage string in MyFirstContribution

4 years agoMerge branch 'ab/fail-prereqs-in-test'
Junio C Hamano [Tue, 9 Jul 2019 22:25:44 +0000 (15:25 -0700)] 
Merge branch 'ab/fail-prereqs-in-test'

Test updates.

* ab/fail-prereqs-in-test:
  tests: mark two failing tests under FAIL_PREREQS

4 years agoMerge branch 'nd/switch-and-restore'
Junio C Hamano [Tue, 9 Jul 2019 22:25:44 +0000 (15:25 -0700)] 
Merge branch 'nd/switch-and-restore'

Two new commands "git switch" and "git restore" are introduced to
split "checking out a branch to work on advancing its history" and
"checking out paths out of the index and/or a tree-ish to work on
advancing the current history" out of the single "git checkout"
command.

* nd/switch-and-restore: (46 commits)
  completion: disable dwim on "git switch -d"
  switch: allow to switch in the middle of bisect
  t2027: use test_must_be_empty
  Declare both git-switch and git-restore experimental
  help: move git-diff and git-reset to different groups
  doc: promote "git restore"
  user-manual.txt: prefer 'merge --abort' over 'reset --hard'
  completion: support restore
  t: add tests for restore
  restore: support --patch
  restore: replace --force with --ignore-unmerged
  restore: default to --source=HEAD when only --staged is specified
  restore: reject invalid combinations with --staged
  restore: add --worktree and --staged
  checkout: factor out worktree checkout code
  restore: disable overlay mode by default
  restore: make pathspec mandatory
  restore: take tree-ish from --source option instead
  checkout: split part of it to new command 'restore'
  doc: promote "git switch"
  ...

4 years agoMerge branch 'nd/fetch-capability-tweak'
Junio C Hamano [Tue, 9 Jul 2019 22:25:43 +0000 (15:25 -0700)] 
Merge branch 'nd/fetch-capability-tweak'

Protocol capabilities that go over wire should never be translated,
but it was incorrectly marked for translation, which has been
corrected.  The output of protocol capabilities for debugging has
been tweaked a bit.

* nd/fetch-capability-tweak:
  fetch-pack: print server version at the top in -v -v
  fetch-pack: print all relevant supported capabilities with -v -v
  fetch-pack: move capability names out of i18n strings

4 years agoMerge branch 'jk/oidhash'
Junio C Hamano [Tue, 9 Jul 2019 22:25:43 +0000 (15:25 -0700)] 
Merge branch 'jk/oidhash'

Code clean-up to remove hardcoded SHA-1 hash from many places.

* jk/oidhash:
  hashmap: convert sha1hash() to oidhash()
  hash.h: move object_id definition from cache.h
  khash: rename oid helper functions
  khash: drop sha1-specific map types
  pack-bitmap: convert khash_sha1 maps into kh_oid_map
  delta-islands: convert island_marks khash to use oids
  khash: rename kh_oid_t to kh_oid_set
  khash: drop broken oid_map typedef
  object: convert create_object() to use object_id
  object: convert internal hash_obj() to object_id
  object: convert lookup_object() to use object_id
  object: convert lookup_unknown_object() to use object_id
  pack-objects: convert locate_object_entry_hash() to object_id
  pack-objects: convert packlist_find() to use object_id
  pack-bitmap-write: convert some helpers to use object_id
  upload-pack: rename a "sha1" variable to "oid"
  describe: fix accidental oid/hash type-punning

4 years agoMerge branch 'jk/delta-islands-progress-fix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:43 +0000 (15:25 -0700)] 
Merge branch 'jk/delta-islands-progress-fix'

The codepath to compute delta islands used to spew progress output
without giving the callers any way to squelch it, which has been
fixed.

* jk/delta-islands-progress-fix:
  delta-islands: respect progress flag

4 years agoMerge branch 'md/sort-detached-head-first'
Junio C Hamano [Tue, 9 Jul 2019 22:25:42 +0000 (15:25 -0700)] 
Merge branch 'md/sort-detached-head-first'

"git branch --list" learned to always output the detached HEAD as
the first item (when the HEAD is detached, of course), regardless
of the locale.

* md/sort-detached-head-first:
  ref-filter: sort detached HEAD lines firstly

4 years agoMerge branch 'nd/fetch-multi-gc-once'
Junio C Hamano [Tue, 9 Jul 2019 22:25:42 +0000 (15:25 -0700)] 
Merge branch 'nd/fetch-multi-gc-once'

"git fetch" that grabs from a group of remotes learned to run the
auto-gc only once at the very end.

* nd/fetch-multi-gc-once:
  fetch: only run 'gc' once when fetching multiple remotes

4 years agoMerge branch 'es/rev-list-no-object-names'
Junio C Hamano [Tue, 9 Jul 2019 22:25:42 +0000 (15:25 -0700)] 
Merge branch 'es/rev-list-no-object-names'

"git rev-list --objects" learned with "--no-object-names" option to
squelch the path to the object that is used as a grouping hint for
pack-objects.

* es/rev-list-no-object-names:
  rev-list: teach --no-object-names to enable piping

4 years agoMerge branch 'rs/config-unit-parsing'
Junio C Hamano [Tue, 9 Jul 2019 22:25:41 +0000 (15:25 -0700)] 
Merge branch 'rs/config-unit-parsing'

The code to parse scaled numbers out of configuration files has
been made more robust and also easier to follow.

* rs/config-unit-parsing:
  config: simplify parsing of unit factors
  config: don't multiply in parse_unit_factor()
  config: use unsigned_mult_overflows to check for overflows

4 years agoMerge branch 'js/gcc-8-and-9'
Junio C Hamano [Tue, 9 Jul 2019 22:25:41 +0000 (15:25 -0700)] 
Merge branch 'js/gcc-8-and-9'

Code clean-up for new compilers.

* js/gcc-8-and-9:
  config: avoid calling `labs()` on too-large data type
  winansi: simplify loading the GetCurrentConsoleFontEx() function
  kwset: allow building with GCC 8
  poll (mingw): allow compiling with GCC 8 and DEVELOPER=1

4 years agoMerge branch 'dl/includeif-onbranch'
Junio C Hamano [Tue, 9 Jul 2019 22:25:41 +0000 (15:25 -0700)] 
Merge branch 'dl/includeif-onbranch'

The conditional inclusion mechanism learned to base the choice on
the branch the HEAD currently is on.

* dl/includeif-onbranch:
  config: learn the "onbranch:" includeIf condition

4 years agoMerge branch 'pw/rebase-abort-clean-rewritten'
Junio C Hamano [Tue, 9 Jul 2019 22:25:41 +0000 (15:25 -0700)] 
Merge branch 'pw/rebase-abort-clean-rewritten'

"git rebase --abort" used to leave refs/rewritten/ when concluding
"git rebase -r", which has been corrected.

* pw/rebase-abort-clean-rewritten:
  rebase --abort/--quit: cleanup refs/rewritten
  sequencer: return errors from sequencer_remove_state()
  rebase: warn if state directory cannot be removed
  rebase: fix a memory leak

4 years agoMerge branch 'am/p4-branches-excludes'
Junio C Hamano [Tue, 9 Jul 2019 22:25:40 +0000 (15:25 -0700)] 
Merge branch 'am/p4-branches-excludes'

"git p4" update.

* am/p4-branches-excludes:
  git-p4: respect excluded paths when detecting branches
  git-p4: add failing test for "git-p4: respect excluded paths when detecting branches"
  git-p4: don't exclude other files with same prefix
  git-p4: add failing test for "don't exclude other files with same prefix"
  git-p4: don't groom exclude path list on every commit
  git-p4: match branches case insensitively if configured
  git-p4: add failing test for "git-p4: match branches case insensitively if configured"
  git-p4: detect/prevent infinite loop in gitCommitByP4Change()

4 years agoMerge branch 'tg/stash-ref-by-index-fix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:40 +0000 (15:25 -0700)] 
Merge branch 'tg/stash-ref-by-index-fix'

"git stash show 23" used to work, but no more after getting
rewritten in C; this regression has been corrected.

* tg/stash-ref-by-index-fix:
  stash: fix show referencing stash index

4 years agoMerge branch 'cb/mkstemps-uint-type-fix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:40 +0000 (15:25 -0700)] 
Merge branch 'cb/mkstemps-uint-type-fix'

Variable type fix.

* cb/mkstemps-uint-type-fix:
  wrapper: avoid undefined behaviour in macOS

4 years agoMerge branch 'jk/trailers-use-config'
Junio C Hamano [Tue, 9 Jul 2019 22:25:40 +0000 (15:25 -0700)] 
Merge branch 'jk/trailers-use-config'

"git interpret-trailers" always treated '#' as the comment
character, regardless of core.commentChar setting, which has been
corrected.

* jk/trailers-use-config:
  interpret-trailers: load default config

4 years agoMerge branch 'js/t3404-typofix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:39 +0000 (15:25 -0700)] 
Merge branch 'js/t3404-typofix'

Typofix.

* js/t3404-typofix:
  t3404: fix a typo

4 years agoMerge branch 'pw/doc-synopsis-markup-opmode-options'
Junio C Hamano [Tue, 9 Jul 2019 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'pw/doc-synopsis-markup-opmode-options'

Docfix.

* pw/doc-synopsis-markup-opmode-options:
  show --continue/skip etc. consistently in synopsis

4 years agoMerge branch 'rs/copy-array'
Junio C Hamano [Tue, 9 Jul 2019 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'rs/copy-array'

Code clean-up.

* rs/copy-array:
  use COPY_ARRAY for copying arrays
  coccinelle: use COPY_ARRAY for copying arrays

4 years agoMerge branch 'cb/fsmonitor-intfix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'cb/fsmonitor-intfix'

Variable type fix.

* cb/fsmonitor-intfix:
  fsmonitor: avoid signed integer overflow / infinite loop

4 years agoMerge branch 'rs/avoid-overflow-in-midpoint-computation'
Junio C Hamano [Tue, 9 Jul 2019 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'rs/avoid-overflow-in-midpoint-computation'

Code clean-up to avoid signed integer overlaps during binary search.

* rs/avoid-overflow-in-midpoint-computation:
  cleanup: fix possible overflow errors in binary search, part 2

4 years agoMerge branch 'pw/add-p-recount'
Junio C Hamano [Tue, 9 Jul 2019 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'pw/add-p-recount'

"git checkout -p" needs to selectively apply a patch in reverse,
which did not work well.

* pw/add-p-recount:
  add -p: fix checkout -p with pathological context

4 years agoMerge branch 'ds/close-object-store'
Junio C Hamano [Tue, 9 Jul 2019 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'ds/close-object-store'

The commit-graph file is now part of the "files that the runtime
may keep open file descriptors on, all of which would need to be
closed when done with the object store", and the file descriptor to
an existing commit-graph file now is closed before "gc" finalizes a
new instance to replace it.

* ds/close-object-store:
  packfile: rename close_all_packs to close_object_store
  packfile: close commit-graph in close_all_packs
  commit-graph: use raw_object_store when closing

4 years agoMerge branch 'ds/commit-graph-write-refactor'
Junio C Hamano [Tue, 9 Jul 2019 22:25:36 +0000 (15:25 -0700)] 
Merge branch 'ds/commit-graph-write-refactor'

Renamed from commit-graph-format-v2 and changed scope.

* ds/commit-graph-write-refactor:
  commit-graph: extract write_commit_graph_file()
  commit-graph: extract copy_oids_to_commits()
  commit-graph: extract count_distinct_commits()
  commit-graph: extract fill_oids_from_all_packs()
  commit-graph: extract fill_oids_from_commit_hex()
  commit-graph: extract fill_oids_from_packs()
  commit-graph: create write_commit_graph_context
  commit-graph: remove Future Work section
  commit-graph: collapse parameters into flags
  commit-graph: return with errors during write
  commit-graph: fix the_repository reference

4 years agoMerge branch 'sg/trace2-rename'
Junio C Hamano [Tue, 9 Jul 2019 22:25:36 +0000 (15:25 -0700)] 
Merge branch 'sg/trace2-rename'

Dev support update to help tracing out tests.

* sg/trace2-rename:
  trace2: correct typo in technical documentation
  Revert "test-lib: whitelist GIT_TR2_* in the environment"

4 years agoMerge branch 'nd/completion-no-cache-failure'
Junio C Hamano [Tue, 9 Jul 2019 22:25:35 +0000 (15:25 -0700)] 
Merge branch 'nd/completion-no-cache-failure'

An incorrect list of options was cached after command line
completion failed (e.g. trying to complete a command that requires
a repository outside one), which has been corrected.

* nd/completion-no-cache-failure:
  completion: do not cache if --git-completion-helper fails

4 years agoMerge branch 'js/mergetool-optim'
Junio C Hamano [Tue, 9 Jul 2019 22:25:35 +0000 (15:25 -0700)] 
Merge branch 'js/mergetool-optim'

"git mergetool" and its tests now spawn fewer subprocesses.

* js/mergetool-optim:
  mergetool: use shell variable magic instead of `awk`
  mergetool: dissect strings with shell variable magic instead of `expr`
  t7610-mergetool: use test_cmp instead of test $(cat file) = $txt
  t7610-mergetool: do not place pipelines headed by `yes` in subshells

4 years agoMerge branch 'mo/hpux-dynpath'
Junio C Hamano [Tue, 9 Jul 2019 22:25:35 +0000 (15:25 -0700)] 
Merge branch 'mo/hpux-dynpath'

Auto-detect how to tell HP-UX aCC where to use dynamically linked
libraries from at runtime.

* mo/hpux-dynpath:
  configure: Detect linking style for HP aCC on HP-UX

4 years agoMerge branch 'dl/config-alias-doc'
Junio C Hamano [Tue, 9 Jul 2019 22:25:35 +0000 (15:25 -0700)] 
Merge branch 'dl/config-alias-doc'

Doc update.

* dl/config-alias-doc:
  config/alias.txt: document alias accepting non-command first word
  config/alias.txt: change " and ' to `

4 years agoMerge branch 'tm/tag-gpgsign-config'
Junio C Hamano [Tue, 9 Jul 2019 22:25:34 +0000 (15:25 -0700)] 
Merge branch 'tm/tag-gpgsign-config'

A new tag.gpgSign configuration variable turns "git tag -a" into
"git tag -s".

* tm/tag-gpgsign-config:
  tag: add tag.gpgSign config option to force all tags be GPG-signed

4 years agoMerge branch 'fc/fetch-with-import-fix'
Junio C Hamano [Tue, 9 Jul 2019 22:25:34 +0000 (15:25 -0700)] 
Merge branch 'fc/fetch-with-import-fix'

Code restructuring during 2.20 period broke fetching tags via
"import" based transports.

* fc/fetch-with-import-fix:
  fetch: fix regression with transport helpers
  fetch: make the code more understandable
  fetch: trivial cleanup
  t5801 (remote-helpers): add test to fetch tags
  t5801 (remote-helpers): cleanup refspec stuff

4 years agoMerge branch 'po/doc-branch'
Junio C Hamano [Tue, 9 Jul 2019 22:25:34 +0000 (15:25 -0700)] 
Merge branch 'po/doc-branch'

Doc update.

* po/doc-branch:
  doc branch: provide examples for listing remote tracking branches

4 years agoMerge branch 'nb/branch-show-other-worktrees-head'
Junio C Hamano [Tue, 9 Jul 2019 22:25:33 +0000 (15:25 -0700)] 
Merge branch 'nb/branch-show-other-worktrees-head'

"git branch --list" learned to show branches that are checked out
in other worktrees connected to the same repository prefixed with
'+', similar to the way the currently checked out branch is shown
with '*' in front.

* nb/branch-show-other-worktrees-head:
  branch: add worktree info on verbose output
  branch: update output to include worktree info
  ref-filter: add worktreepath atom

4 years agobuiltin/merge.c - cleanup of code in for-cycle that tests strategies
Edmundo Carmona Antoranz [Tue, 9 Jul 2019 03:15:59 +0000 (21:15 -0600)] 
builtin/merge.c - cleanup of code in for-cycle that tests strategies

The cmd_merge() function has a loop that tries different
merge strategies in turn, and stops when a strategy gets a
clean merge, while keeping the "best" conflicted merge so
far.

Make the loop easier to follow by moving the code around,
ensuring that there is only one "break" in the loop where
an automerge succeeds.  Also group the actions that are
performed after an automerge succeeds together to a single
location, outside and after the loop.

Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: only pass required data to find_name_*
Thomas Gummerer [Mon, 8 Jul 2019 16:33:06 +0000 (17:33 +0100)] 
apply: only pass required data to find_name_*

Currently the 'find_name_*()' functions take 'struct apply_state' as
parameter, even though they only need the 'root' member from that
struct.

These functions are in the callchain of 'parse_git_header()', which we
want to make more generally useful in a subsequent commit.  To make
that happen we only want to pass in the required data to
'parse_git_header()', and not the whole 'struct apply_state', and thus
we want functions in the callchain of 'parse_git_header()' to only
take arguments they really need.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: only pass required data to check_header_line
Thomas Gummerer [Mon, 8 Jul 2019 16:33:05 +0000 (17:33 +0100)] 
apply: only pass required data to check_header_line

Currently the 'check_header_line()' function takes 'struct
apply_state' as parameter, even though it only needs the linenr from
that struct.

This function is in the callchain of 'parse_git_header()', which we
want to make more generally useful in a subsequent commit.  To make
that happen we only want to pass in the required data to
'parse_git_header()', and not the whole 'struct apply_state', and thus
we want functions in the callchain of 'parse_git_header()' to only
take arguments they really need.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: only pass required data to git_header_name
Thomas Gummerer [Mon, 8 Jul 2019 16:33:04 +0000 (17:33 +0100)] 
apply: only pass required data to git_header_name

Currently the 'git_header_name()' function takes 'struct apply_state'
as parameter, even though it only needs the p_value from that struct.

This function is in the callchain of 'parse_git_header()', which we
want to make more generally useful in a subsequent commit.  To make
that happen we only want to pass in the required data to
'parse_git_header()', and not the whole 'struct apply_state', and thus
we want functions in the callchain of 'parse_git_header()' to only
take arguments they really need.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: only pass required data to skip_tree_prefix
Thomas Gummerer [Mon, 8 Jul 2019 16:33:03 +0000 (17:33 +0100)] 
apply: only pass required data to skip_tree_prefix

Currently the 'skip_tree_prefix()' function takes 'struct apply_state'
as parameter, even though it only needs the p_value from that struct.

This function is in the callchain of 'parse_git_header()', which we
want to make more generally useful in a subsequent commit.  To make
that happen we only want to pass in the required data to
'parse_git_header()', and not the whole 'struct apply_state', and thus
we want functions in the callchain of 'parse_git_header()' to only
take arguments they really need.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply: replace marc.info link with public-inbox
Thomas Gummerer [Mon, 8 Jul 2019 16:33:02 +0000 (17:33 +0100)] 
apply: replace marc.info link with public-inbox

public-inbox.org links include the whole message ID by default.  This
means the message can still be found even if the site goes away, which
is not the case with the marc.info link.  Replace the marc.info link
with a more future proof one.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3420: remove progress lines before comparing output
Phillip Wood [Thu, 4 Jul 2019 09:47:02 +0000 (02:47 -0700)] 
t3420: remove progress lines before comparing output

Some of the tests check the output of rebase is what we expect. These
were added after a regression that added unwanted stash output when
using --autostash. They are useful as they prevent unintended changes to
the output of the various rebase commands. However they also include all
the progress output which is less useful as it only tests what would be
written to a dumb terminal which is not the normal use case. The recent
changes to fix clearing the line when printing progress necessarily
meant making an ugly change to these tests. Address this my removing the
progress output before comparing it to the expected output. We do this
by removing everything before the final "\r" on each line as we don't
care about the progress indicator, but we do care about what is printed
immediately after it.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: initialize HOME on startup
Karsten Blees [Thu, 4 Jul 2019 09:20:33 +0000 (02:20 -0700)] 
mingw: initialize HOME on startup

HOME initialization was historically duplicated in many different places,
including /etc/profile, launch scripts such as git-bash.vbs and gitk.cmd,
and (although slightly broken) in the git-wrapper.

Even unrelated projects such as GitExtensions and TortoiseGit need to
implement the same logic to be able to call git directly.

Initialize HOME in git's own startup code so that we can eventually retire
all the duplicate initialization code.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: fix possible buffer overrun when calling `GetUserNameW()`
Johannes Schindelin [Thu, 4 Jul 2019 22:36:57 +0000 (15:36 -0700)] 
mingw: fix possible buffer overrun when calling `GetUserNameW()`

In 39a98e9b68b8 (mingw: get pw_name in UTF-8 format, 2019-06-27), this
developer missed the fact that the `GetUserNameW()` function takes the
number of characters as `len` parameter, not the number of bytes.

Reported-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoci/lib.sh: update a comment about installed P4 and Git-LFS versions
SZEDER Gábor [Sat, 6 Jul 2019 16:21:14 +0000 (18:21 +0200)] 
ci/lib.sh: update a comment about installed P4 and Git-LFS versions

A comment in 'ci/lib.sh' claims that the "OS X build installs the
latest available versions" of P4 and Git-LFS, but since f2f47150
("ci: don't update Homebrew", 2019-07-03) that's no longer the case,
as it will install the versions which were recorded in the image's
Homebrew database when the image was created.

Update this comment accordingly.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agogettext: always use UTF-8 on native Windows
Karsten Blees [Wed, 3 Jul 2019 20:46:04 +0000 (13:46 -0700)] 
gettext: always use UTF-8 on native Windows

On native Windows, Git exclusively uses UTF-8 for console output (both
with MinTTY and native Win32 Console). Gettext uses `setlocale()` to
determine the output encoding for translated text, however, MSVCRT's
`setlocale()` does not support UTF-8. As a result, translated text is
encoded in system encoding (as per `GetAPC()`), and non-ASCII chars are
mangled in console output.

Side note: There is actually a code page for UTF-8: 65001. In practice,
it does not work as expected at least on Windows 7, though, so we cannot
use it in Git. Besides, if we overrode the code page, any process
spawned from Git would inherit that code page (as opposed to the code
page configured for the current user), which would quite possibly break
e.g. diff or merge helpers. So we really cannot override the code page.

In `init_gettext_charset()`, Git calls gettext's
`bind_textdomain_codeset()` with the character set obtained via
`locale_charset()`; Let's override that latter function to force the
encoding to UTF-8 on native Windows.

In Git for Windows' SDK, there is a `libcharset.h` and therefore we
define `HAVE_LIBCHARSET_H` in the MINGW-specific section in
`config.mak.uname`, therefore we need to add the override before that
conditionally-compiled code block.

Rather than simply defining `locale_charset()` to return the string
`"UTF-8"`, though, we are careful not to break `LC_ALL=C`: the
`ab/no-kwset` patch series, for example, needs to have a way to prevent
Git from expecting UTF-8-encoded input.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoci: disable Homebrew's auto cleanup
SZEDER Gábor [Wed, 3 Jul 2019 10:47:48 +0000 (12:47 +0200)] 
ci: disable Homebrew's auto cleanup

Lately Homebrew learned to automagically clean up information about
outdated packages during other 'brew' commands, which might be useful
for the avarage user, but is a waste of time in CI build jobs, because
the next build jobs will start from the exact same image containing
the same outdated packages anyway.

Export HOMEBREW_NO_INSTALL_CLEANUP=1 to disable this auto cleanup feature,
shaving off about 20-30s from the time needed to install dependencies
in our macOS build jobs on Travis CI.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoci: don't update Homebrew
SZEDER Gábor [Wed, 3 Jul 2019 10:47:47 +0000 (12:47 +0200)] 
ci: don't update Homebrew

Lately our GCC macOS build job on Travis CI has been erroring out
while installing dependencies with:

  +brew link gcc@8
  Error: No such keg: /usr/local/Cellar/gcc@8
  The command "ci/install-dependencies.sh" failed and exited with 1 during .

Now, while gcc@8 is still pre-installed (but not linked) and would be
perfectly usable in the Travis CI macOS image we use [1], it's at
version 8.2.  However, when installing dependencies we first
explicitly run 'brew update', which spends over two minutes to update
itself and information about the available packages, and it learns
about GCC 8.3.  After that point gcc@8 exclusively refers to v8.3,
and, unfortunately, 'brew' is just too dumb to be able to do anything
with the still installed 8.2 package, and the subsequent 'brew link
gcc@8' fails.  (Even 'brew uninstall gcc@8' fails with the same
error!)

Don't run 'brew update' to keep the already installed GCC 8.2 'brew
link'-able.  Note that in addition we have to 'export
HOMEBREW_NO_AUTO_UPDATE=1' first, because 'brew' is so very helpful
that it would implicitly run update for us on the next 'brew install
<pkg>' otherwise.

Disabling 'brew update' has additional benefits:

  - It shaves off 2-3mins from the ~4mins currently spent on
    installing dependencies, and the macOS build jobs have always been
    prone to exceeding the time limit on Travis CI.

  - Our builds won't suddenly break because of the occasional Homebrew
    breakages [2].

The drawback is that we'll be stuck with slightly older versions of
the packages that we install via Homebrew (Git-LFS 2.5.2 and Perforce
2018.1; they are currently at 2.7.2 and 2019.1, respectively).  We
might want to reconsider this decision as time goes on and/or switch
to a more recent macOS image as they become available.

[1] 2000ac9fbf (travis-ci: switch to Xcode 10.1 macOS image,
    2019-01-17)

[2] See e.g. a1ccaedd62 (travis-ci: make the OSX build jobs' 'brew
    update' more quiet, 2019-02-02) or

    https://public-inbox.org/git/20180907032002.23366-1-szeder.dev@gmail.com/T/#+u

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agol10n: localizable upload progress messages
Dimitriy Ryazantcev [Tue, 2 Jul 2019 18:22:48 +0000 (21:22 +0300)] 
l10n: localizable upload progress messages

Currenly the data rate in throughput_string(...) method is
output by simple strbuf_humanise_bytes(...) call and '/s' append.
But for proper translation of such string the translator needs
full context.

Add strbuf_humanise_rate(...) method to properly print out
localizable version of data rate ('3.5 MiB/s' etc) with full context.

Strings with the units in strbuf_humanise_bytes(...) are marked
for translation.

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodocs: git-clone: list short form of options first
Quentin Nerden [Tue, 2 Jul 2019 14:37:41 +0000 (07:37 -0700)] 
docs: git-clone: list short form of options first

List the short form of options (e.g.: '-l') before the long form (e.g.
'--local').
This is to match the doc of git-add, git-commit, git-clean, git-branch...

Signed-off-by: Quentin Nerden <quentin.nerden@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodocs: git-clone: refer to long form of options
Quentin Nerden [Tue, 2 Jul 2019 14:37:40 +0000 (07:37 -0700)] 
docs: git-clone: refer to long form of options

To make the doc of git-clone easier to read,
refer to the long form of the options
(it is easier to guess what '--verbose' is doing than '-v').

Signed-off-by: Quentin Nerden <quentin.nerden@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocherry-pick/revert: advise using --skip
Rohit Ashiwal [Tue, 2 Jul 2019 09:11:29 +0000 (14:41 +0530)] 
cherry-pick/revert: advise using --skip

The previous commit introduced a --skip flag for cherry-pick and
revert. Update the advice messages, to tell users about this less
cumbersome way of skipping commits. Also add tests to ensure
everything is working fine.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agocherry-pick/revert: add --skip option
Rohit Ashiwal [Tue, 2 Jul 2019 09:11:28 +0000 (14:41 +0530)] 
cherry-pick/revert: add --skip option

git am or rebase have a --skip flag to skip the current commit if the
user wishes to do so. During a cherry-pick or revert a user could
likewise skip a commit, but needs to use 'git reset' (or in the case
of conflicts 'git reset --merge'), followed by 'git (cherry-pick |
revert) --continue' to skip the commit. This is more annoying and
sometimes confusing on the users' part. Add a `--skip` option to make
skipping commits easier for the user and to make the commands more
consistent.

In the next commit, we will change the advice messages hence finishing
the process of teaching revert and cherry-pick "how to skip commits".

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: use argv_array in reset_merge
Rohit Ashiwal [Tue, 2 Jul 2019 09:11:27 +0000 (14:41 +0530)] 
sequencer: use argv_array in reset_merge

Avoid using magic numbers for array size and index under `reset_merge`
function. Use `argv_array` instead. This will make code shorter and
easier to extend.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: rename reset_for_rollback to reset_merge
Rohit Ashiwal [Tue, 2 Jul 2019 09:11:26 +0000 (14:41 +0530)] 
sequencer: rename reset_for_rollback to reset_merge

We are on a path to teach cherry-pick/revert how to skip commits. To
achieve this, we could really make use of existing functions.
reset_for_rollback is one such function, but the name does not
intuitively suggest to use it to reset a merge, which it was born to
perform, see 539047c ("revert: introduce --abort to cancel a failed
cherry-pick", 2011-11-23). Change the name to reset_merge to make
it more intuitive.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: add advice for revert
Rohit Ashiwal [Tue, 2 Jul 2019 09:11:25 +0000 (14:41 +0530)] 
sequencer: add advice for revert

In the case of merge conflicts, while performing a revert, we are
currently advised to use `git cherry-pick --<sequencer-options>`.
Introduce a separate advice message for `git revert`. Also change
the signature of `create_seq_dir` to handle which advice to display
selectively.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot5703: use test_commit_bulk
Jeff King [Fri, 28 Jun 2019 09:42:07 +0000 (05:42 -0400)] 
t5703: use test_commit_bulk

There are two loops that create 33 commits each using test_commit. Using
test_commit_bulk speeds this up from:

  Benchmark #1: ./t5703-upload-pack-ref-in-want.sh --root=/var/ram/git-tests
    Time (mean ± σ):      2.142 s ±  0.161 s    [User: 1.136 s, System: 0.974 s]
    Range (min … max):    1.903 s …  2.401 s    10 runs

to:

  Benchmark #1: ./t5703-upload-pack-ref-in-want.sh --root=/var/ram/git-tests
    Time (mean ± σ):      1.440 s ±  0.114 s    [User: 737.7 ms, System: 615.4 ms]
    Range (min … max):    1.230 s …  1.604 s    10 runs

for an average savings of almost 33%.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot5702: use test_commit_bulk
Jeff King [Fri, 28 Jun 2019 09:41:54 +0000 (05:41 -0400)] 
t5702: use test_commit_bulk

There are two loops that create 32 commits each using test_commit. Using
test_commit_bulk speeds this up from:

  Benchmark #1: ./t5702-protocol-v2.sh --root=/var/ram/git-tests
    Time (mean ± σ):      5.409 s ±  0.513 s    [User: 2.382 s, System: 2.466 s]
    Range (min … max):    4.633 s …  5.927 s    10 runs

to:

  Benchmark #1: ./t5702-protocol-v2.sh --root=/var/ram/git-tests
    Time (mean ± σ):      3.956 s ±  0.242 s    [User: 1.775 s, System: 1.627 s]
    Range (min … max):    3.449 s …  4.239 s    10 runs

for an average savings of over 25%.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot3311: use test_commit_bulk
Jeff King [Fri, 28 Jun 2019 09:41:35 +0000 (05:41 -0400)] 
t3311: use test_commit_bulk

One of the tests in t3311 creates 300 commits by running "test_commit"
in a loop. This requires 900 processes. Instead, we can use
test_commit_bulk to do it with only four. This improves the runtime of
the script from:

  Benchmark #1: ./t3311-notes-merge-fanout.sh --root=/var/ram/git-tests
    Time (mean ± σ):      5.821 s ±  0.691 s    [User: 3.146 s, System: 2.782 s]
    Range (min … max):    4.783 s …  6.841 s    10 runs

to:

  Benchmark #1: ./t3311-notes-merge-fanout.sh --root=/var/ram/git-tests
    Time (mean ± σ):      1.743 s ±  0.116 s    [User: 1.144 s, System: 0.691 s]
    Range (min … max):    1.629 s …  1.994 s    10 runs

for an average speedup of over 70%.

Unfortunately we still have to run 300 instances of "git notes add",
since the point is to test the fanout that comes from adding notes one
by one.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot5310: increase the number of bitmapped commits
Jeff King [Fri, 28 Jun 2019 09:39:42 +0000 (05:39 -0400)] 
t5310: increase the number of bitmapped commits

The bitmap index we compute in t5310 has only 20 commits in it. This
gives poor coverage of bitmap_writer_select_commits(), which simply
writes a bitmap for everything when there are fewer than 100 commits.

Let's bump the number of commits in the test to cover the more complex
code paths (this does drop coverage of the individual lines of the
trivial path, but the complex path does everything it does and more).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agotest-lib: introduce test_commit_bulk
Jeff King [Tue, 2 Jul 2019 05:16:49 +0000 (01:16 -0400)] 
test-lib: introduce test_commit_bulk

Some tests need to create a string of commits. Doing this with
test_commit is very heavy-weight, as it needs at least one process per
commit (and in fact, uses several).

For bulk creation, we can do much better by using fast-import, but it's
often a pain to generate the input. Let's provide a helper to do so.

We'll use t5310 as a guinea pig, as it has three 10-commit loops. Here
are hyperfine results before and after:

  [before]
  Benchmark #1: ./t5310-pack-bitmaps.sh --root=/var/ram/git-tests
    Time (mean ± σ):      2.846 s ±  0.305 s    [User: 3.042 s, System: 0.919 s]
    Range (min … max):    2.250 s …  3.210 s    10 runs

  [after]
  Benchmark #1: ./t5310-pack-bitmaps.sh --root=/var/ram/git-tests
    Time (mean ± σ):      2.210 s ±  0.174 s    [User: 2.570 s, System: 0.604 s]
    Range (min … max):    1.999 s …  2.590 s    10 runs

So we're over 20% faster, while making the callers slightly shorter. We
added a lot more lines in test-lib-function.sh, of course, and the
helper is way more featureful than we need here. But my hope is that it
will be flexible enough to use in more places.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot5319: use 'test-tool path-utils' instead of 'ls -l'
Derrick Stolee [Mon, 1 Jul 2019 13:16:19 +0000 (06:16 -0700)] 
t5319: use 'test-tool path-utils' instead of 'ls -l'

Using 'ls -l' and parsing the columns to find file sizes is
problematic when the platform could report the owner as a name
with spaces. Instead, use the 'test-tool path-utils file-size'
command to list only the sizes.

Reported-by: Johannes Sixt <j6t@kdbg.org>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot2203: avoid hard-coded object ID values
brian m. carlson [Fri, 28 Jun 2019 22:59:28 +0000 (22:59 +0000)] 
t2203: avoid hard-coded object ID values

In order to make this test work with multiple hash algorithms, compute
the object ID used in this test instead of hard-coding it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>