diff --git a/src/subcommand/clone_subcommand.cpp b/src/subcommand/clone_subcommand.cpp index d660ae1..acc6f14 100644 --- a/src/subcommand/clone_subcommand.cpp +++ b/src/subcommand/clone_subcommand.cpp @@ -21,6 +21,20 @@ clone_subcommand::clone_subcommand(const libgit2_object&, CLI::App& app) void clone_subcommand::run() { + // m_depth = 0 means no shallow clone in libgit2, while + // it is forbidden with git. Therefore we use another + // sentinel value to detect full clone. + if (m_depth == 0) + { + std::cout << "fatal: depth 0 is not a positive number" << std::endl; + return; + } + + if (m_depth == std::numeric_limits::max()) + { + m_depth = 0; + } + git_indexer_progress pd; git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; @@ -34,8 +48,6 @@ void clone_subcommand::run() clone_opts.fetch_opts.depth = m_depth; clone_opts.bare = m_bare ? 1 : 0; - - std::string short_name = m_directory; if (m_directory.empty()) { diff --git a/src/subcommand/clone_subcommand.hpp b/src/subcommand/clone_subcommand.hpp index 76e6074..ab61461 100644 --- a/src/subcommand/clone_subcommand.hpp +++ b/src/subcommand/clone_subcommand.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../utils/common.hpp" @@ -16,7 +17,7 @@ class clone_subcommand std::string m_repository = {}; std::string m_directory = {}; bool m_bare = false; - size_t m_depth = 0; + size_t m_depth = std::numeric_limits::max(); // std::string m_shallow_since; // std::vector m_shallow_exclude; }; diff --git a/src/subcommand/fetch_subcommand.cpp b/src/subcommand/fetch_subcommand.cpp index b5e26c6..0662970 100644 --- a/src/subcommand/fetch_subcommand.cpp +++ b/src/subcommand/fetch_subcommand.cpp @@ -14,7 +14,7 @@ fetch_subcommand::fetch_subcommand(const libgit2_object&, CLI::App& app) sub->add_option("", m_remote_name, "The remote to fetch from") ->default_val("origin"); sub->add_option("--depth", m_depth, "deepen or shorten history of shallow clone"); - // sub->add_option("--deepen", m_deepen, "deepen history of shallow clone"); + sub->add_option("--deepen", m_deepen, "deepen history of shallow clone"); // sub->add_option("--shallow-since", m_shallow_since, "