diff options
| author | Etienne Samson <samson.etienne@gmail.com> | 2019-08-21 19:48:05 +0200 |
|---|---|---|
| committer | Etienne Samson <samson.etienne@gmail.com> | 2019-08-23 15:22:31 +0200 |
| commit | 53f51c60afd3c2e4640de622ce274b70b6c1346a (patch) | |
| tree | 5a079d7b7420d71d74c95faa97f06cb8844f981e /src | |
| parent | 4b91f058f673a3392481753a89f606317ade480f (diff) | |
| download | libgit2-53f51c60afd3c2e4640de622ce274b70b6c1346a.tar.gz | |
smart: implement by-date insertion when revwalking
Diffstat (limited to 'src')
| -rw-r--r-- | src/revwalk.c | 4 | ||||
| -rw-r--r-- | src/revwalk.h | 1 | ||||
| -rw-r--r-- | src/transports/smart_protocol.c | 5 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/revwalk.c b/src/revwalk.c index 38f40831a..6f49bf2dc 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 852ab8bda..94b8a6fb1 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 1a8ede580..87400bb9e 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; /* |
