smart: implement by-date insertion when revwalking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/src/revwalk.c b/src/revwalk.c
index 38f4083..6f49bf2 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -83,7 +83,9 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
commit->uninteresting = opts->uninteresting;
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();
return -1;
}
diff --git a/src/revwalk.h b/src/revwalk.h
index 852ab8b..94b8a6f 100644
--- a/src/revwalk.h
+++ b/src/revwalk.h
@@ -53,6 +53,7 @@ git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oi
typedef struct {
int uninteresting;
int from_glob;
+ int insert_by_date;
} git_revwalk__push_options;
#define GIT_REVWALK__PUSH_OPTIONS_INIT { 0 }
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 1a8ede5..87400bb 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -17,6 +17,7 @@
#include "pack-objects.h"
#include "remote.h"
#include "util.h"
+#include "revwalk.h"
#define NETWORK_XFER_THRESHOLD (100*1024)
/* The minimal interval between progress updates (in seconds). */
@@ -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)
{
transport_smart *t = (transport_smart *)transport;
+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
gitno_buffer *buf = &t->buffer;
git_buf data = GIT_BUF_INIT;
git_revwalk *walk = NULL;
@@ -317,7 +319,8 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
if ((error = git_revwalk_new(&walk, repo)) < 0)
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;
/*