Skip to content

Commit 68a86d0

Browse files
committed
Merge branch 'master' of github.com:git/git
* 'master' of github.com:git/git: A few more topics after 2.41-rc1 Git 2.41-rc1 t/lib-httpd: make CGIPassAuth support conditional t9001: mark the script as no longer leak checker clean send-email: clear the $message_id after validation upload-pack: advertise capabilities when cloning empty repos A bit more before -rc1 imap-send: include strbuf.h run-command.c: fix missing include under `NO_PTHREADS` test: do not negate test_path_is_* to assert absense t2021: do not negate test_path_is_dir tests: do not negate test_path_exists doc/git-config: add unit for http.lowSpeedLimit rebase -r: fix the total number shown in the progress rebase --update-refs: fix loops attr: teach "--attr-source=<tree>" global option to "git"
2 parents 03d0593 + 9e49351 commit 68a86d0

36 files changed

+292
-55
lines changed

Documentation/RelNotes/2.41.0.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Git v2.41 Release Notes
33

44
UI, Workflows & Features
55

6-
* Allow information carried on the WWW-AUthenticate header to be
6+
* Allow information carried on the WWW-Authenticate header to be
77
passed to the credential helpers.
88

99
* A new "fetch.hideRefs" option can be used to exclude specified refs
@@ -48,7 +48,7 @@ UI, Workflows & Features
4848

4949
* "git clone" from an empty repository learned to propagate the
5050
choice of the hash algorithm from the source repository to the
51-
newly created repository.
51+
newly created repository over any one of the v0/v1/v2 protocol.
5252

5353
* "git mergetool" and "git difftool" learns a new configuration
5454
guiDefault to optionally favor configured guitool over non-gui-tool
@@ -113,6 +113,10 @@ UI, Workflows & Features
113113
* "git fetch" learned the "--porcelain" option that emits what it did
114114
in a machine-parseable format.
115115

116+
* "git --attr-source=<tree> cmd $args" is a new way to have any
117+
command to read attributes not from the working tree but from the
118+
given tree object.
119+
116120

117121
Performance, Internal Implementation, Development Support etc.
118122

@@ -365,6 +369,10 @@ Fixes since v2.40
365369
by git forges to disable replace-refs feature.
366370
(merge b6551feadf ds/merge-tree-use-config later to maint).
367371

372+
* A few bugs in the sequencer machinery that results in miscounting
373+
the steps have been corrected.
374+
(merge 170eea9750 js/rebase-count-fixes later to maint).
375+
368376
* Other code cleanup, docfix, build fix, etc.
369377
(merge f7111175df as/doc-markup-fix later to maint).
370378
(merge 90ff7c9898 fc/test-aggregation-clean-up later to maint).

Documentation/config/http.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ significantly since the entire buffer is allocated even for small
246246
pushes.
247247

248248
http.lowSpeedLimit, http.lowSpeedTime::
249-
If the HTTP transfer speed is less than 'http.lowSpeedLimit'
250-
for longer than 'http.lowSpeedTime' seconds, the transfer is aborted.
249+
If the HTTP transfer speed, in bytes per second, is less than
250+
'http.lowSpeedLimit' for longer than 'http.lowSpeedTime' seconds,
251+
the transfer is aborted.
251252
Can be overridden by the `GIT_HTTP_LOW_SPEED_LIMIT` and
252253
`GIT_HTTP_LOW_SPEED_TIME` environment variables.
253254

Documentation/git.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ If you just want to run git as if it was started in `<path>` then use
212212
nohelpers (exclude helper commands), alias and config
213213
(retrieve command list from config variable completion.commands)
214214

215+
--attr-source=<tree-ish>::
216+
Read gitattributes from <tree-ish> instead of the worktree. See
217+
linkgit:gitattributes[5]. This is equivalent to setting the
218+
`GIT_ATTR_SOURCE` environment variable.
219+
215220
GIT COMMANDS
216221
------------
217222

@@ -686,6 +691,9 @@ for further details.
686691
tells Git not to verify the SSL certificate when fetching or
687692
pushing over HTTPS.
688693

694+
`GIT_ATTR_SOURCE`::
695+
Sets the treeish that gitattributes will be read from.
696+
689697
`GIT_ASKPASS`::
690698
If this environment variable is set, then Git commands which need to
691699
acquire passwords or passphrases (e.g. for HTTP or IMAP authentication)

GIT-VERSION-GEN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
GVF=GIT-VERSION-FILE
4-
DEF_VER=v2.40.GIT
4+
DEF_VER=v2.41.0-rc1
55

66
LF='
77
'

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static const struct attr_check *get_archive_attrs(struct index_state *istate,
130130
static struct attr_check *check;
131131
if (!check)
132132
check = attr_check_initl("export-ignore", "export-subst", NULL);
133-
git_check_attr(istate, NULL, path, check);
133+
git_check_attr(istate, path, check);
134134
return check;
135135
}
136136

attr.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "setup.h"
2222
#include "thread-utils.h"
2323
#include "tree-walk.h"
24+
#include "object-name.h"
2425

2526
const char git_attr__true[] = "(builtin)true";
2627
const char git_attr__false[] = "\0(builtin)false";
@@ -1170,11 +1171,42 @@ static void collect_some_attrs(struct index_state *istate,
11701171
fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem);
11711172
}
11721173

1174+
static const char *default_attr_source_tree_object_name;
1175+
1176+
void set_git_attr_source(const char *tree_object_name)
1177+
{
1178+
default_attr_source_tree_object_name = xstrdup(tree_object_name);
1179+
}
1180+
1181+
static void compute_default_attr_source(struct object_id *attr_source)
1182+
{
1183+
if (!default_attr_source_tree_object_name)
1184+
default_attr_source_tree_object_name = getenv(GIT_ATTR_SOURCE_ENVIRONMENT);
1185+
1186+
if (!default_attr_source_tree_object_name || !is_null_oid(attr_source))
1187+
return;
1188+
1189+
if (repo_get_oid_treeish(the_repository, default_attr_source_tree_object_name, attr_source))
1190+
die(_("bad --attr-source or GIT_ATTR_SOURCE"));
1191+
}
1192+
1193+
static struct object_id *default_attr_source(void)
1194+
{
1195+
static struct object_id attr_source;
1196+
1197+
if (is_null_oid(&attr_source))
1198+
compute_default_attr_source(&attr_source);
1199+
if (is_null_oid(&attr_source))
1200+
return NULL;
1201+
return &attr_source;
1202+
}
1203+
11731204
void git_check_attr(struct index_state *istate,
1174-
const struct object_id *tree_oid, const char *path,
1205+
const char *path,
11751206
struct attr_check *check)
11761207
{
11771208
int i;
1209+
const struct object_id *tree_oid = default_attr_source();
11781210

11791211
collect_some_attrs(istate, tree_oid, path, check);
11801212

@@ -1187,10 +1219,11 @@ void git_check_attr(struct index_state *istate,
11871219
}
11881220
}
11891221

1190-
void git_all_attrs(struct index_state *istate, const struct object_id *tree_oid,
1222+
void git_all_attrs(struct index_state *istate,
11911223
const char *path, struct attr_check *check)
11921224
{
11931225
int i;
1226+
const struct object_id *tree_oid = default_attr_source();
11941227

11951228
attr_check_reset(check);
11961229
collect_some_attrs(istate, tree_oid, path, check);

attr.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* const char *path;
4646
*
4747
* setup_check();
48-
* git_check_attr(&the_index, tree_oid, path, check);
48+
* git_check_attr(&the_index, path, check);
4949
* ------------
5050
*
5151
* - Act on `.value` member of the result, left in `check->items[]`:
@@ -120,7 +120,6 @@
120120
#define ATTR_MAX_FILE_SIZE (100 * 1024 * 1024)
121121

122122
struct index_state;
123-
struct object_id;
124123

125124
/**
126125
* An attribute is an opaque object that is identified by its name. Pass the
@@ -135,6 +134,12 @@ struct git_attr;
135134
struct all_attrs_item;
136135
struct attr_stack;
137136

137+
/*
138+
* The textual object name for the tree-ish used by git_check_attr()
139+
* to read attributes from (instead of from the working tree).
140+
*/
141+
void set_git_attr_source(const char *);
142+
138143
/*
139144
* Given a string, return the gitattribute object that
140145
* corresponds to it.
@@ -203,14 +208,14 @@ void attr_check_free(struct attr_check *check);
203208
const char *git_attr_name(const struct git_attr *);
204209

205210
void git_check_attr(struct index_state *istate,
206-
const struct object_id *tree_oid, const char *path,
211+
const char *path,
207212
struct attr_check *check);
208213

209214
/*
210215
* Retrieve all attributes that apply to the specified path.
211216
* check holds the attributes and their values.
212217
*/
213-
void git_all_attrs(struct index_state *istate, const struct object_id *tree_oid,
218+
void git_all_attrs(struct index_state *istate,
214219
const char *path, struct attr_check *check);
215220

216221
enum git_attr_direction {

builtin/check-attr.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ static void output_attr(struct attr_check *check, const char *file)
6464
}
6565

6666
static void check_attr(const char *prefix, struct attr_check *check,
67-
const struct object_id *tree_oid, int collect_all,
67+
int collect_all,
6868
const char *file)
6969

7070
{
7171
char *full_path =
7272
prefix_path(prefix, prefix ? strlen(prefix) : 0, file);
7373

7474
if (collect_all) {
75-
git_all_attrs(&the_index, tree_oid, full_path, check);
75+
git_all_attrs(&the_index, full_path, check);
7676
} else {
77-
git_check_attr(&the_index, tree_oid, full_path, check);
77+
git_check_attr(&the_index, full_path, check);
7878
}
7979
output_attr(check, file);
8080

8181
free(full_path);
8282
}
8383

8484
static void check_attr_stdin_paths(const char *prefix, struct attr_check *check,
85-
const struct object_id *tree_oid, int collect_all)
85+
int collect_all)
8686
{
8787
struct strbuf buf = STRBUF_INIT;
8888
struct strbuf unquoted = STRBUF_INIT;
@@ -96,7 +96,7 @@ static void check_attr_stdin_paths(const char *prefix, struct attr_check *check,
9696
die("line is badly quoted");
9797
strbuf_swap(&buf, &unquoted);
9898
}
99-
check_attr(prefix, check, tree_oid, collect_all, buf.buf);
99+
check_attr(prefix, check, collect_all, buf.buf);
100100
maybe_flush_or_die(stdout, "attribute to stdout");
101101
}
102102
strbuf_release(&buf);
@@ -112,7 +112,6 @@ static NORETURN void error_with_usage(const char *msg)
112112
int cmd_check_attr(int argc, const char **argv, const char *prefix)
113113
{
114114
struct attr_check *check;
115-
struct object_id *tree_oid = NULL;
116115
struct object_id initialized_oid;
117116
int cnt, i, doubledash, filei;
118117

@@ -188,14 +187,14 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
188187
if (source) {
189188
if (repo_get_oid_tree(the_repository, source, &initialized_oid))
190189
die("%s: not a valid tree-ish source", source);
191-
tree_oid = &initialized_oid;
190+
set_git_attr_source(source);
192191
}
193192

194193
if (stdin_paths)
195-
check_attr_stdin_paths(prefix, check, tree_oid, all_attrs);
194+
check_attr_stdin_paths(prefix, check, all_attrs);
196195
else {
197196
for (i = filei; i < argc; i++)
198-
check_attr(prefix, check, tree_oid, all_attrs, argv[i]);
197+
check_attr(prefix, check, all_attrs, argv[i]);
199198
maybe_flush_or_die(stdout, "attribute to stdout");
200199
}
201200

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ static int no_try_delta(const char *path)
13311331

13321332
if (!check)
13331333
check = attr_check_initl("delta", NULL);
1334-
git_check_attr(the_repository->index, NULL, path, check);
1334+
git_check_attr(the_repository->index, path, check);
13351335
if (ATTR_FALSE(check->items[0].value))
13361336
return 1;
13371337
return 0;

convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ void convert_attrs(struct index_state *istate,
13151315
git_config(read_convert_config, NULL);
13161316
}
13171317

1318-
git_check_attr(istate, NULL, path, check);
1318+
git_check_attr(istate, path, check);
13191319
ccheck = check->items;
13201320
ca->crlf_action = git_path_check_crlf(ccheck + 4);
13211321
if (ca->crlf_action == CRLF_UNDEFINED)

environment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const char *getenv_safe(struct strvec *argv, const char *name);
5555
#define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH"
5656
#define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS"
5757
#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR"
58+
#define GIT_ATTR_SOURCE_ENVIRONMENT "GIT_ATTR_SOURCE"
5859

5960
/*
6061
* Environment variable used in handshaking the wire protocol.

git-send-email.perl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,7 @@ sub pre_process_file {
17881788
$subject = $initial_subject;
17891789
$message = "";
17901790
$message_num++;
1791+
undef $message_id;
17911792
# Retrieve and unfold header fields.
17921793
my @header_lines = ();
17931794
while(<$fh>) {

git.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "alias.h"
1010
#include "replace-object.h"
1111
#include "setup.h"
12+
#include "attr.h"
1213
#include "shallow.h"
1314
#include "trace.h"
1415
#include "trace2.h"
@@ -314,6 +315,21 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
314315
} else {
315316
exit(list_cmds(cmd));
316317
}
318+
} else if (!strcmp(cmd, "--attr-source")) {
319+
if (*argc < 2) {
320+
fprintf(stderr, _("no attribute source given for --attr-source\n" ));
321+
usage(git_usage_string);
322+
}
323+
setenv(GIT_ATTR_SOURCE_ENVIRONMENT, (*argv)[1], 1);
324+
if (envchanged)
325+
*envchanged = 1;
326+
(*argv)++;
327+
(*argc)--;
328+
} else if (skip_prefix(cmd, "--attr-source=", &cmd)) {
329+
set_git_attr_source(cmd);
330+
setenv(GIT_ATTR_SOURCE_ENVIRONMENT, cmd, 1);
331+
if (envchanged)
332+
*envchanged = 1;
317333
} else {
318334
fprintf(stderr, _("unknown option: %s\n"), cmd);
319335
usage(git_usage_string);

imap-send.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "run-command.h"
3030
#include "parse-options.h"
3131
#include "setup.h"
32+
#include "strbuf.h"
3233
#include "wrapper.h"
3334
#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
3435
typedef void *SSL;

ll-merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ enum ll_merge_result ll_merge(mmbuffer_t *result_buf,
394394
normalize_file(theirs, path, istate);
395395
}
396396

397-
git_check_attr(istate, NULL, path, check);
397+
git_check_attr(istate, path, check);
398398
ll_driver_name = check->items[0].value;
399399
if (check->items[1].value) {
400400
marker_size = atoi(check->items[1].value);
@@ -422,7 +422,7 @@ int ll_merge_marker_size(struct index_state *istate, const char *path)
422422

423423
if (!check)
424424
check = attr_check_initl("conflict-marker-size", NULL);
425-
git_check_attr(istate, NULL, path, check);
425+
git_check_attr(istate, path, check);
426426
if (check->items[0].value) {
427427
marker_size = atoi(check->items[0].value);
428428
if (marker_size <= 0)

pathspec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ int match_pathspec_attrs(struct index_state *istate,
736736
if (name[namelen])
737737
name = to_free = xmemdupz(name, namelen);
738738

739-
git_check_attr(istate, NULL, name, item->attr_check);
739+
git_check_attr(istate, name, item->attr_check);
740740

741741
free(to_free);
742742

run-command.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "packfile.h"
1717
#include "hook.h"
1818
#include "compat/nonblock.h"
19+
#include "alloc.h"
1920

2021
void child_process_init(struct child_process *child)
2122
{

0 commit comments

Comments
 (0)