Commit 1564db11 by Carlos Martín Nieto Committed by Vicent Marti

Remove enum git_whn

Instead, use flags inside the git_remote_head structure.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent ade3c9bb
...@@ -48,18 +48,12 @@ GIT_BEGIN_DECL ...@@ -48,18 +48,12 @@ GIT_BEGIN_DECL
#define GIT_DIR_FETCH 0 #define GIT_DIR_FETCH 0
#define GIT_DIR_PUSH 1 #define GIT_DIR_PUSH 1
enum git_whn {
GIT_WHN_NONE,
GIT_WHN_HAVE,
GIT_WHN_WANT,
};
/** /**
* Remote head description, given out on `ls` calls. * Remote head description, given out on `ls` calls.
*/ */
struct git_remote_head { struct git_remote_head {
enum git_whn type; int local:1, /* available locally */
int local; /** Exists locally */ want:1; /* want to update */
git_oid oid; git_oid oid;
git_oid loid; git_oid loid;
char *name; char *name;
......
...@@ -34,17 +34,6 @@ ...@@ -34,17 +34,6 @@
#include "refspec.h" #include "refspec.h"
#include "fetch.h" #include "fetch.h"
/*
* Don't forget that this depends on the enum being correctly set
*/
static int whn_cmp(const void *a, const void *b)
{
git_remote_head *heada = (git_remote_head *) a;
git_remote_head *headb = (git_remote_head *) b;
return headb->type - heada->type;
}
static int filter_wants(git_remote *remote) static int filter_wants(git_remote *remote)
{ {
git_vector list; git_vector list;
...@@ -55,7 +44,7 @@ static int filter_wants(git_remote *remote) ...@@ -55,7 +44,7 @@ static int filter_wants(git_remote *remote)
int error; int error;
unsigned int i; unsigned int i;
error = git_vector_init(&list, 16, whn_cmp); error = git_vector_init(&list, 16, NULL);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
return error; return error;
...@@ -112,13 +101,12 @@ static int filter_wants(git_remote *remote) ...@@ -112,13 +101,12 @@ static int filter_wants(git_remote *remote)
* to the list, storing the local oid for that branch so we * to the list, storing the local oid for that branch so we
* don't have to look for it again. * don't have to look for it again.
*/ */
head->type = GIT_WHN_WANT; head->want = 1;
error = git_vector_insert(&list, head); error = git_vector_insert(&list, head);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
goto cleanup; goto cleanup;
} }
git_vector_sort(&list);
remote->refs.len = list.length; remote->refs.len = list.length;
remote->refs.heads = (git_remote_head **) list.contents; remote->refs.heads = (git_remote_head **) list.contents;
......
...@@ -318,8 +318,8 @@ int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd) ...@@ -318,8 +318,8 @@ int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd)
for (; i < refs->len; ++i) { for (; i < refs->len; ++i) {
head = refs->heads[i]; head = refs->heads[i];
if (head->type != GIT_WHN_WANT) if (head->local)
continue; /* FIXME: return? refs shouldn't have any other type */ continue;
git_oid_fmt(buf + STRLEN(WANT_PREFIX), &head->oid); git_oid_fmt(buf + STRLEN(WANT_PREFIX), &head->oid);
gitno_send(fd, buf, STRLEN(buf), 0); gitno_send(fd, buf, STRLEN(buf), 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment