Skip to content

Commit 4cd84b9

Browse files
authored
Merge branch 'master' into repo-toplevel
2 parents c239cac + cf2139f commit 4cd84b9

34 files changed

Lines changed: 800 additions & 94 deletions

Documentation/RelNotes/2.54.0.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ UI, Workflows & Features
104104
line number when it encounters a corrupt patch, and correctly
105105
resets the line counter when processing multiple patch files.
106106

107+
* The HTTP transport learned to react to "429 Too Many Requests".
108+
109+
* "git repo info -h" and "git repo structure -h" limit their help output
110+
to the part that is specific to the subcommand.
111+
107112

108113
Performance, Internal Implementation, Development Support etc.
109114
--------------------------------------------------------------
@@ -253,6 +258,15 @@ Performance, Internal Implementation, Development Support etc.
253258
of branches interpret_branch_name() function has been changed to
254259
use a dedicated enum type.
255260
261+
* Various updates to contrib/diff-highlight, including documentation
262+
updates, test improvements, and color configuration handling.
263+
264+
* Code paths that loop over another array to push each element into a
265+
strvec have been rewritten to use strvec_pushv() instead.
266+
267+
* In case homebrew breaks REG_ENHANCED again, leave a in-code comment
268+
to suggest use of our replacement regex as a workaround.
269+
256270
257271
Fixes since v2.53
258272
-----------------
@@ -420,6 +434,17 @@ Fixes since v2.53
420434
* "git apply -p<n>" parses <n> more carefully now.
421435
(merge d05d84c5f5 mf/apply-p-no-atoi later to maint).
422436

437+
* A test to run a .bat file with whitespaces in the name with arguments
438+
with whitespaces in them was flaky in that sometimes it got killed
439+
before it produced expected side effects, which has been rewritten to
440+
make it more robust.
441+
(merge 3ad4921838 jk/t0061-bat-test-update later to maint).
442+
443+
* "git ls-remote '+refs/tags/*:refs/tags/*' https://..." run outside a
444+
repository would dereference a NULL while trying to see if the given
445+
refspec is a single-object refspec, which has been corrected.
446+
(merge 4e5dc601dd kj/refspec-parsing-outside-repository later to maint).
447+
423448
* Other code cleanup, docfix, build fix, etc.
424449
(merge d79fff4a11 jk/remote-tracking-ref-leakfix later to maint).
425450
(merge 7a747f972d dd/t5403-modernise later to maint).

Documentation/config/http.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,32 @@ http.keepAliveCount::
315315
unset, curl's default value is used. Can be overridden by the
316316
`GIT_HTTP_KEEPALIVE_COUNT` environment variable.
317317

318+
http.retryAfter::
319+
Default wait time in seconds before retrying when a server returns
320+
HTTP 429 (Too Many Requests) without a Retry-After header.
321+
Defaults to 0 (retry immediately). When a Retry-After header is
322+
present, its value takes precedence over this setting; however,
323+
automatic use of the server-provided `Retry-After` header requires
324+
libcurl 7.66.0 or later. On older versions, configure this setting
325+
manually to control the retry delay. Can be overridden by the
326+
`GIT_HTTP_RETRY_AFTER` environment variable.
327+
See also `http.maxRetries` and `http.maxRetryTime`.
328+
329+
http.maxRetries::
330+
Maximum number of times to retry after receiving HTTP 429 (Too Many
331+
Requests) responses. Set to 0 (the default) to disable retries.
332+
Can be overridden by the `GIT_HTTP_MAX_RETRIES` environment variable.
333+
See also `http.retryAfter` and `http.maxRetryTime`.
334+
335+
http.maxRetryTime::
336+
Maximum time in seconds to wait for a single retry attempt when
337+
handling HTTP 429 (Too Many Requests) responses. If the server
338+
requests a delay (via Retry-After header) or if `http.retryAfter`
339+
is configured with a value that exceeds this maximum, Git will fail
340+
immediately rather than waiting. Default is 300 seconds (5 minutes).
341+
Can be overridden by the `GIT_HTTP_MAX_RETRY_TIME` environment
342+
variable. See also `http.retryAfter` and `http.maxRetries`.
343+
318344
http.noEPSV::
319345
A boolean which disables using of EPSV ftp command by curl.
320346
This can be helpful with some "poor" ftp servers which don't

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ static void am_append_signoff(struct am_state *state)
11881188
{
11891189
struct strbuf sb = STRBUF_INIT;
11901190

1191-
strbuf_attach(&sb, state->msg, state->msg_len, state->msg_len);
1191+
strbuf_attach(&sb, state->msg, state->msg_len, state->msg_len + 1);
11921192
append_signoff(&sb, 0, 0);
11931193
state->msg = strbuf_detach(&sb, &state->msg_len);
11941194
}

builtin/fast-import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3307,7 +3307,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
33073307
cat_blob_write("\n", 1);
33083308
if (oe && oe->pack_id == pack_id) {
33093309
last_blob.offset = oe->idx.offset;
3310-
strbuf_attach(&last_blob.data, buf, size, size);
3310+
strbuf_attach(&last_blob.data, buf, size, size + 1);
33113311
last_blob.depth = oe->depth;
33123312
} else
33133313
free(buf);

builtin/rebase.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
182182

183183
replay.signoff = opts->signoff;
184184

185-
for (size_t i = 0; i < opts->trailer_args.nr; i++)
186-
strvec_push(&replay.trailer_args, opts->trailer_args.v[i]);
185+
strvec_pushv(&replay.trailer_args, opts->trailer_args.v);
187186

188187
replay.allow_ff = !(opts->flags & REBASE_FORCE);
189188
if (opts->allow_rerere_autoupdate)

builtin/repo.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@
2020
#include "tree-walk.h"
2121
#include "utf8.h"
2222

23+
#define REPO_INFO_USAGE \
24+
"git repo info [--format=(lines|nul) | -z] [--all | <key>...]", \
25+
"git repo info --keys [--format=(lines|nul) | -z]"
26+
27+
#define REPO_STRUCTURE_USAGE \
28+
"git repo structure [--format=(table|lines|nul) | -z]"
29+
2330
static const char *const repo_usage[] = {
24-
"git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
25-
"git repo info --keys [--format=(lines|nul) | -z]",
26-
"git repo structure [--format=(table|lines|nul) | -z]",
27-
NULL
31+
REPO_INFO_USAGE,
32+
REPO_STRUCTURE_USAGE,
33+
NULL,
34+
};
35+
36+
static const char *const repo_info_usage[] = {
37+
REPO_INFO_USAGE,
38+
NULL,
39+
};
40+
41+
static const char *const repo_structure_usage[] = {
42+
REPO_STRUCTURE_USAGE,
43+
NULL,
2844
};
2945

3046
typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
@@ -226,7 +242,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
226242
OPT_END()
227243
};
228244

229-
argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
245+
argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0);
230246

231247
if (show_keys && (all_keys || argc))
232248
die(_("--keys cannot be used with a <key> or --all"));
@@ -891,7 +907,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
891907
OPT_END()
892908
};
893909

894-
argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
910+
argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);
895911
if (argc)
896912
usage(_("too many arguments"));
897913

compat/regcomp_enhanced.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
int git_regcomp(regex_t *preg, const char *pattern, int cflags)
55
{
6+
/*
7+
* If you are on macOS with clang and fail to compile this line,
8+
* https://lore.kernel.org/git/458ad3c1-96df-4575-ee42-e6eb754f25f6@gmx.de/
9+
* might be relevant.
10+
*/
611
if (!(cflags & REG_EXTENDED))
712
cflags |= REG_ENHANCED;
813
return regcomp(preg, pattern, cflags);

contrib/diff-highlight/DiffHighlight.pm

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package DiffHighlight;
22

3-
require v5.26;
3+
require v5.008;
44
use warnings FATAL => 'all';
55
use strict;
66

@@ -9,18 +9,11 @@ use File::Spec;
99

1010
my $NULL = File::Spec->devnull();
1111

12-
# Highlight by reversing foreground and background. You could do
13-
# other things like bold or underline if you prefer.
14-
my @OLD_HIGHLIGHT = (
15-
color_config('color.diff-highlight.oldnormal'),
16-
color_config('color.diff-highlight.oldhighlight', "\x1b[7m"),
17-
color_config('color.diff-highlight.oldreset', "\x1b[27m")
18-
);
19-
my @NEW_HIGHLIGHT = (
20-
color_config('color.diff-highlight.newnormal', $OLD_HIGHLIGHT[0]),
21-
color_config('color.diff-highlight.newhighlight', $OLD_HIGHLIGHT[1]),
22-
color_config('color.diff-highlight.newreset', $OLD_HIGHLIGHT[2])
23-
);
12+
# The color theme is initially set to nothing here to allow outside callers
13+
# to set the colors for their application. If nothing is sent in we use
14+
# colors from git config in load_color_config().
15+
our @OLD_HIGHLIGHT = ();
16+
our @NEW_HIGHLIGHT = ();
2417

2518
my $RESET = "\x1b[m";
2619
my $COLOR = qr/\x1b\[[0-9;]*m/;
@@ -138,9 +131,21 @@ sub highlight_stdin {
138131
# of it being used in other settings. Let's handle our own
139132
# fallback, which means we will work even if git can't be run.
140133
sub color_config {
134+
our $cached_config;
141135
my ($key, $default) = @_;
142-
my $s = `git config --get-color $key 2>$NULL`;
143-
return length($s) ? $s : $default;
136+
137+
if (!defined $cached_config) {
138+
$cached_config = {};
139+
my $data = `git config --type=color --get-regexp '^color\.diff-highlight\.' 2>$NULL`;
140+
for my $line (split /\n/, $data) {
141+
my ($key, $color) = split ' ', $line, 2;
142+
$key =~ s/^color\.diff-highlight\.// or next;
143+
$cached_config->{$key} = $color;
144+
}
145+
}
146+
147+
my $s = $cached_config->{$key};
148+
return defined($s) ? $s : $default;
144149
}
145150

146151
sub show_hunk {
@@ -170,6 +175,29 @@ sub show_hunk {
170175
$line_cb->(@queue);
171176
}
172177

178+
sub load_color_config {
179+
# If the colors were NOT set from outside this module we load them on-demand
180+
# from the git config. Note that only one of elements 0 and 2 in each
181+
# array is used (depending on whether you are doing set/unset on an
182+
# attribute, or specifying normal vs highlighted coloring). So we use
183+
# element 1 as our check for whether colors were passed in; it should
184+
# always be set if you want highlighting to do anything.
185+
if (!defined $OLD_HIGHLIGHT[1]) {
186+
@OLD_HIGHLIGHT = (
187+
color_config('oldnormal'),
188+
color_config('oldhighlight', "\x1b[7m"),
189+
color_config('oldreset', "\x1b[27m")
190+
);
191+
}
192+
if (!defined $NEW_HIGHLIGHT[1]) {
193+
@NEW_HIGHLIGHT = (
194+
color_config('newnormal', $OLD_HIGHLIGHT[0]),
195+
color_config('newhighlight', $OLD_HIGHLIGHT[1]),
196+
color_config('newreset', $OLD_HIGHLIGHT[2])
197+
);
198+
};
199+
}
200+
173201
sub highlight_pair {
174202
my @a = split_line(shift);
175203
my @b = split_line(shift);
@@ -218,6 +246,7 @@ sub highlight_pair {
218246
}
219247

220248
if (is_pair_interesting(\@a, $pa, $sa, \@b, $pb, $sb)) {
249+
load_color_config();
221250
return highlight_line(\@a, $pa, $sa, \@OLD_HIGHLIGHT),
222251
highlight_line(\@b, $pb, $sb, \@NEW_HIGHLIGHT);
223252
}

contrib/diff-highlight/README

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,21 @@ visually distracting. Non-diff lines and existing diff coloration is
3939
preserved; the intent is that the output should look exactly the same as
4040
the input, except for the occasional highlight.
4141

42+
Build/Install
43+
-------------
44+
45+
You can build the `diff-highlight` script by running `make` from within
46+
the diff-highlight directory. There is no `make install` target; you can
47+
copy the built script to your $PATH.
48+
49+
You can run diff-highlight's internal tests by running `make test`. Note
50+
that you must also build Git itself first (by running `make` from the
51+
top-level of the project).
52+
4253
Use
4354
---
4455

45-
You can try out the diff-highlight program with:
56+
You can try out the built diff-highlight program with:
4657

4758
---------------------------------------------
4859
git log -p --color | /path/to/diff-highlight
@@ -127,6 +138,12 @@ Your script may set up one or more of the following variables:
127138
processing a logical chunk of input). The default function flushes
128139
stdout.
129140

141+
- @DiffHighlight::OLD_HIGHLIGHT and @DiffHighlight::NEW_HIGHLIGHT - these
142+
arrays specify the normal, highlighted, and reset colors (in that order)
143+
for old/new lines. If unset, values will be retrieved by calling `git
144+
config` (see "Color Config" above). Note that these should be the literal
145+
color bytes (starting with an ANSI escape code), not color names.
146+
130147
The script may then feed lines, one at a time, to DiffHighlight::handle_line().
131148
When lines are done processing, they will be fed to $line_cb. Note that
132149
DiffHighlight may queue up many input lines (to analyze a whole hunk)

0 commit comments

Comments
 (0)