Compare commits

...

29 Commits

Author SHA1 Message Date
876b142331 Git 2.34-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-03 13:32:40 -07:00
0cb1330bc6 Merge branch 'pw/rebase-r-fixes'
Regression fix.

* pw/rebase-r-fixes:
  rebase -i: fix rewording with --committer-date-is-author-date
2021-11-03 13:32:29 -07:00
36f0a2e20f Merge branch 'ds/add-rm-with-sparse-index'
Regression fix.

* ds/add-rm-with-sparse-index:
  dir: fix directory-matching bug
2021-11-03 13:32:28 -07:00
e2a33ef9e2 Merge branch 'jx/message-fixes'
Fixes to recently added messages.

* jx/message-fixes:
  i18n: fix typos found during l10n for git 2.34.0
2021-11-03 13:32:28 -07:00
e890c845b8 Merge branch 'rs/ssh-signing-fix'
Fixes to recently merged topic.

* rs/ssh-signing-fix:
  gpg-interface: avoid buffer overrun in parse_ssh_output()
  gpg-interface: handle missing " with " gracefully in parse_ssh_output()
2021-11-03 13:32:28 -07:00
9d6b9df128 rebase -i: fix rewording with --committer-date-is-author-date
baf8ec8d3a (rebase -r: don't write .git/MERGE_MSG when
fast-forwarding, 2021-08-20) stopped reading the author script in
run_git_commit() when rewording a commit. This is normally safe
because "git commit --amend" preserves the authorship. However if the
user passes "--committer-date-is-author-date" then we need to read the
author date from the author script when rewording. Fix this regression
by tightening the check for when it is safe to skip reading the author
script.

Reported-by: Jonas Kittner <jonas.kittner@ruhr-uni-bochum.de>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-03 10:44:45 -07:00
5ceb663e92 dir: fix directory-matching bug
This reverts the change from ed49584 (dir: fix pattern matching on dirs,
2021-09-24), which claimed to fix a directory-matching problem without a
test case. It turns out to _create_ a bug, but it is a bit subtle.

The bug would have been revealed by the first of two tests being added to
t0008-ignores.sh. The first uses a pattern "/git/" inside the a/.gitignores
file, which matches against 'a/git/foo' but not 'a/git-foo/bar'. This test
would fail before the revert.

The second test shows what happens if the test instead uses a pattern "git/"
and this test passes both before and after the revert.

The difference in these two cases are due to how
last_matching_pattern_from_list() checks patterns both if they have the
PATTERN_FLAG_MUSTBEDIR and PATTERN_FLAG_NODIR flags. In the case of "git/",
the PATTERN_FLAG_NODIR is also provided, making the change in behavior in
match_pathname() not affect the end result of
last_matching_pattern_from_list().

Reported-by: Glen Choo <chooglen@google.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-03 10:10:36 -07:00
65db97b4fa gpg-interface: avoid buffer overrun in parse_ssh_output()
If the string "key" we found in the output of ssh-keygen happens to be
located at the very end of the line, then going four characters further
leaves us beyond the end of the string.  Explicitly search for the
space after "key" to handle a missing one gracefully.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-01 17:00:41 -07:00
18b18503e3 gpg-interface: handle missing " with " gracefully in parse_ssh_output()
If the output of ssh-keygen starts with "Good \"git\" signature for ",
but is not followed by " with " for some reason, then parse_ssh_output()
uses -1 as the len parameter of xmemdupz(), which in turn will end the
program.  Reject the signature and carry on instead in that case.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-01 17:00:41 -07:00
0cddd84c9f A few more topics before -rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-01 13:48:08 -07:00
cfd86ee3dd Merge branch 'ab/test-lib'
Test (cosmetic) fix.

* ab/test-lib:
  t5310: drop lib-bundle.sh include
2021-11-01 13:48:08 -07:00
7baf6588c5 Merge branch 'jc/doc-format-patch-clarify-auto-base'
Rephrase the description of "format-patch --base=auto".

* jc/doc-format-patch-clarify-auto-base:
  format-patch (doc): clarify --base=auto
2021-11-01 13:48:08 -07:00
7afb458e91 Merge branch 'gc/use-repo-settings'
It is wrong to read some settings directly from the config
subsystem, as things like feature.experimental can affect their
default values.

* gc/use-repo-settings:
  gc: perform incremental repack when implictly enabled
  fsck: verify multi-pack-index when implictly enabled
  fsck: verify commit graph when implicitly enabled
2021-11-01 13:48:08 -07:00
b82299ec6f Merge branch 'ab/ignore-replace-while-working-on-commit-graph'
Teach "git commit-graph" command not to allow using replace objects
at all, as we do not use the commit-graph at runtime when we see
object replacement.

* ab/ignore-replace-while-working-on-commit-graph:
  commit-graph: don't consider "replace" objects with "verify"
  commit-graph tests: fix another graph_git_two_modes() helper
  commit-graph tests: fix error-hiding graph_git_two_modes() helper
2021-11-01 13:48:08 -07:00
b93d720691 Merge branch 'hm/paint-hits-in-log-grep'
"git log --grep=string --author=name" learns to highlight hits just
like "git grep string" does.

* hm/paint-hits-in-log-grep:
  grep/pcre2: fix an edge case concerning ascii patterns and UTF-8 data
  pretty: colorize pattern matches in commit messages
  grep: refactor next_match() and match_one_pattern() for external use
2021-11-01 13:48:08 -07:00
f733719316 i18n: fix typos found during l10n for git 2.34.0
Emir and Jean-Noël reported typos in some i18n messages when preparing
l10n for git 2.34.0.

* Fix unstable spelling of config variable "gpg.ssh.defaultKeyCommand"
  which was introduced in commit fd9e226776 (ssh signing: retrieve a
  default key from ssh-agent, 2021-09-10).

* Add missing space between "with" and "--python" which was introduced
  in commit bd0708c7eb (ref-filter: add %(raw) atom, 2021-07-26).

* Fix unmatched single quote in 'builtin/index-pack.c' which was
  introduced in commit 8737dab346 (index-pack: refactor renaming in
  final(), 2021-09-09)

[1] https://github.com/git-l10n/git-po/pull/567

Reported-by: Emir Sarı <bitigchi@me.com>
Reported-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-31 22:49:49 -07:00
559664c792 t5310: drop lib-bundle.sh include
Commit ddfe900612 (test-lib-functions: move function to lib-bitmap.sh,
2021-02-09) meant to include lib-bitmap.sh in t5310, but also includes
lib-bundle.sh. Yet we don't use any of its functions, nor have anything
to do with bundles. This is probably just a typo/copy-paste error, as
lib-bundle.sh was added (correctly) to other scripts in the same series.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-29 00:06:12 -07:00
203eb8381a format-patch (doc): clarify --base=auto
What --base=auto tells format-patch is to compute the base commit
itself, using the tracking information.  It does not make anything
track anything.

Tighten the phrasing so that it won't be copied and pasted to other
places.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-23 14:33:20 -07:00
a897ab7ed1 gc: perform incremental repack when implictly enabled
builtin/gc.c has two ways of checking if multi-pack-index is enabled:
- git_config_get_bool() in incremental_repack_auto_condition()
- the_repository->settings.core_multi_pack_index in
  maintenance_task_incremental_repack()

The two implementations have existed since the incremental-repack task
was introduced in e841a79a13 (maintenance: add incremental-repack auto
condition, 2020-09-25). These two values can diverge because
prepare_repo_settings() enables the feature in the_repository->settings
by default.

In the case where core.multiPackIndex is not set in the config, the auto
condition would fail, causing the incremental-repack task to not be
run. Because we always want to consider the default values, we should
always use the_repository->settings.

Standardize on using the_repository->settings.core_multi_pack_index to
check if multi-pack-index is enabled.

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 14:30:10 -07:00
dc5570872f fsck: verify multi-pack-index when implictly enabled
Like the previous commit, change fsck to check the
"core_multi_pack_index" variable set in "repo-settings.c" instead of
reading the "core.multiPackIndex" config variable. This fixes a bug
where we wouldn't verify midx if the config key was missing. This bug
was introduced in 18e449f86b (midx: enable core.multiPackIndex by
default, 2020-09-25) where core.multiPackIndex was turned on by default.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 14:30:08 -07:00
f30e4d854b fsck: verify commit graph when implicitly enabled
Change fsck to check the "core_commit_graph" variable set in
"repo-settings.c" instead of reading the "core.commitGraph" variable.
This fixes a bug where we wouldn't verify the commit-graph if the
config key was missing. This bug was introduced in
31b1de6a09 (commit-graph: turn on commit-graph by default, 2019-08-13),
where core.commitGraph was turned on by default.

Add tests to "t5318-commit-graph.sh" to verify that fsck checks the
commit-graph as expected for the 3 values of core.commitGraph. Also,
disable GIT_TEST_COMMIT_GRAPH in t/t0410-partial-clone.sh because some
test cases use fsck in ways that assume that commit-graph checking is
disabled.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 14:30:07 -07:00
ed41385ad6 Merge branch 'ab/ignore-replace-while-working-on-commit-graph' into gc/use-repo-settings
* ab/ignore-replace-while-working-on-commit-graph:
  commit-graph: don't consider "replace" objects with "verify"
  commit-graph tests: fix another graph_git_two_modes() helper
  commit-graph tests: fix error-hiding graph_git_two_modes() helper
2021-10-15 14:30:00 -07:00
ae39ba431a grep/pcre2: fix an edge case concerning ascii patterns and UTF-8 data
If we attempt to grep non-ascii log message text with an ascii pattern, we
run into the following issue:

    $ git log --color --author='.var.*Bjar' -1 origin/master | grep ^Author
    grep: (standard input): binary file matches

So, to fix this teach the grep code to use PCRE2_UTF, as long as the log
output is encoded in UTF-8.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 12:45:39 -07:00
095d112f8c commit-graph: don't consider "replace" objects with "verify"
Extend the code added in d6538246d3 (commit-graph: not compatible
with replace objects, 2018-08-20) which ignored replace objects in the
"write" command to ignore it in the "verify" command too.

We can just move this assignment to the cmd_commit_graph(), it
dispatches to "write" and "verify", and we're unlikely to ever get a
sub-command that would like to consider replace refs.

This will make tests added in eddc1f556c (mktag tests: test
update-ref and reachable fsck, 2021-06-17) pass in combination with
the "GIT_TEST_COMMIT_GRAPH" mode added in 859fdc0c3c (commit-graph:
define GIT_TEST_COMMIT_GRAPH, 2018-08-29), except that mode is
currently broken (but is being fixed concurrently). See the discussion
starting at [1].

1. https://lore.kernel.org/git/87wnmihswp.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 09:21:30 -07:00
a046aa38ca commit-graph tests: fix another graph_git_two_modes() helper
In 135a712375 (commit-graph: add --split option to builtin,
2019-06-18) this function was copy/pasted to the split commit-graph
tests, as in the preceding commit we need to fix this to use
&&-chaining, so it won't be hiding errors.

Unlike its sister function in "t5318-commit-graph.sh", which we got
lucky with, this one was hiding a real test failure. A tests added in
c523035cbd (commit-graph: allow cross-alternate chains, 2019-06-18)
has never worked as intended. Unlike most other graph_git_behavior
uses in this file it clones the repository into a sub-directory, so
we'll need to refer to "commits/6" as "origin/commits/6".

It's not easy to simply move the "graph_git_behavior" to the test
above it, since it itself spawns a "test_expect_success". Let's
instead add support to "graph_git_behavior()" and
"graph_git_two_modes()" to pass a "-C" argument to git.

We also need to add a "test -d fork" here, because otherwise we'll
fail on e.g.:

    GIT_SKIP_TESTS=t5324.13 ./t5324-split-commit-graph.sh

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 09:21:30 -07:00
3247919a75 commit-graph tests: fix error-hiding graph_git_two_modes() helper
The graph_git_two_modes() helper added in 177722b344 (commit:
integrate commit graph with commit parsing, 2018-04-10) didn't
&&-chain its "git commit-graph" invocations, which as can be seen with
SANITIZE=leak will happily mark tests as passing if both of these
commands die, since test_cmp() will be comparing two empty files.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-15 09:21:30 -07:00
6a5c337922 pretty: colorize pattern matches in commit messages
The "git log" command limits its output to the commits that contain strings
matched by a pattern when the "--grep=<pattern>" option is used, but unlike
output from "git grep -e <pattern>", the matches are not highlighted,
making them harder to spot.

Teach the pretty-printer code to highlight matches from the
"--grep=<pattern>", "--author=<pattern>" and "--committer=<pattern>"
options (to view the last one, you may have to ask for --pretty=fuller).

Also, it must be noted that we are effectively greping the content twice
(because it would be a hassle to rework the existing matching code to do
a /g match and then pass it all down to the coloring code), however it only
slows down "git log --author=^H" on this repository by around 1-2%
(compared to v2.33.0), so it should be a small enough slow down to justify
the addition of the feature.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-08 14:19:14 -07:00
3f566c4e69 grep: refactor next_match() and match_one_pattern() for external use
These changes are made in preparation of, the colorization support for the
"git log" subcommands that, rely on regex functionality (i.e. "--author",
"--committer" and "--grep"). These changes are necessary primarily because
match_one_pattern() expects header lines to be prefixed, however, in
pretty, the prefixes are stripped from the lines because the name-email
pairs need to go through additional parsing, before they can be printed and
because next_match() doesn't handle the case of
"ctx == GREP_CONTEXT_HEAD" at all. So, teach next_match() how to handle the
new case and move match_one_pattern()'s core logic to
headerless_match_one_pattern() while preserving match_one_pattern()'s uses
that depend on the additional processing.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-29 13:23:11 -07:00
28ecef4c84 Merge branch 'jk/grep-haystack-is-read-only' into hm/paint-hits-in-log-grep
* jk/grep-haystack-is-read-only:
  grep: store grep_source buffer as const
  grep: mark "haystack" buffers as const
  grep: stop modifying buffer in grep_source_1()
  grep: stop modifying buffer in show_line()
  grep: stop modifying buffer in strip_timestamp
2021-09-23 09:47:05 -07:00
25 changed files with 416 additions and 85 deletions

View File

@ -79,6 +79,10 @@ UI, Workflows & Features
* Use ssh public crypto for object and push-cert signing.
* "git log --grep=string --author=name" learns to highlight hits just
like "git grep string" does.
Performance, Internal Implementation, Development Support etc.
@ -392,6 +396,11 @@ Fixes since v2.33
* Fix long-standing shell syntax error in the completion script.
(merge 46b0585286 re/completion-fix-test-equality later to maint).
* Teach "git commit-graph" command not to allow using replace objects
at all, as we do not use the commit-graph at runtime when we see
object replacement.
(merge 095d112f8c ab/ignore-replace-while-working-on-commit-graph later to maint).
* Other code cleanup, docfix, build fix, etc.
(merge f188160be9 ab/bundle-remove-verbose-option later to maint).
(merge 8c6b4332b4 rs/close-pack-leakfix later to maint).
@ -407,3 +416,5 @@ Fixes since v2.33
(merge 1c720357ce ab/test-lib-diff-cleanup later to maint).
(merge 6b615dbece ks/submodule-add-message-fix later to maint).
(merge 82a57cd13f ma/doc-git-version later to maint).
(merge 203eb8381a jc/doc-format-patch-clarify-auto-base later to maint).
(merge 559664c792 ab/test-lib later to maint).

View File

@ -105,9 +105,12 @@ color.grep.<slot>::
`matchContext`;;
matching text in context lines
`matchSelected`;;
matching text in selected lines
matching text in selected lines. Also, used to customize the following
linkgit:git-log[1] subcommands: `--grep`, `--author` and `--committer`.
`selected`;;
non-matching text in selected lines
non-matching text in selected lines. Also, used to customize the
following linkgit:git-log[1] subcommands: `--grep`, `--author` and
`--committer`.
`separator`;;
separators between fields on a line (`:`, `-`, and `=`)
and between hunks (`--`)

View File

@ -689,10 +689,10 @@ You can also use `git format-patch --base=P -3 C` to generate patches
for A, B and C, and the identifiers for P, X, Y, Z are appended at the
end of the first message.
If set `--base=auto` in cmdline, it will track base commit automatically,
the base commit will be the merge base of tip commit of the remote-tracking
If set `--base=auto` in cmdline, it will automatically compute
the base commit as the merge base of tip commit of the remote-tracking
branch and revision-range specified in cmdline.
For a local branch, you need to track a remote branch by `git branch
For a local branch, you need to make it to track a remote branch by `git branch
--set-upstream-to` before using this option.
EXAMPLES

View File

@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
DEF_VER=v2.34.0-rc0
DEF_VER=v2.34.0-rc1
LF='
'

View File

@ -263,7 +263,6 @@ static int graph_write(int argc, const char **argv)
git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
read_replace_refs = 0;
odb = find_odb(the_repository, opts.obj_dir);
if (opts.reachable) {
@ -318,6 +317,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
if (!argc)
goto usage;
read_replace_refs = 0;
save_commit_buffer = 0;
if (!strcmp(argv[0], "verify"))

View File

@ -835,6 +835,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
fsck_enable_object_names(&fsck_walk_options);
git_config(git_fsck_config, &fsck_obj_options);
prepare_repo_settings(the_repository);
if (connectivity_only) {
for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
@ -940,7 +941,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
check_connectivity();
if (!git_config_get_bool("core.commitgraph", &i) && i) {
if (the_repository->settings.core_commit_graph) {
struct child_process commit_graph_verify = CHILD_PROCESS_INIT;
const char *verify_argv[] = { "commit-graph", "verify", NULL, NULL, NULL };
@ -956,7 +957,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
}
}
if (!git_config_get_bool("core.multipackindex", &i) && i) {
if (the_repository->settings.core_multi_pack_index) {
struct child_process midx_verify = CHILD_PROCESS_INIT;
const char *midx_argv[] = { "multi-pack-index", "verify", NULL, NULL, NULL };

View File

@ -1049,12 +1049,11 @@ static int maintenance_task_loose_objects(struct maintenance_run_opts *opts)
static int incremental_repack_auto_condition(void)
{
struct packed_git *p;
int enabled;
int incremental_repack_auto_limit = 10;
int count = 0;
if (git_config_get_bool("core.multiPackIndex", &enabled) ||
!enabled)
prepare_repo_settings(the_repository);
if (!the_repository->settings.core_multi_pack_index)
return 0;
git_config_get_int("maintenance.incremental-repack.auto",

View File

@ -1486,7 +1486,7 @@ static void rename_tmp_packfile(const char **final_name,
if (!*final_name)
*final_name = odb_pack_name(name, hash, ext);
if (finalize_object_file(curr_name, *final_name))
die(_("unable to rename temporary '*.%s' file to '%s"),
die(_("unable to rename temporary '*.%s' file to '%s'"),
ext, *final_name);
} else if (make_read_only_if_same) {
chmod(*final_name, 0444);

2
dir.c
View File

@ -1294,7 +1294,7 @@ int match_pathname(const char *pathname, int pathlen,
* then our prefix match is all we need; we
* do not need to call fnmatch at all.
*/
if (!patternlen && (!namelen || (flags & PATTERN_FLAG_MUSTBEDIR)))
if (!patternlen && !namelen)
return 1;
}

View File

@ -387,10 +387,6 @@ static void parse_ssh_output(struct signature_check *sigc)
line = to_free = xmemdupz(sigc->output, strcspn(sigc->output, "\n"));
if (skip_prefix(line, "Good \"git\" signature for ", &line)) {
/* Valid signature and known principal */
sigc->result = 'G';
sigc->trust_level = TRUST_FULLY;
/* Search for the last "with" to get the full principal */
principal = line;
do {
@ -398,6 +394,12 @@ static void parse_ssh_output(struct signature_check *sigc)
if (search)
line = search + 1;
} while (search != NULL);
if (line == principal)
goto cleanup;
/* Valid signature and known principal */
sigc->result = 'G';
sigc->trust_level = TRUST_FULLY;
sigc->signer = xmemdupz(principal, line - principal - 1);
} else if (skip_prefix(line, "Good \"git\" signature with ", &line)) {
/* Valid signature, but key unknown */
@ -407,9 +409,9 @@ static void parse_ssh_output(struct signature_check *sigc)
goto cleanup;
}
key = strstr(line, "key");
key = strstr(line, "key ");
if (key) {
sigc->fingerprint = xstrdup(strstr(line, "key") + 4);
sigc->fingerprint = xstrdup(strstr(line, "key ") + 4);
sigc->key = xstrdup(sigc->fingerprint);
} else {
/*
@ -775,7 +777,7 @@ static const char *get_default_ssh_signing_key(void)
if (keys[0] && starts_with(keys[0]->buf, "ssh-")) {
default_key = strbuf_detach(keys[0], NULL);
} else {
warning(_("gpg.ssh.defaultKeycommand succeeded but returned no keys: %s %s"),
warning(_("gpg.ssh.defaultKeyCommand succeeded but returned no keys: %s %s"),
key_stderr.buf, key_stdout.buf);
}

85
grep.c
View File

@ -382,8 +382,10 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
}
options |= PCRE2_CASELESS;
}
if (!opt->ignore_locale && is_utf8_locale() && has_non_ascii(p->pattern) &&
!(!opt->ignore_case && (p->fixed || p->is_fixed)))
if ((!opt->ignore_locale && !has_non_ascii(p->pattern)) ||
(!opt->ignore_locale && is_utf8_locale() &&
has_non_ascii(p->pattern) && !(!opt->ignore_case &&
(p->fixed || p->is_fixed))))
options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
#ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER
@ -944,10 +946,10 @@ static struct {
{ "reflog ", 7 },
};
static int match_one_pattern(struct grep_pat *p,
const char *bol, const char *eol,
enum grep_context ctx,
regmatch_t *pmatch, int eflags)
static int headerless_match_one_pattern(struct grep_pat *p,
const char *bol, const char *eol,
enum grep_context ctx,
regmatch_t *pmatch, int eflags)
{
int hit = 0;
const char *start = bol;
@ -956,25 +958,6 @@ static int match_one_pattern(struct grep_pat *p,
((p->token == GREP_PATTERN_HEAD) != (ctx == GREP_CONTEXT_HEAD)))
return 0;
if (p->token == GREP_PATTERN_HEAD) {
const char *field;
size_t len;
assert(p->field < ARRAY_SIZE(header_field));
field = header_field[p->field].field;
len = header_field[p->field].len;
if (strncmp(bol, field, len))
return 0;
bol += len;
switch (p->field) {
case GREP_HEADER_AUTHOR:
case GREP_HEADER_COMMITTER:
strip_timestamp(bol, &eol);
break;
default:
break;
}
}
again:
hit = patmatch(p, bol, eol, pmatch, eflags);
@ -1025,6 +1008,36 @@ static int match_one_pattern(struct grep_pat *p,
return hit;
}
static int match_one_pattern(struct grep_pat *p,
const char *bol, const char *eol,
enum grep_context ctx, regmatch_t *pmatch,
int eflags)
{
const char *field;
size_t len;
if (p->token == GREP_PATTERN_HEAD) {
assert(p->field < ARRAY_SIZE(header_field));
field = header_field[p->field].field;
len = header_field[p->field].len;
if (strncmp(bol, field, len))
return 0;
bol += len;
switch (p->field) {
case GREP_HEADER_AUTHOR:
case GREP_HEADER_COMMITTER:
strip_timestamp(bol, &eol);
break;
default:
break;
}
}
return headerless_match_one_pattern(p, bol, eol, ctx, pmatch, eflags);
}
static int match_expr_eval(struct grep_opt *opt, struct grep_expr *x,
const char *bol, const char *eol,
enum grep_context ctx, ssize_t *col,
@ -1143,7 +1156,7 @@ static int match_next_pattern(struct grep_pat *p,
{
regmatch_t match;
if (!match_one_pattern(p, bol, eol, ctx, &match, eflags))
if (!headerless_match_one_pattern(p, bol, eol, ctx, &match, eflags))
return 0;
if (match.rm_so < 0 || match.rm_eo < 0)
return 0;
@ -1158,19 +1171,26 @@ static int match_next_pattern(struct grep_pat *p,
return 1;
}
static int next_match(struct grep_opt *opt,
const char *bol, const char *eol,
enum grep_context ctx, regmatch_t *pmatch, int eflags)
int grep_next_match(struct grep_opt *opt,
const char *bol, const char *eol,
enum grep_context ctx, regmatch_t *pmatch,
enum grep_header_field field, int eflags)
{
struct grep_pat *p;
int hit = 0;
pmatch->rm_so = pmatch->rm_eo = -1;
if (bol < eol) {
for (p = opt->pattern_list; p; p = p->next) {
for (p = ((ctx == GREP_CONTEXT_HEAD)
? opt->header_list : opt->pattern_list);
p; p = p->next) {
switch (p->token) {
case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD:
if ((field != GREP_HEADER_FIELD_MAX) &&
(p->field != field))
continue;
/* fall thru */
case GREP_PATTERN: /* atom */
case GREP_PATTERN_BODY:
hit |= match_next_pattern(p, bol, eol, ctx,
pmatch, eflags);
@ -1261,7 +1281,8 @@ static void show_line(struct grep_opt *opt,
else if (sign == '=')
line_color = opt->colors[GREP_COLOR_FUNCTION];
}
while (next_match(opt, bol, eol, ctx, &match, eflags)) {
while (grep_next_match(opt, bol, eol, ctx, &match,
GREP_HEADER_FIELD_MAX, eflags)) {
if (match.rm_so == match.rm_eo)
break;

9
grep.h
View File

@ -191,6 +191,15 @@ void compile_grep_patterns(struct grep_opt *opt);
void free_grep_patterns(struct grep_opt *opt);
int grep_buffer(struct grep_opt *opt, const char *buf, unsigned long size);
/* The field parameter is only used to filter header patterns
* (where appropriate). If filtering isn't desirable
* GREP_HEADER_FIELD_MAX should be supplied.
*/
int grep_next_match(struct grep_opt *opt,
const char *bol, const char *eol,
enum grep_context ctx, regmatch_t *pmatch,
enum grep_header_field field, int eflags);
struct grep_source {
char *name;

101
pretty.c
View File

@ -431,6 +431,52 @@ const char *show_ident_date(const struct ident_split *ident,
return show_date(date, tz, mode);
}
static inline void strbuf_add_with_color(struct strbuf *sb, const char *color,
const char *buf, size_t buflen)
{
strbuf_addstr(sb, color);
strbuf_add(sb, buf, buflen);
if (*color)
strbuf_addstr(sb, GIT_COLOR_RESET);
}
static void append_line_with_color(struct strbuf *sb, struct grep_opt *opt,
const char *line, size_t linelen,
int color, enum grep_context ctx,
enum grep_header_field field)
{
const char *buf, *eol, *line_color, *match_color;
regmatch_t match;
int eflags = 0;
buf = line;
eol = buf + linelen;
if (!opt || !want_color(color) || opt->invert)
goto end;
line_color = opt->colors[GREP_COLOR_SELECTED];
match_color = opt->colors[GREP_COLOR_MATCH_SELECTED];
while (grep_next_match(opt, buf, eol, ctx, &match, field, eflags)) {
if (match.rm_so == match.rm_eo)
break;
strbuf_add_with_color(sb, line_color, buf, match.rm_so);
strbuf_add_with_color(sb, match_color, buf + match.rm_so,
match.rm_eo - match.rm_so);
buf += match.rm_eo;
eflags = REG_NOTBOL;
}
if (eflags)
strbuf_add_with_color(sb, line_color, buf, eol - buf);
else {
end:
strbuf_add(sb, buf, eol - buf);
}
}
void pp_user_info(struct pretty_print_context *pp,
const char *what, struct strbuf *sb,
const char *line, const char *encoding)
@ -496,9 +542,26 @@ void pp_user_info(struct pretty_print_context *pp,
strbuf_addch(sb, '\n');
strbuf_addf(sb, " <%.*s>\n", (int)maillen, mailbuf);
} else {
strbuf_addf(sb, "%s: %.*s%.*s <%.*s>\n", what,
(pp->fmt == CMIT_FMT_FULLER) ? 4 : 0, " ",
(int)namelen, namebuf, (int)maillen, mailbuf);
struct strbuf id = STRBUF_INIT;
enum grep_header_field field = GREP_HEADER_FIELD_MAX;
struct grep_opt *opt = pp->rev ? &pp->rev->grep_filter : NULL;
if (!strcmp(what, "Author"))
field = GREP_HEADER_AUTHOR;
else if (!strcmp(what, "Commit"))
field = GREP_HEADER_COMMITTER;
strbuf_addf(sb, "%s: ", what);
if (pp->fmt == CMIT_FMT_FULLER)
strbuf_addchars(sb, ' ', 4);
strbuf_addf(&id, "%.*s <%.*s>", (int)namelen, namebuf,
(int)maillen, mailbuf);
append_line_with_color(sb, opt, id.buf, id.len, pp->color,
GREP_CONTEXT_HEAD, field);
strbuf_addch(sb, '\n');
strbuf_release(&id);
}
switch (pp->fmt) {
@ -1935,8 +1998,9 @@ static int pp_utf8_width(const char *start, const char *end)
return width;
}
static void strbuf_add_tabexpand(struct strbuf *sb, int tabwidth,
const char *line, int linelen)
static void strbuf_add_tabexpand(struct strbuf *sb, struct grep_opt *opt,
int color, int tabwidth, const char *line,
int linelen)
{
const char *tab;
@ -1953,7 +2017,9 @@ static void strbuf_add_tabexpand(struct strbuf *sb, int tabwidth,
break;
/* Output the data .. */
strbuf_add(sb, line, tab - line);
append_line_with_color(sb, opt, line, tab - line, color,
GREP_CONTEXT_BODY,
GREP_HEADER_FIELD_MAX);
/* .. and the de-tabified tab */
strbuf_addchars(sb, ' ', tabwidth - (width % tabwidth));
@ -1968,7 +2034,8 @@ static void strbuf_add_tabexpand(struct strbuf *sb, int tabwidth,
* worrying about width - there's nothing more to
* align.
*/
strbuf_add(sb, line, linelen);
append_line_with_color(sb, opt, line, linelen, color, GREP_CONTEXT_BODY,
GREP_HEADER_FIELD_MAX);
}
/*
@ -1980,11 +2047,16 @@ static void pp_handle_indent(struct pretty_print_context *pp,
struct strbuf *sb, int indent,
const char *line, int linelen)
{
struct grep_opt *opt = pp->rev ? &pp->rev->grep_filter : NULL;
strbuf_addchars(sb, ' ', indent);
if (pp->expand_tabs_in_log)
strbuf_add_tabexpand(sb, pp->expand_tabs_in_log, line, linelen);
strbuf_add_tabexpand(sb, opt, pp->color, pp->expand_tabs_in_log,
line, linelen);
else
strbuf_add(sb, line, linelen);
append_line_with_color(sb, opt, line, linelen, pp->color,
GREP_CONTEXT_BODY,
GREP_HEADER_FIELD_MAX);
}
static int is_mboxrd_from(const char *line, int len)
@ -2002,7 +2074,9 @@ void pp_remainder(struct pretty_print_context *pp,
struct strbuf *sb,
int indent)
{
struct grep_opt *opt = pp->rev ? &pp->rev->grep_filter : NULL;
int first = 1;
for (;;) {
const char *line = *msg_p;
int linelen = get_one_line(line);
@ -2023,14 +2097,17 @@ void pp_remainder(struct pretty_print_context *pp,
if (indent)
pp_handle_indent(pp, sb, indent, line, linelen);
else if (pp->expand_tabs_in_log)
strbuf_add_tabexpand(sb, pp->expand_tabs_in_log,
line, linelen);
strbuf_add_tabexpand(sb, opt, pp->color,
pp->expand_tabs_in_log, line,
linelen);
else {
if (pp->fmt == CMIT_FMT_MBOXRD &&
is_mboxrd_from(line, linelen))
strbuf_addch(sb, '>');
strbuf_add(sb, line, linelen);
append_line_with_color(sb, opt, line, linelen,
pp->color, GREP_CONTEXT_BODY,
GREP_HEADER_FIELD_MAX);
}
strbuf_addch(sb, '\n');
}

View File

@ -1037,7 +1037,7 @@ int verify_ref_format(struct ref_format *format)
format->quote_style == QUOTE_TCL) &&
used_atom[at].atom_type == ATOM_RAW &&
used_atom[at].u.raw_data.option == RAW_BARE)
die(_("--format=%.*s cannot be used with"
die(_("--format=%.*s cannot be used with "
"--python, --shell, --tcl"), (int)(ep - sp - 2), sp + 2);
cp = ep + 1;

View File

@ -997,7 +997,9 @@ static int run_git_commit(const char *defmsg,
cmd.git_cmd = 1;
if (is_rebase_i(opts) && !(!defmsg && (flags & AMEND_MSG)) &&
if (is_rebase_i(opts) &&
((opts->committer_date_is_author_date && !opts->ignore_date) ||
!(!defmsg && (flags & AMEND_MSG))) &&
read_env_script(&cmd.env_array)) {
const char *gpg_opt = gpg_sign_opt_quoted(opts);

View File

@ -803,6 +803,32 @@ test_expect_success 'existing directory and file' '
grep top-level-dir actual
'
test_expect_success 'exact prefix matching (with root)' '
test_when_finished rm -r a &&
mkdir -p a/git a/git-foo &&
touch a/git/foo a/git-foo/bar &&
echo /git/ >a/.gitignore &&
git check-ignore a/git a/git/foo a/git-foo a/git-foo/bar >actual &&
cat >expect <<-\EOF &&
a/git
a/git/foo
EOF
test_cmp expect actual
'
test_expect_success 'exact prefix matching (without root)' '
test_when_finished rm -r a &&
mkdir -p a/git a/git-foo &&
touch a/git/foo a/git-foo/bar &&
echo git/ >a/.gitignore &&
git check-ignore a/git a/git/foo a/git-foo a/git-foo/bar >actual &&
cat >expect <<-\EOF &&
a/git
a/git/foo
EOF
test_cmp expect actual
'
############################################################################
#
# test whitespace handling

View File

@ -6,6 +6,10 @@ test_description='partial clone'
# missing promisor objects cause repacks which write bitmaps to fail
GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0
# When enabled, some commands will write commit-graphs. This causes fsck
# to fail when delete_object() is called because fsck will attempt to
# verify the out-of-sync commit graph.
GIT_TEST_COMMIT_GRAPH=0
delete_object () {
rm $1/.git/objects/$(echo $2 | sed -e 's|^..|&/|')
@ -322,7 +326,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' '
git -C repo config core.repositoryformatversion 1 &&
git -C repo config extensions.partialclone "arbitrary string" &&
GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out &&
git -C repo rev-list --exclude-promisor-objects --objects bar >out &&
grep $(git -C repo rev-parse bar) out &&
! grep $FOO out
'

View File

@ -82,6 +82,20 @@ test_expect_success '--committer-date-is-author-date works with merge backend' '
test_ctime_is_atime -1
'
test_expect_success '--committer-date-is-author-date works when rewording' '
GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
(
set_fake_editor &&
FAKE_COMMIT_MESSAGE=edited \
FAKE_LINES="reword 1" \
git rebase -i --committer-date-is-author-date HEAD^
) &&
test_write_lines edited "" >expect &&
git log --format="%B" -1 >actual &&
test_cmp expect actual &&
test_ctime_is_atime -1
'
test_expect_success '--committer-date-is-author-date works with rebase -r' '
git checkout side &&
GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 &&
@ -155,6 +169,21 @@ test_expect_success '--reset-author-date with --committer-date-is-author-date wo
test_atime_is_ignored -2
'
test_expect_success 'reset-author-date with --committer-date-is-author-date works when rewording' '
GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author &&
(
set_fake_editor &&
FAKE_COMMIT_MESSAGE=edited \
FAKE_LINES="reword 1" \
git rebase -i --committer-date-is-author-date \
--reset-author-date HEAD^
) &&
test_write_lines edited "" >expect &&
git log --format="%B" -1 >actual &&
test_cmp expect actual &&
test_atime_is_ignored -1
'
test_expect_success '--reset-author-date --committer-date-is-author-date works when forking merge' '
GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \
PATH="./test-bin:$PATH" git rebase -i --strategy=test \

View File

@ -449,6 +449,57 @@ test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurati
)
'
test_expect_success 'log --author' '
cat >expect <<-\EOF &&
Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
EOF
git log -1 --color=always --author="A U" >log &&
grep Author log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expect actual
'
test_expect_success 'log --committer' '
cat >expect <<-\EOF &&
Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
EOF
git log -1 --color=always --pretty=fuller --committer="example" >log &&
grep "Commit:" log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expect actual
'
test_expect_success 'log -i --grep with color' '
cat >expect <<-\EOF &&
<BOLD;RED>Sec<RESET>ond
<BOLD;RED>sec<RESET>ond
EOF
git log --color=always -i --grep=^sec >log &&
grep -i sec log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expect actual
'
test_expect_success '-c color.grep.selected log --grep' '
cat >expect <<-\EOF &&
<GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
EOF
git -c color.grep.selected="green" log --color=always --grep=ir >log &&
grep ir log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expect actual
'
test_expect_success '-c color.grep.matchSelected log --grep' '
cat >expect <<-\EOF &&
<BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
EOF
git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
grep al log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expect actual
'
cat > expect <<EOF
* Second
* sixth

View File

@ -5,7 +5,6 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-bundle.sh
. "$TEST_DIRECTORY"/lib-bitmap.sh
# t5310 deals only with single-pack bitmaps, so don't write MIDX bitmaps in

View File

@ -70,8 +70,8 @@ test_expect_success 'create commits and repack' '
'
graph_git_two_modes() {
git -c core.commitGraph=true $1 >output
git -c core.commitGraph=false $1 >expect
git -c core.commitGraph=true $1 >output &&
git -c core.commitGraph=false $1 >expect &&
test_cmp expect output
}
@ -385,6 +385,7 @@ test_expect_success 'replace-objects invalidates commit-graph' '
git commit-graph write --reachable &&
test_path_is_file .git/objects/info/commit-graph &&
git replace HEAD~1 HEAD~2 &&
graph_git_two_modes "commit-graph verify" &&
git -c core.commitGraph=false log >expect &&
git -c core.commitGraph=true log >actual &&
test_cmp expect actual &&
@ -693,12 +694,33 @@ test_expect_success 'detect incorrect chunk count' '
$GRAPH_CHUNK_LOOKUP_OFFSET
'
test_expect_success 'git fsck (checks commit-graph)' '
test_expect_success 'git fsck (checks commit-graph when config set to true)' '
cd "$TRASH_DIRECTORY/full" &&
git fsck &&
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
"incorrect checksum" &&
cp commit-graph-pre-write-test $objdir/info/commit-graph &&
test_must_fail git -c core.commitGraph=true fsck
'
test_expect_success 'git fsck (ignores commit-graph when config set to false)' '
cd "$TRASH_DIRECTORY/full" &&
git fsck &&
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
"incorrect checksum" &&
cp commit-graph-pre-write-test $objdir/info/commit-graph &&
git -c core.commitGraph=false fsck
'
test_expect_success 'git fsck (checks commit-graph when config unset)' '
cd "$TRASH_DIRECTORY/full" &&
test_when_finished "git config core.commitGraph true" &&
git fsck &&
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
"incorrect checksum" &&
test_unconfig core.commitGraph &&
cp commit-graph-pre-write-test $objdir/info/commit-graph &&
test_must_fail git fsck
'

View File

@ -467,7 +467,10 @@ test_expect_success 'verify incorrect offset' '
test_expect_success 'git-fsck incorrect offset' '
corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \
"incorrect object offset" \
"git -c core.multipackindex=true fsck"
"git -c core.multiPackIndex=true fsck" &&
test_unconfig core.multiPackIndex &&
test_must_fail git fsck &&
git -c core.multiPackIndex=false fsck
'
test_expect_success 'corrupt MIDX is not reused' '

View File

@ -55,8 +55,8 @@ test_expect_success 'create commits and write commit-graph' '
'
graph_git_two_modes() {
git -c core.commitGraph=true $1 >output
git -c core.commitGraph=false $1 >expect
git ${2:+ -C "$2"} -c core.commitGraph=true $1 >output &&
git ${2:+ -C "$2"} -c core.commitGraph=false $1 >expect &&
test_cmp expect output
}
@ -64,12 +64,13 @@ graph_git_behavior() {
MSG=$1
BRANCH=$2
COMPARE=$3
DIR=$4
test_expect_success "check normal git operations: $MSG" '
graph_git_two_modes "log --oneline $BRANCH" &&
graph_git_two_modes "log --topo-order $BRANCH" &&
graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
graph_git_two_modes "branch -vv" &&
graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
graph_git_two_modes "log --oneline $BRANCH" "$DIR" &&
graph_git_two_modes "log --topo-order $BRANCH" "$DIR" &&
graph_git_two_modes "log --graph $COMPARE..$BRANCH" "$DIR" &&
graph_git_two_modes "branch -vv" "$DIR" &&
graph_git_two_modes "merge-base -a $BRANCH $COMPARE" "$DIR"
'
}
@ -187,7 +188,10 @@ test_expect_success 'create fork and chain across alternate' '
)
'
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
if test -d fork
then
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 origin/commits/6 "fork"
fi
test_expect_success 'test merge stragety constants' '
git clone . merge-2 &&

View File

@ -53,6 +53,54 @@ test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' '
test_cmp expected actual
'
test_expect_success GETTEXT_LOCALE,PCRE 'log --author with an ascii pattern on UTF-8 data' '
cat >expected <<-\EOF &&
Author: <BOLD;RED>À Ú Thor<RESET> <author@example.com>
EOF
test_write_lines "forth" >file4 &&
git add file4 &&
git commit --author="À Ú Thor <author@example.com>" -m sécond &&
git log -1 --color=always --perl-regexp --author=".*Thor" >log &&
grep Author log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expected actual
'
test_expect_success GETTEXT_LOCALE,PCRE 'log --committer with an ascii pattern on ISO-8859-1 data' '
cat >expected <<-\EOF &&
Commit: Ç<BOLD;RED> O Mîtter <committer@example.com><RESET>
EOF
test_write_lines "fifth" >file5 &&
git add file5 &&
GIT_COMMITTER_NAME="Ç O Mîtter" &&
GIT_COMMITTER_EMAIL="committer@example.com" &&
git -c i18n.commitEncoding=latin1 commit -m thïrd &&
git -c i18n.logOutputEncoding=latin1 log -1 --pretty=fuller --color=always --perl-regexp --committer=" O.*" >log &&
grep Commit: log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expected actual
'
test_expect_success GETTEXT_LOCALE,PCRE 'log --grep with an ascii pattern on UTF-8 data' '
cat >expected <<-\EOF &&
sé<BOLD;RED>con<RESET>d
EOF
git log -1 --color=always --perl-regexp --grep="con" >log &&
grep con log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expected actual
'
test_expect_success GETTEXT_LOCALE,PCRE 'log --grep with an ascii pattern on ISO-8859-1 data' '
cat >expected <<-\EOF &&
<BOLD;RED>thïrd<RESET>
EOF
git -c i18n.logOutputEncoding=latin1 log -1 --color=always --perl-regexp --grep="th.*rd" >log &&
grep "th.*rd" log >actual.raw &&
test_decode_color <actual.raw >actual &&
test_cmp expected actual
'
test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data' '
printf "\\200\\n" >invalid-0x80 &&
echo "ævar" >expected &&

View File

@ -336,15 +336,15 @@ test_expect_success EXPENSIVE 'incremental-repack 2g limit' '
--no-progress --batch-size=2147483647 <run-2g.txt
'
test_expect_success 'maintenance.incremental-repack.auto' '
run_incremental_repack_and_verify () {
test_commit A &&
git repack -adk &&
git config core.multiPackIndex true &&
git multi-pack-index write &&
GIT_TRACE2_EVENT="$(pwd)/midx-init.txt" git \
-c maintenance.incremental-repack.auto=1 \
maintenance run --auto --task=incremental-repack 2>/dev/null &&
test_subcommand ! git multi-pack-index write --no-progress <midx-init.txt &&
test_commit A &&
test_commit B &&
git pack-objects --revs .git/objects/pack/pack <<-\EOF &&
HEAD
^HEAD~1
@ -353,7 +353,7 @@ test_expect_success 'maintenance.incremental-repack.auto' '
-c maintenance.incremental-repack.auto=2 \
maintenance run --auto --task=incremental-repack 2>/dev/null &&
test_subcommand ! git multi-pack-index write --no-progress <trace-A &&
test_commit B &&
test_commit C &&
git pack-objects --revs .git/objects/pack/pack <<-\EOF &&
HEAD
^HEAD~1
@ -362,6 +362,26 @@ test_expect_success 'maintenance.incremental-repack.auto' '
-c maintenance.incremental-repack.auto=2 \
maintenance run --auto --task=incremental-repack 2>/dev/null &&
test_subcommand git multi-pack-index write --no-progress <trace-B
}
test_expect_success 'maintenance.incremental-repack.auto' '
rm -rf incremental-repack-true &&
git init incremental-repack-true &&
(
cd incremental-repack-true &&
git config core.multiPackIndex true &&
run_incremental_repack_and_verify
)
'
test_expect_success 'maintenance.incremental-repack.auto (when config is unset)' '
rm -rf incremental-repack-unset &&
git init incremental-repack-unset &&
(
cd incremental-repack-unset &&
test_unconfig core.multiPackIndex &&
run_incremental_repack_and_verify
)
'
test_expect_success 'pack-refs task' '