Skip to content

Commit 512fccf

Browse files
derrickstoleegitster
authored andcommitted
bundle-uri: parse bundle.<id>.creationToken values
The previous change taught Git to parse the bundle.heuristic value, especially when its value is "creationToken". Now, teach Git to parse the bundle.<id>.creationToken values on each bundle in a bundle list. Before implementing any logic based on creationToken values for the creationToken heuristic, parse and print these values for testing purposes. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c93c3d2 commit 512fccf

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

bundle-uri.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ static int summarize_bundle(struct remote_bundle_info *info, void *data)
8383
FILE *fp = data;
8484
fprintf(fp, "[bundle \"%s\"]\n", info->id);
8585
fprintf(fp, "\turi = %s\n", info->uri);
86+
87+
if (info->creationToken)
88+
fprintf(fp, "\tcreationToken = %"PRIu64"\n", info->creationToken);
8689
return 0;
8790
}
8891

@@ -203,6 +206,13 @@ static int bundle_list_update(const char *key, const char *value,
203206
return 0;
204207
}
205208

209+
if (!strcmp(subkey, "creationtoken")) {
210+
if (sscanf(value, "%"PRIu64, &bundle->creationToken) != 1)
211+
warning(_("could not parse bundle list key %s with value '%s'"),
212+
"creationToken", value);
213+
return 0;
214+
}
215+
206216
/*
207217
* At this point, we ignore any information that we don't
208218
* understand, assuming it to be hints for a heuristic the client

bundle-uri.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ struct remote_bundle_info {
4242
* this boolean is true.
4343
*/
4444
unsigned unbundled:1;
45+
46+
/**
47+
* If the bundle is part of a list with the creationToken
48+
* heuristic, then we use this member for sorting the bundles.
49+
*/
50+
uint64_t creationToken;
4551
};
4652

4753
#define REMOTE_BUNDLE_INFO_INIT { 0 }

t/t5750-bundle-uri-parse.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,33 @@ test_expect_success 'parse config format: creationToken heuristic' '
258258
heuristic = creationToken
259259
[bundle "one"]
260260
uri = http://example.com/bundle.bdl
261+
creationToken = 123456
261262
[bundle "two"]
262263
uri = https://example.com/bundle.bdl
264+
creationToken = 12345678901234567890
263265
[bundle "three"]
264266
uri = file:///usr/share/git/bundle.bdl
267+
creationToken = 1
265268
EOF
266269
267270
test-tool bundle-uri parse-config expect >actual 2>err &&
268271
test_must_be_empty err &&
269272
test_cmp_config_output expect actual
270273
'
271274

275+
test_expect_success 'parse config format edge cases: creationToken heuristic' '
276+
cat >expect <<-\EOF &&
277+
[bundle]
278+
version = 1
279+
mode = all
280+
heuristic = creationToken
281+
[bundle "one"]
282+
uri = http://example.com/bundle.bdl
283+
creationToken = bogus
284+
EOF
285+
286+
test-tool bundle-uri parse-config expect >actual 2>err &&
287+
grep "could not parse bundle list key creationToken with value '\''bogus'\''" err
288+
'
289+
272290
test_done

0 commit comments

Comments
 (0)