Skip to content

Commit 720ba25

Browse files
peffgitster
authored andcommitted
upload-pack: switch deepen-not list to an oid_array
When we see a "deepen-not" line from the client, we verify that the given name can be resolved as a ref, and then add it to a string list to be passed later to an internal "rev-list --not" traversal. We record the actual refname in the string list (so the traversal resolves it again later), but we'd be better off recording the resolved oid: 1. There's a tiny bit of wasted work in resolving it twice. 2. There's a small race condition with simultaneous updates; the later traversal may resolve to a different value (or not at all). This shouldn't cause any bad behavior (we do not care about the value in this first resolution, so whatever value rev-list gets is OK) but it could mean a confusing error message (if upload-pack fails to resolve the ref it produces a useful message, but a failing traversal later results in just "revision walk setup failed"). 3. It makes it simpler to de-duplicate the results. We don't de-dup at all right now, but we will in the next patch. >From the client's perspective the behavior should be the same. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fae9627 commit 720ba25

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

upload-pack.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct upload_pack_data {
6565
struct strvec hidden_refs;
6666

6767
struct object_array shallows;
68-
struct string_list deepen_not;
68+
struct oid_array deepen_not;
6969
struct object_array extra_edge_obj;
7070
int depth;
7171
timestamp_t deepen_since;
@@ -125,7 +125,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
125125
struct object_array want_obj = OBJECT_ARRAY_INIT;
126126
struct object_array have_obj = OBJECT_ARRAY_INIT;
127127
struct object_array shallows = OBJECT_ARRAY_INIT;
128-
struct string_list deepen_not = STRING_LIST_INIT_DUP;
128+
struct oid_array deepen_not = OID_ARRAY_INIT;
129129
struct string_list uri_protocols = STRING_LIST_INIT_DUP;
130130
struct object_array extra_edge_obj = OBJECT_ARRAY_INIT;
131131
struct string_list allowed_filters = STRING_LIST_INIT_DUP;
@@ -158,7 +158,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
158158
object_array_clear(&data->want_obj);
159159
object_array_clear(&data->have_obj);
160160
object_array_clear(&data->shallows);
161-
string_list_clear(&data->deepen_not, 0);
161+
oid_array_clear(&data->deepen_not);
162162
object_array_clear(&data->extra_edge_obj);
163163
list_objects_filter_release(&data->filter_options);
164164
string_list_clear(&data->allowed_filters, 0);
@@ -926,8 +926,8 @@ static int send_shallow_list(struct upload_pack_data *data)
926926
if (data->deepen_not.nr) {
927927
strvec_push(&av, "--not");
928928
for (i = 0; i < data->deepen_not.nr; i++) {
929-
struct string_list_item *s = data->deepen_not.items + i;
930-
strvec_push(&av, s->string);
929+
struct object_id *oid = data->deepen_not.oid + i;
930+
strvec_push(&av, oid_to_hex(oid));
931931
}
932932
strvec_push(&av, "--not");
933933
}
@@ -1004,15 +1004,15 @@ static int process_deepen_since(const char *line, timestamp_t *deepen_since, int
10041004
return 0;
10051005
}
10061006

1007-
static int process_deepen_not(const char *line, struct string_list *deepen_not, int *deepen_rev_list)
1007+
static int process_deepen_not(const char *line, struct oid_array *deepen_not, int *deepen_rev_list)
10081008
{
10091009
const char *arg;
10101010
if (skip_prefix(line, "deepen-not ", &arg)) {
10111011
char *ref = NULL;
10121012
struct object_id oid;
10131013
if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1)
10141014
die("git upload-pack: ambiguous deepen-not: %s", line);
1015-
string_list_append(deepen_not, ref);
1015+
oid_array_append(deepen_not, &oid);
10161016
free(ref);
10171017
*deepen_rev_list = 1;
10181018
return 1;

0 commit comments

Comments
 (0)