git
4 years agosequencer: clear state upon dropping a become-empty commit
Elijah Newren [Wed, 11 Mar 2020 15:30:22 +0000 (15:30 +0000)] 
sequencer: clear state upon dropping a become-empty commit

In commit e98c4269c8 ("rebase (interactive-backend): fix handling of
commits that become empty", 2020-02-15), the merge backend was changed
to drop commits that did not start empty but became so after being
applied (because their changes were a subset of what was already
upstream).  This new code path did not need to go through the process of
creating a commit, since we were dropping the commit instead.
Unfortunately, this also means we bypassed the clearing of the
CHERRY_PICK_HEAD and MERGE_MSG files, which if there were no further
commits to cherry-pick would mean that the rebase would end but assume
there was still an operation in progress.  Ensure that we clear such
state files when we decide to drop the commit.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoi18n: unmark a message in rebase.c
Jiang Xin [Wed, 11 Mar 2020 06:55:27 +0000 (14:55 +0800)] 
i18n: unmark a message in rebase.c

Commit v2.25.0-4-ge98c4269c8 (rebase (interactive-backend): fix handling
of commits that become empty, 2020-02-15) marked "{drop,keep,ask}" for
translation, but this message should not be changed.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopull: document more passthru options
René Scharfe [Mon, 9 Mar 2020 21:51:39 +0000 (22:51 +0100)] 
pull: document more passthru options

git pull accepts the options --dry-run, -p/--prune, --refmap, and
-t/--tags since a32975f516 (pull: pass git-fetch's options to git-fetch,
2015-06-18), -j/--jobs since 62104ba14a (submodules: allow parallel
fetching, add tests and documentation, 2015-12-15), and --set-upstream
since 24bc1a1292 (pull, fetch: add --set-upstream option, 2019-08-19).
Update its documentation to match.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ds/sparse-add'
Junio C Hamano [Wed, 11 Mar 2020 17:58:16 +0000 (10:58 -0700)] 
Merge branch 'ds/sparse-add'

Test fix.

* ds/sparse-add:
  t1091: don't grep for `strerror()` string

4 years agoMerge branch 'dr/push-remote-ref-update'
Junio C Hamano [Wed, 11 Mar 2020 17:58:16 +0000 (10:58 -0700)] 
Merge branch 'dr/push-remote-ref-update'

Code clean-up.

* dr/push-remote-ref-update:
  remote: drop "explicit" parameter from remote_ref_for_branch()

4 years agoMerge branch 'jc/doc-single-h-is-for-help'
Junio C Hamano [Wed, 11 Mar 2020 17:58:16 +0000 (10:58 -0700)] 
Merge branch 'jc/doc-single-h-is-for-help'

Both "git ls-remote -h" and "git grep -h" give short usage help,
like any other Git subcommand, but it is not unreasonable to expect
that the former would behave the same as "git ls-remote --head"
(there is no other sensible behaviour for the latter).  The
documentation has been updated in an attempt to clarify this.

* jc/doc-single-h-is-for-help:
  Documentation: clarify that `-h` alone stands for `help`

4 years agol10n: git.pot: v2.26.0 round 2 (7 new, 2 removed)
Jiang Xin [Wed, 11 Mar 2020 06:59:57 +0000 (14:59 +0800)] 
l10n: git.pot: v2.26.0 round 2 (7 new, 2 removed)

Generate po/git.pot from v2.26.0-rc1 for git v2.26.0 l10n round 2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
4 years agoMerge branch 'master' of github.com:git/git into git-po-master
Jiang Xin [Wed, 11 Mar 2020 06:59:05 +0000 (14:59 +0800)] 
Merge branch 'master' of github.com:git/git into git-po-master

* 'master' of github.com:git/git: (27 commits)
  Git 2.26-rc1
  remote-curl: show progress for fetches over dumb HTTP
  show_one_mergetag: print non-parent in hex form.
  config.mak.dev: re-enable -Wformat-zero-length
  rebase-interactive.c: silence format-zero-length warnings
  mingw: workaround for hangs when sending STDIN
  t6020: new test with interleaved lexicographic ordering of directories
  t6022, t6046: test expected behavior instead of testing a proxy for it
  t3035: prefer test_must_fail to bash negation for git commands
  t6020, t6022, t6035: update merge tests to use test helper functions
  t602[1236], t6034: modernize test formatting
  merge-recursive: apply collision handling unification to recursive case
  completion: add diff --color-moved[-ws]
  t1050: replace test -f with test_path_is_file
  am: support --show-current-patch=diff to retrieve .git/rebase-apply/patch
  am: support --show-current-patch=raw as a synonym for--show-current-patch
  am: convert "resume" variable to a struct
  parse-options: convert "command mode" to a flag
  parse-options: add testcases for OPT_CMDMODE()
  stash push: support the --pathspec-from-file option
  ...

4 years agol10n: tr: Add glossary for Turkish translations
Emir Sarı [Tue, 10 Mar 2020 20:31:48 +0000 (23:31 +0300)] 
l10n: tr: Add glossary for Turkish translations

Signed-off-by: Emir Sarı <bitigchi@me.com>
4 years agocommit-slab: clarify slabname##_peek()'s return value
SZEDER Gábor [Tue, 10 Mar 2020 15:30:49 +0000 (16:30 +0100)] 
commit-slab: clarify slabname##_peek()'s return value

Ever since 862e730ec1 (commit-slab: introduce slabname##_peek()
function, 2015-05-14) the slabname##_peek() function is documented as:

  This function is similar to indegree_at(), but it will return NULL
  until a call to indegree_at() was made for the commit.

This, however, is usually not the case.  If indegree_at() allocates
memory, then it will do so not only for the single commit it got as
parameter, but it will allocate a whole new, ~512kB slab.  Later on,
if any other commit's 'index' field happens to point into an already
allocated slab, then indegree_peek() for such a commit will return a
valid non-NULL pointer, pointing to a zero-initialized location in the
slab, even if no indegree_at() call has been made for that commit yet.

Update slabname##_peek()'s documentation to clarify this.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoget_superproject_working_tree(): return strbuf
Alexandr Miloslavskiy [Tue, 10 Mar 2020 13:11:24 +0000 (13:11 +0000)] 
get_superproject_working_tree(): return strbuf

Together with the previous commits, this commit fully fixes the problem
of using shared buffer for `real_path()` in `get_superproject_working_tree()`.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreal_path_if_valid(): remove unsafe API
Alexandr Miloslavskiy [Tue, 10 Mar 2020 13:11:23 +0000 (13:11 +0000)] 
real_path_if_valid(): remove unsafe API

This commit continues the work started with previous commit.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoreal_path: remove unsafe API
Alexandr Miloslavskiy [Tue, 10 Mar 2020 13:11:22 +0000 (13:11 +0000)] 
real_path: remove unsafe API

Returning a shared buffer invites very subtle bugs due to reentrancy or
multi-threading, as demonstrated by the previous patch.

There was an unfinished effort to abolish this [1].

Let's finally rid of `real_path()`, using `strbuf_realpath()` instead.

This patch uses a local `strbuf` for most places where `real_path()` was
previously called.

However, two places return the value of `real_path()` to the caller. For
them, a `static` local `strbuf` was added, effectively pushing the
problem one level higher:
    read_gitfile_gently()
    get_superproject_working_tree()

[1] https://lore.kernel.org/git/1480964316-99305-1-git-send-email-bmwill@google.com/

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoci: use python3 in linux-gcc and osx-gcc and python2 elsewhere
SZEDER Gábor [Thu, 23 Jan 2020 17:56:45 +0000 (18:56 +0100)] 
ci: use python3 in linux-gcc and osx-gcc and python2 elsewhere

Python2 reached end of life, and we have been preparing our Python
scripts to work with Python3.  'git p4', the main in-tree user of
Python, has just received a number of compatibility updates.  Our
other notable Python script 'contrib/svn-fe/svnrdump_sim.py' is only
used in 't9020-remote-svn.sh', and is apparently already compatible
with both Python2 and 3.

Our CI jobs currently only use Python2.  We want to make sure that
these Python scripts do indeed work with Python3, and we also want to
make sure that these scripts keep working with Python2 as well, for
the sake of some older LTS/Enterprise setups.

Therefore, pick two jobs and use Python3 there, while leaving other
jobs to still stick to Python2 for now.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Tue, 10 Mar 2020 06:28:22 +0000 (14:28 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation (4835t0f0u)

4 years agoMerge branch 'fr_2.26.0' of github.com:jnavila/git
Jiang Xin [Tue, 10 Mar 2020 06:26:58 +0000 (14:26 +0800)] 
Merge branch 'fr_2.26.0' of github.com:jnavila/git

* 'fr_2.26.0' of github.com:jnavila/git:
  l10n: fr v2.26.0 rnd1

4 years agol10n: sv.po: Update Swedish translation (4835t0f0u)
Peter Krefting [Mon, 9 Mar 2020 19:57:46 +0000 (20:57 +0100)] 
l10n: sv.po: Update Swedish translation (4835t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
4 years agol10n: tr: Add Turkish translations
Emir Sarı [Mon, 9 Mar 2020 18:41:28 +0000 (21:41 +0300)] 
l10n: tr: Add Turkish translations

Signed-off-by: Emir Sarı <bitigchi@me.com>
4 years agol10n: tr: Add Turkish translation team info
Emir Sarı [Mon, 9 Mar 2020 18:39:08 +0000 (21:39 +0300)] 
l10n: tr: Add Turkish translation team info

Signed-off-by: Emir Sarı <bitigchi@me.com>
4 years agoGit 2.26-rc1 v2.26.0-rc1
Junio C Hamano [Mon, 9 Mar 2020 18:20:59 +0000 (11:20 -0700)] 
Git 2.26-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'rs/show-progress-in-dumb-http-fetch'
Junio C Hamano [Mon, 9 Mar 2020 18:21:21 +0000 (11:21 -0700)] 
Merge branch 'rs/show-progress-in-dumb-http-fetch'

"git fetch" over HTTP walker protocol did not show any progress
output.  We inherently do not know how much work remains, but still
we can show something not to bore users.

* rs/show-progress-in-dumb-http-fetch:
  remote-curl: show progress for fetches over dumb HTTP

4 years agoMerge branch 'hd/show-one-mergetag-fix'
Junio C Hamano [Mon, 9 Mar 2020 18:21:21 +0000 (11:21 -0700)] 
Merge branch 'hd/show-one-mergetag-fix'

"git show" and others gave an object name in raw format in its
error output, which has been corrected to give it in hex.

* hd/show-one-mergetag-fix:
  show_one_mergetag: print non-parent in hex form.

4 years agoMerge branch 'rt/format-zero-length-fix'
Junio C Hamano [Mon, 9 Mar 2020 18:21:21 +0000 (11:21 -0700)] 
Merge branch 'rt/format-zero-length-fix'

Recently we inadvertently added a few instances of using 0-width
format string to functions that we mark as printf-like without any
developers noticing.  The root cause was that the compiler warning
that is triggered by this is almost always useless and we disabled
the warning in our developer builds, but not for general public.
The new instances have been corrected, and the warning has been
resurrected in the developer builds.

* rt/format-zero-length-fix:
  config.mak.dev: re-enable -Wformat-zero-length
  rebase-interactive.c: silence format-zero-length warnings

4 years agoMerge branch 'am/mingw-poll-fix'
Junio C Hamano [Mon, 9 Mar 2020 18:21:20 +0000 (11:21 -0700)] 
Merge branch 'am/mingw-poll-fix'

MinGW's poll() emulation has been improved.

* am/mingw-poll-fix:
  mingw: workaround for hangs when sending STDIN

4 years agoMerge branch 'en/test-cleanup'
Junio C Hamano [Mon, 9 Mar 2020 18:21:20 +0000 (11:21 -0700)] 
Merge branch 'en/test-cleanup'

Test cleanup.

* en/test-cleanup:
  t6020: new test with interleaved lexicographic ordering of directories
  t6022, t6046: test expected behavior instead of testing a proxy for it
  t3035: prefer test_must_fail to bash negation for git commands
  t6020, t6022, t6035: update merge tests to use test helper functions
  t602[1236], t6034: modernize test formatting

4 years agoMerge branch 'en/merge-path-collision'
Junio C Hamano [Mon, 9 Mar 2020 18:21:20 +0000 (11:21 -0700)] 
Merge branch 'en/merge-path-collision'

Handling of conflicting renames in merge-recursive have further
been made consistent with how existing codepaths try to mimic what
is done to add/add conflicts.

* en/merge-path-collision:
  merge-recursive: apply collision handling unification to recursive case

4 years agoMerge branch 'kk/complete-diff-color-moved'
Junio C Hamano [Mon, 9 Mar 2020 18:21:20 +0000 (11:21 -0700)] 
Merge branch 'kk/complete-diff-color-moved'

Completion update.

* kk/complete-diff-color-moved:
  completion: add diff --color-moved[-ws]

4 years agoMerge branch 'rj/t1050-use-test-path-is-file'
Junio C Hamano [Mon, 9 Mar 2020 18:21:19 +0000 (11:21 -0700)] 
Merge branch 'rj/t1050-use-test-path-is-file'

Code cleanup.

* rj/t1050-use-test-path-is-file:
  t1050: replace test -f with test_path_is_file

4 years agoMerge branch 'pb/am-show-current-patch'
Junio C Hamano [Mon, 9 Mar 2020 18:21:19 +0000 (11:21 -0700)] 
Merge branch 'pb/am-show-current-patch'

"git am --short-current-patch" is a way to show the piece of e-mail
for the stopped step, which is not suitable to directly feed "git
apply" (it is designed to be a good "git am" input).  It learned a
new option to show only the patch part.

* pb/am-show-current-patch:
  am: support --show-current-patch=diff to retrieve .git/rebase-apply/patch
  am: support --show-current-patch=raw as a synonym for--show-current-patch
  am: convert "resume" variable to a struct
  parse-options: convert "command mode" to a flag
  parse-options: add testcases for OPT_CMDMODE()

4 years agoMerge branch 'am/pathspec-f-f-more'
Junio C Hamano [Mon, 9 Mar 2020 18:21:19 +0000 (11:21 -0700)] 
Merge branch 'am/pathspec-f-f-more'

"git rm" and "git stash" learns the new "--pathspec-from-file"
option.

* am/pathspec-f-f-more:
  stash push: support the --pathspec-from-file option
  stash: eliminate crude option parsing
  doc: stash: synchronize <pathspec> description
  doc: stash: document more options
  doc: stash: split options from description (2)
  doc: stash: split options from description (1)
  rm: support the --pathspec-from-file option
  doc: rm: synchronize <pathspec> description

4 years agot1091: don't grep for `strerror()` string
Martin Ågren [Sun, 8 Mar 2020 08:46:27 +0000 (09:46 +0100)] 
t1091: don't grep for `strerror()` string

We grep for "File exists" in stderr of the failing `git sparse-checkout`
to make sure that it failed for the right reason. We expect the string
to show up there since we call `strerror(errno)` in
`unable_to_lock_message()` in lockfile.c.

On the NonStop platform, this fails because the error string is "File
already exists", which doesn't match our grepping.

See 9042140097 ("test-dir-iterator: do not assume errno values",
2019-07-30) for a somewhat similar fix. There, we patched a test helper,
which meant we had access to `errno` and could investigate it better in
the test helper instead of just outputting the numerical value and
evaluating it in the test script. The current situation is different,
since (short of modifying the lockfile machinery, e.g., to be more
verbose) we don't have more than the output from `strerror()` available.

Except we do: We prefix `strerror(errno)` with `_("Unable to create
'%s.lock': ")`. Let's grep for that part instead. It verifies that we
were indeed unable to create the lock file. (If that fails for some
other reason than the file existing, we really really should expect
other tests to fail as well.)

An alternative fix would be to loosen the expression a bit and grep for
"File.* exists" instead. There would be no guarantee that some other
implementation couldn't come up with another error string, That is, that
could be the first move in an endless game of whack-a-mole. Of course,
it could also take us from "99" to "100" percent of the platforms and
we'd never have this problem again. But since we have another way of
addressing this, let's not even try the "loosen it up a bit" strategy.

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoupdate how-to-maintain-git
Junio C Hamano [Fri, 6 Mar 2020 17:23:38 +0000 (09:23 -0800)] 
update how-to-maintain-git

Some parts of the workflow described in the document has got a bit
stale with the recent toolchain improvements.  Update the procedure
a bit, and also describe the convention used around SQUASH??? fixups.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agol10n: fr v2.26.0 rnd1
Jean-Noël Avila [Sat, 7 Mar 2020 21:35:29 +0000 (22:35 +0100)] 
l10n: fr v2.26.0 rnd1

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
4 years agoMerge branch of github.com:alshopov/git-po into master
Jiang Xin [Sun, 8 Mar 2020 15:44:13 +0000 (23:44 +0800)] 
Merge branch of github.com:alshopov/git-po into master

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

4 years agol10n: it.po: update the Italian translation for Git 2.26.0 round 1
Alessandro Menti [Sat, 7 Mar 2020 08:57:36 +0000 (09:57 +0100)] 
l10n: it.po: update the Italian translation for Git 2.26.0 round 1

Signed-off-by: Alessandro Menti <alessandro.menti@alessandromenti.it>
4 years agoset_git_dir: fix crash when used with real_path()
Alexandr Miloslavskiy [Fri, 6 Mar 2020 19:03:13 +0000 (19:03 +0000)] 
set_git_dir: fix crash when used with real_path()

`real_path()` returns result from a shared buffer, inviting subtle
reentrance bugs. One of these bugs occur when invoked this way:
    set_git_dir(real_path(git_dir))

In this case, `real_path()` has reentrance:
    real_path
    read_gitfile_gently
    repo_set_gitdir
    setup_git_env
    set_git_dir_1
    set_git_dir

Later, `set_git_dir()` uses its now-dead parameter:
    !is_absolute_path(path)

Fix this by using a dedicated `strbuf` to hold `strbuf_realpath()`.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agol10n: bg.po: Updated Bulgarian translation (4835t)
Alexander Shopov [Sun, 1 Mar 2020 17:18:57 +0000 (18:18 +0100)] 
l10n: bg.po: Updated Bulgarian translation (4835t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
4 years agol10n: git.pot: v2.26.0 round 1 (73 new, 38 removed)
Jiang Xin [Fri, 6 Mar 2020 06:27:08 +0000 (14:27 +0800)] 
l10n: git.pot: v2.26.0 round 1 (73 new, 38 removed)

Generate po/git.pot from v2.26.0-rc0 for git v2.26.0 l10n round 1.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
4 years agoMerge branch 'master' of github.com:git-l10n/git-po
Jiang Xin [Fri, 6 Mar 2020 06:24:01 +0000 (14:24 +0800)] 
Merge branch 'master' of github.com:git-l10n/git-po

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

4 years agohttp: add environment variable support for HTTPS proxies
Jorge Lopez Silva [Wed, 4 Mar 2020 18:40:06 +0000 (18:40 +0000)] 
http: add environment variable support for HTTPS proxies

Add 4 environment variables that can be used to configure the proxy
cert, proxy ssl key, the proxy cert password protected flag, and the
CA info for the proxy.

Documentation for the options was also updated.

Signed-off-by: Jorge Lopez Silva <jalopezsilva@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohttp: add client cert support for HTTPS proxies
Jorge Lopez Silva [Wed, 4 Mar 2020 18:40:05 +0000 (18:40 +0000)] 
http: add client cert support for HTTPS proxies

Git supports performing connections to HTTPS proxies, but we don't
support doing mutual authentication with them (through TLS).

Add the necessary options to be able to send a client certificate to
the HTTPS proxy.

A client certificate can provide an alternative way of authentication
instead of using 'ProxyAuthorization' or other more common methods of
authentication.  Libcurl supports this functionality already, so changes
are somewhat minimal. The feature is guarded by the first available
libcurl version that supports these options.

4 configuration options are added and documented, cert, key, cert
password protected and CA info. The CA info should be used to specify a
different CA path to validate the HTTPS proxy cert.

Signed-off-by: Jorge Lopez Silva <jalopezsilva@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoGit 2.26-rc0 v2.26.0-rc0
Junio C Hamano [Thu, 5 Mar 2020 19:15:45 +0000 (11:15 -0800)] 
Git 2.26-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5537: adjust test_oid label
Johannes Schindelin [Wed, 4 Mar 2020 15:53:12 +0000 (15:53 +0000)] 
t5537: adjust test_oid label

We recently switched to using Perl instead of `sed` in the httpd-based
tests. Let's reflect that in the label we give the corresponding commit
hashes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'hi/gpg-use-check-signature'
Junio C Hamano [Thu, 5 Mar 2020 18:43:05 +0000 (10:43 -0800)] 
Merge branch 'hi/gpg-use-check-signature'

"git merge signed-tag" while lacking the public key started to say
"No signature", which was utterly wrong.  This regression has been
reverted.

* hi/gpg-use-check-signature:
  Revert "gpg-interface: prefer check_signature() for GPG verification"

4 years agoMerge branch 'rs/commit-graph-code-simplification'
Junio C Hamano [Thu, 5 Mar 2020 18:43:04 +0000 (10:43 -0800)] 
Merge branch 'rs/commit-graph-code-simplification'

Code simplfication.

* rs/commit-graph-code-simplification:
  commit-graph: use progress title directly

4 years agoMerge branch 'js/ci-windows-update'
Junio C Hamano [Thu, 5 Mar 2020 18:43:04 +0000 (10:43 -0800)] 
Merge branch 'js/ci-windows-update'

Updates to the CI settings.

* js/ci-windows-update:
  Azure Pipeline: switch to the latest agent pools
  ci: prevent `perforce` from being quarantined
  t/lib-httpd: avoid using macOS' sed

4 years agoMerge branch 'be/describe-multiroot'
Junio C Hamano [Thu, 5 Mar 2020 18:43:04 +0000 (10:43 -0800)] 
Merge branch 'be/describe-multiroot'

"git describe" in a repository with multiple root commits sometimes
gave up looking for the best tag to describe a given commit with
too early, which has been adjusted.

* be/describe-multiroot:
  describe: don't abort too early when searching tags

4 years agoMerge branch 'ag/rebase-remove-redundant-code'
Junio C Hamano [Thu, 5 Mar 2020 18:43:04 +0000 (10:43 -0800)] 
Merge branch 'ag/rebase-remove-redundant-code'

Code reduction.

* ag/rebase-remove-redundant-code:
  builtin/rebase: remove a call to get_oid() on `options.switch_to'

4 years agoMerge branch 'es/recursive-single-branch-clone'
Junio C Hamano [Thu, 5 Mar 2020 18:43:03 +0000 (10:43 -0800)] 
Merge branch 'es/recursive-single-branch-clone'

"git clone --recurse-submodules --single-branch" now uses the same
single-branch option when cloning the submodules.

* es/recursive-single-branch-clone:
  clone: pass --single-branch during --recurse-submodules
  submodule--helper: use C99 named initializer

4 years agoMerge branch 'jk/nth-packed-object-id'
Junio C Hamano [Thu, 5 Mar 2020 18:43:03 +0000 (10:43 -0800)] 
Merge branch 'jk/nth-packed-object-id'

Code cleanup to use "struct object_id" more by replacing use of
"char *sha1"

* jk/nth-packed-object-id:
  packfile: drop nth_packed_object_sha1()
  packed_object_info(): use object_id internally for delta base
  packed_object_info(): use object_id for returning delta base
  pack-check: push oid lookup into loop
  pack-check: convert "internal error" die to a BUG()
  pack-bitmap: use object_id when loading on-disk bitmaps
  pack-objects: use object_id struct in pack-reuse code
  pack-objects: convert oe_set_delta_ext() to use object_id
  pack-objects: read delta base oid into object_id struct
  nth_packed_object_oid(): use customary integer return

4 years agoMerge branch 'es/do-not-let-rebase-switch-to-protected-branch'
Junio C Hamano [Thu, 5 Mar 2020 18:43:03 +0000 (10:43 -0800)] 
Merge branch 'es/do-not-let-rebase-switch-to-protected-branch'

"git rebase BASE BRANCH" rebased/updated the tip of BRANCH and
checked it out, even when the BRANCH is checked out in a different
worktree.  This has been corrected.

* es/do-not-let-rebase-switch-to-protected-branch:
  rebase: refuse to switch to branch already checked out elsewhere
  t3400: make test clean up after itself

4 years agoMerge branch 'hv/receive-denycurrent-everywhere'
Junio C Hamano [Thu, 5 Mar 2020 18:43:02 +0000 (10:43 -0800)] 
Merge branch 'hv/receive-denycurrent-everywhere'

"git push" should stop from updating a branch that is checked out
when receive.denyCurrentBranch configuration is set, but it failed
to pay attention to checkouts in secondary worktrees.  This has
been corrected.

* hv/receive-denycurrent-everywhere:
  t2402: test worktree path when called in .git directory
  receive.denyCurrentBranch: respect all worktrees
  t5509: use a bare repository for test push target
  get_main_worktree(): allow it to be called in the Git directory

4 years agoMerge branch 'es/worktree-avoid-duplication-fix'
Junio C Hamano [Thu, 5 Mar 2020 18:43:02 +0000 (10:43 -0800)] 
Merge branch 'es/worktree-avoid-duplication-fix'

In rare cases "git worktree add <path>" could think that <path>
was already a registered worktree even when it wasn't and refuse
to add the new worktree. This has been corrected.

* es/worktree-avoid-duplication-fix:
  worktree: don't allow "add" validation to be fooled by suffix matching
  worktree: add utility to find worktree by pathname
  worktree: improve find_worktree() documentation

4 years agoMerge branch 'bc/wildcard-credential'
Junio C Hamano [Thu, 5 Mar 2020 18:43:02 +0000 (10:43 -0800)] 
Merge branch 'bc/wildcard-credential'

A configuration element used for credential subsystem can now use
wildcard pattern to specify for which set of URLs the entry
applies.

* bc/wildcard-credential:
  credential: allow wildcard patterns when matching config
  credential: use the last matching username in the config
  t0300: add tests for some additional cases
  t1300: add test for urlmatch with multiple wildcards
  mailmap: add an additional email address for brian m. carlson

4 years agoMerge branch 'mr/bisect-in-c-1'
Junio C Hamano [Thu, 5 Mar 2020 18:43:02 +0000 (10:43 -0800)] 
Merge branch 'mr/bisect-in-c-1'

Underlying machinery of "git bisect--helper" is being refactored
into pieces that are more easily reused.

* mr/bisect-in-c-1:
  bisect: libify `bisect_next_all`
  bisect: libify `handle_bad_merge_base` and its dependents
  bisect: libify `check_good_are_ancestors_of_bad` and its dependents
  bisect: libify `check_merge_bases` and its dependents
  bisect: libify `bisect_checkout`
  bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependents
  bisect--helper: return error codes from `cmd_bisect__helper()`
  bisect: add enum to represent bisect returning codes
  bisect--helper: introduce new `decide_next()` function
  bisect: use the standard 'if (!var)' way to check for 0
  bisect--helper: change `retval` to `res`
  bisect--helper: convert `vocab_*` char pointers to char arrays

4 years agoMerge branch 'ds/sparse-add'
Junio C Hamano [Thu, 5 Mar 2020 18:43:01 +0000 (10:43 -0800)] 
Merge branch 'ds/sparse-add'

"git sparse-checkout" learned a new "add" subcommand.

* ds/sparse-add:
  sparse-checkout: allow one-character directories in cone mode
  sparse-checkout: work with Windows paths
  sparse-checkout: create 'add' subcommand
  sparse-checkout: extract pattern update from 'set' subcommand
  sparse-checkout: extract add_patterns_from_input()

4 years agotag: use new advice API to check visibility
Heba Waly [Mon, 2 Mar 2020 20:02:00 +0000 (20:02 +0000)] 
tag: use new advice API to check visibility

change the advise call in tag library from advise() to
advise_if_enabled() to construct an example of the usage of
the new API.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoadvice: revamp advise API
Heba Waly [Mon, 2 Mar 2020 20:01:59 +0000 (20:01 +0000)] 
advice: revamp advise API

Currently it's very easy for the advice library's callers to miss
checking the visibility step before printing an advice. Also, it makes
more sense for this step to be handled by the advice library.

Add a new advise_if_enabled function that checks the visibility of
advice messages before printing.

Add a new helper advise_enabled to check the visibility of the advice
if the caller needs to carry out complicated processing based on that
value.

A list of advice_settings is added to cache the config variables names
and values, it's intended to replace advice_config[] and the global
variables once we migrate all the callers to use the new APIs.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot2402: test worktree path when called in .git directory
Hariom Verma [Wed, 4 Mar 2020 07:00:00 +0000 (07:00 +0000)] 
t2402: test worktree path when called in .git directory

The bug which reports an extra `/.git/.` in worktree path when called in
'.git' directory already has been fixed. But unfortunately, the regression
test to ensure this behavior has been forgotten.
Here is that test.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Hariom Verma <hariom18599@gmail.com>
Acked-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoremote: drop "explicit" parameter from remote_ref_for_branch()
Jeff King [Tue, 3 Mar 2020 16:12:22 +0000 (17:12 +0100)] 
remote: drop "explicit" parameter from remote_ref_for_branch()

Commit 9700fae5ee (for-each-ref: let upstream/push report the remote
ref name, 2017-11-07) added a remote_ref_for_branch() helper, which
is modeled after remote_for_branch(). This includes providing an
"explicit" out-parameter that tells the caller whether the remote
was configured by the user, or whether we picked a default name like
"origin".

But unlike remote names, there is no default name when the user
didn't configure one.  The only way the "explicit" parameter is used
by the caller is to use the value returned from the helper when it
is set, and use an empty string otherwise, ignoring the returned
value from the helper.

Let's drop the "explicit" out-parameter, and return NULL when the
returned value from the helper should be ignored, to simplify the
function interface.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoremote-curl: show progress for fetches over dumb HTTP
René Scharfe [Tue, 3 Mar 2020 20:55:34 +0000 (21:55 +0100)] 
remote-curl: show progress for fetches over dumb HTTP

Fetching over dumb HTTP transport doesn't show any progress, even with
the option --progress.  If the connection is slow or there is a lot of
data to get then this can take a long time while the user is left to
wonder if git got stuck.

We don't know the number of objects to fetch at the outset, but we can
count the ones we got.  Show an open-ended progress indicator based on
that number if the user asked for it.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoThe eighth batch for 2.26
Junio C Hamano [Mon, 2 Mar 2020 23:07:40 +0000 (15:07 -0800)] 
The eighth batch for 2.26

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ma/test-cleanup'
Junio C Hamano [Mon, 2 Mar 2020 23:07:20 +0000 (15:07 -0800)] 
Merge branch 'ma/test-cleanup'

Code cleanup.

* ma/test-cleanup:
  t: drop debug `cat` calls
  t9810: drop debug `cat` call
  t4117: check for files using `test_path_is_file`

4 years agoMerge branch 'rs/blame-typefix-for-fingerprint'
Junio C Hamano [Mon, 2 Mar 2020 23:07:20 +0000 (15:07 -0800)] 
Merge branch 'rs/blame-typefix-for-fingerprint'

Code cleanup.

* rs/blame-typefix-for-fingerprint:
  blame: provide type of fingerprints pointer

4 years agoMerge branch 'rs/micro-cleanups'
Junio C Hamano [Mon, 2 Mar 2020 23:07:20 +0000 (15:07 -0800)] 
Merge branch 'rs/micro-cleanups'

Code cleanup.

* rs/micro-cleanups:
  use strpbrk(3) to search for characters from a given set
  quote: use isalnum() to check for alphanumeric characters

4 years agoMerge branch 'es/worktree-cleanup'
Junio C Hamano [Mon, 2 Mar 2020 23:07:20 +0000 (15:07 -0800)] 
Merge branch 'es/worktree-cleanup'

Code cleanup.

* es/worktree-cleanup:
  worktree: drop unused code from get_main_worktree()

4 years agoMerge branch 'ak/test-log-graph'
Junio C Hamano [Mon, 2 Mar 2020 23:07:19 +0000 (15:07 -0800)] 
Merge branch 'ak/test-log-graph'

Test update.

* ak/test-log-graph:
  lib-log-graph: consolidate colored graph cmp logic
  lib-log-graph: consolidate test_cmp_graph logic

4 years agoMerge branch 'jk/run-command-formatfix'
Junio C Hamano [Mon, 2 Mar 2020 23:07:19 +0000 (15:07 -0800)] 
Merge branch 'jk/run-command-formatfix'

Code style cleanup.

* jk/run-command-formatfix:
  run-command.h: fix mis-indented struct member

4 years agoMerge branch 'ds/partial-clone-fixes'
Junio C Hamano [Mon, 2 Mar 2020 23:07:19 +0000 (15:07 -0800)] 
Merge branch 'ds/partial-clone-fixes'

Fix for a bug revealed by a recent change to make the protocol v2
the default.

* ds/partial-clone-fixes:
  partial-clone: avoid fetching when looking for objects
  partial-clone: demonstrate bugs in partial fetch

4 years agoMerge branch 'en/t3433-rebase-stat-dirty-failure'
Junio C Hamano [Mon, 2 Mar 2020 23:07:19 +0000 (15:07 -0800)] 
Merge branch 'en/t3433-rebase-stat-dirty-failure'

The merge-recursive machinery failed to refresh the cache entry for
a merge result in a couple of places, resulting in an unnecessary
merge failure, which has been fixed.

* en/t3433-rebase-stat-dirty-failure:
  merge-recursive: fix the refresh logic in update_file_flags
  t3433: new rebase testcase documenting a stat-dirty-like failure

4 years agoMerge branch 'en/rebase-backend'
Junio C Hamano [Mon, 2 Mar 2020 23:07:18 +0000 (15:07 -0800)] 
Merge branch 'en/rebase-backend'

"git rebase" has learned to use the merge backend (i.e. the
machinery that drives "rebase -i") by default, while allowing
"--apply" option to use the "apply" backend (e.g. the moral
equivalent of "format-patch piped to am").  The rebase.backend
configuration variable can be set to customize.

* en/rebase-backend:
  rebase: rename the two primary rebase backends
  rebase: change the default backend from "am" to "merge"
  rebase: make the backend configurable via config setting
  rebase tests: repeat some tests using the merge backend instead of am
  rebase tests: mark tests specific to the am-backend with --am
  rebase: drop '-i' from the reflog for interactive-based rebases
  git-prompt: change the prompt for interactive-based rebases
  rebase: add an --am option
  rebase: move incompatibility checks between backend options a bit earlier
  git-rebase.txt: add more details about behavioral differences of backends
  rebase: allow more types of rebases to fast-forward
  t3432: make these tests work with either am or merge backends
  rebase: fix handling of restrict_revision
  rebase: make sure to pass along the quiet flag to the sequencer
  rebase, sequencer: remove the broken GIT_QUIET handling
  t3406: simplify an already simple test
  rebase (interactive-backend): fix handling of commits that become empty
  rebase (interactive-backend): make --keep-empty the default
  t3404: directly test the behavior of interest
  git-rebase.txt: update description of --allow-empty-message

4 years agoMerge branch 'en/check-ignore'
Junio C Hamano [Mon, 2 Mar 2020 23:07:18 +0000 (15:07 -0800)] 
Merge branch 'en/check-ignore'

"git check-ignore" did not work when the given path is explicitly
marked as not ignored with a negative entry in the .gitignore file.

* en/check-ignore:
  check-ignore: fix documentation and implementation to match

4 years agoMerge branch 'jk/object-filter-with-bitmap'
Junio C Hamano [Mon, 2 Mar 2020 23:07:18 +0000 (15:07 -0800)] 
Merge branch 'jk/object-filter-with-bitmap'

The object reachability bitmap machinery and the partial cloning
machinery were not prepared to work well together, because some
object-filtering criteria that partial clones use inherently rely
on object traversal, but the bitmap machinery is an optimization
to bypass that object traversal.  There however are some cases
where they can work together, and they were taught about them.

* jk/object-filter-with-bitmap:
  rev-list --count: comment on the use of count_right++
  pack-objects: support filters with bitmaps
  pack-bitmap: implement BLOB_LIMIT filtering
  pack-bitmap: implement BLOB_NONE filtering
  bitmap: add bitmap_unset() function
  rev-list: use bitmap filters for traversal
  pack-bitmap: basic noop bitmap filter infrastructure
  rev-list: allow commit-only bitmap traversals
  t5310: factor out bitmap traversal comparison
  rev-list: allow bitmaps when counting objects
  rev-list: make --count work with --objects
  rev-list: factor out bitmap-optimized routines
  pack-bitmap: refuse to do a bitmap traversal with pathspecs
  rev-list: fallback to non-bitmap traversal when filtering
  pack-bitmap: fix leak of haves/wants object lists
  pack-bitmap: factor out type iterator initialization

4 years agoMerge branch 'jk/push-option-doc-markup-fix'
Junio C Hamano [Mon, 2 Mar 2020 23:07:18 +0000 (15:07 -0800)] 
Merge branch 'jk/push-option-doc-markup-fix'

Doc markup fix.

* jk/push-option-doc-markup-fix:
  doc/config/push: use longer "--" line for preformatted example

4 years agoMerge branch 'jk/doc-diff-parallel'
Junio C Hamano [Mon, 2 Mar 2020 23:07:17 +0000 (15:07 -0800)] 
Merge branch 'jk/doc-diff-parallel'

Update to doc-diff.

* jk/doc-diff-parallel:
  doc-diff: use single-colon rule in rendering Makefile

4 years agoadvice: change "setupStreamFailure" to "setUpstreamFailure"
Heba Waly [Mon, 2 Mar 2020 20:01:58 +0000 (20:01 +0000)] 
advice: change "setupStreamFailure" to "setUpstreamFailure"

fb6fbffbda (advice: keep config name in camelCase in advice_config[],
2018-05-26) changed the config names to camelCase, but one of the names
wasn't changed correctly. Fix it.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoadvice: extract vadvise() from advise()
Heba Waly [Mon, 2 Mar 2020 20:01:57 +0000 (20:01 +0000)] 
advice: extract vadvise() from advise()

In preparation for a new advice method, extract a version of advise()
that uses an explict 'va_list' parameter. Call it from advise() for a
functionally equivalent version.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoshow_one_mergetag: print non-parent in hex form.
Harald van Dijk [Sat, 29 Feb 2020 13:07:57 +0000 (13:07 +0000)] 
show_one_mergetag: print non-parent in hex form.

When a mergetag names a non-parent, which can occur after a shallow
clone, its hash was previously printed as raw data. Print it in hex form
instead.

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agogit-gui: fix error popup when doing blame -> "Show History Context"
Pratyush Yadav [Mon, 2 Mar 2020 18:15:54 +0000 (23:45 +0530)] 
git-gui: fix error popup when doing blame -> "Show History Context"

In d9c6469 (git-gui: update status bar to track operations, 2019-12-01)
the call to 'ui_status' in 'do_gitk' was updated to create the newly
introduced "status bar operation". This allowed this status text to show
along with other operations happening in parallel, and removed a race
between all these operations.

But in that refactor, the fact that 'ui_status' checks for the existence
of 'main_status' was overlooked. This leads to an error message popping
up when the user selects "Show History Context" from the blame window
context menu on a source line. The error occurs because when running
"blame" 'main_status' is not initialized.

So, add a check for the existence of 'main_status' in 'do_gitk'. This
fix reverts to the original behaviour. In the future, we might want to
look into a better way of telling 'do_gitk' which status bar to use.

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agol10n: Update Catalan translation
Jordi Mas [Sun, 1 Mar 2020 11:58:32 +0000 (12:58 +0100)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
4 years agofast-import: add options for rewriting submodules
brian m. carlson [Sat, 22 Feb 2020 20:17:49 +0000 (20:17 +0000)] 
fast-import: add options for rewriting submodules

When converting a repository using submodules from one hash algorithm to
another, it is necessary to rewrite the submodules from the old
algorithm to the new algorithm, since only references to submodules, not
their contents, are written to the fast-export stream. Without rewriting
the submodules, fast-import fails with an "Invalid dataref" error when
encountering a submodule in another algorithm.

Add a pair of options, --rewrite-submodules-from and
--rewrite-submodules-to, that take a list of marks produced by
fast-export and fast-import, respectively, when processing the
submodule. Use these marks to map the submodule commits from the old
algorithm to the new algorithm.

We read marks into two corresponding struct mark_set objects and then
perform a mapping from the old to the new using a hash table. This lets
us reuse the same mark parsing code that is used elsewhere and allows us
to efficiently read and match marks based on their ID, since mark files
need not be sorted.

Note that because we're using a khash table for the object IDs, and this
table copies values of struct object_id instead of taking references to
them, it's necessary to zero the struct object_id values that we use to
insert and look up in the table. Otherwise, we would end up with SHA-1
values that don't match because of whatever stack garbage might be left
in the unused area.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofast-import: add a generic function to iterate over marks
brian m. carlson [Sat, 22 Feb 2020 20:17:48 +0000 (20:17 +0000)] 
fast-import: add a generic function to iterate over marks

Currently, we can iterate over marks only to dump them to a file. In the
future, we'll want to perform an arbitrary operation over the items of a
mark set. Add a function, for_each_mark, that iterates over marks in a
set and performs an arbitrary callback function for each mark. Switch
the mark dumping routine to use this function now that it's available.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofast-import: make find_marks work on any mark set
brian m. carlson [Sat, 22 Feb 2020 20:17:47 +0000 (20:17 +0000)] 
fast-import: make find_marks work on any mark set

In the future, we'll use multiple different mark sets with this
function, so make it take an argument that points to the mark set to
operate on.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofast-import: add helper function for inserting mark object entries
brian m. carlson [Sat, 22 Feb 2020 20:17:46 +0000 (20:17 +0000)] 
fast-import: add helper function for inserting mark object entries

Currently, everything we want to insert into a mark set is an object
entry. However, in the future, we will want to insert objects of other
types. Teach read_mark_file to take a function pointer which helps us
insert the object we want into our mark set.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofast-import: permit reading multiple marks files
brian m. carlson [Sat, 22 Feb 2020 20:17:45 +0000 (20:17 +0000)] 
fast-import: permit reading multiple marks files

In the future, we'll want to read marks files for submodules as well.
Refactor the existing code to make it possible to read multiple marks
files, each into their own marks set.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoRevert "gpg-interface: prefer check_signature() for GPG verification"
Junio C Hamano [Fri, 28 Feb 2020 17:43:17 +0000 (09:43 -0800)] 
Revert "gpg-interface: prefer check_signature() for GPG verification"

This reverts commit 72b006f4bfd30b7c5037c163efaf279ab65bea9c, which
breaks the end-user experience when merging a signed tag without
having the public key.  We should report "can't check because we
have no public key", but the code with this change claimed that
there was no signature.

4 years agoconfig.mak.dev: re-enable -Wformat-zero-length
Jeff King [Thu, 27 Feb 2020 23:54:45 +0000 (18:54 -0500)] 
config.mak.dev: re-enable -Wformat-zero-length

We recently triggered some -Wformat-zero-length warnings in the code,
but no developers noticed because we suppress that warning in builds
with the DEVELOPER=1 Makefile knob set. But we _don't_ suppress them in
a non-developer build (and they're part of -Wall). So even though
non-developers probably aren't using -Werror, they see the annoying
warnings when they build.

We've had back and forth discussion over the years on whether this
warning is useful or not. In most cases we've seen, it's not true that
the call is a mistake, since we're using its side effects (like adding a
newline status_printf_ln()) or writing an empty string to a destination
which is handled by the function (as in write_file()). And so we end up
working around it in the source by passing ("%s", "").

There's more discussion in the subthread starting at:

  https://lore.kernel.org/git/xmqqtwaod7ly.fsf@gitster.mtv.corp.google.com/

The short of it is that we probably can't just disable the warning for
everybody because of portability issues. And ignoring it for developers
puts us in the situation we're in now, where non-dev builds are annoyed.

Since the workaround is both rarely needed and fairly straight-forward,
let's just commit to doing it as necessary, and re-enable the warning.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorebase-interactive.c: silence format-zero-length warnings
Ralf Thielow [Thu, 27 Feb 2020 20:25:30 +0000 (20:25 +0000)] 
rebase-interactive.c: silence format-zero-length warnings

Fixes the following warnings:

rebase-interactive.c: In function ‘edit_todo_list’:
rebase-interactive.c:137:38: warning: zero-length gnu_printf format string [-Wformat-zero-length]
    write_file(rebase_path_dropped(), "");
rebase-interactive.c:144:37: warning: zero-length gnu_printf format string [-Wformat-zero-length]
   write_file(rebase_path_dropped(), "");

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: workaround for hangs when sending STDIN
Alexandr Miloslavskiy [Mon, 17 Feb 2020 18:01:26 +0000 (18:01 +0000)] 
mingw: workaround for hangs when sending STDIN

Explanation
-----------
The problem here is flawed `poll()` implementation. When it tries to
see if pipe can be written without blocking, it eventually calls
`NtQueryInformationFile()` and tests `WriteQuotaAvailable`. However,
the meaning of quota was misunderstood. The value of quota is reduced
when either some data was written to a pipe, *or* there is a pending
read on the pipe. Therefore, if there is a pending read of size >= than
the pipe's buffer size, poll() will think that pipe is not writable and
will hang forever, usually that means deadlocking both pipe users.

I have studied the problem and found that Windows pipes track two values:
`QuotaUsed` and `BytesInQueue`. The code in `poll()` apparently wants to
know `BytesInQueue` instead of quota. Unfortunately, `BytesInQueue` can
only be requested from read end of the pipe, while `poll()` receives
write end.

The git's implementation of `poll()` was copied from gnulib, which also
contains a flawed implementation up to today.

I also had a look at implementation in cygwin, which is also broken in a
subtle way. It uses this code in `pipe_data_available()`:
fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable)
However, `ReadDataAvailable` always returns 0 for the write end of the pipe,
turning the code into an obfuscated version of returning pipe's total
buffer size, which I guess will in turn have `poll()` always say that pipe
is writable. The commit that introduced the code doesn't say anything about
this change, so it could be some debugging code that slipped in.

These are the typical sizes used in git:
0x2000 - default read size in `strbuf_read()`
0x1000 - default read size in CRT, used by `strbuf_getwholeline()`
0x2000 - pipe buffer size in compat\mingw.c

As a consequence, as soon as child process uses `strbuf_read()`,
`poll()` in parent process will hang forever, deadlocking both
processes.

This results in two observable behaviors:
1) If parent process begins sending STDIN quickly (and usually that's
   the case), then first `poll()` will succeed and first block will go
   through. MAX_IO_SIZE_DEFAULT is 8MB, so if STDIN exceeds 8MB, then
   it will deadlock.
2) If parent process waits a little bit for any reason (including OS
   scheduler) and child is first to issue `strbuf_read()`, then it will
   deadlock immediately even on small STDINs.

The problem is illustrated by `git stash push`, which will currently
read the entire patch into memory and then send it to `git apply` via
STDIN. If patch exceeds 8MB, git hangs on Windows.

Possible solutions
------------------
1) Somehow obtain `BytesInQueue` instead of `QuotaUsed`
   I did a pretty thorough search and didn't find any ways to obtain
   the value from write end of the pipe.
2) Also give read end of the pipe to `poll()`
   That can be done, but it will probably invite some dirty code,
   because `poll()`
   * can accept multiple pipes at once
   * can accept things that are not pipes
   * is expected to have a well known signature.
3) Make `poll()` always reply "writable" for write end of the pipe
   Afterall it seems that cygwin (accidentally?) does that for years.
   Also, it should be noted that `pump_io_round()` writes 8MB blocks,
   completely ignoring the fact that pipe's buffer size is only 8KB,
   which means that pipe gets clogged many times during that single
   write. This may invite a deadlock, if child's STDERR/STDOUT gets
   clogged while it's trying to deal with 8MB of STDIN. Such deadlocks
   could be defeated with writing less than pipe's buffer size per
   round, and always reading everything from STDOUT/STDERR before
   starting next round. Therefore, making `poll()` always reply
   "writable" shouldn't cause any new issues or block any future
   solutions.
4) Increase the size of the pipe's buffer
   The difference between `BytesInQueue` and `QuotaUsed` is the size
   of pending reads. Therefore, if buffer is bigger than size of reads,
   `poll()` won't hang so easily. However, I found that for example
   `strbuf_read()` will get more and more hungry as it reads large inputs,
   eventually surpassing any reasonable pipe buffer size.

Chosen solution
---------------
Make `poll()` always reply "writable" for write end of the pipe.
Hopefully one day someone will find a way to implement it properly.

Reproduction
------------
printf "%8388608s" X >large_file.txt
git stash push --include-untracked -- large_file.txt

I have decided not to include this as test to avoid slowing down the
test suite. I don't expect the specific problem to come back, and
chances are that `git stash push` will be reworked to avoid sending the
entire patch via STDIN.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation: clarify that `-h` alone stands for `help`
Junio C Hamano [Thu, 27 Feb 2020 16:10:20 +0000 (08:10 -0800)] 
Documentation: clarify that `-h` alone stands for `help`

We seem to be getting new users who get confused every 20 months or
so with this "-h consistently wants to give help, but the commands
to which `-h` may feel like a good short-form option want it to mean
something else." compromise.

Let's make sure that the readers know that `git cmd -h` (with no
other arguments) is a way to get usage text, even for commands like
ls-remote and grep.

Also extend the description that is already in gitcli.txt, as it is
clear that users still get confused with the current text.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot6020: new test with interleaved lexicographic ordering of directories
Elijah Newren [Thu, 27 Feb 2020 00:14:24 +0000 (00:14 +0000)] 
t6020: new test with interleaved lexicographic ordering of directories

If a repository has two files:
    foo/bar/baz
    foo/bar-2/baz
then a simple lexicographic ordering of files and directories shows
    ...
    foo/bar
    foo/bar-2
    foo/bar/baz
    ...
and the appearance of foo/bar-2 between foo/bar and foo/bar/baz can trip
up some codepaths.  Add a test to catch such cases.

t6020 might be a slight misfit since this testcase does not test any
kind of file/directory conflict.  However, it is similar in spirit to
some tests (4-6) already in t6020 that check cases where a *file* sorted
between a directory and the files underneath that directory.  This
testcase differs in that now there is a *directory* that sorts in the
middle.

Although merge-recursive currently has no problems with this simple
testcase, I discovered that it's very possible to accidentally mess it
up.  Further, we have no other merge or cherry-pick or rebase testcases
in the entire testsuite that cover such a case, so I felt like it would
be a worthwhile addition to the testsuite.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot6022, t6046: test expected behavior instead of testing a proxy for it
Elijah Newren [Thu, 27 Feb 2020 00:14:23 +0000 (00:14 +0000)] 
t6022, t6046: test expected behavior instead of testing a proxy for it

In t6022, we were testing for file being overwritten (or not) based on
an output message instead of checking for the file being overwritten.
Since we can check for the file being overwritten via mtime updates,
check that instead.

In t6046, we were largely checking for both the expected behavior and a
proxy for it, which is unnecessary.  The calls to test-tool also were a
bit cryptic.  Make them a little clearer.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3035: prefer test_must_fail to bash negation for git commands
Elijah Newren [Thu, 27 Feb 2020 00:14:22 +0000 (00:14 +0000)] 
t3035: prefer test_must_fail to bash negation for git commands

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot6020, t6022, t6035: update merge tests to use test helper functions
Elijah Newren [Thu, 27 Feb 2020 00:14:21 +0000 (00:14 +0000)] 
t6020, t6022, t6035: update merge tests to use test helper functions

Make use of test_path_is_file, test_write_lines, and similar helpers
in these old test files.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot602[1236], t6034: modernize test formatting
Elijah Newren [Thu, 27 Feb 2020 00:14:20 +0000 (00:14 +0000)] 
t602[1236], t6034: modernize test formatting

Indent code, and include it inside test_expect* blocks.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomerge-recursive: apply collision handling unification to recursive case
Elijah Newren [Thu, 27 Feb 2020 00:05:05 +0000 (00:05 +0000)] 
merge-recursive: apply collision handling unification to recursive case

In the en/merge-path-collision topic (see commit ac193e0e0aa5, "Merge
branch 'en/merge-path-collision'", 2019-01-04), all the "file collision"
conflict types were modified for consistency.  In particular,
rename/add, rename/rename(2to1) and each rename/add piece of a
rename/rename(1to2)/add[/add] conflict were made to behave like add/add
conflicts have always been handled.

However, this consistency was not enforced when opt->priv->call_depth >
0 for rename/rename conflicts.  Update rename/rename(1to2) and
rename/rename(2to1) conflicts in the recursive case to also be
consistent.  As an added bonus, this simplifies the code considerably.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoAzure Pipeline: switch to the latest agent pools
Johannes Schindelin [Thu, 27 Feb 2020 13:23:13 +0000 (13:23 +0000)] 
Azure Pipeline: switch to the latest agent pools

It would seem that at least the `vs2015-win2012r2` pool (which we use
via its old name, `Hosted`) is about to be phased out. Let's switch
before that.

While at it, use the newer pool names as suggested at
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops#use-a-microsoft-hosted-agent

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoci: prevent `perforce` from being quarantined
Johannes Schindelin [Thu, 27 Feb 2020 13:23:12 +0000 (13:23 +0000)] 
ci: prevent `perforce` from being quarantined

The most recent Azure Pipelines macOS agents enable what Apple calls
"System Integrity Protection". This makes `p4d -V` hang: there is some
sort of GUI dialog waiting for the user to acknowledge that the copied
binaries are legit and may be executed, but on build agents, there is no
user who could acknowledge that.

Let's ask Homebrew specifically to _not_ quarantine the Perforce
binaries.

Helped-by: Aleksandr Chebotov
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/lib-httpd: avoid using macOS' sed
Johannes Schindelin [Thu, 27 Feb 2020 13:23:11 +0000 (13:23 +0000)] 
t/lib-httpd: avoid using macOS' sed

Among other differences relative to GNU sed, macOS' sed always ends its
output with a trailing newline, even if the input did not have such a
trailing newline.

Surprisingly, this makes three httpd-based tests fail on macOS: t5616,
t5702 and t5703. ("Surprisingly" because those tests have been around
for some time, but apparently nobody runs them on macOS with a working
Apache2 setup.)

The reason is that we use `sed` in those tests to filter the response of
the web server. Apart from the fact that we use GNU constructs (such as
using a space after the `c` command instead of a backslash and a
newline), we have another problem: macOS' sed LF-only newlines while
webservers are supposed to use CR/LF ones.

Even worse, t5616 uses `sed` to replace a binary part of the response
with a new binary part (kind of hoping that the replaced binary part
does not contain a 0x0a byte which would be interpreted as a newline).

To that end, it calls on Perl to read the binary pack file and
hex-encode it, then calls on `sed` to prefix every hex digit pair with a
`\x` in order to construct the text that the `c` statement of the `sed`
invocation is supposed to insert. So we call Perl and sed to construct a
sed statement. The final nail in the coffin is that macOS' sed does not
even interpret those `\x<hex>` constructs.

Let's just replace all of that by Perl snippets. With Perl, at least, we
do not have to deal with GNU vs macOS semantics, we do not have to worry
about unwanted trailing newlines, and we do not have to spawn commands
to construct arguments for other commands to be spawned (i.e. we can
avoid a whole lot of shell scripting complexity).

The upshot is that this fixes t5616, t5702 and t5703 on macOS with
Apache2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocommit-graph: use progress title directly
René Scharfe [Thu, 20 Feb 2020 18:49:18 +0000 (19:49 +0100)] 
commit-graph: use progress title directly

merge_commit_graphs() copies the (translated) progress message into a
strbuf and passes the copy to start_delayed_progress() at each loop
iteration.  The latter function takes a string pointer, so let's avoid
the detour and hand the string to it directly.  That's shorter, simpler
and slightly more efficient.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>