]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
6 years agoMerge tag 'l10n-2.27.0-rnd2' of git://github.com/git-l10n/git-po
Junio C Hamano [Sun, 31 May 2020 18:14:07 +0000 (11:14 -0700)] 
Merge tag 'l10n-2.27.0-rnd2' of git://github.com/git-l10n/git-po

l10n-2.27.0-rnd2

* tag 'l10n-2.27.0-rnd2' of git://github.com/git-l10n/git-po: (23 commits)
  l10n: zh_TW.po: v2.27.0 round 2 (0 untranslated)
  l10n: zh_TW.po: v2.27.0 round 1 (0 untranslated)
  l10n: de.po: Fix typo in the German translation of octopus
  l10n: de.po: Update German translation for Git 2.27.0
  l10n: it.po: update for Git 2.27.0 round #2
  l10n: tr: v2.27.0 round 2
  l10n: fr.po v2.27.0 rnd 2
  l10n: bg.po: Updated Bulgarian translation (4875t)
  l10n: Update Catalan translation
  l10n: sv.po: Update Swedish translation (4875t0f0u)
  l10n: vi(4875t): Updated Vietnamses translation for 2.27.0rd2
  l10n: zh_CN: for git v2.27.0 l10n round 1~2
  l10n: git.pot: v2.27.0 round 2 (+1)
  l10n: Update Catalan translation
  l10n: vi(4874t): Updated Vietnamses translation for 2.27.0
  l10n: es: 2.27.0 round 1
  l10n: bg.po: Updated Bulgarian translation (4868t)
  l10n: fr v2.27.0 rnd 1
  l10n: sv.po: Update Swedish translation (4839t0f0u)
  l10n: tr: v2.27.0 round 1
  ...

6 years agofast-import: add new --date-format=raw-permissive format
Elijah Newren [Sat, 30 May 2020 20:25:57 +0000 (20:25 +0000)] 
fast-import: add new --date-format=raw-permissive format

There are multiple repositories in the wild with random, invalid
timezones.  Most notably is a commit from rails.git with a timezone of
"+051800"[1].  A few searches will find other repos with that same
invalid timezone as well.  Further, Peff reports that GitHub relaxed
their fsck checks in August 2011 to accept any timezone value[2], and
there have been multiple reports to filter-repo about fast-import
crashing while trying to import their existing repositories since they
had timezone values such as "-7349423" and "-43455309"[3].

The existing check on timezone values inside fast-import may prove
useful for people who are crafting fast-import input by hand or with a
new script.  For them, the check may help them avoid accidentally
recording invalid dates.  (Note that this check is rather simplistic and
there are still several forms of invalid dates that fast-import does not
check for: dates in the future, timezone values with minutes that are
not divisible by 15, and timezone values with minutes that are 60 or
greater.)  While this simple check may have some value for those users,
other users or tools will want to import existing repositories as-is.
Provide a --date-format=raw-permissive format that will not error out on
these otherwise invalid timezones so that such existing repositories can
be imported.

[1] https://github.com/rails/rails/commit/4cf94979c9f4d6683c9338d694d5eb3106a4e734
[2] https://lore.kernel.org/git/20200521195513.GA1542632@coredump.intra.peff.net/
[3] https://github.com/newren/git-filter-repo/issues/88

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'master' of github.com:ruester/git-po-de
Jiang Xin [Sat, 30 May 2020 03:26:53 +0000 (11:26 +0800)] 
Merge branch 'master' of github.com:ruester/git-po-de

* 'master' of github.com:ruester/git-po-de:
  l10n: de.po: Fix typo in the German translation of octopus
  l10n: de.po: Update German translation for Git 2.27.0

6 years agoMerge branch of github.com:AlessandroMenti/git-po
Jiang Xin [Sat, 30 May 2020 03:25:17 +0000 (11:25 +0800)] 
Merge branch of github.com:AlessandroMenti/git-po

* 'update-italian-translation' of github.com:AlessandroMenti/git-po:
  l10n: it.po: update for Git 2.27.0 round #2

6 years agoMerge branch 'bc/sha-256-part-1-of-4'
Junio C Hamano [Fri, 29 May 2020 22:12:20 +0000 (15:12 -0700)] 
Merge branch 'bc/sha-256-part-1-of-4'

Docfix.

* bc/sha-256-part-1-of-4:
  Documentation: correct hash environment variable

6 years agoMerge branch 'ma/rev-list-options-docfix'
Junio C Hamano [Fri, 29 May 2020 22:12:19 +0000 (15:12 -0700)] 
Merge branch 'ma/rev-list-options-docfix'

Docfix.

* ma/rev-list-options-docfix:
  rev-list-options.txt: start a list for `show-pulls`

6 years agoMerge branch 'jk/ci-only-on-selected-branches'
Junio C Hamano [Fri, 29 May 2020 22:12:19 +0000 (15:12 -0700)] 
Merge branch 'jk/ci-only-on-selected-branches'

Dev support.

* jk/ci-only-on-selected-branches:
  ci/config: correct instruction for CI preferences

6 years agot: avoid alternation (not POSIX) in grep's BRE
Carlo Marcelo Arenas Belón [Fri, 29 May 2020 08:20:08 +0000 (01:20 -0700)] 
t: avoid alternation (not POSIX) in grep's BRE

f1e3df3169 (t: increase test coverage of signature verification output,
2020-03-04) adds GPG dependent tests to t4202 and t6200 that were found
problematic with at least OpenBSD 6.7.

Using an escaped '|' for alternations works only in some implementations
of grep (e.g. GNU and busybox).

It is not part of POSIX[1] and not supported by some BSD, macOS, and
possibly other POSIX compatible implementations.

Use `grep -E`, and write it using extended regular expression.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03

Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: zh_TW.po: v2.27.0 round 2 (0 untranslated)
Yi-Jyun Pan [Fri, 29 May 2020 16:37:53 +0000 (00:37 +0800)] 
l10n: zh_TW.po: v2.27.0 round 2 (0 untranslated)

Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
6 years agol10n: zh_TW.po: v2.27.0 round 1 (0 untranslated)
Yi-Jyun Pan [Sat, 23 May 2020 13:26:15 +0000 (21:26 +0800)] 
l10n: zh_TW.po: v2.27.0 round 1 (0 untranslated)

Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
6 years agol10n: de.po: Fix typo in the German translation of octopus
Jan Engelhardt [Tue, 31 Mar 2020 20:37:26 +0000 (22:37 +0200)] 
l10n: de.po: Fix typo in the German translation of octopus

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
6 years agol10n: de.po: Update German translation for Git 2.27.0
Matthias Rüster [Sun, 24 May 2020 11:27:46 +0000 (13:27 +0200)] 
l10n: de.po: Update German translation for Git 2.27.0

Reviewed-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
6 years agocompletion: improve handling of --orphan option of switch/checkout
Jacob Keller [Thu, 28 May 2020 18:10:48 +0000 (11:10 -0700)] 
completion: improve handling of --orphan option of switch/checkout

The --orphan option is used to create a local branch which is detached
from the current history. In git switch, it always resets to the empty
tree, and thus the only completion we can provide is a branch name.
Follow the same rules for -c/-C (and -b/-B) when completing the argument
to --orphan.

In the case of git switch, after we complete the argument, there is
nothing more we can complete for git switch, so do not even try. Nothing
else would be valid.

In the case of git checkout, --orphan takes a start point which it uses
to determine the checked out tree, even though it created orphaned
history.

Update the previously added test cases as they are now passing.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: improve handling of -c/-C and -b/-B in switch/checkout
Jacob Keller [Thu, 28 May 2020 18:10:47 +0000 (11:10 -0700)] 
completion: improve handling of -c/-C and -b/-B in switch/checkout

A previous commit added several test cases highlighting the subpar
completion logic for -c/-C and -b/-B when completing git switch and git
checkout.

In order to distinguish completing the argument vs the start-point for
this option, we now use the wordlist to determine the previous full word
on the command line.

If it's -c or -C (-b/-B for checkout), then we know that we are
completing the argument for the branch name.

Given that a user who already knows the branch name they want to
complete will simply not use completion, it makes sense to complete the
small subset of local branches when completing the argument for -c/-C.

In all other cases, if -c/-C are on the command line but are not the
most recent option, then we must be completing a start-point, and should
allow completing against all references.

Update the -c/-C and -b/-B tests to indicate they now pass.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: improve handling of --track in switch/checkout
Jacob Keller [Thu, 28 May 2020 18:10:46 +0000 (11:10 -0700)] 
completion: improve handling of --track in switch/checkout

Current completion for the --track option of git switch and git checkout
is sub par. In addition to the DWIM logic of a bare branch name, --track
has DWIM logic to convert specified remote/branch names into a local
branch tracking that remote. For example

  $git switch --track origin/master

This will create a local branch name master, that tracks the master
branch of the origin remote.

In fact, git switch --track on its own will not accept other forms of
references. These must instead be specified manually via the -c/-C/-b/-B
options.

Introduce __git_remote_heads() and the "remote-heads" mode for
__git_complete_refs. Use this when the --track option is provided while
completing in _git_switch and _git_checkout. Just as in the --detach
case, we never enable DWIM mode for --track, because it doesn't make
sense.

It should be noted that completion support is still a bit sub par when
it comes to handling -c/-C and --orphan. This will be resolved in
a future change.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: improve handling of --detach in checkout
Jacob Keller [Thu, 28 May 2020 18:10:45 +0000 (11:10 -0700)] 
completion: improve handling of --detach in checkout

Just like git switch, we should not complete DWIM remote branch names
if --detach has been specified. To avoid this, refactor _git_checkout in
a similar way to _git_switch.

Note that we don't simply clear dwim_opt when we find -d or --detach, as
we will be adding other modes and checks, making this flow easier to
follow.

Update the previously failing tests to show that the breakage has been
resolved.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: improve completion for git switch with no options
Jacob Keller [Thu, 28 May 2020 18:10:44 +0000 (11:10 -0700)] 
completion: improve completion for git switch with no options

Add a new --mode option to __git_complete_refs, which allows changing
the behavior to call __git_heads instead of __git_refs.

By passing --mode=heads, __git_complete_refs will only output local
branches. This enables using "--mode=heads --dwim" to enable listing
local branches and the remote unique branch names for DWIM.

Refactor completion support to use the new mode option, rather than
calling __git_heads directly. This has the advantage that we can now
correctly allow local branches along with suitable DWIM refs, rather
than only allowing DWIM when we complete all references.

Choose what mode it uses when calling __git_complete_refs. If -d or
--detach have been provided, then simply complete all refs, but
*without* the DWIM option as these DWIM names won't work properly in
--detach mode.

Otherwise, call __git_complete_refs with the default dwim_opt value and
use the new "heads" mode.

In this way, the basic support for completing just "git switch <TAB>"
will result in only local branches and remote unique names for DWIM.

The basic no-options tests for git switch, as well as several of the
-c/-C tests now pass, so remove the known breakage tags.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: improve handling of DWIM mode for switch/checkout
Jacob Keller [Thu, 28 May 2020 18:10:43 +0000 (11:10 -0700)] 
completion: improve handling of DWIM mode for switch/checkout

A new helper, __git_find_last_on_cmdline is introduced, similar to the
already existing __git_find_on_cmdline, but which operates in reverse,
finding the *last* matching word of the provided wordlist.

Use this in a new __git_checkout_default_dwim_mode() function that will
determine when to enable listing of DWIM remote branches.

The __git_find_last_on_cmdline() function is used to determine which
--guess or --no-guess is in effect. If either one is provided, then we
unconditionally enable or disable the DWIM mode based on the last
provided option.

If neither --guess nor --no-guess is provided, then we check for
--no-track, and finally for GIT_COMPLETION_CHECKOUT_NO_GUESS=1.

This function is then used in _git_switch and _git_checkout to improve
the handling for when we enable listing of these DWIM remote branches.

This new logic is more robust, as we will correctly identify superseded
options, and ensure that both _git_switch and _git_checkout enable DWIM
in similar ways.

We can now update a few tests to indicate they pass. A few of the tests
previously added to highlight issues with the old DWIM logic still fail.
This is because of a separate issue related to the default completion
behavior of git switch, which will be addressed in a future change.

Additionally, due to this change, a few tests for the -b/-B handling of
git checkout now fail. This is a minor regression, and will be fixed by
a following change that improves the overall handling of -b/-B. Mark
these tests as known breakages for now.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: perform DWIM logic directly in __git_complete_refs
Jacob Keller [Thu, 28 May 2020 18:10:42 +0000 (11:10 -0700)] 
completion: perform DWIM logic directly in __git_complete_refs

__git_complete_refs is the main function used for completing references.
It is primarily used as a wrapper around __git_refs, and is easier to
extend since its arguments are option-like.

One major downside of __git_complete_refs and __git_refs currently, is
the lack of ability to complete only a subset of refs such as branches
(refs/heads) or tags (refs/tags).

Normally, a caller might just decide to use __git_heads() or
__git_tags(). However, in the case of git-switch, it is useful to
complete both branches *and* DWIM remote branch names.

Due to the complexity and implementation of __git_refs, it is not easy
to extend it to support listing only a subset of references.

Instead, we can extend __git_complete_refs to do this. For this to be
done, we must first ensure that "--dwim" support is not tied to calling
__git_refs.

Instead of passing $dwim into __git_refs, we can implement
a __gitcomp_direct_append function which can append to COMPREPLY after
a call to __gitcomp_direct.

If --dwim is passed to __git_complete_refs, use __gitcomp_direct_append
to add the output of __git_dwim_remote_heads to the completion list.

In this way, --dwim support is now independent of calling __git_refs.

A future change will add an additional option to control what set of
references __git_complete_refs will output.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: extract function __git_dwim_remote_heads
Jacob Keller [Thu, 28 May 2020 18:10:41 +0000 (11:10 -0700)] 
completion: extract function __git_dwim_remote_heads

__git_refs() has the ability to report unique remote names for
supporting completion of remote branch names for the DWIMery of git
checkout and git switch.

For git checkout, this is fine, because it always supports completing
all local references.

However, git switch by default only supports either switching branches
or using this DWIMery to create a local branch tracking the remote
branch.

Future work to cleanup and improve completion support for git switch
will be aided if the remote branch names can be completed separately
from __git_refs.

Extract this logic to a function __git_dwim_remote_heads(), and use it
in __git_refs.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: replace overloaded track term for __git_complete_refs
Jacob Keller [Thu, 28 May 2020 18:10:40 +0000 (11:10 -0700)] 
completion: replace overloaded track term for __git_complete_refs

The __git_complete_refs uses the "--track" option to specify when to
enable listing of unique remote branches which are used by the DWIM
logic of git checkout and git switch.

Using the term '--track' here is confusing because the git commands
themselves have '--track' as an argument. Additionally, the completion
logic for _git_switch also checks for --track. Keeping the meaning of
track_opt and --track for __git_complete_refs straight from the --track
git switch and git checkout option is difficult when reading this code.

Use the option '--dwim' instead, indicating this is about enabling or
disabling logic related to DWIM mode. Also rename the local variable
track_opt to dwim_opt to further reduce the confusion when reading the
completion code for _git_switch.

Because it is plausible for users to have developed their own
completions which rely on __git_complete_ref, keep --track as a synonym
for --dwim, even though we no longer use it in any of the core git
completion logic. Add a comment explaining why it remains as an
alternative spelling for --dwim.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add tests showing subpar switch/checkout --orphan logic
Jacob Keller [Thu, 28 May 2020 18:10:39 +0000 (11:10 -0700)] 
completion: add tests showing subpar switch/checkout --orphan logic

Similar to -c/-C, --orphan takes an argument which is the branch name to
use. We ought to complete this branch name using similar rules as to how
we complete new branch names for -c/-C and -b/-B. Namely, limit the
total number of options provided by completing to the local branches.

Additionally, git switch --orphan does not take any start point and will
always create using the empty-tree. Thus, after the branch name is
completed, git switch --orphan should not complete any references.

Add test cases showing the expected behavior of --orphan, for both the
argument and starting point.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add tests showing subpar -c/C argument completion
Jacob Keller [Thu, 28 May 2020 18:10:38 +0000 (11:10 -0700)] 
completion: add tests showing subpar -c/C argument completion

When using the branch creation argument for git switch or git checkout
(-c/-C or -b/-B), the commands switch to a different mode: `git switch
-c <branch> <some-referance>` means to create a branch named <branch> at
the commit referred to by <some-reference>.

When completing git switch or git checkout, it makes sense to complete
the branch name differently from the start point.

When completing a branch, one might consider that we do not have
anything worth completing. After all, a new branch must have an entirely
new name. Consider, however, that if a user names branches using some
similar scheme, they might wish to name a new branch by modifying the
name of an existing branch.

To avoid overloading completion for the argument, it seems reasonable to
complete only the local branch names and the valid "Do What I Mean"
remote branch names.

Add tests for the completion of the argument to -c/-C and -b/-B,
highlighting this preferred completion behavior.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add tests showing subpar -c/-C startpoint completion
Jacob Keller [Thu, 28 May 2020 18:10:37 +0000 (11:10 -0700)] 
completion: add tests showing subpar -c/-C startpoint completion

When using the branch creation argument for git switch or git checkout,
-c/-C or -b/-B, the commands operate in a different mode: `git switch -c
<branch> <some-reference>` means to create a branch named <branch> at
the commit referred to by <some-reference>.

When completing the start-point, we ought to always complete all valid
references.

Add tests for the completion of the start-point to -c/-C and -b/-B.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add tests showing subpar switch/checkout --track logic
Jacob Keller [Thu, 28 May 2020 18:10:36 +0000 (11:10 -0700)] 
completion: add tests showing subpar switch/checkout --track logic

When the --track option is provided to git switch or git checkout, and
no branch is specified by -c or -b, git will interpret the tracking
branch to determine the local branch name to use. This "Do What I Mean"
logic is similar but distinct from the default DWIM logic of
interpreting a unique remote branch name as a request to create and
track that branch.

For example, `git switch --track origin/master` is interpreted as
a request to create a local branch named master that is tracking
origin/master.

The current completion for git checkout in this regard is only somewhat
poor:

 $git checkout --track <TAB>
 HEAD
 master
 matching-branch
 matching-tag
 other/branch-in-other
 other/master-in-other

At least it still includes remote references. The clutter from including
all references isn't too bad.

However, git switch completion is terrible:

 $git switch --track <TAB>
 master
 matching-branch

It only shows local branches, not even allowing any form of completion
of the remote references!

Add tests which highlight the expected behavior of completing --track on
its own.

Note that when -c/-C or -b/-B are provided we do expect completing more
references, but this will be discussed in a future change that addresses
these options specifically.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add tests showing subar checkout --detach logic
Jacob Keller [Thu, 28 May 2020 18:10:35 +0000 (11:10 -0700)] 
completion: add tests showing subar checkout --detach logic

When completing words for git switch, the completion function correctly
disables the DWIM remote branch names when in the '--detach' mode. These
DWIM remote branch names will not work when the --detach option is
specified, so it does not make sense to complete them.

git checkout, however, does not disable the completion of DWIM remote
branch names in this case.

Add test cases for both git switch and git checkout showing the expected
behavior.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add tests showing subpar DWIM logic for switch/checkout
Jacob Keller [Thu, 28 May 2020 18:10:34 +0000 (11:10 -0700)] 
completion: add tests showing subpar DWIM logic for switch/checkout

When provided with a single argument that is the name of a remote branch
that does not yet exist locally, both git switch and git checkout can
interpret this as a request to create a local branch that tracks that
remote branch. We call this behavior "Do What I Mean", or DWIM for
short.

To aid in using this DWIM, it makes sense for completion to list these
unique remote branch names when completing possible arguments for git
switch and git checkout. Indeed, both _git_checkout and _git_switch
implement support for completing such DWIM branch names.

In other words, in addition to the usual completions provided for git
switch, this "DWIM" logic means completion will include the names of
branches on remotes that are unique and thus there can be no ambiguity
of which remote to track when creating the local branch.

However, the DWIM logic is not always active. Many options, such as
--no-guess, --no-track, and --track disable this DWIM logic, as they
cause git switch and git checkout to behave in different modes.

Additionally, some completion users do not wish to have tab completion
include these remote names by default, and thus introduced
GIT_COMPLETION_CHECKOUT_NO_GUESS as an optional way to configure the
completion support to disable this feature of completion support.

For this reason, _git_checkout and _git_switch have many rules about
when to enable or disable completing of these remote refs. The two
commands follow similar but not identical rules.

Set aside the question of command modes that do not accept this DWIM
logic (--track, -c, --orphan, --detach) for now. Thinking just about the
main mode of git checkout and git switch, the following guidelines will
help explain the basic rules we ought to support when deciding whether
to list the remote branches for DWIM in completion.

1.  if --guess is enabled, we should list DWIM remote branch names, even
    if something else would disable it
2.  if --no-guess, --no-track or GIT_COMPLETION_CHECKOUT_NO_GUESS=1,
    then we should disable listing DWIM remote branch names.
3.  Since the '--guess' option is a boolean option, a later --guess
    should override --no-guess, and a later --no-guess should override
    --guess.

Putting all of these together, add some tests that highlight the
expected behavior of this DWIM logic.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add test showing subpar git switch completion
Jacob Keller [Thu, 28 May 2020 18:10:33 +0000 (11:10 -0700)] 
completion: add test showing subpar git switch completion

When provided with no options, git switch only allows switching between
branches. The one exception to this is the "Do What I Mean" logic that
allows a unique remote branch name to be interpreted as a request to
create a branch of the same name that is tracking that remote branch.

Unfortunately, the logic for the completion of git switch results in
completing not just branch names, but also pseudorefs like HEAD, tags,
and fully specified <remote>/<branch> references.

For example, we currently complete the following:

 $git switch <TAB>
 HEAD
 branch-in-other
 master
 master-in-other
 matching-branch
 matching-tag
 other/branch-in-other
 other/master-in-other

Indeed, if one were to attempt to use git switch with some of these
provided options, git will reject the request:

 $git switch HEAD
 fatal: a branch is expected, got 'HEAD

 $git switch matching-tag
 fatal: a branch is expected, got tag 'matching-tag'

 $git switch other/branch-in-other
 fatal: a branch is expected, got remote branch 'other/branch-in-other'

Ideally, git switch without options ought to complete only words which
will be accepted. Without options, this means to list local branch names
and the unique remote branch names without their remote name pre-pended.

 $git switch <TAB>
 branch-in-other
 master
 master-in-other
 matching-branch

Add a test case that highlights this subpar completion. Also add
a similar test for git checkout completion that shows that due to the
complex nature of git checkout, it must complete all references.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: use native ZSH array pattern matching
Marco Trevisan (Treviño) [Tue, 26 May 2020 19:13:17 +0000 (19:13 +0000)] 
completion: use native ZSH array pattern matching

When clearing the builtin operations on re-sourcing in the ZSH case we
can use the native ${parameters} associative array keys values to get
the currently `__gitcomp_builtin_*` operations using pattern matching
instead of using sed.

As also stated in commit 94408dc7, introducing this change the usage of
sed has some overhead implications, while ZSH can do this check just
using its native syntax.

Signed-off-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: it.po: update for Git 2.27.0 round #2
Alessandro Menti [Wed, 27 May 2020 16:22:22 +0000 (18:22 +0200)] 
l10n: it.po: update for Git 2.27.0 round #2

Signed-off-by: Alessandro Menti <alessandro.menti@alessandromenti.it>
6 years agoMerge branch 'fr_2.27.0rnd2' of github.com:jnavila/git
Jiang Xin [Thu, 28 May 2020 02:46:04 +0000 (10:46 +0800)] 
Merge branch 'fr_2.27.0rnd2' of github.com:jnavila/git

* 'fr_2.27.0rnd2' of github.com:jnavila/git:
  l10n: fr.po v2.27.0 rnd 2

6 years agoMerge branch 'master' of github.com:bitigchi/git-po
Jiang Xin [Thu, 28 May 2020 02:45:33 +0000 (10:45 +0800)] 
Merge branch 'master' of github.com:bitigchi/git-po

* 'master' of github.com:bitigchi/git-po:
  l10n: tr: v2.27.0 round 2

6 years agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Thu, 28 May 2020 02:45:11 +0000 (10:45 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (4875t)

6 years agoMerge branch 'master' of github.com:Softcatala/git-po
Jiang Xin [Thu, 28 May 2020 02:44:21 +0000 (10:44 +0800)] 
Merge branch 'master' of github.com:Softcatala/git-po

* 'master' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

6 years agocheckout -p: handle new files correctly
Johannes Schindelin [Wed, 27 May 2020 21:09:06 +0000 (21:09 +0000)] 
checkout -p: handle new files correctly

The original patch selection code was written for `git add -p`, and the
fundamental unit on which it works is a hunk.

We hacked around that to handle deletions back in 24ab81ae4d
(add-interactive: handle deletion of empty files, 2009-10-27). But `git
add -p` would never see a new file, since we only consider the set of
tracked files in the index.

However, since the same machinery was used for `git checkout -p` &
friends, we can see new files.

Handle this case specifically, adding a new prompt for it that is
modeled after the `deleted file` case.

This also fixes the problem where added _empty_ files could not be
staged via `git checkout -p`.

Reported-by: Merlin Büge <toni@bluenox07.de>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/ls-remote: initialize repository based on fetch
brian m. carlson [Mon, 25 May 2020 19:59:19 +0000 (19:59 +0000)] 
builtin/ls-remote: initialize repository based on fetch

ls-remote may or may not operate within a repository, and as such will
not have been initialized with the repository's hash algorithm.  Even if
it were, the remote side could be using a different algorithm and we
would still want to display those refs properly.  Find the hash
algorithm used by the remote side by querying the transport object and
set our hash algorithm accordingly.

Without this change, if the remote side is using SHA-256, we truncate
the refs to 40 hex characters, since that's the length of the default
hash algorithm (SHA-1).

Note that technically this is not a correct setting of the repository
hash algorithm since, if we are in a repository, it might be one of a
different hash algorithm from the remote side.  However, our current
code paths don't handle multiple algorithms and won't for some time, so
this is the best we can do.  We rely on the fact that ls-remote never
modifies the current repository, which is a reasonable assumption to
make.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5500: make hash independent
brian m. carlson [Mon, 25 May 2020 19:59:18 +0000 (19:59 +0000)] 
t5500: make hash independent

This test has hard-coded pkt-lines with object IDs.  The pkt-line
lengths necessarily differ between hash algorithms, so generate these
lines with the packetize helper so they're always the right size.  In
addition, we will require an object-format capability for SHA-256, so
pass that capability on to the upload-pack process.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoserve: advertise object-format capability for protocol v2
brian m. carlson [Mon, 25 May 2020 19:59:17 +0000 (19:59 +0000)] 
serve: advertise object-format capability for protocol v2

In order to communicate the protocol supported by the server side, add
support for advertising the object-format capability.  We check that the
client side sends us an identical algorithm if it sends us its own
object-format capability, and assume it speaks SHA-1 if not.

In the test, when we're using an algorithm other than SHA-1, we need to
specify the algorithm in use so we don't get a failure with an "unknown
format" message.  Add a test that we handle a mismatched algorithm.
Remove the test_oid_init call since it's no longer necessary.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: parse v2 refs with correct hash algorithm
brian m. carlson [Mon, 25 May 2020 19:59:16 +0000 (19:59 +0000)] 
connect: parse v2 refs with correct hash algorithm

When using protocol v2, we need to know what hash algorithm is used by
the remote end.  See if the server has sent us an object-format
capability, and if so, use it to determine the hash algorithm in use and
set that value in the packet reader.  Parse the refs using this
algorithm.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: pass full packet reader when parsing v2 refs
brian m. carlson [Mon, 25 May 2020 19:59:15 +0000 (19:59 +0000)] 
connect: pass full packet reader when parsing v2 refs

When we're parsing refs, we need to know not only what the line we're
parsing is, but also the hash algorithm we should use to parse it, which
is stored in the reader object.  Pass the packet reader object through
to the protocol v2 ref parsing function.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation/technical: document object-format for protocol v2
brian m. carlson [Mon, 25 May 2020 19:59:14 +0000 (19:59 +0000)] 
Documentation/technical: document object-format for protocol v2

Document the object-format extension for protocol v2.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot1302: expect repo format version 1 for SHA-256
brian m. carlson [Mon, 25 May 2020 19:59:13 +0000 (19:59 +0000)] 
t1302: expect repo format version 1 for SHA-256

When using SHA-256, we need to take advantage of the extensions section
in the config file, so we need to use repository format version 1.
Update the test to look for the correct value.

Note that test_oid produces a value without a trailing newline, so use
echo to ensure we print a trailing newline to compare it correctly
against the actual results.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/show-index: provide options to determine hash algo
brian m. carlson [Mon, 25 May 2020 19:59:12 +0000 (19:59 +0000)] 
builtin/show-index: provide options to determine hash algo

show-index is capable of reading any possible index file whether or not
the index is inside a repository.  However, because our index files lack
metadata about the hash algorithm in use, it's not possible to
autodetect the algorithm that a particular index file is using.

In order to allow us to read index files of any algorithm, let's set up
the .git directory gently so that we default to the algorithm for the
current repository, and add an --object-format option to allow users to
override this setting and continue to run show-index outside of a
repository altogether.  Let's also document this new option so that
people can find it and use it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5302: modernize test formatting
brian m. carlson [Mon, 25 May 2020 19:59:11 +0000 (19:59 +0000)] 
t5302: modernize test formatting

Our style these days is to place the description and the opening quote
of the body on the same line as test_expect_success (if it fits), to
place the trailing quote on a line by itself after the body, and to use
tabs.  Since we're going to be making several significant changes to
this test, modernize the style to aid in readability of the subsequent
patches.

This patch should have no functional change.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopackfile: compute and use the index CRC offset
brian m. carlson [Mon, 25 May 2020 19:59:10 +0000 (19:59 +0000)] 
packfile: compute and use the index CRC offset

Both v2 pack index files and the v3 format specified as part of the
NewHash work have similar data starting at the CRC table.  Much of the
existing code wants to read either this table or the offset entries
following it, and in doing so computes the offset each time.

In order to share as much code between v2 and v3, compute the offset of
the CRC table and store it when the pack is opened.  Use this value to
compute offsets to not only the CRC table, but to the offset entries
beyond it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot3200: mark assertion with SHA1 prerequisite
brian m. carlson [Mon, 25 May 2020 19:59:09 +0000 (19:59 +0000)] 
t3200: mark assertion with SHA1 prerequisite

One of the test assertions in this test checks that git branch -m works
even without a .git/config file.  However, if the repository requires
configuration extensions, such as because it uses a non-SHA-1 algorithm,
this assertion will fail.  Mark the assertion as requiring SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosetup: set the_repository's hash algo when checking format
brian m. carlson [Mon, 25 May 2020 19:59:08 +0000 (19:59 +0000)] 
setup: set the_repository's hash algo when checking format

When we're checking the repository's format, set the hash algorithm at
the same time.  This ensures that we perform a suitable initialization
early enough to avoid confusing any parts of the code.  If we defer
until later, we can end up with portions of the code which are confused
about the hash algorithm, resulting in segfaults when working with
SHA-256 repositories.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofetch-pack: parse and advertise the object-format capability
brian m. carlson [Mon, 25 May 2020 19:59:07 +0000 (19:59 +0000)] 
fetch-pack: parse and advertise the object-format capability

Parse the server's object-format capability and respond accordingly,
dying if there is a mismatch.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5562: pass object-format in synthesized test data
brian m. carlson [Mon, 25 May 2020 19:59:06 +0000 (19:59 +0000)] 
t5562: pass object-format in synthesized test data

Ensure that we pass the object-format capability in the synthesized test
data so that this test works with algorithms other than SHA-1.

In addition, add an additional test using the old data for when we're
using SHA-1 so that we can be sure that we preserve backwards
compatibility with servers not offering the object-format capability.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/clone: initialize hash algorithm properly
brian m. carlson [Mon, 25 May 2020 19:59:05 +0000 (19:59 +0000)] 
builtin/clone: initialize hash algorithm properly

When performing a clone, we don't know what hash algorithm the other end
will support.  Currently, we don't support fetching data belonging to a
different algorithm, so we must know what algorithm the remote side is
using in order to properly initialize the repository.  We can know that
only after fetching the refs, so if the remote side has any references,
use that information to reinitialize the repository with the correct
hash algorithm information.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoremote-curl: implement object-format extensions
brian m. carlson [Mon, 25 May 2020 19:59:04 +0000 (19:59 +0000)] 
remote-curl: implement object-format extensions

Implement the object-format extensions that let us determine the hash
algorithm in use when pushing, pulling, and fetching.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotransport-helper: implement object-format extensions
brian m. carlson [Mon, 25 May 2020 19:59:03 +0000 (19:59 +0000)] 
transport-helper: implement object-format extensions

Implement the object-format extensions that let us determine the hash
algorithm in use when pushing or pulling data.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodocs: update remote helper docs for object-format extensions
brian m. carlson [Mon, 25 May 2020 19:59:02 +0000 (19:59 +0000)] 
docs: update remote helper docs for object-format extensions

Update the remote helper docs to document the object-format extensions
we will implement in remote-curl and the transport helper code shortly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/receive-pack: detect when the server doesn't support our hash
brian m. carlson [Mon, 25 May 2020 19:59:01 +0000 (19:59 +0000)] 
builtin/receive-pack: detect when the server doesn't support our hash

Detect when the server doesn't support our hash algorithm and abort.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: detect algorithm when fetching refs
brian m. carlson [Mon, 25 May 2020 19:59:00 +0000 (19:59 +0000)] 
connect: detect algorithm when fetching refs

If we're fetching refs, detect the hash algorithm and parse the refs
using that algorithm.

As mentioned in the documentation, if multiple versions of the
object-format capability are provided, we use the first.  No known
implementation supports multiple algorithms now, but they may in the
future.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofetch-pack: detect when the server doesn't support our hash
brian m. carlson [Mon, 25 May 2020 19:58:59 +0000 (19:58 +0000)] 
fetch-pack: detect when the server doesn't support our hash

Detect when the server doesn't support our hash algorithm and abort.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: make parse_feature_value extern
brian m. carlson [Mon, 25 May 2020 19:58:58 +0000 (19:58 +0000)] 
connect: make parse_feature_value extern

We're going to be using this function in other files, so no longer mark
this function static.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosend-pack: detect when the server doesn't support our hash
brian m. carlson [Mon, 25 May 2020 19:58:57 +0000 (19:58 +0000)] 
send-pack: detect when the server doesn't support our hash

Detect when the server doesn't support our hash algorithm and abort.
If the server does support our hash, advertise it as part of our
capabilities.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: add function to detect supported v1 hash functions
brian m. carlson [Mon, 25 May 2020 19:58:56 +0000 (19:58 +0000)] 
connect: add function to detect supported v1 hash functions

Add a function, server_supports_hash, to see if the remote server
supports a particular hash algorithm when speaking protocol v1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotransport: add a hash algorithm member
brian m. carlson [Mon, 25 May 2020 19:58:55 +0000 (19:58 +0000)] 
transport: add a hash algorithm member

When connecting to a remote system, we need to know what hash algorithm
it will be using to talk to us.  Add a hash_algo member to struct
transport and add a function to read this data from the transport
object.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopkt-line: add a member for hash algorithm
brian m. carlson [Mon, 25 May 2020 19:58:54 +0000 (19:58 +0000)] 
pkt-line: add a member for hash algorithm

Add a member for the hash algorithm currently in use to the packet
reader so it can parse references correctly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: add function to fetch value of a v2 server capability
brian m. carlson [Mon, 25 May 2020 19:58:53 +0000 (19:58 +0000)] 
connect: add function to fetch value of a v2 server capability

So far in protocol v2, all of our server capabilities that have values
have not had values that we've been interested in parsing.  For example,
we receive but ignore the agent value.

However, in a future commit, we're going to want to parse out the value
of a server capability.  To make this easy, add a function,
server_feature_v2, that can fetch the value provided as part of the
server capability.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: add function to parse multiple v1 capability values
brian m. carlson [Mon, 25 May 2020 19:58:52 +0000 (19:58 +0000)] 
connect: add function to parse multiple v1 capability values

In a capability response, we can have multiple symref entries.  In the
future, we will also allow for multiple hash algorithms to be specified.
To avoid duplication, expand the parse_feature_value function to take an
optional offset where the parsing should begin next time.  Add a wrapper
function that allows us to query the next server feature value, and use
it in the existing symref parsing code.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoremote: advertise the object-format capability on the server side
brian m. carlson [Mon, 25 May 2020 19:58:51 +0000 (19:58 +0000)] 
remote: advertise the object-format capability on the server side

Advertise the current hash algorithm in use by using the object-format
capability as part of the ref advertisement.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowrapper: add function to compare strings with different NUL termination
brian m. carlson [Mon, 25 May 2020 19:58:50 +0000 (19:58 +0000)] 
wrapper: add function to compare strings with different NUL termination

When parsing capabilities for the pack protocol, there are times we'll
want to compare the value of a capability to a NUL-terminated string.
Since the data we're reading will be space-terminated, not
NUL-terminated, we need a function that compares the two strings, but
also checks that they're the same length.  Otherwise, if we used strncmp
to compare these strings, we might accidentally accept a parameter that
was a prefix of the expected value.

Add a function, xstrncmpz, that takes a NUL-terminated string and a
non-NUL-terminated string, plus a length, and compares them, ensuring
that they are the same length.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconnect: have ref processing code take struct packet_reader
brian m. carlson [Mon, 25 May 2020 19:58:49 +0000 (19:58 +0000)] 
connect: have ref processing code take struct packet_reader

In a future patch, we'll want to access multiple members from struct
packet_reader when parsing references.  Therefore, have the ref parsing
code take pointers to struct reader instead of having to pass multiple
arguments to each function.

Rename the len variable to "linelen" to make it clearer what the
variable does in light of the variable change.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation: correct hash environment variable
Toon Claes [Tue, 26 May 2020 18:37:20 +0000 (20:37 +0200)] 
Documentation: correct hash environment variable

To set the default hash algorithm you can set the `GIT_DEFAULT_HASH`
environment variable. In the documentation this variable is named
`GIT_DEFAULT_HASH_ALGORITHM`, which is incorrect.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: tr: v2.27.0 round 2
Emir Sarı [Wed, 27 May 2020 09:48:41 +0000 (12:48 +0300)] 
l10n: tr: v2.27.0 round 2

Signed-off-by: Emir Sarı <bitigchi@me.com>
6 years agol10n: fr.po v2.27.0 rnd 2
Jean-Noël Avila [Wed, 27 May 2020 09:18:48 +0000 (11:18 +0200)] 
l10n: fr.po v2.27.0 rnd 2

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
6 years agol10n: bg.po: Updated Bulgarian translation (4875t)
Alexander Shopov [Wed, 27 May 2020 07:44:12 +0000 (09:44 +0200)] 
l10n: bg.po: Updated Bulgarian translation (4875t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
6 years agol10n: Update Catalan translation
Jordi Mas [Wed, 27 May 2020 06:59:48 +0000 (08:59 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
6 years agol10n: sv.po: Update Swedish translation (4875t0f0u)
Peter Krefting [Wed, 27 May 2020 06:41:28 +0000 (07:41 +0100)] 
l10n: sv.po: Update Swedish translation (4875t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
6 years agol10n: vi(4875t): Updated Vietnamses translation for 2.27.0rd2
Tran Ngoc Quan [Wed, 27 May 2020 01:07:58 +0000 (08:07 +0700)] 
l10n: vi(4875t): Updated Vietnamses translation for 2.27.0rd2

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
6 years agol10n: zh_CN: for git v2.27.0 l10n round 1~2
Jiang Xin [Sun, 11 Mar 2018 00:53:35 +0000 (08:53 +0800)] 
l10n: zh_CN: for git v2.27.0 l10n round 1~2

Translate 73 new messages (4875t0f0u) for git 2.27.0.

Reviewed-by: 依云 <lilydjwg@gmail.com>
Reviewed-by: Fangyi Zhou <me@fangyi.io>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
6 years agol10n: git.pot: v2.27.0 round 2 (+1)
Jiang Xin [Tue, 26 May 2020 23:24:01 +0000 (07:24 +0800)] 
l10n: git.pot: v2.27.0 round 2 (+1)

Generate po/git.pot from v2.27.0-rc2 for git v2.27.0 l10n round 2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
6 years agoMerge branch 'master' of github.com:git-l10n/git-po
Jiang Xin [Tue, 26 May 2020 23:22:26 +0000 (07:22 +0800)] 
Merge branch 'master' of github.com:git-l10n/git-po

* 'master' of github.com:git-l10n/git-po:
  l10n: Update Catalan translation
  l10n: vi(4874t): Updated Vietnamses translation for 2.27.0
  l10n: es: 2.27.0 round 1
  l10n: bg.po: Updated Bulgarian translation (4868t)
  l10n: fr v2.27.0 rnd 1
  l10n: sv.po: Update Swedish translation (4839t0f0u)
  l10n: tr: v2.27.0 round 1
  l10n: it.po: update the Italian translation for Git 2.27.0 round 1
  l10n: git.pot: v2.27.0 round 1 (72 new, 37 removed)
  l10n: Update Catalan translation

6 years agoGit 2.27-rc2 v2.27.0-rc2
Junio C Hamano [Tue, 26 May 2020 16:38:13 +0000 (09:38 -0700)] 
Git 2.27-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ss/faq-ignore'
Junio C Hamano [Tue, 26 May 2020 16:32:08 +0000 (09:32 -0700)] 
Merge branch 'ss/faq-ignore'

Doc markup fix.

* ss/faq-ignore:
  gitfaq: avoid validation error with older asciidoc

6 years agorev-list-options.txt: start a list for `show-pulls`
Martin Ågren [Mon, 25 May 2020 17:06:07 +0000 (19:06 +0200)] 
rev-list-options.txt: start a list for `show-pulls`

The explanation of the `--show-pulls` option added in commit 8d049e182e
("revision: --show-pulls adds helpful merges", 2020-04-10) consists of
several paragraphs and we use "+" throughout to tie them together in one
long chain of list continuations. Only thing is, we're not in any kind
of list, so these pluses end up being rendered literally.

The preceding few paragraphs describe `--ancestry-path` and there we
*do* have a list, since we've started one with `--ancestry-path::`. In
fact, we have several such lists for all the various history-simplifying
options we're discussing earlier in this file.

Thus, we're missing a list both from a consistency point of view and
from a practical rendering standpoint.

Let's start a list for `--show-pulls` where we start actually discussing
the option, and keep the paragraphs preceding it out of that list. That
is, drop all those pluses before the new list we're adding here.

Helped-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogitfaq: avoid validation error with older asciidoc
Todd Zullinger [Tue, 19 May 2020 04:53:01 +0000 (00:53 -0400)] 
gitfaq: avoid validation error with older asciidoc

When building with asciidoc-8.4.5 (as found on CentOS/Red Hat 6), the
period in the "[[files-in-.gitignore-are-tracked]]" anchor is not
properly parsed as a section:

  WARNING: gitfaq.txt: line 245: missing [[files-in-.gitignore-are-tracked]] section

The resulting XML file fails to validate with xmlto:

    xmlto: /git/Documentation/gitfaq.xml does not validate (status 3)
    xmlto: Fix document syntax or use --skip-validation option
     /git/Documentation/gitfaq.xml:3: element refentry: validity error :
     Element refentry content does not follow the DTD, expecting
     (beginpage? , indexterm* , refentryinfo? , refmeta? , (remark | link
     | olink | ulink)* , refnamediv+ , refsynopsisdiv? , (refsect1+ |
     refsection+)), got (refmeta refnamediv refsynopsisdiv refsect1
     refsect1 refsect1 refsect1 variablelist refsect1 refsect1 )
    Document /git/Documentation/gitfaq.xml does not validate

Let's avoid breaking users of platforms which ship an old version of
asciidoc, since the cost to do so is quite low.

Reported-by: Son Luong Ngoc <sluongng@gmail.com>
Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoHopefully final batch before 2.27-rc2
Junio C Hamano [Mon, 25 May 2020 01:13:53 +0000 (18:13 -0700)] 
Hopefully final batch before 2.27-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'dd/t5703-grep-a-fix'
Junio C Hamano [Mon, 25 May 2020 02:39:40 +0000 (19:39 -0700)] 
Merge branch 'dd/t5703-grep-a-fix'

Update an unconditional use of "grep -a" with a perl script in a test.

* dd/t5703-grep-a-fix:
  t5703: replace "grep -a" usage by perl

6 years agoMerge branch 'ds/multi-pack-verify'
Junio C Hamano [Mon, 25 May 2020 02:39:39 +0000 (19:39 -0700)] 
Merge branch 'ds/multi-pack-verify'

Fix for a copy-and-paste error introduced during 2.20 era.

* ds/multi-pack-verify:
  fsck: use ERROR_MULTI_PACK_INDEX

6 years agoMerge branch 'ma/doc-fixes'
Junio C Hamano [Mon, 25 May 2020 02:39:38 +0000 (19:39 -0700)] 
Merge branch 'ma/doc-fixes'

Various doc fixes.

* ma/doc-fixes:
  git-sparse-checkout.txt: add missing '
  git-credential.txt: use list continuation
  git-commit-graph.txt: fix list rendering
  git-commit-graph.txt: fix grammo
  date-formats.txt: fix list continuation

6 years agoMerge branch 'cb/bisect-replay-with-dos-fix'
Junio C Hamano [Mon, 25 May 2020 02:39:38 +0000 (19:39 -0700)] 
Merge branch 'cb/bisect-replay-with-dos-fix'

Re-fix longstanding "edited bisect log may confuse bisect replay
with trailing carriage-return" issue.

* cb/bisect-replay-with-dos-fix:
  bisect: avoid tailing CR characters from revision in replay

6 years agoMerge branch 'gs/commit-graph-path-filter'
Junio C Hamano [Mon, 25 May 2020 02:39:38 +0000 (19:39 -0700)] 
Merge branch 'gs/commit-graph-path-filter'

Test fix.

* gs/commit-graph-path-filter:
  t4216: avoid unnecessary subshell in test_bloom_filters_not_used

6 years agoMerge branch 'dl/merge-autostash'
Junio C Hamano [Mon, 25 May 2020 02:39:37 +0000 (19:39 -0700)] 
Merge branch 'dl/merge-autostash'

Test fix.

* dl/merge-autostash:
  t5520: avoid alternation in grep's BRE (not POSIX)

6 years agoMerge branch 'bc/faq'
Junio C Hamano [Mon, 25 May 2020 02:39:36 +0000 (19:39 -0700)] 
Merge branch 'bc/faq'

"git help guides" now includes the newly added FAQ document.

* bc/faq:
  command-list.txt: add gitfaq to the list of guides

6 years agoMerge branch 'jt/avoid-prefetch-when-able-in-diff'
Junio C Hamano [Mon, 25 May 2020 02:39:35 +0000 (19:39 -0700)] 
Merge branch 'jt/avoid-prefetch-when-able-in-diff'

Test-coverage enhancement.

* jt/avoid-prefetch-when-able-in-diff:
  t4067: make rename detection test output raw diff

6 years agoMerge branch 'gp/hppa-stack-test-fix'
Junio C Hamano [Mon, 25 May 2020 02:39:35 +0000 (19:39 -0700)] 
Merge branch 'gp/hppa-stack-test-fix'

Platform dependent tweak to a test for HP-PA.

* gp/hppa-stack-test-fix:
  tests: skip small-stack tests on hppa architecture

6 years agosparse: allow '{ 0 }' to be used without warnings
Luc Van Oostenryck [Fri, 22 May 2020 00:25:02 +0000 (02:25 +0200)] 
sparse: allow '{ 0 }' to be used without warnings

In standard C, '{ 0 }' can be used as an universal zero-initializer.
However, Sparse complains if this is used on a type where the first
member (possibly nested) is a pointer since Sparse purposely wants
to warn when '0' is used to initialize a pointer type.

Legitimaly, it's desirable to be able to use '{ 0 }' as an idiom
without these warnings [1,2]. To allow this, an option have now
been added to Sparse:
    537e3e2dae univ-init: conditionally accept { 0 } without warnings

So, add this option to the SPARSE_FLAGS variable.

Note: The option have just been added to Sparse. So, to benefit
      now from this patch it's needed to use the latest Sparse
      source from kernel.org. The option will simply be ignored
      by older versions of Sparse.

[1] https://lore.kernel.org/r/e6796c60-a870-e761-3b07-b680f934c537@ramsayjones.plus.com
[2] https://lore.kernel.org/r/xmqqd07xem9l.fsf@gitster.c.googlers.com

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostateless-connect: send response end packet
Denton Liu [Tue, 19 May 2020 10:54:00 +0000 (06:54 -0400)] 
stateless-connect: send response end packet

Currently, remote-curl acts as a proxy and blindly forwards packets
between an HTTP server and fetch-pack. In the case of a stateless RPC
connection where the connection is terminated before the transaction is
complete, remote-curl will blindly forward the packets before waiting on
more input from fetch-pack. Meanwhile, fetch-pack will read the
transaction and continue reading, expecting more input to continue the
transaction. This results in a deadlock between the two processes.

This can be seen in the following command which does not terminate:

$ git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012
Cloning into 'git'...

whereas the v1 version does terminate as expected:

$ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=20151012
Cloning into 'git'...
fatal: the remote end hung up unexpectedly

Instead of blindly forwarding packets, make remote-curl insert a
response end packet after proxying the responses from the remote server
when using stateless_connect(). On the RPC client side, ensure that each
response ends as described.

A separate control packet is chosen because we need to be able to
differentiate between what the remote server sends and remote-curl's
control packets. By ensuring in the remote-curl code that a server
cannot send response end packets, we prevent a malicious server from
being able to perform a denial of service attack in which they spoof a
response end packet and cause the described deadlock to happen.

Reported-by: Force Charlie <charlieio@outlook.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopkt-line: define PACKET_READ_RESPONSE_END
Denton Liu [Tue, 19 May 2020 10:53:59 +0000 (06:53 -0400)] 
pkt-line: define PACKET_READ_RESPONSE_END

In a future commit, we will use PACKET_READ_RESPONSE_END to separate
messages proxied by remote-curl. To prepare for this, add the
PACKET_READ_RESPONSE_END enum value.

In switch statements that need a case added, die() or BUG() when a
PACKET_READ_RESPONSE_END is unexpected. Otherwise, mirror how
PACKET_READ_DELIM is implemented (especially in cases where packets are
being forwarded).

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoremote-curl: error on incomplete packet
Denton Liu [Tue, 19 May 2020 10:53:58 +0000 (06:53 -0400)] 
remote-curl: error on incomplete packet

Currently, remote-curl acts as a proxy and blindly forwards packets
between an HTTP server and fetch-pack. In the case of a stateless RPC
connection where the connection is terminated with a partially written
packet, remote-curl will blindly send the partially written packet
before waiting on more input from fetch-pack. Meanwhile, fetch-pack will
read the partial packet and continue reading, expecting more input. This
results in a deadlock between the two processes.

For a stateless connection, inspect packets before sending them and
error out if a packet line packet is incomplete.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff: add config option relative
Laurent Arnoud [Fri, 22 May 2020 10:46:18 +0000 (12:46 +0200)] 
diff: add config option relative

The `diff.relative` boolean option set to `true` shows only changes in
the current directory/value specified by the `path` argument of the
`relative` option and shows pathnames relative to the aforementioned
directory.

Teach `--no-relative` to override earlier `--relative`

Add for git-format-patch(1) options documentation `--relative` and
`--no-relative`

Signed-off-by: Laurent Arnoud <laurent@spkdev.net>
Acked-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5608: avoid say() and use "skip_all" instead for consistency
Carlo Marcelo Arenas Belón [Fri, 22 May 2020 18:42:14 +0000 (11:42 -0700)] 
t5608: avoid say() and use "skip_all" instead for consistency

Printing a message directly to stdout could affect TAP processing
and is not really needed, as there is a standard way to skip all
tests that could be used instead, while printing an equivalent
message.

While at it; update the message to better reflect that since
a85efb5985 (t5608-clone-2gb.sh: turn GIT_TEST_CLONE_2GB into a bool,
2019-11-22), the enabling variable should be a recognized boolean
(ex: true, false, 1, 0) and get rid of the prerequisite that used
to guard all the tests, since "skip_all" is just much faster and
idempotent.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocheckout: improve error messages for -b with extra argument
René Scharfe [Sun, 24 May 2020 07:23:00 +0000 (09:23 +0200)] 
checkout: improve error messages for -b with extra argument

When we try to create a branch "foo" based on "origin/master" and give
git commit -b an extra unsupported argument "bar", it confusingly
reports:

   $ git checkout -b foo origin/master bar
   fatal: 'bar' is not a commit and a branch 'foo' cannot be created from it

   $ git checkout --track -b foo origin/master bar
   fatal: 'bar' is not a commit and a branch 'foo' cannot be created from it

That's wrong, because it very well understands that "origin/master" is
supposed to be the start point for the new branch and not "bar".  Check
if we got a commit and show more fitting messages in that case instead:

   $ git checkout -b foo origin/master bar
   fatal: Cannot update paths and switch to branch 'foo' at the same time.

   $ git checkout --track -b foo origin/master bar
   fatal: '--track' cannot be used with updating paths

Original-patch-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocheckout: add tests for -b and --track
René Scharfe [Sun, 24 May 2020 07:22:51 +0000 (09:22 +0200)] 
checkout: add tests for -b and --track

Test git checkout -b with and without --track and demonstrate unexpected
error messages when it's given an extra (i.e. unsupported) path
argument.  In both cases it reports:

   $ git checkout -b foo origin/master bar
   fatal: 'bar' is not a commit and a branch 'foo' cannot be created from it

The problem is that the start point we gave for the new branch is
"origin/master" and "bar" is just some extra argument -- it could even
be a valid commit, which would make the message even more confusing.  We
have more fitting error messages in git commit, but get confused; use
the text of the rights ones in the tests.

Reported-by: Dana Dahlstrom <dahlstrom@google.com>
Original-test-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobisect--helper: avoid segfault with bad syntax in `start --term-*`
Carlo Marcelo Arenas Belón [Wed, 20 May 2020 23:26:27 +0000 (16:26 -0700)] 
bisect--helper: avoid segfault with bad syntax in `start --term-*`

06f5608c14 (bisect--helper: `bisect_start` shell function partially in C,
2019-01-02) adds a lax parser for `git bisect start` which could result
in a segfault under a bad syntax call for start with custom terms.

Detect if there are enough arguments left in the command line to use for
--term-{old,good,new,bad} and abort with the same syntax error the original
implementation will show if not.

While at it, remove an unnecessary (and incomplete) check for unknown
arguments and make sure to add a test to avoid regressions.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Acked-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: Update Catalan translation
Jordi Mas [Fri, 22 May 2020 05:59:22 +0000 (07:59 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>