View | Details | Raw Unified | Return to bug 257959 | Differences between
and this patch

Collapse All | Expand All

(-)b/devel/git/Makefile (-1 / +1 lines)
Lines 2-8 Link Here
2
2
3
PORTNAME=	git
3
PORTNAME=	git
4
DISTVERSION=	2.32.0
4
DISTVERSION=	2.32.0
5
PORTREVISION=	1
5
PORTREVISION=	2
6
CATEGORIES=	devel
6
CATEGORIES=	devel
7
MASTER_SITES=	KERNEL_ORG/software/scm/git
7
MASTER_SITES=	KERNEL_ORG/software/scm/git
8
DISTFILES=	${DISTNAME}${EXTRACT_SUFX} \
8
DISTFILES=	${DISTNAME}${EXTRACT_SUFX} \
(-)b/devel/git/files/patch-builtin__checkout--worker.c (+46 lines)
Added Link Here
1
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
2
index fb9fd13b73..61ba39402a 100644
3
--- builtin/checkout--worker.c
4
+++ builtin/checkout--worker.c
5
@@ -9,7 +9,7 @@ static void packet_to_pc_item(const char *buffer, int len,
6
 			      struct parallel_checkout_item *pc_item)
7
 {
8
 	const struct pc_item_fixed_portion *fixed_portion;
9
-	const char *variant;
10
+	const char *variant, *ident_action;
11
 	char *encoding;
12
 
13
 	if (len < sizeof(struct pc_item_fixed_portion))
14
@@ -19,7 +19,8 @@ static void packet_to_pc_item(const char *buffer, int len,
15
 	fixed_portion = (struct pc_item_fixed_portion *)buffer;
16
 
17
 	if (len - sizeof(struct pc_item_fixed_portion) !=
18
-		fixed_portion->name_len + fixed_portion->working_tree_encoding_len)
19
+		fixed_portion->name_len + fixed_portion->working_tree_encoding_len +
20
+		fixed_portion->ident_action_len)
21
 		BUG("checkout worker received corrupted item");
22
 
23
 	variant = buffer + sizeof(struct pc_item_fixed_portion);
24
@@ -43,11 +44,21 @@ static void packet_to_pc_item(const char *buffer, int len,
25
 	pc_item->ce->ce_namelen = fixed_portion->name_len;
26
 	pc_item->ce->ce_mode = fixed_portion->ce_mode;
27
 	memcpy(pc_item->ce->name, variant, pc_item->ce->ce_namelen);
28
+	variant += pc_item->ce->ce_namelen;
29
 	oidcpy(&pc_item->ce->oid, &fixed_portion->oid);
30
 
31
+	if (fixed_portion->ident_action_len) {
32
+		ident_action = xmemdupz(variant,
33
+					fixed_portion->ident_action_len);
34
+		variant += fixed_portion->ident_action_len;
35
+	} else {
36
+		ident_action = NULL;
37
+	}
38
+
39
 	pc_item->id = fixed_portion->id;
40
 	pc_item->ca.crlf_action = fixed_portion->crlf_action;
41
-	pc_item->ca.ident = fixed_portion->ident;
42
+	pc_item->ca.ident_action.id = ident_action;
43
+	pc_item->ca.ident_action.id_len = fixed_portion->ident_action_len;
44
 	pc_item->ca.working_tree_encoding = encoding;
45
 }
46
 
(-)b/devel/git/files/patch-convert.c (+304 lines)
Added Link Here
1
--- convert.c.orig	2021-06-06 05:13:45.000000000 -0700
2
+++ convert.c	2021-08-20 11:05:22.792030000 -0700
3
@@ -1054,7 +1054,12 @@
4
 	return 0;
5
 }
6
 
7
-static int count_ident(const char *cp, unsigned long size)
8
+#define ID_STR "Id"
9
+
10
+#define GIT_MAX_IDENT_LEN 255
11
+
12
+static int count_ident(const char *cp, unsigned long size,
13
+		       const struct ident_action *idact)
14
 {
15
 	/*
16
 	 * "$Id: 0000000000000000000000000000000000000000 $" <=> "$Id$"
17
@@ -1067,13 +1072,13 @@
18
 		size--;
19
 		if (ch != '$')
20
 			continue;
21
-		if (size < 3)
22
+		if (size < idact->id_len + 1)
23
 			break;
24
-		if (memcmp("Id", cp, 2))
25
+		if (memcmp(idact->id, cp, idact->id_len))
26
 			continue;
27
-		ch = cp[2];
28
-		cp += 3;
29
-		size -= 3;
30
+		ch = cp[idact->id_len];
31
+		cp += idact->id_len + 1;
32
+		size -= idact->id_len + 1;
33
 		if (ch == '$')
34
 			cnt++; /* $Id$ */
35
 		if (ch != ':')
36
@@ -1097,11 +1102,11 @@
37
 }
38
 
39
 static int ident_to_git(const char *src, size_t len,
40
-			struct strbuf *buf, int ident)
41
+			struct strbuf *buf, const struct ident_action *idact)
42
 {
43
 	char *dst, *dollar;
44
 
45
-	if (!ident || (src && !count_ident(src, len)))
46
+	if (!idact->id || (src && !count_ident(src, len, idact)))
47
 		return 0;
48
 
49
 	if (!buf)
50
@@ -1120,17 +1125,18 @@
51
 		len -= dollar + 1 - src;
52
 		src  = dollar + 1;
53
 
54
-		if (len > 3 && !memcmp(src, "Id:", 3)) {
55
-			dollar = memchr(src + 3, '$', len - 3);
56
+		if (len > idact->id_len + 1 && !memcmp(src, idact->id, idact->id_len) && src[idact->id_len + 1] == ':') {
57
+			dollar = memchr(src + idact->id_len + 1, '$', len - (idact->id_len + 1));
58
 			if (!dollar)
59
 				break;
60
-			if (memchr(src + 3, '\n', dollar - src - 3)) {
61
+			if (memchr(src + idact->id_len + 1, '\n', dollar - src - (idact->id_len + 1))) {
62
 				/* Line break before the next dollar. */
63
 				continue;
64
 			}
65
 
66
-			memcpy(dst, "Id$", 3);
67
-			dst += 3;
68
+			memcpy(dst, idact->id, idact->id_len);
69
+			dst[idact->id_len] = '$';
70
+			dst += idact->id_len + 1;
71
 			len -= dollar + 1 - src;
72
 			src  = dollar + 1;
73
 		}
74
@@ -1141,16 +1147,16 @@
75
 }
76
 
77
 static int ident_to_worktree(const char *src, size_t len,
78
-			     struct strbuf *buf, int ident)
79
+			     struct strbuf *buf, const struct ident_action *idact)
80
 {
81
 	struct object_id oid;
82
 	char *to_free = NULL, *dollar, *spc;
83
 	int cnt;
84
 
85
-	if (!ident)
86
+	if (!idact->id)
87
 		return 0;
88
 
89
-	cnt = count_ident(src, len);
90
+	cnt = count_ident(src, len, idact);
91
 	if (!cnt)
92
 		return 0;
93
 
94
@@ -1159,7 +1165,7 @@
95
 		to_free = strbuf_detach(buf, NULL);
96
 	hash_object_file(the_hash_algo, src, len, "blob", &oid);
97
 
98
-	strbuf_grow(buf, len + cnt * (the_hash_algo->hexsz + 3));
99
+	strbuf_grow(buf, len + cnt * (the_hash_algo->hexsz + idact->id_len + 1));
100
 	for (;;) {
101
 		/* step 1: run to the next '$' */
102
 		dollar = memchr(src, '$', len);
103
@@ -1170,14 +1176,14 @@
104
 		src  = dollar + 1;
105
 
106
 		/* step 2: does it looks like a bit like Id:xxx$ or Id$ ? */
107
-		if (len < 3 || memcmp("Id", src, 2))
108
+		if (len < idact->id_len + 1 || memcmp(idact->id, src, idact->id_len))
109
 			continue;
110
 
111
 		/* step 3: skip over Id$ or Id:xxxxx$ */
112
-		if (src[2] == '$') {
113
-			src += 3;
114
-			len -= 3;
115
-		} else if (src[2] == ':') {
116
+		if (src[idact->id_len] == '$') {
117
+			src += idact->id_len + 1;
118
+			len -= idact->id_len + 1;
119
+		} else if (src[idact->id_len] == ':') {
120
 			/*
121
 			 * It's possible that an expanded Id has crept its way into the
122
 			 * repository, we cope with that by stripping the expansion out.
123
@@ -1185,18 +1191,18 @@
124
 			 * on checkout, which won't go away by stash, but let's keep it
125
 			 * for git-style ids.
126
 			 */
127
-			dollar = memchr(src + 3, '$', len - 3);
128
+			dollar = memchr(src + idact->id_len + 1, '$', len - (idact->id_len + 1));
129
 			if (!dollar) {
130
 				/* incomplete keyword, no more '$', so just quit the loop */
131
 				break;
132
 			}
133
 
134
-			if (memchr(src + 3, '\n', dollar - src - 3)) {
135
+			if (memchr(src + idact->id_len + 1, '\n', dollar - src - (idact->id_len + 1))) {
136
 				/* Line break before the next dollar. */
137
 				continue;
138
 			}
139
 
140
-			spc = memchr(src + 4, ' ', dollar - src - 4);
141
+			spc = memchr(src + idact->id_len + 2, ' ', dollar - src - (idact->id_len + 2));
142
 			if (spc && spc < dollar-1) {
143
 				/* There are spaces in unexpected places.
144
 				 * This is probably an id from some other
145
@@ -1213,7 +1219,8 @@
146
 		}
147
 
148
 		/* step 4: substitute */
149
-		strbuf_addstr(buf, "Id: ");
150
+		strbuf_addstr(buf, idact->id);
151
+		strbuf_addstr(buf, ": ");
152
 		strbuf_addstr(buf, oid_to_hex(&oid));
153
 		strbuf_addstr(buf, " $");
154
 	}
155
@@ -1284,11 +1291,21 @@
156
 	return NULL;
157
 }
158
 
159
-static int git_path_check_ident(struct attr_check_item *check)
160
+static struct ident_action git_path_check_ident(struct attr_check_item *check)
161
 {
162
+	struct ident_action idact = {.id = NULL, .id_len = 0};
163
 	const char *value = check->value;
164
 
165
-	return !!ATTR_TRUE(value);
166
+	if (!ATTR_UNSET(value) && !ATTR_FALSE(value)) {
167
+		if (ATTR_TRUE(value))
168
+			idact.id = ID_STR;
169
+		else
170
+			idact.id = value;
171
+		idact.id_len = strlen(idact.id);
172
+		if (idact.id_len > GIT_MAX_IDENT_LEN)
173
+			die(_("ident value length exceeds GIT_MAX_IDENT_LEN"));
174
+	}
175
+	return idact;
176
 }
177
 
178
 static struct attr_check *check;
179
@@ -1311,7 +1328,7 @@
180
 	ca->crlf_action = git_path_check_crlf(ccheck + 4);
181
 	if (ca->crlf_action == CRLF_UNDEFINED)
182
 		ca->crlf_action = git_path_check_crlf(ccheck + 0);
183
-	ca->ident = git_path_check_ident(ccheck + 1);
184
+	ca->ident_action = git_path_check_ident(ccheck + 1);
185
 	ca->drv = git_path_check_convert(ccheck + 2);
186
 	if (ca->crlf_action != CRLF_BINARY) {
187
 		enum eol eol_attr = git_path_check_eol(ccheck + 3);
188
@@ -1431,7 +1448,7 @@
189
 			len = dst->len;
190
 		}
191
 	}
192
-	return ret | ident_to_git(src, len, dst, ca.ident);
193
+	return ret | ident_to_git(src, len, dst, &ca.ident_action);
194
 }
195
 
196
 void convert_to_git_filter_fd(struct index_state *istate,
197
@@ -1448,7 +1465,7 @@
198
 
199
 	encode_to_git(path, dst->buf, dst->len, dst, ca.working_tree_encoding, conv_flags);
200
 	crlf_to_git(istate, path, dst->buf, dst->len, dst, ca.crlf_action, conv_flags);
201
-	ident_to_git(dst->buf, dst->len, dst, ca.ident);
202
+	ident_to_git(dst->buf, dst->len, dst, &ca.ident_action);
203
 }
204
 
205
 static int convert_to_working_tree_ca_internal(const struct conv_attrs *ca,
206
@@ -1460,7 +1477,7 @@
207
 {
208
 	int ret = 0, ret_filter = 0;
209
 
210
-	ret |= ident_to_worktree(src, len, dst, ca->ident);
211
+	ret |= ident_to_worktree(src, len, dst, &(ca->ident_action));
212
 	if (ret) {
213
 		src = dst->buf;
214
 		len = dst->len;
215
@@ -1808,7 +1825,8 @@
216
 	struct stream_filter filter;
217
 	struct strbuf left;
218
 	int state;
219
-	char ident[GIT_MAX_HEXSZ + 5]; /* ": x40 $" */
220
+	const struct ident_action *idact;
221
+	char ident[GIT_MAX_HEXSZ + GIT_MAX_IDENT_LEN + 3]; /* ": x40 $" */
222
 };
223
 
224
 static int is_foreign_ident(const char *str)
225
@@ -1845,13 +1863,16 @@
226
 			   char *output, size_t *osize_p)
227
 {
228
 	struct ident_filter *ident = (struct ident_filter *)filter;
229
-	static const char head[] = "$Id";
230
+	const struct ident_action *idact = ident->idact;
231
 
232
 	if (!input) {
233
 		/* drain upon eof */
234
 		switch (ident->state) {
235
 		default:
236
-			strbuf_add(&ident->left, head, ident->state);
237
+			if (ident->state > 0)
238
+				strbuf_addch(&ident->left, '$');
239
+			if (ident->state > 1)
240
+				strbuf_add(&ident->left, idact->id, ident->state - 1);
241
 			/* fallthrough */
242
 		case IDENT_SKIPPING:
243
 			/* fallthrough */
244
@@ -1883,22 +1904,26 @@
245
 			if (ch != '\n' && ch != '$')
246
 				continue;
247
 			if (ch == '$' && !is_foreign_ident(ident->left.buf)) {
248
-				strbuf_setlen(&ident->left, sizeof(head) - 1);
249
+				strbuf_setlen(&ident->left, idact->id_len + 1);
250
 				strbuf_addstr(&ident->left, ident->ident);
251
 			}
252
 			ident->state = IDENT_DRAINING;
253
 			continue;
254
 		}
255
 
256
-		if (ident->state < sizeof(head) &&
257
-		    head[ident->state] == ch) {
258
+		if ((ident->state == 0 && ch == '$') ||
259
+		    (ident->state > 0 && ident->state < idact->id_len + 1 &&
260
+		     idact->id[ident->state - 1] == ch)) {
261
 			ident->state++;
262
 			continue;
263
 		}
264
 
265
-		if (ident->state)
266
-			strbuf_add(&ident->left, head, ident->state);
267
-		if (ident->state == sizeof(head) - 1) {
268
+		if (ident->state) {
269
+			strbuf_addch(&ident->left, '$');
270
+			if (ident->state > 1)
271
+				strbuf_add(&ident->left, idact->id, ident->state - 1);
272
+		}
273
+		if (ident->state == idact->id_len + 1) {
274
 			if (ch != ':' && ch != '$') {
275
 				strbuf_addch(&ident->left, ch);
276
 				ident->state = 0;
277
@@ -1933,7 +1958,7 @@
278
 	ident_free_fn,
279
 };
280
 
281
-static struct stream_filter *ident_filter(const struct object_id *oid)
282
+static struct stream_filter *ident_filter(const struct object_id *oid, const struct ident_action *idact)
283
 {
284
 	struct ident_filter *ident = xmalloc(sizeof(*ident));
285
 
286
@@ -1942,6 +1967,7 @@
287
 	strbuf_init(&ident->left, 0);
288
 	ident->filter.vtbl = &ident_vtbl;
289
 	ident->state = 0;
290
+	ident->idact = idact;
291
 	return (struct stream_filter *)ident;
292
 }
293
 
294
@@ -1961,8 +1987,8 @@
295
 	if (classify_conv_attrs(ca) != CA_CLASS_STREAMABLE)
296
 		return NULL;
297
 
298
-	if (ca->ident)
299
-		filter = ident_filter(oid);
300
+	if (ca->ident_action.id)
301
+		filter = ident_filter(oid, &(ca->ident_action));
302
 
303
 	if (output_eol(ca->crlf_action) == EOL_CRLF)
304
 		filter = cascade_filter(filter, lf_to_crlf_filter());
(-)b/devel/git/files/patch-convert.h (+20 lines)
Added Link Here
1
--- convert.h	2021/08/20 18:01:30	1.1
2
+++ convert.h	2021/08/20 18:03:07
3
@@ -76,11 +76,16 @@
4
 
5
 struct convert_driver;
6
 
7
+struct ident_action {
8
+	const char *id;
9
+	int id_len;
10
+};
11
+
12
 struct conv_attrs {
13
 	struct convert_driver *drv;
14
 	enum convert_crlf_action attr_action; /* What attr says */
15
 	enum convert_crlf_action crlf_action; /* When no attr is set, use core.autocrlf */
16
-	int ident;
17
+	struct ident_action ident_action; /* What ident says */
18
 	const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */
19
 };
20
 
(-)b/devel/git/files/patch-parallel-checkout.c (+40 lines)
Added Link Here
1
--- parallel-checkout.c.orig	2021-06-06 05:13:45.000000000 -0700
2
+++ parallel-checkout.c	2021-08-21 15:01:06.622636000 -0700
3
@@ -403,13 +403,15 @@
4
 	size_t name_len = pc_item->ce->ce_namelen;
5
 	size_t working_tree_encoding_len = working_tree_encoding ?
6
 					   strlen(working_tree_encoding) : 0;
7
+	const char *ident_action_id = pc_item->ca.ident_action.id;
8
+	size_t ident_action_len = pc_item->ca.ident_action.id_len;
9
 
10
 	/*
11
 	 * Any changes in the calculation of the message size must also be made
12
 	 * in is_eligible_for_parallel_checkout().
13
 	 */
14
 	len_data = sizeof(struct pc_item_fixed_portion) + name_len +
15
-		   working_tree_encoding_len;
16
+		   working_tree_encoding_len + ident_action_len;
17
 
18
 	data = xcalloc(1, len_data);
19
 
20
@@ -417,7 +419,7 @@
21
 	fixed_portion->id = pc_item->id;
22
 	fixed_portion->ce_mode = pc_item->ce->ce_mode;
23
 	fixed_portion->crlf_action = pc_item->ca.crlf_action;
24
-	fixed_portion->ident = pc_item->ca.ident;
25
+	fixed_portion->ident_action_len = ident_action_len;
26
 	fixed_portion->name_len = name_len;
27
 	fixed_portion->working_tree_encoding_len = working_tree_encoding_len;
28
 	/*
29
@@ -435,6 +437,11 @@
30
 		variant += working_tree_encoding_len;
31
 	}
32
 	memcpy(variant, pc_item->ce->name, name_len);
33
+	variant += name_len;
34
+	if (ident_action_len) {
35
+		memcpy(variant, ident_action_id, ident_action_len);
36
+		variant += ident_action_len;
37
+	}
38
 
39
 	packet_write(fd, data, len_data);
40
 
(-)b/devel/git/files/patch-parallel-checkout.h (+24 lines)
Added Link Here
1
--- parallel-checkout.h	2021/08/20 18:16:10	1.1
2
+++ parallel-checkout.h	2021/08/20 18:21:18
3
@@ -76,9 +76,9 @@
4
 
5
 /*
6
  * The fixed-size portion of `struct parallel_checkout_item` that is sent to the
7
- * workers. Following this will be 2 strings: ca.working_tree_encoding and
8
- * ce.name; These are NOT null terminated, since we have the size in the fixed
9
- * portion.
10
+ * workers. Following this will be 3 strings: ca.working_tree_encoding, ca.name
11
+ * and ca.ident_action.id; These are NOT null terminated, since we have the size
12
+ * in the fixed portion.
13
  *
14
  * Note that not all fields of conv_attrs and cache_entry are passed, only the
15
  * ones that will be required by the workers to smudge and write the entry.
16
@@ -88,7 +88,7 @@
17
 	struct object_id oid;
18
 	unsigned int ce_mode;
19
 	enum convert_crlf_action crlf_action;
20
-	int ident;
21
+	size_t ident_action_len;
22
 	size_t working_tree_encoding_len;
23
 	size_t name_len;
24
 };

Return to bug 257959