]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
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 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 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: 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 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>
4 years agomingw: help debugging by optionally executing bash with strace
Johannes Schindelin [Thu, 9 Apr 2020 10:21:47 +0000 (10:21 +0000)] 
mingw: help debugging by optionally executing bash with strace

MSYS2's strace facility is very useful for debugging... With this patch,
the bash will be executed through strace if the environment variable
GIT_STRACE_COMMANDS is set, which comes in real handy when investigating
issues in the test suite.

Also support passing a path to a log file via GIT_STRACE_COMMANDS to
force Git to call strace.exe with the `-o <path>` argument, i.e. to log
into a file rather than print the log directly.

That comes in handy when the output would otherwise misinterpreted by a
calling process as part of Git's output.

Note: the values "1", "yes" or "true" are *not* specifying paths, but
tell Git to let strace.exe log directly to the console.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorevision: --show-pulls adds helpful merges
Derrick Stolee [Fri, 10 Apr 2020 12:19:43 +0000 (12:19 +0000)] 
revision: --show-pulls adds helpful merges

The default file history simplification of "git log -- <path>" or
"git rev-list -- <path>" focuses on providing the smallest set of
commits that first contributed a change. The revision walk greatly
restricts the set of walked commits by visiting only the first
TREESAME parent of a merge commit, when one exists. This means
that portions of the commit-graph are not walked, which can be a
performance benefit, but can also "hide" commits that added changes
but were ignored by a merge resolution.

The --full-history option modifies this by walking all commits and
reporting a merge commit as "interesting" if it has _any_ parent
that is not TREESAME. This tends to be an over-representation of
important commits, especially in an environment where most merge
commits are created by pull request completion.

Suppose we have a commit A and we create a commit B on top that
changes our file. When we merge the pull request, we create a merge
commit M. If no one else changed the file in the first-parent
history between M and A, then M will not be TREESAME to its first
parent, but will be TREESAME to B. Thus, the simplified history
will be "B". However, M will appear in the --full-history mode.

However, suppose that a number of topics T1, T2, ..., Tn were
created based on commits C1, C2, ..., Cn between A and M as
follows:

  A----C1----C2--- ... ---Cn----M------P1---P2--- ... ---Pn
   \     \     \            \  /      /    /            /
    \     \__.. \            \/ ..__T1    /           Tn
     \           \__..       /\     ..__T2           /
      \_____________________B  \____________________/

If the commits T1, T2, ... Tn did not change the file, then all of
P1 through Pn will be TREESAME to their first parent, but not
TREESAME to their second. This means that all of those merge commits
appear in the --full-history view, with edges that immediately
collapse into the lower history without introducing interesting
single-parent commits.

The --simplify-merges option was introduced to remove these extra
merge commits. By noticing that the rewritten parents are reachable
from their first parents, those edges can be simplified away. Finally,
the commits now look like single-parent commits that are TREESAME to
their "only" parent. Thus, they are removed and this issue does not
cause issues anymore. However, this also ends up removing the commit
M from the history view! Even worse, the --simplify-merges option
requires walking the entire history before returning a single result.

Many Git users are using Git alongside a Git service that provides
code storage alongside a code review tool commonly called "Pull
Requests" or "Merge Requests" against a target branch.  When these
requests are accepted and merged, they typically create a merge
commit whose first parent is the previous branch tip and the second
parent is the tip of the topic branch used for the request. This
presents a valuable order to the parents, but also makes that merge
commit slightly special. Users may want to see not only which
commits changed a file, but which pull requests merged those commits
into their branch. In the previous example, this would mean the
users want to see the merge commit "M" in addition to the single-
parent commit "C".

Users are even more likely to want these merge commits when they
use pull requests to merge into a feature branch before merging that
feature branch into their trunk.

In some sense, users are asking for the "first" merge commit to
bring in the change to their branch. As long as the parent order is
consistent, this can be handled with the following rule:

  Include a merge commit if it is not TREESAME to its first
  parent, but is TREESAME to a later parent.

These merges look like the merge commits that would result from
running "git pull <topic>" on a main branch. Thus, the option to
show these commits is called "--show-pulls". This has the added
benefit of showing the commits created by closing a pull request or
merge request on any of the Git hosting and code review platforms.

To test these options, extend the standard test example to include
a merge commit that is not TREESAME to its first parent. It is
surprising that that option was not already in the example, as it
is instructive.

In particular, this extension demonstrates a common issue with file
history simplification. When a user resolves a merge conflict using
"-Xours" or otherwise ignoring one side of the conflict, they create
a TREESAME edge that probably should not be TREESAME. This leads
users to become frustrated and complain that "my change disappeared!"
In my experience, showing them history with --full-history and
--simplify-merges quickly reveals the problematic merge. As mentioned,
this option is expensive to compute. The --show-pulls option
_might_ show the merge commit (usually titled "resolving conflicts")
more quickly. Of course, this depends on the user having the correct
parent order, which is backwards when using "git pull master" from a
topic branch.

There are some special considerations when combining the --show-pulls
option with --simplify-merges. This requires adding a new PULL_MERGE
object flag to store the information from the initial TREESAME
comparisons. This helps avoid dropping those commits in later filters.
This is covered by a test, including how the parents can be simplified.
Since "struct object" has already ruined its 32-bit alignment by using
33 bits across parsed, type, and flags member, let's not make it worse.
PULL_MERGE is used in revision.c with the same value (1u<<15) as
REACHABLE in commit-graph.c. The REACHABLE flag is only used when
writing a commit-graph file, and a revision walk using --show-pulls
does not happen in the same process. Care must be taken in the future
to ensure this remains the case.

Update Documentation/rev-list-options.txt with significant details
around this option. This requires updating the example in the
History Simplification section to demonstrate some of the problems
with TREESAME second parents.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorepository: mark the "refs" pointer as private
Jeff King [Fri, 10 Apr 2020 03:04:11 +0000 (23:04 -0400)] 
repository: mark the "refs" pointer as private

The "refs" pointer in a struct repository starts life as NULL, but then
is lazily initialized when it is accessed via get_main_ref_store().
However, it's easy for calling code to forget this and access it
directly, leading to code which works _some_ of the time, but fails if
it is called before anybody else accesses the refs.

This was the cause of the bug fixed by 5ff4b920eb (sha1-name: do not
assume that the ref store is initialized, 2020-04-09). In order to
prevent similar bugs, let's more clearly mark the "refs" field as
private.

In addition to helping future code, the name change will help us audit
any existing direct uses. Besides get_main_ref_store() itself, it turns
out there is only one. But we know it's OK as it is on the line directly
after the fix from 5ff4b920eb, which will have initialized the pointer.
However it's still a good idea for it to model the proper use of the
accessing function, so we'll convert it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosha1-name: do not assume that the ref store is initialized
Junio C Hamano [Fri, 10 Apr 2020 00:03:45 +0000 (17:03 -0700)] 
sha1-name: do not assume that the ref store is initialized

c931ba4e (sha1-name.c: remove the_repo from handle_one_ref(),
2019-04-16) replaced the use of for_each_ref() helper, which works
with the main ref store of the default repository instance, with
refs_for_each_ref(), which can work on any ref store instance, by
assuming that the repository instance the function is given has its
ref store already initialized.

But it is possible that nobody has initialized it, in which case,
the code ends up dereferencing a NULL pointer.

Reported-by: Érico Rolim <erico.erc@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconfig.txt: move closing "----" to cover entire listing
Martin Ågren [Thu, 9 Apr 2020 10:35:41 +0000 (12:35 +0200)] 
config.txt: move closing "----" to cover entire listing

Commit 1925fe0c8a ("Documentation: wrap config listings in "----"",
2019-09-07) wrapped this fairly large block of example config directives
in "----". The closing "----" ended up a few lines too early though.
Make sure to include the trailing "IncludeIf.onbranch:..." example, too.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: do not treat `COM0` as a reserved file name
Johannes Schindelin [Wed, 8 Apr 2020 18:06:49 +0000 (18:06 +0000)] 
mingw: do not treat `COM0` as a reserved file name

In 4dc42c6c186 (mingw: refuse paths containing reserved names,
2019-12-21), we started disallowing file names that are reserved, e.g.
`NUL`, `CONOUT$`, etc.

This included `COM<n>` where `<n>` is a digit. Unfortunately, this
includes `COM0` but only `COM1`, ..., `COM9` are reserved, according to
the official documentation, `COM0` is mentioned in the "NT Namespaces"
section but it is explicitly _omitted_ from the list of reserved names:
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions

Tests corroborate this: it is totally possible to write a file called
`com0.c` on Windows 10, but not `com1.c`.

So let's tighten the code to disallow only the reserved `COM<n>` file
names, but to allow `COM0` again.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomingw: use modern strftime implementation if possible
Matthias Aßhauer [Wed, 8 Apr 2020 17:58:49 +0000 (17:58 +0000)] 
mingw: use modern strftime implementation if possible

Microsoft introduced a new "Universal C Runtime Library" (UCRT) with
Visual Studio 2015. The UCRT comes with a new strftime() implementation
that supports more date formats. We link git against the older
"Microsoft Visual C Runtime Library" (MSVCRT), so to use the UCRT
strftime() we need to load it from ucrtbase.dll using
DECLARE_PROC_ADDR()/INIT_PROC_ADDR().

Most supported Windows systems should have recieved the UCRT via Windows
update, but in some cases only MSVCRT might be available. In that case
we fall back to using that implementation.

With this change, it is possible to use e.g. the `%g` and `%V` date
format specifiers, e.g.

git show -s --format=%cd --date=format:‘%g.%V’ HEAD

Without this change, the user would see this error message on Windows:

fatal: invalid strftime format: '‘%g.%V’'

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

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoformat-patch: teach --no-encode-email-headers
Emma Brooks [Wed, 8 Apr 2020 04:31:38 +0000 (04:31 +0000)] 
format-patch: teach --no-encode-email-headers

When commit subjects or authors have non-ASCII characters, git
format-patch Q-encodes them so they can be safely sent over email.
However, if the patch transfer method is something other than email (web
review tools, sneakernet), this only serves to make the patch metadata
harder to read without first applying it (unless you can decode RFC 2047
in your head). git am as well as some email software supports
non-Q-encoded mail as described in RFC 6531.

Add --[no-]encode-email-headers and format.encodeEmailHeaders to let the
user control this behavior.

Signed-off-by: Emma Brooks <me@pluvano.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosequencer: honor GIT_REFLOG_ACTION
Elijah Newren [Tue, 7 Apr 2020 16:59:23 +0000 (16:59 +0000)] 
sequencer: honor GIT_REFLOG_ACTION

There is a lot of code to honor GIT_REFLOG_ACTION throughout git,
including some in sequencer.c; unfortunately, reflog_message() and its
callers ignored it.  Instruct reflog_message() to check the existing
environment variable, and use it when present as an override to
action_name().

Also restructure pick_commits() to only temporarily modify
GIT_REFLOG_ACTION for a short duration and then restore the old value,
so that when we do this setting within a loop we do not keep adding "
(pick)" substrings and end up with a reflog message of the form
    rebase (pick) (pick) (pick) (finish): returning to refs/heads/master

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopull doc: correct outdated description of an example
Philippe Blain [Sun, 5 Apr 2020 15:50:19 +0000 (15:50 +0000)] 
pull doc: correct outdated description of an example

Since f269048754 (fetch: opportunistically update tracking refs,
2013-05-11), the underlying `git fetch` in `git pull <remote> <branch>`
updates the configured remote-tracking branch for <branch>.

However, an example in the 'Examples' section of the `git pull`
documentation still states that this is not the case.

Correct the description of this example.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopull doc: refer to a specific section in 'fetch' doc
Philippe Blain [Sun, 5 Apr 2020 15:50:18 +0000 (15:50 +0000)] 
pull doc: refer to a specific section in 'fetch' doc

The documentation for the `<refspec>` parameter in the `git fetch`
documentation refers to the section "CONFIGURED REMOTE-TRACKING
BRANCHES" in this same documentation page.

In the `git pull` documentation, let's also refer specifically to this
section instead of just linking to the `git fetch` documentation.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot0007: fix a typo
Johannes Schindelin [Sat, 4 Apr 2020 14:16:21 +0000 (14:16 +0000)] 
t0007: fix a typo

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation: document merge option --no-gpg-sign
Đoàn Trần Công Danh [Fri, 3 Apr 2020 10:28:07 +0000 (17:28 +0700)] 
Documentation: document merge option --no-gpg-sign

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation: merge commit-tree --[no-]gpg-sign
Đoàn Trần Công Danh [Fri, 3 Apr 2020 10:28:06 +0000 (17:28 +0700)] 
Documentation: merge commit-tree --[no-]gpg-sign

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation: reword commit --no-gpg-sign
Đoàn Trần Công Danh [Fri, 3 Apr 2020 10:28:05 +0000 (17:28 +0700)] 
Documentation: reword commit --no-gpg-sign

Merge with --gpg-sign option, and clarify that --no-gpg-sign also
override earlier --gpg-sign.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation: document am --no-gpg-sign
Đoàn Trần Công Danh [Fri, 3 Apr 2020 10:28:04 +0000 (17:28 +0700)] 
Documentation: document am --no-gpg-sign

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocherry-pick/revert: honour --no-gpg-sign in all case
Đoàn Trần Công Danh [Fri, 3 Apr 2020 10:28:03 +0000 (17:28 +0700)] 
cherry-pick/revert: honour --no-gpg-sign in all case

{cherry-pick,revert} --edit hasn't honoured --no-gpg-sign yet.

Pass this option down to git-commit to honour it.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorebase.c: honour --no-gpg-sign
Đoàn Trần Công Danh [Fri, 3 Apr 2020 10:28:02 +0000 (17:28 +0700)] 
rebase.c: honour --no-gpg-sign

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoclone: use "quick" lookup while following tags
Jeff King [Wed, 1 Apr 2020 12:15:37 +0000 (08:15 -0400)] 
clone: use "quick" lookup while following tags

When cloning with --single-branch, we implement git-fetch's usual
tag-following behavior, grabbing any tag objects that point to objects
we have locally.

When we're a partial clone, though, our has_object_file() check will
actually lazy-fetch each tag. That not only defeats the purpose of
--single-branch, but it does it incredibly slowly, potentially kicking
off a new fetch for each tag. This is even worse for a shallow clone,
which implies --single-branch, because even tags which are supersets of
each other will be fetched individually.

We can fix this by passing OBJECT_INFO_SKIP_FETCH_OBJECT to the call,
which is what git-fetch does in this case.

Likewise, let's include OBJECT_INFO_QUICK, as that's what git-fetch
does. The rationale is discussed in 5827a03545 (fetch: use "quick"
has_sha1_file for tag following, 2016-10-13), but here the tradeoff
would apply even more so because clone is very unlikely to be racing
with another process repacking our newly-created repository.

This may provide a very small speedup even in the non-partial case case,
as we'd avoid calling reprepare_packed_git() for each tag (though in
practice, we'd only have a single packfile, so that reprepare should be
quite cheap).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3432: test `--merge' with `rebase.abbreviateCommands = true', too
Alban Gruin [Mon, 30 Mar 2020 12:42:36 +0000 (14:42 +0200)] 
t3432: test `--merge' with `rebase.abbreviateCommands = true', too

When fast forwarding, `git --merge' should act the same whether
`rebase.abbreviateCommands' is set or not, but so far it was not the
case.  This duplicates the tests ensuring that `--merge' works when fast
forwarding to check if it also works with abbreviated commands.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosequencer: don't abbreviate a command if it doesn't have a short form
Alban Gruin [Mon, 30 Mar 2020 12:42:35 +0000 (14:42 +0200)] 
sequencer: don't abbreviate a command if it doesn't have a short form

When the sequencer is requested to abbreviate commands, it will replace
those that do not have a short form (eg. `noop') by a comment mark.
`noop' serves no purpose, except when fast-forwarding (ie. by running
`git rebase').  Removing it will break this command when
`rebase.abbreviateCommands' is set to true.

Teach todo_list_to_strbuf() to check if a command has an actual
short form, and to ignore it if not.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMyFirstObjectWalk: remove unnecessary conditional statement
Johannes Schindelin [Sat, 28 Mar 2020 15:19:13 +0000 (15:19 +0000)] 
MyFirstObjectWalk: remove unnecessary conditional statement

In the given example, `commit` cannot be `NULL` (because this is the
loop condition: if it was `NULL`, the loop body would not be entered at
all). It took this developer a moment or two to see that this is
therefore dead code.

Let's remove it, to avoid puzzling future readers.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agooidset: stop referring to sha1-array
Jeff King [Mon, 30 Mar 2020 14:04:13 +0000 (10:04 -0400)] 
oidset: stop referring to sha1-array

Ths has been oid_array for some time, though the source only recently
moved from sha1-array.[ch] to oid-array.[ch]. In either case, we should
say "oid-array" here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoref-filter: stop referring to "sha1 array"
Jeff King [Mon, 30 Mar 2020 14:04:11 +0000 (10:04 -0400)] 
ref-filter: stop referring to "sha1 array"

A comment refers to the "sha1s in the given sha1 array". But this became
an oid_array along with everywhere else in 910650d2f8 (Rename sha1_array
to oid_array, 2017-03-31). Plus there's an extra line of leftover
editing cruft we can drop.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agobisect: stop referring to sha1_array
Jeff King [Mon, 30 Mar 2020 14:04:06 +0000 (10:04 -0400)] 
bisect: stop referring to sha1_array

Our join_sha1_array_hex() function long ago switched to using an
oid_array; let's change the name to match.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-tool: rename sha1-array to oid-array
Jeff King [Mon, 30 Mar 2020 14:04:03 +0000 (10:04 -0400)] 
test-tool: rename sha1-array to oid-array

This matches the actual data structure name, as well as the source file
that contains the code we're testing. The test scripts need updating to
use the new name, as well.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agooid_array: rename source file from sha1-array
Jeff King [Mon, 30 Mar 2020 14:03:46 +0000 (10:03 -0400)] 
oid_array: rename source file from sha1-array

We renamed the actual data structure in 910650d2f8 (Rename sha1_array to
oid_array, 2017-03-31), but the file is still called sha1-array. Besides
being slightly confusing, it makes it more annoying to grep for leftover
occurrences of "sha1" in various files, because the header is included
in so many places.

Let's complete the transition by renaming the source and header files
(and fixing up a few comment references).

I kept the "-" in the name, as that seems to be our style; cf.
fc1395f4a4 (sha1_file.c: rename to use dash in file name, 2018-04-10).
We also have oidmap.h and oidset.h without any punctuation, but those
are "struct oidmap" and "struct oidset" in the code. We _could_ make
this "oidarray" to match, but somehow it looks uglier to me because of
the length of "array" (plus it would be a very invasive patch for little
gain).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>