Skip to content

Commit cca424b

Browse files
committed
Merge branch 'jk/refspecs-cleanup'
Preliminary code clean-up before introducing "negative refspec". * jk/refspecs-cleanup: refspec: make sure stack refspec_item variables are zeroed refspec: fix documentation referring to refspec_item
2 parents e699684 + 95e7c38 commit cca424b

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

builtin/remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ static int get_head_names(const struct ref *remote_refs, struct ref_states *stat
478478
struct ref *fetch_map = NULL, **fetch_map_tail = &fetch_map;
479479
struct refspec_item refspec;
480480

481+
memset(&refspec, 0, sizeof(refspec));
481482
refspec.force = 0;
482483
refspec.pattern = 1;
483484
refspec.src = refspec.dst = "refs/heads/*";

refspec.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
#define TAG_REFSPEC "refs/tags/*:refs/tags/*"
55
extern const struct refspec_item *tag_refspec;
66
7+
/**
8+
* A struct refspec_item holds the parsed interpretation of a refspec. If it will
9+
* force updates (starts with a '+'), force is true. If it is a pattern
10+
* (sides end with '*') pattern is true. src and dest are the two sides
11+
* (including '*' characters if present); if there is only one side, it is src,
12+
* and dst is NULL; if sides exist but are empty (i.e., the refspec either
13+
* starts or ends with ':'), the corresponding side is "".
14+
*
15+
* remote_find_tracking(), given a remote and a struct refspec_item with either src
16+
* or dst filled out, will fill out the other such that the result is in the
17+
* "fetch" specification for the remote (note that this evaluates patterns and
18+
* returns a single result).
19+
*/
720
struct refspec_item {
821
unsigned force : 1;
922
unsigned pattern : 1;
@@ -21,20 +34,8 @@ struct refspec_item {
2134
#define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
2235

2336
/**
24-
* A struct refspec holds the parsed interpretation of a refspec. If it will
25-
* force updates (starts with a '+'), force is true. If it is a pattern
26-
* (sides end with '*') pattern is true. src and dest are the two sides
27-
* (including '*' characters if present); if there is only one side, it is src,
28-
* and dst is NULL; if sides exist but are empty (i.e., the refspec either
29-
* starts or ends with ':'), the corresponding side is "".
30-
*
31-
* An array of strings can be parsed into an array of struct refspecs using
37+
* An array of strings can be parsed into a struct refspec using
3238
* parse_fetch_refspec() or parse_push_refspec().
33-
*
34-
* remote_find_tracking(), given a remote and a struct refspec with either src
35-
* or dst filled out, will fill out the other such that the result is in the
36-
* "fetch" specification for the remote (note that this evaluates patterns and
37-
* returns a single result).
3839
*/
3940
struct refspec {
4041
struct refspec_item *items;

transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v
443443
if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
444444
return;
445445

446+
memset(&rs, 0, sizeof(rs));
446447
rs.src = ref->name;
447448
rs.dst = NULL;
448449

0 commit comments

Comments
 (0)