smart: implement by-date insertion when revwalking

parent 4b91f058
...@@ -83,7 +83,9 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re ...@@ -83,7 +83,9 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
commit->uninteresting = opts->uninteresting; commit->uninteresting = opts->uninteresting;
list = walk->user_input; list = walk->user_input;
if (git_commit_list_insert(commit, &list) == NULL) { if ((opts->insert_by_date &&
git_commit_list_insert_by_date(commit, &list) == NULL) ||
git_commit_list_insert(commit, &list) == NULL) {
git_error_set_oom(); git_error_set_oom();
return -1; return -1;
} }
......
...@@ -53,6 +53,7 @@ git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oi ...@@ -53,6 +53,7 @@ git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oi
typedef struct { typedef struct {
int uninteresting; int uninteresting;
int from_glob; int from_glob;
int insert_by_date;
} git_revwalk__push_options; } git_revwalk__push_options;
#define GIT_REVWALK__PUSH_OPTIONS_INIT { 0 } #define GIT_REVWALK__PUSH_OPTIONS_INIT { 0 }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "pack-objects.h" #include "pack-objects.h"
#include "remote.h" #include "remote.h"
#include "util.h" #include "util.h"
#include "revwalk.h"
#define NETWORK_XFER_THRESHOLD (100*1024) #define NETWORK_XFER_THRESHOLD (100*1024)
/* The minimal interval between progress updates (in seconds). */ /* The minimal interval between progress updates (in seconds). */
...@@ -303,6 +304,7 @@ static int wait_while_ack(gitno_buffer *buf) ...@@ -303,6 +304,7 @@ static int wait_while_ack(gitno_buffer *buf)
int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, const git_remote_head * const *wants, size_t count) int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, const git_remote_head * const *wants, size_t count)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = (transport_smart *)transport;
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
gitno_buffer *buf = &t->buffer; gitno_buffer *buf = &t->buffer;
git_buf data = GIT_BUF_INIT; git_buf data = GIT_BUF_INIT;
git_revwalk *walk = NULL; git_revwalk *walk = NULL;
...@@ -317,7 +319,8 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c ...@@ -317,7 +319,8 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
if ((error = git_revwalk_new(&walk, repo)) < 0) if ((error = git_revwalk_new(&walk, repo)) < 0)
goto on_error; goto on_error;
if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0) opts.insert_by_date = 1;
if ((error = git_revwalk__push_glob(walk, "refs/*", &opts)) < 0)
goto on_error; goto on_error;
/* /*
......
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