summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuang Li <yuangli@uk-yuangli-l.dhcp.mathworks.com>2022-06-27 10:56:02 +0100
committerYuang Li <yuangli@uk-yuangli-l.dhcp.mathworks.com>2022-06-27 10:56:02 +0100
commit13bd14d930006bc01b89f9fd4d0b074c387ef92f (patch)
treebc8ccccfc78b207bf2be27f441b9001a57f45132
parente07aa9c3c4f5d0462662e2c7fc1ae8120a29d740 (diff)
downloadlibgit2-13bd14d930006bc01b89f9fd4d0b074c387ef92f.tar.gz
add feature flag for shallow clone support
-rw-r--r--include/git2/common.h6
-rw-r--r--src/libgit2.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/include/git2/common.h b/include/git2/common.h
index 2ee829025..dff64103d 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -211,7 +211,8 @@ typedef enum {
GIT_OPT_SET_ODB_PACKED_PRIORITY,
GIT_OPT_SET_ODB_LOOSE_PRIORITY,
GIT_OPT_GET_EXTENSIONS,
- GIT_OPT_SET_EXTENSIONS
+ GIT_OPT_SET_EXTENSIONS,
+ GIT_OPT_ENABLE_SHALLOW
} git_libgit2_opt_t;
/**
@@ -448,6 +449,9 @@ typedef enum {
* > { "!noop", "newext" } indicates that the caller does not want
* > to support repositories with the `noop` extension but does want
* > to support repositories with the `newext` extension.
+ *
+ * opts(GIT_OPT_ENABLE_SHALLOW, int enabled)
+ * > Enable or disable shallow clone support completely.
*
* @param option Option key
* @param ... value to set the option
diff --git a/src/libgit2.c b/src/libgit2.c
index cc793b458..4eef2c618 100644
--- a/src/libgit2.c
+++ b/src/libgit2.c
@@ -390,6 +390,10 @@ int git_libgit2_opts(int key, ...)
}
break;
+ case GIT_OPT_ENABLE_SHALLOW:
+ git_cache__enabled = (va_arg(ap, int) != 0);
+ break;
+
default:
git_error_set(GIT_ERROR_INVALID, "invalid option key");
error = -1;