checkout.c: change "unique" member to "num_matches"
Internally track how many matches we find in the check_tracking_name() callback. Nothing uses this now, but it will be made use of in a later change. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jun 5, 2018 at 14:40 UTC
e4d2d55ae46216872c9eaa3b9d0072aa8361d5d3
1 file changed
+4
-4
checkout.c
+4
-4
@@ -7,10 +7,10 @@ struct tracking_name_data {
7
/* const */ char *src_ref;
8
char *dst_ref;
9
struct object_id *dst_oid;
10
- int unique;
10
+ int num_matches;
11
};
12
13
-#define TRACKING_NAME_DATA_INIT { NULL, NULL, NULL, 1 }
13
+#define TRACKING_NAME_DATA_INIT { NULL, NULL, NULL, 0 }
14
15
static int check_tracking_name(struct remote *remote, void *cb_data)
16
{
@@ -23,9 +23,9 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
23
free(query.dst);
24
return 0;
25
}
26
+ cb->num_matches++;
27
if (cb->dst_ref) {
28
free(query.dst);
28
- cb->unique = 0;
29
return 0;
30
}
31
cb->dst_ref = query.dst;
@@ -39,7 +39,7 @@ const char *unique_tracking_name(const char *name, struct object_id *oid)
39
cb_data.dst_oid = oid;
40
for_each_remote(check_tracking_name, &cb_data);
41
free(cb_data.src_ref);
42
- if (cb_data.unique)
42
+ if (cb_data.num_matches == 1)
43
return cb_data.dst_ref;
44
free(cb_data.dst_ref);
45
return NULL;