Denton Liu [Tue, 24 Mar 2020 01:07:51 +0000 (21:07 -0400)]
Lib-ify fmt-merge-msg
In builtin.h, there exists the distinctly "lib-ish" function
fmt_merge_msg(). This function can currently only be called by built-in
commands but, unlike most of the other functions in the header, it does
not make sense to impose this restriction as the functionality can be
logically reused in libgit.
Extract this function into fmt-merge-msg.c so that related definitions
can exist clearly in their own header file.
While we're at it, clean up #includes that are unused.
This patch is best viewed with --color-moved.
Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
Denton Liu [Sat, 21 Mar 2020 09:21:21 +0000 (05:21 -0400)]
t7600: use test_write_lines()
In t7600, we were rewriting `printf '%s\n' ...` to create files from
parameters, one per line. However, we already have a function that wraps
this for us: test_write_lines(). Rewrite these instances to use that
function instead of open coding it.
Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
Denton Liu [Sat, 21 Mar 2020 09:21:20 +0000 (05:21 -0400)]
Makefile: ASCII-sort += lists
There are many += lists in the Makefile and, over time, they have gotten
slightly out of ASCII order. Sort all += lists to bring them back in
order.
ASCII sorting was chosen over strict alphabetical order even though, if
we omit file prefixes, the lists aren't sorted in strictly alphabetical
order (e.g. archive.o comes after archive-zip.o instead of before
archive-tar.o). This is intentional because the purpose of maintaining
the sorted list is to ensure line insertions are deterministic. By using
ASCII ordering, it is more easily mechanically reproducible in the
future, such as by using :sort in Vim.
This patch is best viewed with `--color-moved`.
Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
Johannes Schindelin [Tue, 24 Mar 2020 19:35:45 +0000 (19:35 +0000)]
import-tars: ignore the global PAX header
The tar importer in `contrib/fast-import/import-tars.perl` has a very
convenient feature: if _all_ paths stored in the imported `.tar` start
with a common prefix, e.g. `git-2.26.0/` in the tar at
https://github.com/git/git/archive/v2.26.0.tar.gz, then this prefix is
stripped.
This feature makes a ton of sense because it is relatively common to
import two or more revisions of the same project into Git, and obviously
we don't want all files to live in a tree whose name changes from
revision to revision.
Now, the problem with that feature is that it breaks down if there is a
`pax_global_header` "file" located outside of said prefix, at the top of
the tree. This is the case for `.tar` files generated by Git's very own
`git archive` command: it inserts that header, and `git archive` allows
specifying a common prefix (that the header does _not_ share with the
other files contained in the archive) via `--prefix=my-project-1.0.0/`.
Let's just skip any global header when importing `.tar` files into Git.
Note: this global header might contain useful information. For example,
in the output of `git archive`, it lists the original commit, which _is_
useful information. A future improvement to the `import-tars.perl`
script might be to include that information in the commit message, or do
other things with the information (e.g. use `mtime` information
contained in the global header as date of the commit). This patch does
not prevent any future patch from making that happen, it only prevents
the header from being treated as if it was a regular file.
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
Josh Steadmon [Fri, 20 Mar 2020 21:06:15 +0000 (14:06 -0700)]
trace2: teach Git to log environment variables
Via trace2, Git can already log interesting config parameters (see the
trace2_cmd_list_config() function). However, this can grant an
incomplete picture because many config parameters also allow overrides
via environment variables.
To allow for more complete logs, we add a new trace2_cmd_list_env_vars()
function and supporting implementation, modeled after the pre-existing
config param logging implementation.
Signed-off-by: Josh Steadmon <redacted>
Acked-by: Jeff Hostetler <redacted>
Signed-off-by: Junio C Hamano <redacted>
Johannes Schindelin [Mon, 23 Mar 2020 12:44:35 +0000 (12:44 +0000)]
tests(junit-xml): avoid invalid XML
When a test case is run in a subshell, we finalize the JUnit-style XML
when said subshell exits. But then we continue to write into that XML as
if nothing had happened.
This leads to Azure Pipelines' Publish Test Results task complaining:
Failed to read /home/vsts/work/1/s/t/out/TEST-t0000-basic.xml.
Error : Unexpected end tag. Line 110, position 5.
And indeed, the resulting XML is incorrect.
Let's "re-open" the XML in such a case, i.e. remove the previously added
closing tags.
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Sun, 22 Mar 2020 23:50:46 +0000 (16:50 -0700)]
Git 2.26
Signed-off-by: Junio C Hamano <redacted>
Andrei Rybak [Sun, 22 Mar 2020 21:14:22 +0000 (22:14 +0100)]
t: fix whitespace around &&
Add missing spaces before '&&' and switch tabs around '&&' to spaces.
Also fix the space after redirection operator in t3701 while we're here.
These issues were found using `git grep '[^ ]&&$'` and
`git grep -P '&&\t' t/`.
Signed-off-by: Andrei Rybak <redacted>
Signed-off-by: Junio C Hamano <redacted>
Andrei Rybak [Sun, 22 Mar 2020 21:14:21 +0000 (22:14 +0100)]
t9500: remove spaces after redirect operators
For shell scripts, the usual convention is for there to be no space
after redirection operators, (e.g. `>file`, not `> file`). Remove these
spaces wherever they appear.
Signed-off-by: Andrei Rybak <redacted>
Signed-off-by: Junio C Hamano <redacted>
Derrick Stolee [Sun, 22 Mar 2020 19:50:06 +0000 (19:50 +0000)]
clone: document --filter options
It turns out that the "--filter=<filter-spec>" option is not
documented anywhere in the "git clone" page, and instead is
detailed carefully in "git rev-list" where it serves a
different purpose.
Add a small bit about this option in the documentation. It
would be worth some time to create a subsection in the "git clone"
documentation about partial clone as a concept and how it can be
a surprising experience. For example, "git checkout" will likely
trigger a pack download.
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
Jeff King [Sun, 22 Mar 2020 07:51:40 +0000 (03:51 -0400)]
t3419: drop EXPENSIVE tests
When t3419 was originally written, it was designed to run a smaller test
for correctness, and then the same test with a larger number of patches
for performance. But it seems unlikely the latter was helping us:
- it was marked with EXPENSIVE, so hardly anybody ran it anyway
- there's no indication that it was more likely to find bugs than the
smaller case (the commit message isn't very helpful, but the original
cover letter describes it as: "The first patch adds correctness and
(optional) performance tests".
- the timing results are shown only via test_debug(). So also not run
unless the user says "-d", and then not provided in any
machine-readable form.
If we're interested in performance regressions, a script in t/perf would
be more appropriate. I didn't add one here, because it's not at all
clear to me that what the script is timing is even all that interesting.
Let's simplify the script by dropping the EXPENSIVE run. That in turn
lets us drop the do_tests() wrapper, which lets us consistently use
single-quotes for our test snippets. And we can drop the useless
test_debug() timings, as well as their run() helper. And finally, while
we're here, we can replace the count() helper with the standard
test_seq().
Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Sat, 21 Mar 2020 20:48:54 +0000 (13:48 -0700)]
Merge branch 'en/rebase-backend'
Test fix.
* en/rebase-backend:
t3419: prevent failure when run with EXPENSIVE
Junio C Hamano [Sat, 21 Mar 2020 19:12:28 +0000 (12:12 -0700)]
Merge tag 'l10n-2.26.0-rnd2.1' of git://github.com/git-l10n/git-po.git
l10n-2.26.0-rnd2.1
* tag 'l10n-2.26.0-rnd2.1' of https://github.com/git-l10n/git-po: (28 commits)
l10n: tr.po: change file mode to 644
l10n: de.po: Update German translation for Git 2.26.0
l10n: de.po: add missing space
l10n: tr: Fix a couple of ambiguities
l10n: Update Catalan translation
l10n: sv.po: Update Swedish translation (4839t0f0u)
l10n: zh_CN: Revise v2.26.0 translation
l10n: zh_CN: for git v2.26.0 l10n round 1 and 2
l10n: vi(4839t): Updated Vietnamese translation for v2.26.0
l10n: vi: fix translation + grammar
l10n: zh_TW.po: v2.26.0 round 2 (0 untranslated)
l10n: zh_TW.po: v2.26.0 round 1 (11 untranslated)
l10n: it.po: update the Italian translation for Git 2.26.0 round 2
l10n: es: 2.26.0 round#2
l10n: bg.po: Updated Bulgarian translation (4839t)
l10n: tr: v2.26.0 round 2
l10n: fr : v2.26.0 rnd 2
l10n: git.pot: v2.26.0 round 2 (7 new, 2 removed)
l10n: tr: Add glossary for Turkish translations
l10n: sv.po: Update Swedish translation (4835t0f0u)
...
Jiang Xin [Sat, 21 Mar 2020 10:26:56 +0000 (18:26 +0800)]
l10n: tr.po: change file mode to 644
Signed-off-by: Jiang Xin <redacted>
brian m. carlson [Fri, 20 Mar 2020 21:52:41 +0000 (21:52 +0000)]
t3419: prevent failure when run with EXPENSIVE
This test runs a function which itself runs several assertions. The
last of these assertions cleans up the .git/rebase-apply directory,
since when run with EXPENSIVE set, the function is invoked a second time
to run the same tests with a larger data set.
However, as of
2ac0d6273f ("rebase: change the default backend from "am"
to "merge"", 2020-02-15), the default backend of rebase has changed, and
cleaning up the rebase-apply directory has no effect: it no longer
exists, since we're using rebase-merge instead.
Since we don't really care which rebase backend is in use, let's just
use the command "git rebase --quit", which will do the right thing
regardless.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
Derrick Stolee [Fri, 20 Mar 2020 12:38:10 +0000 (12:38 +0000)]
pack-objects: flip the use of GIT_TEST_PACK_SPARSE
The environment variable GIT_TEST_PACK_SPARSE was previously used
to allow testing the --sparse option for "git pack-objects" in
the test suite. This allowed interesting cases of "git push" to
also test this algorithm.
Since pack.useSparse is now true by default, we do not need this
variable to _enable_ the --sparse option, but instead to _disable_
it. This flips how we work with the variable a bit.
When checking for the variable, default to a value of -1 for
"unset". If unset, then take the default from the repo settings,
which is currently 1. Then, the --[no-]sparse command-line option
will override either of these settings.
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
Derrick Stolee [Fri, 20 Mar 2020 12:38:09 +0000 (12:38 +0000)]
config: set pack.useSparse=true by default
The pack.useSparse config option was introduced by
3d036eb0
(pack-objects: create pack.useSparse setting, 2019-01-19) and was
first available in v2.21.0. When enabled, the pack-objects process
during 'git push' will use a sparse tree walk when deciding which
trees and blobs to send to the remote. The algorithm was introduced
by
d5d2e93 (revision: implement sparse algorithm, 2019-01-16) and
has been in production use by VFS for Git since around that time.
The features.experimental config option also enabled pack.useSparse,
so hopefully that has also increased exposure.
It is worth noting that pack.useSparse has a possibility of
sending more objects across a push, but requires a special
arrangement of exact _copies_ across directories. There is a test
in t5322-pack-objects-sparse.sh that demonstrates this possibility.
This test uses the --sparse option to "git pack-objects" but we
can make it implied by the config value to demonstrate that the
default value has changed.
While updating that test, I noticed that the documentation did not
include an option for --no-sparse, which is now more important than
it was before.
Since the downside is unlikely but the upside is significant, set
the default value of pack.useSparse to true. Remove it from the
set of options implied by features.experimental.
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
Matthias Rüster [Sat, 14 Mar 2020 21:10:16 +0000 (22:10 +0100)]
l10n: de.po: Update German translation for Git 2.26.0
Signed-off-by: Matthias Rüster <redacted>
Reviewed-by: Ralf Thielow <redacted>
Reviewed-by: Phillip Szelat <redacted>
Ralf Thielow [Tue, 21 Jan 2020 16:30:48 +0000 (17:30 +0100)]
l10n: de.po: add missing space
Signed-off-by: Ralf Thielow <redacted>
Junio C Hamano [Thu, 19 Mar 2020 23:06:51 +0000 (16:06 -0700)]
Merge https://github.com/prati0100/git-gui
* 'master' of https://github.com/prati0100/git-gui:
git-gui: create a new namespace for chord script evaluation
git-gui: reduce Tcl version requirement from 8.6 to 8.5
git-gui--askpass: coerce answers to UTF-8 on Windows
git-gui: fix error popup when doing blame -> "Show History Context"
git-gui: add missing close bracket
git-gui: update German translation
git-gui: extend translation glossary template with more terms
git-gui: update pot template and German translation to current source code
Emir Sarı [Thu, 19 Mar 2020 22:36:24 +0000 (01:36 +0300)]
l10n: tr: Fix a couple of ambiguities
Signed-off-by: Emir Sarı <redacted>
Pratyush Yadav [Thu, 19 Mar 2020 15:59:19 +0000 (21:29 +0530)]
Merge branch 'py/remove-tcloo'
Reduce the Tcl version requirement to 8.5 to allow git-gui to run on
MacOS distributions like High Sierra. While here, fix a potential
variable name collision.
* py/remove-tcloo:
git-gui: create a new namespace for chord script evaluation
git-gui: reduce Tcl version requirement from 8.6 to 8.5
Elijah Newren [Wed, 18 Mar 2020 21:18:26 +0000 (21:18 +0000)]
RelNotes/2.26.0: fix various typos
Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
Shourya Shukla [Wed, 18 Mar 2020 14:20:24 +0000 (19:50 +0530)]
submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'
In 'submodule--helper.c', the structures and macros for callbacks belonging
to any subcommand are named in the format: 'subcommand_cb' and 'SUBCOMMAND_CB_INIT'
respectively.
This was an exception for the subcommand 'foreach' of the command
'submodule'. Rename the aforementioned structures and macros:
'struct cb_foreach' to 'struct foreach_cb' and 'CB_FOREACH_INIT'
to 'FOREACH_CB_INIT'.
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Wed, 18 Mar 2020 18:26:00 +0000 (11:26 -0700)]
separate tar.* config to its own source file
Even though there is only one configuration variable in the
namespace, it is not quite right to have tar.umask described
among the variables for tag.* namespace.
Signed-off-by: Junio C Hamano <redacted>
Jordi Mas [Wed, 18 Mar 2020 19:24:20 +0000 (20:24 +0100)]
l10n: Update Catalan translation
Signed-off-by: Jordi Mas <redacted>
Junio C Hamano [Wed, 18 Mar 2020 01:12:01 +0000 (18:12 -0700)]
Git 2.25.3
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 22:16:14 +0000 (15:16 -0700)]
Sync with Git 2.25.2
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 21:54:02 +0000 (14:54 -0700)]
Git 2.25.2
Signed-off-by: Junio C Hamano <redacted>
Beat Bolli [Tue, 17 Mar 2020 15:36:05 +0000 (16:36 +0100)]
unicode: update the width tables to Unicode 13.0
Now that Unicode 13.0 has been announced[0], update the character
width tables to the new version.
[0] https://home.unicode.org/announcing-the-unicode-standard-version-13-0/
Signed-off-by: Beat Bolli <redacted>
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 22:02:26 +0000 (15:02 -0700)]
Merge branch 'js/ci-windows-update' into maint
Updates to the CI settings.
* js/ci-windows-update:
Azure Pipeline: switch to the latest agent pools
ci: prevent `perforce` from being quarantined
t/lib-httpd: avoid using macOS' sed
Junio C Hamano [Tue, 17 Mar 2020 22:02:26 +0000 (15:02 -0700)]
Merge branch 'jk/run-command-formatfix' into maint
Code style cleanup.
* jk/run-command-formatfix:
run-command.h: fix mis-indented struct member
Junio C Hamano [Tue, 17 Mar 2020 22:02:26 +0000 (15:02 -0700)]
Merge branch 'jk/doc-credential-helper' into maint
Docfix.
* jk/doc-credential-helper:
doc: move credential helper info into gitcredentials(7)
Junio C Hamano [Tue, 17 Mar 2020 22:02:25 +0000 (15:02 -0700)]
Merge branch 'js/mingw-open-in-gdb' into maint
Dev support.
* js/mingw-open-in-gdb:
mingw: add a helper function to attach GDB to the current process
Junio C Hamano [Tue, 17 Mar 2020 22:02:25 +0000 (15:02 -0700)]
Merge branch 'js/test-unc-fetch' into maint
Test updates.
* js/test-unc-fetch:
t5580: test cloning without file://, test fetching via UNC paths
Junio C Hamano [Tue, 17 Mar 2020 22:02:25 +0000 (15:02 -0700)]
Merge branch 'js/test-write-junit-xml-fix' into maint
Testfix.
* js/test-write-junit-xml-fix:
tests: fix --write-junit-xml with subshells
Junio C Hamano [Tue, 17 Mar 2020 22:02:25 +0000 (15:02 -0700)]
Merge branch 'en/simplify-check-updates-in-unpack-trees' into maint
Code simplification.
* en/simplify-check-updates-in-unpack-trees:
unpack-trees: exit check_updates() early if updates are not wanted
Junio C Hamano [Tue, 17 Mar 2020 22:02:24 +0000 (15:02 -0700)]
Merge branch 'jc/doc-single-h-is-for-help' into maint
Both "git ls-remote -h" and "git grep -h" give short usage help,
like any other Git subcommand, but it is not unreasonable to expect
that the former would behave the same as "git ls-remote --head"
(there is no other sensible behaviour for the latter). The
documentation has been updated in an attempt to clarify this.
* jc/doc-single-h-is-for-help:
Documentation: clarify that `-h` alone stands for `help`
Junio C Hamano [Tue, 17 Mar 2020 22:02:24 +0000 (15:02 -0700)]
Merge branch 'hd/show-one-mergetag-fix' into maint
"git show" and others gave an object name in raw format in its
error output, which has been corrected to give it in hex.
* hd/show-one-mergetag-fix:
show_one_mergetag: print non-parent in hex form.
Junio C Hamano [Tue, 17 Mar 2020 22:02:23 +0000 (15:02 -0700)]
Merge branch 'am/mingw-poll-fix' into maint
MinGW's poll() emulation has been improved.
* am/mingw-poll-fix:
mingw: workaround for hangs when sending STDIN
Junio C Hamano [Tue, 17 Mar 2020 22:02:23 +0000 (15:02 -0700)]
Merge branch 'hi/gpg-use-check-signature' into maint
"git merge signed-tag" while lacking the public key started to say
"No signature", which was utterly wrong. This regression has been
reverted.
* hi/gpg-use-check-signature:
Revert "gpg-interface: prefer check_signature() for GPG verification"
Junio C Hamano [Tue, 17 Mar 2020 22:02:23 +0000 (15:02 -0700)]
Merge branch 'ds/partial-clone-fixes' into maint
Fix for a bug revealed by a recent change to make the protocol v2
the default.
* ds/partial-clone-fixes:
partial-clone: avoid fetching when looking for objects
partial-clone: demonstrate bugs in partial fetch
Junio C Hamano [Tue, 17 Mar 2020 22:02:23 +0000 (15:02 -0700)]
Merge branch 'en/t3433-rebase-stat-dirty-failure' into maint
The merge-recursive machinery failed to refresh the cache entry for
a merge result in a couple of places, resulting in an unnecessary
merge failure, which has been fixed.
* en/t3433-rebase-stat-dirty-failure:
merge-recursive: fix the refresh logic in update_file_flags
t3433: new rebase testcase documenting a stat-dirty-like failure
Junio C Hamano [Tue, 17 Mar 2020 22:02:23 +0000 (15:02 -0700)]
Merge branch 'en/check-ignore' into maint
"git check-ignore" did not work when the given path is explicitly
marked as not ignored with a negative entry in the .gitignore file.
* en/check-ignore:
check-ignore: fix documentation and implementation to match
Junio C Hamano [Tue, 17 Mar 2020 22:02:22 +0000 (15:02 -0700)]
Merge branch 'jk/push-option-doc-markup-fix' into maint
Doc markup fix.
* jk/push-option-doc-markup-fix:
doc/config/push: use longer "--" line for preformatted example
Junio C Hamano [Tue, 17 Mar 2020 22:02:22 +0000 (15:02 -0700)]
Merge branch 'jk/doc-diff-parallel' into maint
Update to doc-diff.
* jk/doc-diff-parallel:
doc-diff: use single-colon rule in rendering Makefile
Junio C Hamano [Tue, 17 Mar 2020 22:02:22 +0000 (15:02 -0700)]
Merge branch 'jh/notes-fanout-fix' into maint
The code to automatically shrink the fan-out in the notes tree had
an off-by-one bug, which has been killed.
* jh/notes-fanout-fix:
notes.c: fix off-by-one error when decreasing notes fanout
t3305: check notes fanout more carefully and robustly
Junio C Hamano [Tue, 17 Mar 2020 22:02:21 +0000 (15:02 -0700)]
Merge branch 'jk/index-pack-dupfix' into maint
The index-pack code now diagnoses a bad input packstream that
records the same object twice when it is used as delta base; the
code used to declare a software bug when encountering such an
input, but it is an input error.
* jk/index-pack-dupfix:
index-pack: downgrade twice-resolved REF_DELTA to die()
Junio C Hamano [Tue, 17 Mar 2020 22:02:21 +0000 (15:02 -0700)]
Merge branch 'js/rebase-i-with-colliding-hash' into maint
"git rebase -i" identifies existing commits in its todo file with
their abbreviated object name, which could become ambigous as it
goes to create new commits, and has a mechanism to avoid ambiguity
in the main part of its execution. A few other cases however were
not covered by the protection against ambiguity, which has been
corrected.
* js/rebase-i-with-colliding-hash:
rebase -i: also avoid SHA-1 collisions with missingCommitsCheck
rebase -i: re-fix short SHA-1 collision
parse_insn_line(): improve error message when parsing failed
Junio C Hamano [Tue, 17 Mar 2020 22:02:21 +0000 (15:02 -0700)]
Merge branch 'jk/clang-sanitizer-fixes' into maint
C pedantry ;-) fix.
* jk/clang-sanitizer-fixes:
obstack: avoid computing offsets from NULL pointer
xdiff: avoid computing non-zero offset from NULL pointer
avoid computing zero offsets from NULL pointer
merge-recursive: use subtraction to flip stage
merge-recursive: silence -Wxor-used-as-pow warning
Junio C Hamano [Tue, 17 Mar 2020 22:02:21 +0000 (15:02 -0700)]
Merge branch 'dt/submodule-rm-with-stale-cache' into maint
Running "git rm" on a submodule failed unnecessarily when
.gitmodules is only cache-dirty, which has been corrected.
* dt/submodule-rm-with-stale-cache:
git rm submodule: succeed if .gitmodules index stat info is zero
Junio C Hamano [Tue, 17 Mar 2020 22:02:21 +0000 (15:02 -0700)]
Merge branch 'pb/recurse-submodule-in-worktree-fix' into maint
The "--recurse-submodules" option of various subcommands did not
work well when run in an alternate worktree, which has been
corrected.
* pb/recurse-submodule-in-worktree-fix:
submodule.c: use get_git_dir() instead of get_git_common_dir()
t2405: clarify test descriptions and simplify test
t2405: use git -C and test_commit -C instead of subshells
t7410: rename to t2405-worktree-submodule.sh
Junio C Hamano [Tue, 17 Mar 2020 22:02:20 +0000 (15:02 -0700)]
Merge branch 'es/outside-repo-errmsg-hints' into maint
An earlier update to show the location of working tree in the error
message did not consider the possibility that a git command may be
run in a bare repository, which has been corrected.
* es/outside-repo-errmsg-hints:
prefix_path: show gitdir if worktree unavailable
prefix_path: show gitdir when arg is outside repo
Junio C Hamano [Tue, 17 Mar 2020 22:02:20 +0000 (15:02 -0700)]
Merge branch 'js/builtin-add-i-cmds' into maint
Minor bugfixes to "git add -i" that has recently been rewritten in C.
* js/builtin-add-i-cmds:
built-in add -i: accept open-ended ranges again
built-in add -i: do not try to `patch`/`diff` an empty list of files
Junio C Hamano [Tue, 17 Mar 2020 21:36:45 +0000 (14:36 -0700)]
Git 2.24.2
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 21:33:34 +0000 (14:33 -0700)]
Git 2.23.2
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 21:24:55 +0000 (14:24 -0700)]
Git 2.22.3
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 21:16:08 +0000 (14:16 -0700)]
Git 2.21.2
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 20:42:38 +0000 (13:42 -0700)]
Git 2.20.3
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 20:37:37 +0000 (13:37 -0700)]
Git 2.19.4
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 20:34:12 +0000 (13:34 -0700)]
Git 2.18.3
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Tue, 17 Mar 2020 20:23:48 +0000 (13:23 -0700)]
Git 2.17.4
Signed-off-by: Junio C Hamano <redacted>
Peter Krefting [Tue, 17 Mar 2020 17:33:22 +0000 (18:33 +0100)]
l10n: sv.po: Update Swedish translation (4839t0f0u)
Signed-off-by: Peter Krefting <redacted>
Pratyush Yadav [Sat, 14 Mar 2020 21:38:36 +0000 (03:08 +0530)]
git-gui: create a new namespace for chord script evaluation
Evaluating the script in the same namespace as the chord itself creates
potential for variable name collision. And in that case the script would
unknowingly use the chord's variables.
For example, say the script has a variable called 'is_completed', which
also exists in the chord's namespace. The script then calls 'eval' and
sets 'is_completed' to 1 thinking it is setting its own variable,
completely unaware of how the chord works behind the scenes. This leads
to the chord never actually executing because it sees 'is_completed' as
true and thinks it has already completed.
Avoid the potential collision by creating a separate namespace for the
script that is a child of the chord's namespace.
Signed-off-by: Pratyush Yadav <redacted>
Pratyush Yadav [Mon, 17 Feb 2020 15:39:29 +0000 (21:09 +0530)]
git-gui: reduce Tcl version requirement from 8.6 to 8.5
On some MacOS distributions like High Sierra, Tcl 8.5 is shipped by
default. This makes git-gui error out at startup because of the version
mismatch.
The only part that requires Tcl 8.6 is SimpleChord, which depends on
TclOO. So, don't use it and use our homegrown class.tcl instead.
This means some slight syntax changes. Since class.tcl doesn't have an
"unknown" method like TclOO does, we can't just call '$note', but have
to use '$note activate' instead. The constructor now needs a proper
namespace qualifier. Update the documentation to reflect the new syntax.
As of now, the only part of git-gui that needs Tcl 8.5 is a call to
'apply' in lib/index.tcl::lambda. Keep using it until someone shows up
shouting that their OS ships with 8.4 only. Then we would have to look
into implementing it in pure Tcl.
Signed-off-by: Pratyush Yadav <redacted>
Fangyi Zhou [Wed, 11 Mar 2020 11:55:43 +0000 (11:55 +0000)]
l10n: zh_CN: Revise v2.26.0 translation
Signed-off-by: Fangyi Zhou <redacted>
Reviewed-by: 依云 <redacted>
Signed-off-by: Jiang Xin <redacted>
Jiang Xin [Mon, 30 Dec 2019 00:56:49 +0000 (08:56 +0800)]
l10n: zh_CN: for git v2.26.0 l10n round 1 and 2
Translate 79 new messages (4839t0f0u) for git 2.26.0.
Signed-off-by: Jiang Xin <redacted>
Junio C Hamano [Mon, 16 Mar 2020 20:30:38 +0000 (13:30 -0700)]
log: give --[no-]use-mailmap a more sensible synonym --[no-]mailmap
The option name "--use-mailmap" looks OK, but it becomes awkward
when you have to negate it, i.e. "--no-use-mailmap". I, perhaps
with many other users, always try "--no-mailmap" and become unhappy
to see it fail.
Add an alias "--[no-]mailmap" to remedy this.
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Mon, 16 Mar 2020 20:27:43 +0000 (13:27 -0700)]
clone: reorder --recursive/--recurse-submodules
The previous step made an option that is an alias to another option
identify itself as an alias to the latter. Because it is easier to
scan the list when a pointer goes backward to what a reader already
has seen, mention "recurse-submodules" first with its true short
help string, and then "recurse" with the statement that it is a
synonym to "recurse-submodules".
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Mon, 16 Mar 2020 20:22:54 +0000 (13:22 -0700)]
parse-options: teach "git cmd -h" to show alias as alias
There is a long-standing NEEDSWORK comment that complains about
inconsistency between how an aliased option ("git clone --recurse"
which is the only one that currently exists) gives a help text in
a usage-error message vs "git cmd -h"). Get rid of it and then
make sure we say an option is an alias for another, instead of
repeating the same short help text for both, which leads to "they
seem to do the same---is there any subtle difference?" puzzlement
to end-users.
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Mon, 16 Mar 2020 19:46:32 +0000 (12:46 -0700)]
Git 2.26-rc2
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Mon, 16 Mar 2020 19:43:30 +0000 (12:43 -0700)]
Merge branch 'en/test-cleanup'
Test fixes.
* en/test-cleanup:
t6022, t6046: fix flaky files-are-updated checks
Junio C Hamano [Mon, 16 Mar 2020 19:43:29 +0000 (12:43 -0700)]
Merge branch 'es/outside-repo-errmsg-hints'
An earlier update to show the location of working tree in the error
message did not consider the possibility that a git command may be
run in a bare repository, which has been corrected.
* es/outside-repo-errmsg-hints:
prefix_path: show gitdir if worktree unavailable
brian m. carlson [Mon, 16 Mar 2020 18:05:08 +0000 (18:05 +0000)]
t0021: test filter metadata for additional cases
Check that we get the expected data when performing a merges or
generating archives. Note that we don't expect a ref for merges,
because we won't be checking out any particular ref, but instead a tree
of the merged data. For archives, however, we expect a ref as normal if
we have one.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
brian m. carlson [Mon, 16 Mar 2020 18:05:07 +0000 (18:05 +0000)]
builtin/reset: compute checkout metadata for reset
Pass the commit, and if we have it, the ref to the filters when we
perform a checkout. This should only be the case when we invoke git
reset --hard; the metadata will be unused otherwise.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
brian m. carlson [Mon, 16 Mar 2020 18:05:06 +0000 (18:05 +0000)]
builtin/rebase: compute checkout metadata for rebases
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
brian m. carlson [Mon, 16 Mar 2020 18:05:05 +0000 (18:05 +0000)]
builtin/clone: compute checkout metadata for clones
When checking out a commit, provide metadata to the filter process
including the ref we're using.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
brian m. carlson [Mon, 16 Mar 2020 18:05:04 +0000 (18:05 +0000)]
builtin/checkout: compute checkout metadata for checkouts
Provide commit metadata for checkout code paths that use unpack_trees
and friends. When we're checking out a commit, use the commit
information, but don't provide commit information if we're checking out
from the index, since there need not be any particular commit associated
with the index, and even if there is one, we can't know what it is.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
brian m. carlson [Mon, 16 Mar 2020 18:05:03 +0000 (18:05 +0000)]
convert: provide additional metadata to filters
Now that we have the codebase wired up to pass any additional metadata
to filters, let's collect the additional metadata that we'd like to
pass.
The two main places we pass this metadata are checkouts and archives.
In these two situations, reading HEAD isn't a valid option, since HEAD
isn't updated for checkouts until after the working tree is written and
archives can accept an arbitrary tree. In other situations, HEAD will
usually reflect the refname of the branch in current use.
We pass a smaller amount of data in other cases, such as git cat-file,
where we can really only logically know about the blob.
This commit updates only the parts of the checkout code where we don't
use unpack_trees. That function and callers of it will be handled in a
future commit.
In the archive code, we leak a small amount of memory, since nothing we
pass in the archiver argument structure is freed.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
brian m. carlson [Mon, 16 Mar 2020 18:05:02 +0000 (18:05 +0000)]
convert: permit passing additional metadata to filter processes
There are a variety of situations where a filter process can make use of
some additional metadata. For example, some people find the ident
filter too limiting and would like to include the commit or the branch
in their smudged files. This information isn't available during
checkout as HEAD hasn't been updated at that point, and it wouldn't be
available in archives either.
Let's add a way to pass this metadata down to the filter. We pass the
blob we're operating on, the treeish (preferring the commit over the
tree if one exists), and the ref we're operating on. Note that we won't
pass this information in all cases, such as when renormalizing or when
we're performing diffs, since it doesn't make sense in those cases.
The data we currently get from the filter process looks like the
following:
command=smudge
pathname=git.c
0000
With this change, we'll get data more like this:
command=smudge
pathname=git.c
refname=refs/tags/v2.25.1
treeish=
c522f061d551c9bb8684a7c3859b2ece4499b56b
blob=
7be7ad34bd053884ec48923706e70c81719a8660
0000
There are a couple things to note about this approach. For operations
like checkout, treeish will always be a commit, since we cannot check
out individual trees, but for other operations, like archive, we can end
up operating on only a particular tree, so we'll provide only a tree as
the treeish. Similar comments apply for refname, since there are a
variety of cases in which we won't have a ref.
This commit wires up the code to print this information, but doesn't
pass any of it at this point. In a future commit, we'll have various
code paths pass the actual useful data down.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
Tran Ngoc Quan [Mon, 16 Mar 2020 01:55:40 +0000 (08:55 +0700)]
l10n: vi(4839t): Updated Vietnamese translation for v2.26.0
Signed-off-by: Tran Ngoc Quan <redacted>
Đoàn Trần Công Danh [Mon, 13 Jan 2020 15:48:39 +0000 (22:48 +0700)]
l10n: vi: fix translation + grammar
- context should be translated to ngữ cảnh instead of nội dung
- add missing accents
- switch adjective and secondary objects position:
* The formatted English text will be "To remove '+/-' lines",
it should be translated to "Để bỏ dòng bắt đầu với '+/-'
Signed-off-by: Đoàn Trần Công Danh <redacted>
Elijah Newren [Sat, 14 Mar 2020 19:15:47 +0000 (19:15 +0000)]
oidset: remove unnecessary include
When commit
8b2f8cbcb1 ("oidset: use khash", 2018-10-04) moved from
using oidmap to khash, it replaced the oidmap.h include with both one
for hashmap.h and khash.h. Since the hashmap.h header is unnecessary,
and the point of the patch was to switch from hashmap (used by oidmap)
to khash.h, remove the unneccessary include.
Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
Derrick Stolee [Fri, 13 Mar 2020 21:11:55 +0000 (21:11 +0000)]
connected.c: reprepare packs for corner cases
While updating the microsoft/git fork on top of v2.26.0-rc0 and
consuming that build into Scalar, I noticed a corner case bug around
partial clone.
The "scalar clone" command can create a Git repository with the
proper config for using partial clone with the "blob:none" filter.
Instead of calling "git clone", it runs "git init" then sets a few
more config values before running "git fetch".
In our builds on v2.26.0-rc0, we noticed that our "git fetch"
command was failing with
error: https://github.com/microsoft/scalar did not send all necessary objects
This does not happen if you copy the config file from a repository
created by "git clone --filter=blob:none <url>", but it does happen
when adding the config option "core.logAllRefUpdates = true".
By debugging, I was able to see that the loop inside
check_connnected() that checks if all refs are contained in
promisor packs actually did not have any packfiles in the packed_git
list.
I'm not sure what corner-case issues caused this config option to
prevent the reprepare_packed_git() from being called at the proper
spot during the fetch operation. This approach requires a situation
where we use the remote helper process, which makes it difficult to
test.
It is possible to place a reprepare_packed_git() call in the fetch code
closer to where we receive a pack, but that leaves an opening for a
later change to re-introduce this problem. Further, a concurrent repack
operation could replace the pack-file list we already loaded into
memory, causing this issue in an even harder to reproduce scenario.
It is really the responsibility of anyone looping through the list of
pack-files for a certain object to fall back to reprepare_packed_git()
on a fail-to-find. The loop in check_connected() does not have this
fallback, leading to this bug.
We _could_ try looping through the packs and only reprepare the packs
after a miss, but that change is more involved and has little value.
Since this case is isolated to the case when
opt->check_refs_are_promisor_objects_only is true, we are confident that
we are verifying the refs after downloading new data. This implies that
calling reprepare_packed_git() in advance is not a huge cost compared to
the rest of the operations already made.
Helped-by: Jeff King <redacted>
Helped-by: Junio Hamano <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
Hans Jerry Illikainen [Wed, 4 Mar 2020 11:48:04 +0000 (11:48 +0000)]
gpg-interface: prefer check_signature() for GPG verification
This commit refactors the use of verify_signed_buffer() outside of
gpg-interface.c to use check_signature() instead. It also turns
verify_signed_buffer() into a file-local function since it's now only
invoked internally by check_signature().
There were previously two globally scoped functions used in different
parts of Git to perform GPG signature verification:
verify_signed_buffer() and check_signature(). Now only
check_signature() is used.
The verify_signed_buffer() function doesn't guard against duplicate
signatures as described by Michał Górny [1]. Instead it only ensures a
non-erroneous exit code from GPG and the presence of at least one
GOODSIG status field. This stands in contrast with check_signature()
that returns an error if more than one signature is encountered.
The lower degree of verification makes the use of verify_signed_buffer()
problematic if callers don't parse and validate the various parts of the
GPG status message themselves. And processing these messages seems like
a task that should be reserved to gpg-interface.c with the function
check_signature().
Furthermore, the use of verify_signed_buffer() makes it difficult to
introduce new functionality that relies on the content of the GPG status
lines.
Now all operations that does signature verification share a single entry
point to gpg-interface.c. This makes it easier to propagate changed or
additional functionality in GPG signature verification to all parts of
Git, without having odd edge-cases that don't perform the same degree of
verification.
[1] https://dev.gentoo.org/~mgorny/articles/attack-on-git-signature-verification.html
Signed-off-by: Hans Jerry Illikainen <redacted>
Signed-off-by: Junio C Hamano <redacted>
Hans Jerry Illikainen [Wed, 4 Mar 2020 11:48:03 +0000 (11:48 +0000)]
t: increase test coverage of signature verification output
There weren't any tests for unsuccessful signature verification of
signed merge tags shown in 'git log'. There also weren't any tests for
the GPG output from 'git fmt-merge-msg'. This was noticed while
investigating a buggy refactor that slipped through the test suite; see
commit
72b006f4bfd30b7c5037c163efaf279ab65bea9c.
This commit adds signature verification tests to the 'log' and
'fmt-merge-msg' builtins.
Thanks to Linus Torvalds for reporting and finding the (now reverted)
commit that introduced the regression.
Note that the "log --show-signature for merged tag with GPG failure"
test case is really hacky. It relies on an implementation detail of
verify_signed_buffer() -- namely, it assumes that the signature is
written to a temporary file whose path is under TMPDIR.
The rationale for that test case is to check whether the code path that
yields the "No signature" message is reachable on failure. The
functionality in log-tree.c that may show this message does some
pre-parsing of a possible signature that prevents the GPG interface from
being invoked if a signature is actually missing. And I haven't been
able to construct a signature that both 1. satisfies that
pre-processing, and 2. causes GPG to fail without any sort of output on
stderr along the lines of "this is a bogus/corrupt/... signature" (the
"No signature" message should only be shown if GPG produce no output).
Signed-off-by: Hans Jerry Illikainen <redacted>
[jc: fixed missing test title noticed by Dscho]
Signed-off-by: Junio C Hamano <redacted>
Emily Shaffer [Tue, 3 Mar 2020 04:05:06 +0000 (20:05 -0800)]
prefix_path: show gitdir if worktree unavailable
If there is no worktree at present, we can still hint the user about
Git's current directory by showing them the absolute path to the Git
directory. Even though the Git directory doesn't make it as easy to
locate the worktree in question, it can still help a user figure out
what's going on while developing a script.
This fixes a segmentation fault introduced in
e0020b2f
("prefix_path: show gitdir when arg is outside repo", 2020-02-14).
Signed-off-by: Emily Shaffer <redacted>
[jc: added minimum tests, with help from Szeder Gábor]
Signed-off-by: Junio C Hamano <redacted>
Yi-Jyun [Fri, 13 Mar 2020 17:12:19 +0000 (01:12 +0800)]
l10n: zh_TW.po: v2.26.0 round 2 (0 untranslated)
Revision 2.
Signed-off-by: Yi-Jyun Pan <redacted>
Yi-Jyun [Mon, 9 Mar 2020 17:33:00 +0000 (01:33 +0800)]
l10n: zh_TW.po: v2.26.0 round 1 (11 untranslated)
Signed-off-by: Yi-Jyun Pan <redacted>
Pratyush Yadav [Sat, 14 Mar 2020 17:22:43 +0000 (22:52 +0530)]
Merge branch 'js/askpass-coerce-utf8'
Askpass can now send non-ASCII to Git on Windows.
* js/askpass-coerce-utf8:
git-gui--askpass: coerce answers to UTF-8 on Windows
Luke Bonanomi [Thu, 12 Mar 2020 21:31:50 +0000 (21:31 +0000)]
git-gui--askpass: coerce answers to UTF-8 on Windows
This addresses the issue where Git for Windows asks the user for a
password, no credential helper is available, and then Git fails to pick
up non-ASCII characters from the Git GUI helper.
This can be verified e.g. via
echo host=http://abc.com |
git -c credential.helper= credential fill
and then pasting some umlauts.
The underlying reason is that Git for Windows tries to communicate using
the UTF-8 encoding no matter what the actual current code page is. So
let's indulge Git for Windows and do use that encoding.
This fixes https://github.com/git-for-windows/git/issues/2215
Signed-off-by: Luke Bonanomi <redacted>
Helped-by: Junio C Hamano <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Pratyush Yadav <redacted>
Pratyush Yadav [Sat, 14 Mar 2020 17:11:45 +0000 (22:41 +0530)]
Merge branch 'py/blame-status-error'
Fixes an error popup in blame because of a missing closing bracket.
* py/blame-status-error:
git-gui: fix error popup when doing blame -> "Show History Context"
Elijah Newren [Fri, 13 Mar 2020 20:03:02 +0000 (20:03 +0000)]
t6022, t6046: fix flaky files-are-updated checks
Several tests wanted to verify that files were actually modified by a
merge, which it would do by checking that the mtime was updated. In
order to avoid problems with the merge completing so fast that the mtime
at the beginning and end of the operation was the same, these tests
would first set the mtime of a file to something "old". This "old"
value was usually determined as current system clock minus one second,
truncated to the nearest integer. Unfortunately, it appears the system
clock and filesystem clock are different and comparing across the two
runs into race problems resulting in flaky tests.
From https://stackoverflow.com/questions/
14392975/timestamp-accuracy-on-ext4-sub-millsecond:
date will call the gettimeofday system call which will always return
the most accurate time available based on the cached kernel time,
adjusted by the CPU cycle time if available to give nanosecond
resolution. The timestamps stored in the file system however, are
only based on the cached kernel time. ie The time calculated at the
last timer interrupt.
and from https://apenwarr.ca/log/
20181113:
Does mtime get set to >= the current time?
No, this depends on clock granularity. For example, gettimeofday()
can return times in microseconds on my system, but ext4 rounds
timestamps down to the previous ~10ms (but not exactly 10ms)
increment, with the surprising result that a newly-created file is
almost always created in the past:
$ python -c "
import os, time
t0 = time.time()
open('testfile', 'w').close()
print os.stat('testfile').st_mtime - t0
"
-0.
00234484672546
So, instead of trying to compare across what are effectively two
different clocks, just avoid using the system clock. Any new updates to
files have to give an mtime at least as big as what is already in the
file, so we could define "old" as one second before the mtime found in
the file before the merge starts. But, to avoid problems with leap
seconds, ntp updates, filesystems that only provide two second
resolution, and other such weirdness, let's just pick an hour before the
mtime found in the file before the merge starts.
Also, clarify in one test where we check the mtime of different files
that it really was intentional. I totally forgot the reasons for that
and assumed it was a bug when asked.
Reported-by: SZEDER Gábor <redacted>
Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Thu, 12 Mar 2020 21:36:00 +0000 (14:36 -0700)]
Hopefully the final batch before -rc2
Signed-off-by: Junio C Hamano <redacted>
Junio C Hamano [Thu, 12 Mar 2020 21:28:01 +0000 (14:28 -0700)]
Merge branch 'en/rebase-backend'
Band-aid fixes for two fallouts from switching the default "rebase"
backend.
* en/rebase-backend:
git-rebase.txt: highlight backend differences with commit rewording
sequencer: clear state upon dropping a become-empty commit
i18n: unmark a message in rebase.c
brian m. carlson [Tue, 10 Mar 2020 18:20:39 +0000 (18:20 +0000)]
builtin/checkout: pass branch info down to checkout_worktree
In the future, we're going to want to use the branch info in
checkout_worktree, so let's pass the whole struct branch_info down, not
just the revision name. We hoist the definition of struct branch_info
so it's in scope.
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
Jiang Xin [Thu, 12 Mar 2020 10:41:56 +0000 (18:41 +0800)]
Merge branch of github.com:ChrisADR/git-po into master
* 'next' of github.com:ChrisADR/git-po:
l10n: es: 2.26.0 round#2
Jeff King [Wed, 11 Mar 2020 22:48:24 +0000 (18:48 -0400)]
fsck: detect gitmodules URLs with embedded newlines
The credential protocol can't handle values with newlines. We already
detect and block any such URLs from being used with credential helpers,
but let's also add an fsck check to detect and block gitmodules files
with such URLs. That will let us notice the problem earlier when
transfer.fsckObjects is turned on. And in particular it will prevent bad
objects from spreading, which may protect downstream users running older
versions of Git.
We'll file this under the existing gitmodulesUrl flag, which covers URLs
with option injection. There's really no need to distinguish the exact
flaw in the URL in this context. Likewise, I've expanded the description
of t7416 to cover all types of bogus URLs.
Jeff King [Thu, 12 Mar 2020 05:31:11 +0000 (01:31 -0400)]
credential: detect unrepresentable values when parsing urls
The credential protocol can't represent newlines in values, but URLs can
embed percent-encoded newlines in various components. A previous commit
taught the low-level writing routines to die() when encountering this,
but we can be a little friendlier to the user by detecting them earlier
and handling them gracefully.
This patch teaches credential_from_url() to notice such components,
issue a warning, and blank the credential (which will generally result
in prompting the user for a username and password). We blank the whole
credential in this case. Another option would be to blank only the
invalid component. However, we're probably better off not feeding a
partially-parsed URL result to a credential helper. We don't know how a
given helper would handle it, so we're better off to err on the side of
matching nothing rather than something unexpected.
The die() call in credential_write() is _probably_ impossible to reach
after this patch. Values should end up in credential structs only by URL
parsing (which is covered here), or by reading credential protocol input
(which by definition cannot read a newline into a value). But we should
definitely keep the low-level check, as it's our final and most accurate
line of defense against protocol injection attacks. Arguably it could
become a BUG(), but it probably doesn't matter much either way.
Note that the public interface of credential_from_url() grows a little
more than we need here. We'll use the extra flexibility in a future
patch to help fsck catch these cases.
Jeff King [Wed, 11 Mar 2020 22:11:37 +0000 (18:11 -0400)]
t/lib-credential: use test_i18ncmp to check stderr
The credential tests have a "check" function which feeds some input to
git-credential and checks the stdout and stderr. We look for exact
matches in the output. For stdout, this makes sense; the output is
the credential protocol. But for stderr, we may be showing various
diagnostic messages, or the prompts fed to the askpass program, which
could be translated. Let's mark them as such.