summaryrefslogtreecommitdiff
path: root/src/fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/fetch.c b/src/fetch.c
index dedbb54fa..e08671db3 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -18,6 +18,7 @@
#include "netops.h"
#include "repository.h"
#include "refs.h"
+#include "transports/smart.h"
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
{
@@ -128,10 +129,18 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
* Now we have everything set up so we can start tell the
* server what we want and what we have.
*/
+ remote->nego.refs = (const git_remote_head * const *)remote->refs.contents;
+ remote->nego.count = remote->refs.length;
+ remote->nego.depth = opts->depth;
+ remote->nego.shallow_roots = git__malloc(sizeof(git_shallowarray));
+
+ git_array_init(remote->nego.shallow_roots->array);
+
+ git_repository__shallow_roots(&remote->nego.shallow_roots->array, remote->repo);
+
return t->negotiate_fetch(t,
remote->repo,
- (const git_remote_head * const *)remote->refs.contents,
- remote->refs.length);
+ &remote->nego);
}
int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks)
@@ -139,6 +148,7 @@ int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *call
git_transport *t = remote->transport;
git_indexer_progress_cb progress = NULL;
void *payload = NULL;
+ int error;
if (!remote->need_pack)
return 0;
@@ -148,7 +158,13 @@ int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *call
payload = callbacks->payload;
}
- return t->download_pack(t, remote->repo, &remote->stats, progress, payload);
+ if ((error = t->download_pack(t, remote->repo, &remote->stats, progress, payload)) < 0)
+ return error;
+
+ if ((error = git_repository__shallow_roots_write(remote->repo, remote->nego.shallow_roots->array)) < 0)
+ return error;
+
+ return 0;
}
int git_fetch_options_init(git_fetch_options *opts, unsigned int version)