Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1564db1

Browse files
carlosmnvmg
authored andcommitted
Remove enum git_whn
Instead, use flags inside the git_remote_head structure. Signed-off-by: Carlos Martín Nieto <[email protected]>
1 parent ade3c9b commit 1564db1

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

include/git2/net.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,12 @@ GIT_BEGIN_DECL
4848
#define GIT_DIR_FETCH 0
4949
#define GIT_DIR_PUSH 1
5050

51-
enum git_whn {
52-
GIT_WHN_NONE,
53-
GIT_WHN_HAVE,
54-
GIT_WHN_WANT,
55-
};
56-
5751
/**
5852
* Remote head description, given out on `ls` calls.
5953
*/
6054
struct git_remote_head {
61-
enum git_whn type;
62-
int local; /** Exists locally */
55+
int local:1, /* available locally */
56+
want:1; /* want to update */
6357
git_oid oid;
6458
git_oid loid;
6559
char *name;

src/fetch.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@
3434
#include "refspec.h"
3535
#include "fetch.h"
3636

37-
/*
38-
* Don't forget that this depends on the enum being correctly set
39-
*/
40-
static int whn_cmp(const void *a, const void *b)
41-
{
42-
git_remote_head *heada = (git_remote_head *) a;
43-
git_remote_head *headb = (git_remote_head *) b;
44-
45-
return headb->type - heada->type;
46-
}
47-
4837
static int filter_wants(git_remote *remote)
4938
{
5039
git_vector list;
@@ -55,7 +44,7 @@ static int filter_wants(git_remote *remote)
5544
int error;
5645
unsigned int i;
5746

58-
error = git_vector_init(&list, 16, whn_cmp);
47+
error = git_vector_init(&list, 16, NULL);
5948
if (error < GIT_SUCCESS)
6049
return error;
6150

@@ -112,13 +101,12 @@ static int filter_wants(git_remote *remote)
112101
* to the list, storing the local oid for that branch so we
113102
* don't have to look for it again.
114103
*/
115-
head->type = GIT_WHN_WANT;
104+
head->want = 1;
116105
error = git_vector_insert(&list, head);
117106
if (error < GIT_SUCCESS)
118107
goto cleanup;
119108
}
120109

121-
git_vector_sort(&list);
122110
remote->refs.len = list.length;
123111
remote->refs.heads = (git_remote_head **) list.contents;
124112

src/pkt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd)
318318

319319
for (; i < refs->len; ++i) {
320320
head = refs->heads[i];
321-
if (head->type != GIT_WHN_WANT)
322-
continue; /* FIXME: return? refs shouldn't have any other type */
321+
if (head->local)
322+
continue;
323323

324324
git_oid_fmt(buf + STRLEN(WANT_PREFIX), &head->oid);
325325
gitno_send(fd, buf, STRLEN(buf), 0);

0 commit comments

Comments
 (0)