Skip to content

Commit 53f51c6

Browse files
committed
smart: implement by-date insertion when revwalking
1 parent 4b91f05 commit 53f51c6

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/revwalk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
8383

8484
commit->uninteresting = opts->uninteresting;
8585
list = walk->user_input;
86-
if (git_commit_list_insert(commit, &list) == NULL) {
86+
if ((opts->insert_by_date &&
87+
git_commit_list_insert_by_date(commit, &list) == NULL) ||
88+
git_commit_list_insert(commit, &list) == NULL) {
8789
git_error_set_oom();
8890
return -1;
8991
}

src/revwalk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oi
5353
typedef struct {
5454
int uninteresting;
5555
int from_glob;
56+
int insert_by_date;
5657
} git_revwalk__push_options;
5758

5859
#define GIT_REVWALK__PUSH_OPTIONS_INIT { 0 }

src/transports/smart_protocol.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "pack-objects.h"
1818
#include "remote.h"
1919
#include "util.h"
20+
#include "revwalk.h"
2021

2122
#define NETWORK_XFER_THRESHOLD (100*1024)
2223
/* The minimal interval between progress updates (in seconds). */
@@ -303,6 +304,7 @@ static int wait_while_ack(gitno_buffer *buf)
303304
int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, const git_remote_head * const *wants, size_t count)
304305
{
305306
transport_smart *t = (transport_smart *)transport;
307+
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
306308
gitno_buffer *buf = &t->buffer;
307309
git_buf data = GIT_BUF_INIT;
308310
git_revwalk *walk = NULL;
@@ -317,7 +319,8 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
317319
if ((error = git_revwalk_new(&walk, repo)) < 0)
318320
goto on_error;
319321

320-
if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0)
322+
opts.insert_by_date = 1;
323+
if ((error = git_revwalk__push_glob(walk, "refs/*", &opts)) < 0)
321324
goto on_error;
322325

323326
/*

0 commit comments

Comments
 (0)