@matheusbsbs / matheus-bagliano / commits / f01c7916b8
Fork 0

upload-pack: move oldest_have to upload_pack_data

As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'oldest_have' static variable into this struct. It is used by both protocol v0 and protocol v2 code. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Jun 11, 2020 at 14:05 UTC f01c7916b884366b842b585aa55c1c14ba524537
1 file changed +6 -7
upload-pack.c
+6 -7
@@ -42,8 +42,6 @@
42 #define ALL_FLAGS (THEY_HAVE | OUR_REF | WANTED | COMMON_KNOWN | SHALLOW | \
43 NOT_SHALLOW | CLIENT_SHALLOW | HIDDEN_REF)
44
45 -static timestamp_t oldest_have;
46 -
45 /* Enum for allowed unadvertised object request (UOR) */
46 enum allow_uor {
47 /* Allow specifying sha1 if it is a ref tip. */
@@ -74,6 +72,7 @@ struct upload_pack_data {
72 int deepen_relative;
73 int keepalive;
74 int shallow_nr;
75 + timestamp_t oldest_have;
76
77 unsigned int timeout; /* v0 only */
78 enum {
@@ -414,8 +413,8 @@ static int got_oid(struct upload_pack_data *data,
413 we_knew_they_have = 1;
414 else
415 o->flags |= THEY_HAVE;
417 - if (!oldest_have || (commit->date < oldest_have))
418 - oldest_have = commit->date;
416 + if (!data->oldest_have || (commit->date < data->oldest_have))
417 + data->oldest_have = commit->date;
418 for (parents = commit->parents;
419 parents;
420 parents = parents->next)
@@ -436,7 +435,7 @@ static int ok_to_give_up(struct upload_pack_data *data)
435 return 0;
436
437 return can_all_from_reach_with_flag(&data->want_obj, THEY_HAVE,
439 - COMMON_KNOWN, oldest_have,
438 + COMMON_KNOWN, data->oldest_have,
439 min_generation);
440 }
441
@@ -1372,8 +1371,8 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common
1371 we_knew_they_have = 1;
1372 else
1373 o->flags |= THEY_HAVE;
1375 - if (!oldest_have || (commit->date < oldest_have))
1376 - oldest_have = commit->date;
1374 + if (!data->oldest_have || (commit->date < data->oldest_have))
1375 + data->oldest_have = commit->date;
1376 for (parents = commit->parents;
1377 parents;
1378 parents = parents->next)