diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lpm.c | 4 | ||||
-rw-r--r-- | src/lpm.lua | 9 |
2 files changed, 7 insertions, 6 deletions
@@ -483,12 +483,12 @@ 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; + const char* refspec = luaL_optstring(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; #if (LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR >= 7) || LIBGIT2_VER_MAJOR > 1 - fetch_opts.depth = 1; + fetch_opts.depth = lua_toboolean(L, 4) ? GIT_FETCH_DEPTH_FULL : 1; #endif if (no_verify_ssl) fetch_opts.callbacks.certificate_check = lpm_git_transport_certificate_check_cb; diff --git a/src/lpm.lua b/src/lpm.lua index 901c02e..6779e95 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -1262,10 +1262,11 @@ function Repository:fetch() end if not exists or self.branch then log.progress_action("Fetching " .. self.remote .. ":" .. (self.commit or self.branch) .. "...") - if self.commit then - system.fetch(temporary_path or path, write_progress_bar, self.commit) - elseif self.branch then - system.fetch(temporary_path or path, write_progress_bar, "+refs/heads/" .. self.branch .. ":refs/remotes/origin/" .. self.branch) + local status, err = pcall(system.fetch, temporary_path or path, write_progress_bar, self.commit or ("+refs/heads/" .. self.branch .. ":refs/remotes/origin/" .. self.branch)) + if not status and err:find("cannot fetch a specific object") then + system.fetch(temporary_path or path, write_progress_bar, nil, true) + elseif not status then + error(err, 0) end common.reset(temporary_path or path, self.commit or self.branch, "hard") end |