From 1c1de88d2603ebc137ab57218fcdd45935086946 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 27 Jun 2023 11:41:43 -0400 Subject: Added in shallow cloning. --- src/lpm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lpm.c') diff --git a/src/lpm.c b/src/lpm.c index 1f11127..448b5e4 100644 --- a/src/lpm.c +++ b/src/lpm.c @@ -425,14 +425,17 @@ static int lpm_fetch(lua_State* L) { git_repository_free(repository); return luaL_error(L, "git remote fetch error: %s", git_error_last_string()); } + const char* refspec = lua_gettop(L) >= 3 ? luaL_checkstring(L, 3) : NULL; git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT; fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; fetch_opts.callbacks.payload = L; + fetch_opts.depth = 1; if (no_verify_ssl) fetch_opts.callbacks.certificate_check = lpm_git_transport_certificate_check_cb; if (lua_type(L, 2) == LUA_TFUNCTION) fetch_opts.callbacks.transfer_progress = lpm_git_transfer_progress_cb; - if (git_remote_fetch(remote, NULL, &fetch_opts, NULL)) { + git_strarray array = { &refspec, 1 }; + if (git_remote_fetch(remote, refspec ? &array : NULL, &fetch_opts, NULL)) { git_remote_free(remote); git_repository_free(repository); return luaL_error(L, "git remote fetch error: %s", git_error_last_string()); -- cgit v1.2.3