git
4 years agoMerge branch 'js/subtree-doc-update-to-asciidoctor-2'
Junio C Hamano [Tue, 28 Apr 2020 22:50:03 +0000 (15:50 -0700)] 
Merge branch 'js/subtree-doc-update-to-asciidoctor-2'

Doc markup update.

* js/subtree-doc-update-to-asciidoctor-2:
  subtree: fix build with AsciiDoctor 2

4 years agoMerge branch 'ds/t5319-touch-fix'
Junio C Hamano [Tue, 28 Apr 2020 22:50:02 +0000 (15:50 -0700)] 
Merge branch 'ds/t5319-touch-fix'

Tests update to use "test-chmtime" instead of "touch -t".

* ds/t5319-touch-fix:
  t5319: replace 'touch -m' with 'test-tool chmtime'

4 years agoMerge branch 'ds/commit-graph-expiry-fix'
Junio C Hamano [Tue, 28 Apr 2020 22:50:02 +0000 (15:50 -0700)] 
Merge branch 'ds/commit-graph-expiry-fix'

"git commit-graph write --expire-time=<timestamp>" did not use the
given timestamp correctly, which has been corrected.

* ds/commit-graph-expiry-fix:
  commit-graph: fix buggy --expire-time option

4 years agoMerge branch 'dr/doc-recurse-submodules'
Junio C Hamano [Tue, 28 Apr 2020 22:50:01 +0000 (15:50 -0700)] 
Merge branch 'dr/doc-recurse-submodules'

Documentation updates around the "--recurse-submodules" option.

* dr/doc-recurse-submodules:
  doc: --recurse-submodules mostly applies to active submodules
  doc: be more precise on (fetch|push).recurseSubmodules
  doc: explain how to deactivate submodule.recurse completely
  doc: document --recurse-submodules for reset and restore
  doc: list all commands affected by submodule.recurse

4 years agoMerge branch 'jc/log-no-mailmap'
Junio C Hamano [Tue, 28 Apr 2020 22:50:00 +0000 (15:50 -0700)] 
Merge branch 'jc/log-no-mailmap'

"git log" learns "--[no-]mailmap" as a synonym to "--[no-]use-mailmap"

* jc/log-no-mailmap:
  log: give --[no-]use-mailmap a more sensible synonym --[no-]mailmap
  clone: reorder --recursive/--recurse-submodules
  parse-options: teach "git cmd -h" to show alias as alias

4 years agoMerge branch 'ma/doc-discard-docbook-xsl-1.73'
Junio C Hamano [Tue, 28 Apr 2020 22:50:00 +0000 (15:50 -0700)] 
Merge branch 'ma/doc-discard-docbook-xsl-1.73'

Raise the minimum required version of docbook-xsl package to 1.74,
as 1.74.0 was from late 2008, which is more than 10 years old, and
drop compatibility cruft from our documentation suite.

* ma/doc-discard-docbook-xsl-1.73:
  user-manual.conf: don't specify [listingblock]
  INSTALL: drop support for docbook-xsl before 1.74
  manpage-normal.xsl: fold in manpage-base.xsl
  manpage-bold-literal.xsl: stop using git.docbook.backslash
  Doc: drop support for docbook-xsl before 1.73.0
  Doc: drop support for docbook-xsl before 1.72.0
  Doc: drop support for docbook-xsl before 1.71.1

4 years agoMerge branch 'lx/submodule-clear-variables'
Junio C Hamano [Tue, 28 Apr 2020 22:49:59 +0000 (15:49 -0700)] 
Merge branch 'lx/submodule-clear-variables'

The "git submodule" command did not initialize a few variables it
internally uses and was affected by variable settings leaked from
the environment.

* lx/submodule-clear-variables:
  git-submodule.sh: setup uninitialized variables

4 years agoMerge branch 'jk/fast-import-use-hashmap'
Junio C Hamano [Tue, 28 Apr 2020 22:49:58 +0000 (15:49 -0700)] 
Merge branch 'jk/fast-import-use-hashmap'

The custom hash function used by "git fast-import" has been
replaced with the one from hashmap.c, which gave us a nice
performance boost.

* jk/fast-import-use-hashmap:
  fast-import: replace custom hash with hashmap.c

4 years agoMerge branch 'jk/config-use-size-t'
Junio C Hamano [Tue, 28 Apr 2020 22:49:58 +0000 (15:49 -0700)] 
Merge branch 'jk/config-use-size-t'

The config API made mixed uses of int and size_t types to represent
length of various pieces of text it parsed, which has been updated
to use the correct type (i.e. size_t) throughout.

* jk/config-use-size-t:
  config: reject parsing of files over INT_MAX
  config: use size_t to store parsed variable baselen
  git_config_parse_key(): return baselen as size_t
  config: drop useless length variable in write_pair()
  parse_config_key(): return subsection len as size_t
  remote: drop auto-strlen behavior of make_branch() and make_rewrite()

4 years agoMerge branch 'bc/constant-memequal'
Junio C Hamano [Tue, 28 Apr 2020 22:49:57 +0000 (15:49 -0700)] 
Merge branch 'bc/constant-memequal'

Validation of push certificate has been made more robust against
timing attacks.

* bc/constant-memequal:
  receive-pack: compilation fix
  builtin/receive-pack: use constant-time comparison for HMAC value

4 years agoMerge branch 'lr/freshen-file-fix'
Junio C Hamano [Tue, 28 Apr 2020 22:49:56 +0000 (15:49 -0700)] 
Merge branch 'lr/freshen-file-fix'

The code that refreshes the last access and modified time of
on-disk packfiles and loose object files have been updated.

* lr/freshen-file-fix:
  freshen_file(): use NULL `times' for implicit current-time

4 years agoMerge branch 'en/rebase-doc-hooks-called-by-accident'
Junio C Hamano [Tue, 28 Apr 2020 22:49:56 +0000 (15:49 -0700)] 
Merge branch 'en/rebase-doc-hooks-called-by-accident'

"git rebase" happens to call some hooks meant for "checkout" and
"commit" by this was not a designed behaviour than historical
accident.  This has been documented.

* en/rebase-doc-hooks-called-by-accident:
  git-rebase.txt: add another hook to the hooks section, and explain more

4 years agoMerge branch 'jc/doc-test-leaving-early'
Junio C Hamano [Tue, 28 Apr 2020 22:49:55 +0000 (15:49 -0700)] 
Merge branch 'jc/doc-test-leaving-early'

Document the recommended way to abort a failing test early (e.g. by
exiting a loop), which is to say "return 1".

* jc/doc-test-leaving-early:
  t/README: suggest how to leave test early with failure

4 years agoMerge branch 'dd/test-with-busybox'
Junio C Hamano [Tue, 28 Apr 2020 22:49:54 +0000 (15:49 -0700)] 
Merge branch 'dd/test-with-busybox'

Various tests have been updated to work around issues found with
shell utilities that come with busybox etc.

* dd/test-with-busybox:
  t5703: feed raw data into test-tool unpack-sideband
  t4124: tweak test so that non-compliant diff(1) can also be used
  t7063: drop non-POSIX argument "-ls" from find(1)
  t5616: use rev-parse instead to get HEAD's object_id
  t5003: skip conversion test if unzip -a is unavailable
  t5003: drop the subshell in test_lazy_prereq
  test-lib-functions: test_cmp: eval $GIT_TEST_CMP
  t4061: use POSIX compliant regex(7)

4 years agoThe third batch
Junio C Hamano [Wed, 22 Apr 2020 20:42:29 +0000 (13:42 -0700)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'jk/credential-parsing-end-of-host-in-URL'
Junio C Hamano [Wed, 22 Apr 2020 20:43:01 +0000 (13:43 -0700)] 
Merge branch 'jk/credential-parsing-end-of-host-in-URL'

Parsing of URL for the credential helper has been corrected.

* jk/credential-parsing-end-of-host-in-URL:
  credential: treat "?" and "#" in URLs as end of host

4 years agoMerge branch 'jt/rebase-allow-duplicate'
Junio C Hamano [Wed, 22 Apr 2020 20:43:00 +0000 (13:43 -0700)] 
Merge branch 'jt/rebase-allow-duplicate'

Allow "git rebase" to reapply all local commits, even if the may be
already in the upstream, without checking first.

* jt/rebase-allow-duplicate:
  rebase --merge: optionally skip upstreamed commits

4 years agoMerge branch 'en/rebase-no-keep-empty'
Junio C Hamano [Wed, 22 Apr 2020 20:43:00 +0000 (13:43 -0700)] 
Merge branch 'en/rebase-no-keep-empty'

"git rebase" (again) learns to honor "--no-keep-empty", which lets
the user to discard commits that are empty from the beginning (as
opposed to the ones that become empty because of rebasing).  The
interactive rebase also marks commits that are empty in the todo.

* en/rebase-no-keep-empty:
  rebase: fix an incompatible-options error message
  rebase: reinstate --no-keep-empty
  rebase -i: mark commits that begin empty in todo editor

4 years agoMerge branch 'js/mingw-is-hidden-test-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:59 +0000 (13:42 -0700)] 
Merge branch 'js/mingw-is-hidden-test-fix'

A Windows-specific test element has been made more robust against
misuse from both user's environment and programmer's errors.

* js/mingw-is-hidden-test-fix:
  t: restrict `is_hidden` to be called only on Windows
  mingw: make test_path_is_hidden more robust
  t: consolidate the `is_hidden` functions

4 years agoMerge branch 'js/mingw-isilon-nfs'
Junio C Hamano [Wed, 22 Apr 2020 20:42:58 +0000 (13:42 -0700)] 
Merge branch 'js/mingw-isilon-nfs'

* js/mingw-isilon-nfs:
  mingw: cope with the Isilon network file system

4 years agoMerge branch 'js/flush-prompt-before-interative-input'
Junio C Hamano [Wed, 22 Apr 2020 20:42:58 +0000 (13:42 -0700)] 
Merge branch 'js/flush-prompt-before-interative-input'

The interactive input from various codepaths are consolidated and
any prompt possibly issued earlier are fflush()ed before we read.

* js/flush-prompt-before-interative-input:
  interactive: explicitly `fflush` stdout before expecting input
  interactive: refactor code asking the user for interactive input

4 years agoMerge branch 'ds/revision-show-pulls'
Junio C Hamano [Wed, 22 Apr 2020 20:42:57 +0000 (13:42 -0700)] 
Merge branch 'ds/revision-show-pulls'

"git log" learned "--show-pulls" that helps pathspec limited
history views; a merge commit that takes the whole change from a
side branch, which is normally omitted from the output, is shown
in addition to the commits that introduce real changes.

* ds/revision-show-pulls:
  revision: --show-pulls adds helpful merges

4 years agoMerge branch 'ma/simplify-merge-config-parsing'
Junio C Hamano [Wed, 22 Apr 2020 20:42:56 +0000 (13:42 -0700)] 
Merge branch 'ma/simplify-merge-config-parsing'

Code simplification.

* ma/simplify-merge-config-parsing:
  merge: use skip_prefix to parse config key

4 years agoMerge branch 'js/mingw-fixes'
Junio C Hamano [Wed, 22 Apr 2020 20:42:56 +0000 (13:42 -0700)] 
Merge branch 'js/mingw-fixes'

Misc fixes for Windows.

* js/mingw-fixes:
  mingw: help debugging by optionally executing bash with strace
  mingw: do not treat `COM0` as a reserved file name
  mingw: use modern strftime implementation if possible

4 years agoMerge branch 'jc/missing-ref-store-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:55 +0000 (13:42 -0700)] 
Merge branch 'jc/missing-ref-store-fix'

We've left the command line parsing of "git log :/a/b/" broken for
about a full year without anybody noticing, which has been
corrected.

* jc/missing-ref-store-fix:
  repository: mark the "refs" pointer as private
  sha1-name: do not assume that the ref store is initialized

4 years agoMerge branch 'ma/config-doc-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:54 +0000 (13:42 -0700)] 
Merge branch 'ma/config-doc-fix'

Doc update.

* ma/config-doc-fix:
  config.txt: move closing "----" to cover entire listing

4 years agoMerge branch 'eb/format-patch-no-encode-headers'
Junio C Hamano [Wed, 22 Apr 2020 20:42:54 +0000 (13:42 -0700)] 
Merge branch 'eb/format-patch-no-encode-headers'

The output from "git format-patch" uses RFC 2047 encoding for
non-ASCII letters on From: and Subject: headers, so that it can
directly be fed to e-mail programs.  A new option has been added
to produce these headers in raw.

* eb/format-patch-no-encode-headers:
  format-patch: teach --no-encode-email-headers

4 years agoMerge branch 'pb/pull-fetch-doc'
Junio C Hamano [Wed, 22 Apr 2020 20:42:53 +0000 (13:42 -0700)] 
Merge branch 'pb/pull-fetch-doc'

The more aggressive updates to remote-tracking branches we had for
the past 7 years or so were not reflected in the documentation,
which has been corrected.

* pb/pull-fetch-doc:
  pull doc: correct outdated description of an example
  pull doc: refer to a specific section in 'fetch' doc

4 years agoMerge branch 'dd/no-gpg-sign'
Junio C Hamano [Wed, 22 Apr 2020 20:42:52 +0000 (13:42 -0700)] 
Merge branch 'dd/no-gpg-sign'

"git rebase" learned the "--no-gpg-sign" option to countermand
commit.gpgSign the user may have.

* dd/no-gpg-sign:
  Documentation: document merge option --no-gpg-sign
  Documentation: merge commit-tree --[no-]gpg-sign
  Documentation: reword commit --no-gpg-sign
  Documentation: document am --no-gpg-sign
  cherry-pick/revert: honour --no-gpg-sign in all case
  rebase.c: honour --no-gpg-sign

4 years agoMerge branch 'js/t0007-typofix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:52 +0000 (13:42 -0700)] 
Merge branch 'js/t0007-typofix'

Typofix in a test script.

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

4 years agoMerge branch 'en/sequencer-reflog-action'
Junio C Hamano [Wed, 22 Apr 2020 20:42:51 +0000 (13:42 -0700)] 
Merge branch 'en/sequencer-reflog-action'

"git rebase -i" did not leave the reflog entries correctly.

* en/sequencer-reflog-action:
  sequencer: honor GIT_REFLOG_ACTION

4 years agoMerge branch 'jk/use-quick-lookup-in-clone-for-tag-following'
Junio C Hamano [Wed, 22 Apr 2020 20:42:50 +0000 (13:42 -0700)] 
Merge branch 'jk/use-quick-lookup-in-clone-for-tag-following'

The logic to auto-follow tags by "git clone --single-branch" was
not careful to avoid lazy-fetching unnecessary tags, which has been
corrected.

* jk/use-quick-lookup-in-clone-for-tag-following:
  clone: use "quick" lookup while following tags

4 years agoMerge branch 'ag/rebase-merge-allow-ff-under-abbrev-command'
Junio C Hamano [Wed, 22 Apr 2020 20:42:50 +0000 (13:42 -0700)] 
Merge branch 'ag/rebase-merge-allow-ff-under-abbrev-command'

"git rebase" with the merge backend did not work well when the
rebase.abbreviateCommands configuration was set.

* ag/rebase-merge-allow-ff-under-abbrev-command:
  t3432: test `--merge' with `rebase.abbreviateCommands = true', too
  sequencer: don't abbreviate a command if it doesn't have a short form

4 years agoMerge branch 'jk/oid-array-cleanups'
Junio C Hamano [Wed, 22 Apr 2020 20:42:49 +0000 (13:42 -0700)] 
Merge branch 'jk/oid-array-cleanups'

Code cleanup.

* jk/oid-array-cleanups:
  oidset: stop referring to sha1-array
  ref-filter: stop referring to "sha1 array"
  bisect: stop referring to sha1_array
  test-tool: rename sha1-array to oid-array
  oid_array: rename source file from sha1-array
  oid_array: use size_t for iteration
  oid_array: use size_t for count and allocation

4 years agoMerge branch 'jm/gitweb-fastcgi-utf8'
Junio C Hamano [Wed, 22 Apr 2020 20:42:49 +0000 (13:42 -0700)] 
Merge branch 'jm/gitweb-fastcgi-utf8'

Gitweb update.

* jm/gitweb-fastcgi-utf8:
  gitweb: fix UTF-8 encoding when using CGI::Fast

4 years agoMerge branch 'jc/allow-strlen-substitution-in-shell-scripts'
Junio C Hamano [Wed, 22 Apr 2020 20:42:48 +0000 (13:42 -0700)] 
Merge branch 'jc/allow-strlen-substitution-in-shell-scripts'

Coding guideline update.

* jc/allow-strlen-substitution-in-shell-scripts:
  CodingGuidelines: allow ${#posix} == strlen($posix)

4 years agoMerge branch 'en/pull-do-not-rebase-after-fast-forwarding'
Junio C Hamano [Wed, 22 Apr 2020 20:42:47 +0000 (13:42 -0700)] 
Merge branch 'en/pull-do-not-rebase-after-fast-forwarding'

"git pull --rebase" tried to run a rebase even after noticing that
the pull results in a fast-forward and no rebase is needed nor
sensible, for the past few years due to a mistake nobody noticed.

* en/pull-do-not-rebase-after-fast-forwarding:
  pull: avoid running both merge and rebase

4 years agoMerge branch 'dl/wrapper-fix-indentation'
Junio C Hamano [Wed, 22 Apr 2020 20:42:46 +0000 (13:42 -0700)] 
Merge branch 'dl/wrapper-fix-indentation'

Coding style fix.

* dl/wrapper-fix-indentation:
  wrapper: indent with tabs

4 years agoMerge branch 'ag/sequencer-i18n-messages'
Junio C Hamano [Wed, 22 Apr 2020 20:42:45 +0000 (13:42 -0700)] 
Merge branch 'ag/sequencer-i18n-messages'

Message fix.

* ag/sequencer-i18n-messages:
  sequencer: mark messages for translation

4 years agoMerge branch 'rs/pull-options-sync-code-and-doc'
Junio C Hamano [Wed, 22 Apr 2020 20:42:45 +0000 (13:42 -0700)] 
Merge branch 'rs/pull-options-sync-code-and-doc'

"git pull" shares many options with underlying "git fetch", but
some of them were not documented and some of those that would make
sense to pass down were not passed down.

* rs/pull-options-sync-code-and-doc:
  pull: pass documented fetch options on
  pull: remove --update-head-ok from documentation

4 years agoMerge branch 'js/walk-doc-optim'
Junio C Hamano [Wed, 22 Apr 2020 20:42:45 +0000 (13:42 -0700)] 
Merge branch 'js/walk-doc-optim'

Code cleanup.

* js/walk-doc-optim:
  MyFirstObjectWalk: remove unnecessary conditional statement

4 years agoMerge branch 'pb/rebase-doc-typofix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'pb/rebase-doc-typofix'

Typofix.

* pb/rebase-doc-typofix:
  git-rebase.txt: fix typo

4 years agoMerge branch 'jk/p5310-drop-non-bitmap-timing'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'jk/p5310-drop-non-bitmap-timing'

Perf-test update.

* jk/p5310-drop-non-bitmap-timing:
  p5310: stop timing non-bitmap pack-to-disk

4 years agoMerge branch 'jk/harden-protocol-v2-delim-handling'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'jk/harden-protocol-v2-delim-handling'

The server-end of the v2 protocol to serve "git clone" and "git
fetch" was not prepared to see a delim packets at unexpected
places, which led to a crash.

* jk/harden-protocol-v2-delim-handling:
  test-lib-functions: simplify packetize() stdin code
  upload-pack: handle unexpected delim packets
  test-lib-functions: make packetize() more efficient

4 years agoMerge branch 'jk/test-cleanup'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'jk/test-cleanup'

Test cleanup.

* jk/test-cleanup:
  t/lib-*.sh: drop executable bit
  t/lib-credential.sh: drop shebang line

4 years agoMerge branch 'ak/run-command-on-cygwin-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'ak/run-command-on-cygwin-fix'

Utitiles run via the run_command() API were not spawned correctly
on Cygwin, when the paths to them are given as a full path with
backslashes.

* ak/run-command-on-cygwin-fix:
  run-command: trigger PATH lookup properly on Cygwin

4 years agoMerge branch 'dr/midx-avoid-int-underflow'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'dr/midx-avoid-int-underflow'

When fed a midx that records no objects, some codepaths tried to
loop from 0 through (num_objects-1), which, due to integer
arithmetic wrapping around, made it nonsense operation with out of
bounds array accesses.  The code has been corrected to reject such
an midx file.

* dr/midx-avoid-int-underflow:
  midx.c: fix an integer underflow

4 years agoMerge branch 'dl/test-must-fail-fixes-3'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'dl/test-must-fail-fixes-3'

Test clean-up continues.

* dl/test-must-fail-fixes-3:
  t5801: teach compare_refs() to accept !
  t5612: stop losing return codes of git commands
  t5612: don't use `test_must_fail test_cmp`
  t5607: reorder `nongit test_must_fail`
  t5550: simplify no matching line check
  t5512: stop losing return codes of git commands
  t5512: stop losing git exit code in here-docs
  t5512: don't use `test_must_fail test_cmp`

4 years agoMerge branch 'js/trace2-env-vars'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'js/trace2-env-vars'

Trace2 enhancement to allow logging of the environment variables.

* js/trace2-env-vars:
  trace2: teach Git to log environment variables

4 years agoMerge branch 'jt/connectivity-check-optim-in-partial-clone'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'jt/connectivity-check-optim-in-partial-clone'

Simplify the commit ancestry connectedness check in a partial clone
repository in which "promised" objects are assumed to be obtainable
lazily on-demand from promisor remote repositories.

* jt/connectivity-check-optim-in-partial-clone:
  connected: always use partial clone optimization

4 years agoMerge branch 'bc/faq'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'bc/faq'

Doc update.

* bc/faq:
  docs: add a FAQ

4 years agoMerge branch 'bk/p4-pre-edit-changelist'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'bk/p4-pre-edit-changelist'

"git p4" learned four new hooks and also "--no-verify" option to
bypass them (and the existing "p4-pre-submit" hook).

* bk/p4-pre-edit-changelist:
  git-p4: add RCS keyword status message
  git-p4: add p4 submit hooks
  git-p4: restructure code in submit
  git-p4: add --no-verify option
  git-p4: add p4-pre-submit exit text
  git-p4: create new function run_git_hook
  git-p4: rewrite prompt to be Windows compatible

4 years agoMerge branch 'mt/test-lib-bundled-short-options'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'mt/test-lib-bundled-short-options'

Minor test usability improvement.

* mt/test-lib-bundled-short-options:
  test-lib: allow short options to be bundled

4 years agoMerge branch 'js/import-tars-do-not-make-phony-files-from-pax-headers'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'js/import-tars-do-not-make-phony-files-from-pax-headers'

The import-tars importer (in contrib/fast-import/) used to create
phony files at the top-level of the repository when the archive
contains global PAX headers, which made its own logic to detect and
omit the common leading directory ineffective, which has been
corrected.

* js/import-tars-do-not-make-phony-files-from-pax-headers:
  import-tars: ignore the global PAX header

4 years agoMerge branch 'js/test-junit-finalization-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'js/test-junit-finalization-fix'

Test fix.

* js/test-junit-finalization-fix:
  tests(junit-xml): avoid invalid XML

4 years agoMerge branch 'js/tests-gpg-integration-on-windows'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'js/tests-gpg-integration-on-windows'

Enable tests that require GnuPG on Windows.

* js/tests-gpg-integration-on-windows:
  tests: increase the verbosity of the GPG-related prereqs
  tests: turn GPG, GPGSM and RFC1991 into lazy prereqs
  tests: do not let lazy prereqs inside `test_expect_*` turn off tracing
  t/lib-gpg.sh: stop pretending to be a stand-alone script
  tests(gpg): allow the gpg-agent to start on Windows

4 years agoMerge branch 'jk/t3419-drop-expensive-tests'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'jk/t3419-drop-expensive-tests'

Test update.

* jk/t3419-drop-expensive-tests:
  t3419: drop EXPENSIVE tests

4 years agoMerge branch 'ds/doc-clone-filter'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'ds/doc-clone-filter'

Doc update.

* ds/doc-clone-filter:
  clone: document --filter options

4 years agoMerge branch 'ar/test-style-fixes'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'ar/test-style-fixes'

Style fixes.

* ar/test-style-fixes:
  t: fix whitespace around &&
  t9500: remove spaces after redirect operators

4 years agoreceive-pack: compilation fix
Junio C Hamano [Wed, 22 Apr 2020 15:55:11 +0000 (08:55 -0700)] 
receive-pack: compilation fix

We do not use C99 "for loop initial declaration" in our codebase
(yet), but one snuck in.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoSync with 2.26.2
Junio C Hamano [Mon, 20 Apr 2020 05:05:56 +0000 (22:05 -0700)] 
Sync with 2.26.2

4 years agoGit 2.26.2 v2.26.2
Jonathan Nieder [Sun, 19 Apr 2020 23:32:24 +0000 (16:32 -0700)] 
Git 2.26.2

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.25.4 v2.25.4
Jonathan Nieder [Sun, 19 Apr 2020 23:31:07 +0000 (16:31 -0700)] 
Git 2.25.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.24.3 v2.24.3
Jonathan Nieder [Sun, 19 Apr 2020 23:30:34 +0000 (16:30 -0700)] 
Git 2.24.3

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.23.3 v2.23.3
Jonathan Nieder [Sun, 19 Apr 2020 23:30:27 +0000 (16:30 -0700)] 
Git 2.23.3

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.22.4 v2.22.4
Jonathan Nieder [Sun, 19 Apr 2020 23:30:19 +0000 (16:30 -0700)] 
Git 2.22.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.21.3 v2.21.3
Jonathan Nieder [Sun, 19 Apr 2020 23:30:08 +0000 (16:30 -0700)] 
Git 2.21.3

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.20.4 v2.20.4
Jonathan Nieder [Sun, 19 Apr 2020 23:28:57 +0000 (16:28 -0700)] 
Git 2.20.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.19.5 v2.19.5
Jonathan Nieder [Sun, 19 Apr 2020 23:26:41 +0000 (16:26 -0700)] 
Git 2.19.5

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.18.4 v2.18.4
Jonathan Nieder [Sun, 19 Apr 2020 23:24:14 +0000 (16:24 -0700)] 
Git 2.18.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.17.5 v2.17.5
Jeff King [Sun, 19 Apr 2020 06:34:55 +0000 (02:34 -0400)] 
Git 2.17.5

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agofsck: reject URL with empty host in .gitmodules
Jonathan Nieder [Sun, 19 Apr 2020 03:57:22 +0000 (20:57 -0700)] 
fsck: reject URL with empty host in .gitmodules

Git's URL parser interprets

https:///example.com/repo.git

to have no host and a path of "example.com/repo.git".  Curl, on the
other hand, internally redirects it to https://example.com/repo.git.  As
a result, until "credential: parse URL without host as empty host, not
unset", tricking a user into fetching from such a URL would cause Git to
send credentials for another host to example.com.

Teach fsck to block and detect .gitmodules files using such a URL to
prevent sharing them with Git versions that are not yet protected.

A relative URL in a .gitmodules file could also be used to trigger this.
The relative URL resolver used for .gitmodules does not normalize
sequences of slashes and can follow ".." components out of the path part
and to the host part of a URL, meaning that such a relative URL can be
used to traverse from a https://foo.example.com/innocent superproject to
a https:///attacker.example.com/exploit submodule. Fortunately,
redundant extra slashes in .gitmodules are rare, so we can catch this by
detecting one after a leading sequence of "./" and "../" components.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
4 years agocredential: treat URL with empty scheme as invalid
Jonathan Nieder [Sun, 19 Apr 2020 03:54:57 +0000 (20:54 -0700)] 
credential: treat URL with empty scheme as invalid

Until "credential: refuse to operate when missing host or protocol",
Git's credential handling code interpreted URLs with empty scheme to
mean "give me credentials matching this host for any protocol".

Luckily libcurl does not recognize such URLs (it tries to look for a
protocol named "" and fails). Just in case that changes, let's reject
them within Git as well. This way, credential_from_url is guaranteed to
always produce a "struct credential" with protocol and host set.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agocredential: treat URL without scheme as invalid
Jonathan Nieder [Sun, 19 Apr 2020 03:54:13 +0000 (20:54 -0700)] 
credential: treat URL without scheme as invalid

libcurl permits making requests without a URL scheme specified.  In
this case, it guesses the URL from the hostname, so I can run

git ls-remote http::ftp.example.com/path/to/repo

and it would make an FTP request.

Any user intentionally using such a URL is likely to have made a typo.
Unfortunately, credential_from_url is not able to determine the host and
protocol in order to determine appropriate credentials to send, and
until "credential: refuse to operate when missing host or protocol",
this resulted in another host's credentials being leaked to the named
host.

Teach credential_from_url_gently to consider such a URL to be invalid
so that fsck can detect and block gitmodules files with such URLs,
allowing server operators to avoid serving them to downstream users
running older versions of Git.

This also means that when such URLs are passed on the command line, Git
will print a clearer error so affected users can switch to the simpler
URL that explicitly specifies the host and protocol they intend.

One subtlety: .gitmodules files can contain relative URLs, representing
a URL relative to the URL they were cloned from.  The relative URL
resolver used for .gitmodules can follow ".." components out of the path
part and past the host part of a URL, meaning that such a relative URL
can be used to traverse from a https://foo.example.com/innocent
superproject to a https::attacker.example.com/exploit submodule.
Fortunately a leading ':' in the first path component after a series of
leading './' and '../' components is unlikely to show up in other
contexts, so we can catch this by detecting that pattern.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
4 years agocredential: die() when parsing invalid urls
Jeff King [Sun, 19 Apr 2020 03:53:09 +0000 (20:53 -0700)] 
credential: die() when parsing invalid urls

When we try to initialize credential loading by URL and find that the
URL is invalid, we set all fields to NULL in order to avoid acting on
malicious input. Later when we request credentials, we diagonse the
erroneous input:

fatal: refusing to work with credential missing host field

This is problematic in two ways:

- The message doesn't tell the user *why* we are missing the host
  field, so they can't tell from this message alone how to recover.
  There can be intervening messages after the original warning of
  bad input, so the user may not have the context to put two and two
  together.

- The error only occurs when we actually need to get a credential.  If
  the URL permits anonymous access, the only encouragement the user gets
  to correct their bogus URL is a quiet warning.

  This is inconsistent with the check we perform in fsck, where any use
  of such a URL as a submodule is an error.

When we see such a bogus URL, let's not try to be nice and continue
without helpers. Instead, die() immediately. This is simpler and
obviously safe. And there's very little chance of disrupting a normal
workflow.

It's _possible_ that somebody has a legitimate URL with a raw newline in
it. It already wouldn't work with credential helpers, so this patch
steps that up from an inconvenience to "we will refuse to work with it
at all". If such a case does exist, we should figure out a way to work
with it (especially if the newline is only in the path component, which
we normally don't even pass to helpers). But until we see a real report,
we're better off being defensive.

Reported-by: Carlo Arenas <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agofsck: convert gitmodules url to URL passed to curl
Jonathan Nieder [Sun, 19 Apr 2020 03:52:34 +0000 (20:52 -0700)] 
fsck: convert gitmodules url to URL passed to curl

In 07259e74ec1 (fsck: detect gitmodules URLs with embedded newlines,
2020-03-11), git fsck learned to check whether URLs in .gitmodules could
be understood by the credential machinery when they are handled by
git-remote-curl.

However, the check is overbroad: it checks all URLs instead of only
URLs that would be passed to git-remote-curl. In principle a git:// or
file:/// URL does not need to follow the same conventions as an http://
URL; in particular, git:// and file:// protocols are not succeptible to
issues in the credential API because they do not support attaching
credentials.

In the HTTP case, the URL in .gitmodules does not always match the URL
that would be passed to git-remote-curl and the credential machinery:
Git's URL syntax allows specifying a remote helper followed by a "::"
delimiter and a URL to be passed to it, so that

git ls-remote http::https://example.com/repo.git

invokes git-remote-http with https://example.com/repo.git as its URL
argument. With today's checks, that distinction does not make a
difference, but for a check we are about to introduce (for empty URL
schemes) it will matter.

.gitmodules files also support relative URLs. To ensure coverage for the
https based embedded-newline attack, urldecode and check them directly
for embedded newlines.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
4 years agocredential: refuse to operate when missing host or protocol
Jeff King [Sun, 19 Apr 2020 03:50:48 +0000 (20:50 -0700)] 
credential: refuse to operate when missing host or protocol

The credential helper protocol was designed to be very flexible: the
fields it takes as input are treated as a pattern, and any missing
fields are taken as wildcards. This allows unusual things like:

  echo protocol=https | git credential reject

to delete all stored https credentials (assuming the helpers themselves
treat the input that way). But when helpers are invoked automatically by
Git, this flexibility works against us. If for whatever reason we don't
have a "host" field, then we'd match _any_ host. When you're filling a
credential to send to a remote server, this is almost certainly not what
you want.

Prevent this at the layer that writes to the credential helper. Add a
check to the credential API that the host and protocol are always passed
in, and add an assertion to the credential_write function that speaks
credential helper protocol to be doubly sure.

There are a few ways this can be triggered in practice:

  - the "git credential" command passes along arbitrary credential
    parameters it reads from stdin.

  - until the previous patch, when the host field of a URL is empty, we
    would leave it unset (rather than setting it to the empty string)

  - a URL like "example.com/foo.git" is treated by curl as if "http://"
    was present, but our parser sees it as a non-URL and leaves all
    fields unset

  - the recent fix for URLs with embedded newlines blanks the URL but
    otherwise continues. Rather than having the desired effect of
    looking up no credential at all, many helpers will return _any_
    credential

Our earlier test for an embedded newline didn't catch this because it
only checked that the credential was cleared, but didn't configure an
actual helper. Configuring the "verbatim" helper in the test would show
that it is invoked (it's obviously a silly helper which doesn't look at
its input, but the point is that it shouldn't be run at all). Since
we're switching this case to die(), we don't need to bother with a
helper. We can see the new behavior just by checking that the operation
fails.

We'll add new tests covering partial input as well (these can be
triggered through various means with url-parsing, but it's simpler to
just check them directly, as we know we are covered even if the url
parser changes behavior in the future).

[jn: changed to die() instead of logging and showing a manual
 username/password prompt]

Reported-by: Carlo Arenas <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agocredential: parse URL without host as empty host, not unset
Jeff King [Sun, 19 Apr 2020 03:48:05 +0000 (20:48 -0700)] 
credential: parse URL without host as empty host, not unset

We may feed a URL like "cert:///path/to/cert.pem" into the credential
machinery to get the key for a client-side certificate. That
credential has no hostname field, which is about to be disallowed (to
avoid confusion with protocols where a helper _would_ expect a
hostname).

This means as of the next patch, credential helpers won't work for
unlocking certs. Let's fix that by doing two things:

  - when we parse a url with an empty host, set the host field to the
    empty string (asking only to match stored entries with an empty
    host) rather than NULL (asking to match _any_ host).

  - when we build a cert:// credential by hand, similarly assign an
    empty string

It's the latter that is more likely to impact real users in practice,
since it's what's used for http connections. But we don't have good
infrastructure to test it.

The url-parsing version will help anybody using git-credential in a
script, and is easy to test.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agot0300: use more realistic inputs
Jeff King [Sun, 19 Apr 2020 03:47:30 +0000 (20:47 -0700)] 
t0300: use more realistic inputs

Many of the tests in t0300 give partial inputs to git-credential,
omitting a protocol or hostname. We're checking only high-level things
like whether and how helpers are invoked at all, and we don't care about
specific hosts. However, in preparation for tightening up the rules
about when we're willing to run a helper, let's start using input that's
a bit more realistic: pretend as if http://example.com is being
examined.

This shouldn't change the point of any of the tests, but do note we have
to adjust the expected output to accommodate this (filling a credential
will repeat back the protocol/host fields to stdout, and the helper
debug messages and askpass prompt will change on stderr).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agot0300: make "quit" helper more realistic
Jeff King [Sun, 19 Apr 2020 05:36:02 +0000 (01:36 -0400)] 
t0300: make "quit" helper more realistic

We test a toy credential helper that writes "quit=1" and confirms that
we stop running other helpers. However, that helper is unrealistic in
that it does not bother to read its stdin at all.

For now we don't send any input to it, because we feed git-credential a
blank credential. But that will change in the next patch, which will
cause this test to racily fail, as git-credential will get SIGPIPE
writing to the helper rather than exiting because it was asked to.

Let's make this one-off helper more like our other sample helpers, and
have it source the "dump" script. That will read stdin, fixing the
SIGPIPE problem. But it will also write what it sees to stderr. We can
make the test more robust by checking that output, which confirms that
we do run the quit helper, don't run any other helpers, and exit for the
reason we expected.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agocredential: treat "?" and "#" in URLs as end of host
Jeff King [Tue, 14 Apr 2020 21:43:04 +0000 (17:43 -0400)] 
credential: treat "?" and "#" in URLs as end of host

It's unusual to see:

  https://example.com?query-parameters

without an intervening slash, like:

  https://example.com/some-path?query-parameters

or even:

  https://example.com/?query-parameters

but it is a valid end to the hostname (actually "authority component")
according to RFC 3986. Likewise for "#".

And curl will parse the URL according to the standard, meaning it will
contact example.com, but our credential code would ask about a bogus
hostname with a "?" in it. Let's make sure we follow the standard, and
more importantly ask about the same hosts that curl will be talking to.

It would be nice if we could just ask curl to parse the URL for us. But
it didn't grow a URL-parsing API until 7.62, so we'd be stuck with
fallback code either way. Plus we'd need this code in the main Git
binary, where we've tried to avoid having a link dependency on libcurl.

But let's at least fix our parser. Moving to curl's parser would prevent
other potential discrepancies, but this gives us immediate relief for
the known problem, and would help our fallback code if we eventually use
curl.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofreshen_file(): use NULL `times' for implicit current-time
luciano.rocha@booking.com [Tue, 14 Apr 2020 14:27:26 +0000 (16:27 +0200)] 
freshen_file(): use NULL `times' for implicit current-time

Update freshen_file() to use a NULL `times', semantically equivalent to
the currently setup, with an explicit `actime' and `modtime' set to the
"current time", but with the advantage that it works with other files
not owned by the current user.

Fixes an issue on shared repos with a split index, where eventually a
user's operation creates a shared index, and another user will later do
an operation that will try to update its freshness, but will instead
raise a warning:
  $ git status
  warning: could not freshen shared index '.git/sharedindex.bd736fa10e0519593fefdb2aec253534470865b2'

Signed-off-by: Luciano Miguel Ferreira Rocha <luciano.rocha@booking.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoSync with v2.26.1
Junio C Hamano [Tue, 14 Apr 2020 01:40:10 +0000 (18:40 -0700)] 
Sync with v2.26.1

4 years agot: restrict `is_hidden` to be called only on Windows
Johannes Schindelin [Sat, 11 Apr 2020 13:40:22 +0000 (13:40 +0000)] 
t: restrict `is_hidden` to be called only on Windows

The function won't work anywhere else, so let's mark it as an explicit
bug if it is called on a non-Windows platform.

Let's also rename the function to avoid cluttering the global namespace
with an overly-generic function name.

While at it, we also fix the code comment above that function: the
lower-case `windows` refers to something different than `Windows`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: make test_path_is_hidden more robust
Johannes Schindelin [Sat, 11 Apr 2020 13:40:21 +0000 (13:40 +0000)] 
mingw: make test_path_is_hidden more robust

This function uses Windows' system tool `attrib` to determine the state
of the hidden flag of a file or directory.

We should not actually expect the first `attrib.exe` in the PATH to
be the one we are looking for. Or that it is in the PATH, for that
matter.

Let's use the full path to the tool instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot: consolidate the `is_hidden` functions
Johannes Schindelin [Sat, 11 Apr 2020 13:40:20 +0000 (13:40 +0000)] 
t: consolidate the `is_hidden` functions

The `is_hidden` function can be used (only on Windows) to determine
whether a directory or file have their `hidden` flag set.

This function is duplicated between two test scripts. It is better to
move it into `test-lib-functions.sh` so that it is reused.

This patch is best viewed with `--color-moved`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomerge: use skip_prefix to parse config key
Martin Ågren [Sat, 11 Apr 2020 07:11:45 +0000 (09:11 +0200)] 
merge: use skip_prefix to parse config key

Instead of using `starts_with()`, the magic number 7, `strlen()` and a
fair number of additions to verify the three parts of the config key
"branch.<branch>.mergeoptions", use `skip_prefix()` to jump through them
more explicitly.

We need to introduce a new variable for this (we certainly can't modify
`k` just because we see "branch."!). With `skip_prefix()` we often use
quite bland names like `p` or `str`. Let's do the same. If and when this
function needs to do more prefix-skipping, we'll have a generic variable
ready for this.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorebase --merge: optionally skip upstreamed commits
Jonathan Tan [Sat, 11 Apr 2020 02:44:27 +0000 (02:44 +0000)] 
rebase --merge: optionally skip upstreamed commits

When rebasing against an upstream that has had many commits since the
original branch was created:

 O -- O -- ... -- O -- O (upstream)
  \
   -- O (my-dev-branch)

it must read the contents of every novel upstream commit, in addition to
the tip of the upstream and the merge base, because "git rebase"
attempts to exclude commits that are duplicates of upstream ones. This
can be a significant performance hit, especially in a partial clone,
wherein a read of an object may end up being a fetch.

Add a flag to "git rebase" to allow suppression of this feature. This
flag only works when using the "merge" backend.

This flag changes the behavior of sequencer_make_script(), called from
do_interactive_rebase() <- run_rebase_interactive() <-
run_specific_rebase() <- cmd_rebase(). With this flag, limit_list()
(indirectly called from sequencer_make_script() through
prepare_revision_walk()) will no longer call cherry_pick_list(), and
thus PATCHSAME is no longer set. Refraining from setting PATCHSAME both
means that the intermediate commits in upstream are no longer read (as
shown by the test) and means that no PATCHSAME-caused skipping of
commits is done by sequencer_make_script(), either directly or through
make_script_with_merges().

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorebase: fix an incompatible-options error message
Elijah Newren [Sat, 11 Apr 2020 02:44:26 +0000 (02:44 +0000)] 
rebase: fix an incompatible-options error message

When the user specifies the apply backend with options that only work
with the merge backend, such as

    git rebase --apply --exec /bin/true HEAD~3

the error message has always been

    fatal: --exec requires an interactive rebase

This error message is misleading and was one of the reasons we renamed
the interactive backend to the merge backend.  Update the error message
to state that these options merely require use of the merge backend.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorebase: reinstate --no-keep-empty
Elijah Newren [Sat, 11 Apr 2020 02:44:25 +0000 (02:44 +0000)] 
rebase: reinstate --no-keep-empty

Commit d48e5e21da ("rebase (interactive-backend): make --keep-empty the
default", 2020-02-15) turned --keep-empty (for keeping commits which
start empty) into the default.  The logic underpinning that commit was:

  1) 'git commit' errors out on the creation of empty commits without an
     override flag
  2) Once someone determines that the override is worthwhile, it's
     annoying and/or harmful to required them to take extra steps in
     order to keep such commits around (and to repeat such steps with
     every rebase).

While the logic on which the decision was made is sound, the result was
a bit of an overcorrection.  Instead of jumping to having --keep-empty
being the default, it jumped to making --keep-empty the only available
behavior.  There was a simple workaround, though, which was thought to
be good enough at the time.  People could still drop commits which
started empty the same way the could drop any commits: by firing up an
interactive rebase and picking out the commits they didn't want from the
list.  However, there are cases where external tools might create enough
empty commits that picking all of them out is painful.  As such, having
a flag to automatically remove start-empty commits may be beneficial.

Provide users a way to drop commits which start empty using a flag that
existed for years: --no-keep-empty.  Interpret --keep-empty as
countermanding any previous --no-keep-empty, but otherwise leaving
--keep-empty as the default.

This might lead to some slight weirdness since commands like
  git rebase --empty=drop --keep-empty
  git rebase --empty=keep --no-keep-empty
look really weird despite making perfect sense (the first will drop
commits which become empty, but keep commits that started empty; the
second will keep commits which become empty, but drop commits which
started empty).  However, --no-keep-empty was named years ago and we are
predominantly keeping it for backward compatibility; also we suspect it
will only be used rarely since folks already have a simple way to drop
commits they don't want with an interactive rebase.

Reported-by: Bryan Turner <bturner@atlassian.com>
Reported-by: Sami Boukortt <sami@boukortt.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorebase -i: mark commits that begin empty in todo editor
Elijah Newren [Sat, 11 Apr 2020 02:44:24 +0000 (02:44 +0000)] 
rebase -i: mark commits that begin empty in todo editor

While many users who intentionally create empty commits do not want them
thrown away by a rebase, there are third-party tools that generate empty
commits that a user might not want.  In the past, users have used rebase
to get rid of such commits (a side-effect of the fact that the --apply
backend is not currently capable of keeping them).  While such users
could fire up an interactive rebase and just remove the lines
corresponding to empty commits, that might be difficult if the
third-party tool generates many of them.  Simplify this task for users
by marking such lines with a suffix of " # empty" in the todo list.

Suggested-by: Sami Boukortt <sami@boukortt.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconfig: reject parsing of files over INT_MAX
Jeff King [Fri, 10 Apr 2020 19:50:07 +0000 (15:50 -0400)] 
config: reject parsing of files over INT_MAX

While the last few commits have made it possible for the config parser
to handle config files up to the limits of size_t, the rest of the code
isn't really ready for this. In particular, we often feed the keys as
strings into printf "%s" format specifiers. And because the printf
family of functions must return an int to specify the result, they
complain. Here are two concrete examples (using glibc; we're in
uncharted territory here so results may vary):

Generate a gigantic .gitmodules file like this:

   git submodule add /some/other/repo foo
   {
           printf '[submodule "'
           perl -e 'print "a" x 2**31'
   echo '"]path = foo'
   } >.gitmodules
   git commit -m 'huge gitmodule'

then try this:

   $ git show
   BUG: strbuf.c:397: your vsnprintf is broken (returned -1)

The problem is that we end up calling:

   strbuf_addf(&sb, "submodule.%s.ignore", submodule_name);

which relies on vsnprintf(), and that function has no way to report back
a size larger than INT_MAX.

Taking that same file, try this:

  git config --file=.gitmodules --list --name-only

On my system it produces an output with exactly 4GB of spaces. I
confirmed in a debugger that we reach the config callback with the key
intact: it's 2147483663 bytes and full of a's. But when we print it with
this call:

  printf("%s%c", key_, term);

we just get the spaces.

So given the fact that these are insane cases which we have no need to
support, the weird behavior from feeding the results to printf even if
the code is careful, and the possibility of uncareful code introducing
its own integer truncation issues, let's just declare INT_MAX as a limit
for parsing config files.

We'll enforce the limit in get_next_char(), which generalizes over all
sources (blobs, files, etc) and covers any element we're parsing
(whether section, key, value, etc). For simplicity, the limit is over
the length of the _whole_ file, so you couldn't have two 1GB values in
the same file. This should be perfectly fine, as the expected size for
config files is generally kilobytes at most.

With this patch both cases above will yield:

  fatal: bad config line 1 in file .gitmodules

That's not an amazing error message, but the parser isn't set up to
provide specific messages (it just breaks out of the parsing loop and
gives that generic error even if see a syntactic issue). And we really
wouldn't expect to see this case outside of somebody maliciously probing
the limits of the config system.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconfig: use size_t to store parsed variable baselen
Jeff King [Fri, 10 Apr 2020 19:47:51 +0000 (15:47 -0400)] 
config: use size_t to store parsed variable baselen

Most of the config parsing infrastructure is limited in what it can
parse only by the size of memory, because it parses character by
character, building up strbufs for keys, values, etc. One exception is
the "baselen" value we keep in git_parse_source(), which is an int.

That stores the length of the section.subsection base, to which we can
then append individual key names (by truncating back to the baselen with
strbuf_setlen(), and then appending characters for the key name). But
because it's an int, if we see an absurdly long section or subsection,
we may overflow the integer, wrapping negative. That negative value is
then implicitly cast to a size_t when we pass it to strbuf_setlen(),
creating a very large value and triggering a BUG. For example:

  $ {
       printf '[foo "'
       perl -e 'print "a" x 2**31'
       echo '"]bar = value'
    } >huge
  $ git config --file=huge --list
  fatal: BUG: strbuf_setlen() beyond buffer

While this is obviously a silly case that we don't care about
supporting, it's worth fixing it by switching to a size_t for a few
reasons:

  - we should try to avoid hitting BUG assertions at all

  - avoiding integer truncation or overflow sets a good example and
    makes it easier to audit the code for more important issues

  - the BUG outcome is what happens in _this_ instance, because we wrap
    negative. If we used a 2**32 subsection, we'd wrap to a small
    positive value and actually generate wrong output (the subsection of
    our key would be truncated).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agogit_config_parse_key(): return baselen as size_t
Jeff King [Fri, 10 Apr 2020 19:46:07 +0000 (15:46 -0400)] 
git_config_parse_key(): return baselen as size_t

As with the recent change to parse_config_key(), the best type to return
a string length is a size_t, as it won't cause integer truncation for a
gigantic key. And as with that change, this is mostly a clarity /
hygiene issue for now, as our config parser would choke on such a large
key anyway.

There are a few ripple effects within the config code, as callers switch
to using size_t. I also adjusted a few related variables that iterate
over strings. The most unexpected change is that a call to strbuf_addf()
had to switch to strbuf_add(). We can't use a size_t with "%.*s",
because printf precisions must have type "int" (we could cast, of
course, but that would miss the point of using size_t in the first
place).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconfig: drop useless length variable in write_pair()
Jeff King [Fri, 10 Apr 2020 19:44:45 +0000 (15:44 -0400)] 
config: drop useless length variable in write_pair()

We compute the length of a subset of a string, but then use that length
only to feed a "%.*s" printf placeholder for the same string. We can
just use "%s" to achieve the same thing.

The variable became useless in cb891a5989 (Use a strbuf for building up
section header and key/value pair strings., 2007-12-14), which swapped
out a write() which _did_ use the length for a strbuf_addf() call.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoparse_config_key(): return subsection len as size_t
Jeff King [Fri, 10 Apr 2020 19:44:28 +0000 (15:44 -0400)] 
parse_config_key(): return subsection len as size_t

We return the length to a subset of a string using an "int *"
out-parameter. This is fine most of the time, as we'd expect config keys
to be relatively short, but it could behave oddly if we had a gigantic
config key. A more appropriate type is size_t.

Let's switch over, which lets our callers use size_t as appropriate
(they are bound by our type because they must pass the out-parameter as
a pointer). This is mostly just a cleanup to make it clear this code
handles long strings correctly. In practice, our config parser already
chokes on long key names (because of a similar int/size_t mixup!).

When doing an int/size_t conversion, we have to be careful that nobody
was trying to assign a negative value to the variable. I manually
confirmed that for each case here. They tend to just feed the result to
xmemdupz() or similar; in a few cases I adjusted the parameter types for
helper functions to make sure the size_t is preserved.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoremote: drop auto-strlen behavior of make_branch() and make_rewrite()
Jeff King [Fri, 10 Apr 2020 19:43:41 +0000 (15:43 -0400)] 
remote: drop auto-strlen behavior of make_branch() and make_rewrite()

The make_branch() and make_rewrite() functions can take a NUL-terminated
string or a ptr/len pair. They use a sentinel value of "0" for the len
to tell the difference between the two. However, when parsing config
like:

  [branch ""]
  merge = whatever

whose key flattens to:

  branch..merge

we might actually have a zero-length branch name. This is obviously
nonsense, but the current code would consider it as a NUL-terminated
string and use the branch name ".merge".

We could use a better sentinel value here (like "-1"), but that gets in
the way of moving to size_t, which is a more appropriate type for a
ptr/len combo.

Let's instead just drop this feature and have the callers (of which
there are only two total) use strlen() themselves. This simplifies the
code, and lets us move to using size_t.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: cope with the Isilon network file system
Nathan Sanders [Fri, 10 Apr 2020 11:28:56 +0000 (11:28 +0000)] 
mingw: cope with the Isilon network file system

On certain network filesystems (currently encountered with Isilon, but
in theory more network storage solutions could be causing the same
issue), when the directory in question is missing,
`raceproof_create_file()` fails with an `ERROR_INVALID_PARAMETER`
instead of an `ERROR_PATH_NOT_FOUND`.

Since it is highly unlikely that we produce such an error by mistake
(the parameters we pass are fairly benign), we can be relatively certain
that the directory is missing in this instance. So let's just translate
that error automagically.

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

Signed-off-by: Nathan Sanders <spekbukkem@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agointeractive: explicitly `fflush` stdout before expecting input
마누엘 [Fri, 10 Apr 2020 11:27:51 +0000 (11:27 +0000)] 
interactive: explicitly `fflush` stdout before expecting input

At least one interactive command writes a prompt to `stdout` and then
reads user input on `stdin`: `git clean --interactive`. If the prompt is
left in the buffer, the user will not realize the program is waiting for
their input.

So let's just flush `stdout` before reading the user's input.

Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agointeractive: refactor code asking the user for interactive input
Johannes Schindelin [Fri, 10 Apr 2020 11:27:50 +0000 (11:27 +0000)] 
interactive: refactor code asking the user for interactive input

There are quite a few code locations (e.g. `git clean --interactive`)
where Git asks the user for an answer. In preparation for fixing a bug
shared by all of them, and also to DRY up the code, let's refactor it.

Please note that most of these callers trimmed white-space both at the
beginning and at the end of the answer, instead of trimming only the
end (as the caller in `add-patch.c` does).

Therefore, technically speaking, we change behavior in this patch. At
the same time, it can be argued that this is actually a bug fix.

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