summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-03-01 22:36:50 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-03-23 08:35:59 -0400
commit09a51af5e234c5961e64f6fd16935a4daa31aa5c (patch)
tree86096feede60ee946198c9e1cd1109dabe727519
parent2a827f80474d74ba7d145afeb0fc0795282fabc4 (diff)
downloadlibgit2-ethomson/checkout_safety.tar.gz
checkout: deprecate GIT_CHECKOUT_NONEethomson/checkout_safety
`GIT_CHECKOUT_NONE` makes little sense. Users should prefer `DRY_RUN`, and `NONE` should be deprecated.
-rw-r--r--include/git2/checkout.h9
-rw-r--r--include/git2/deprecated.h15
-rw-r--r--src/libgit2/clone.c2
3 files changed, 19 insertions, 7 deletions
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index 1d145336b..02950eb3c 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -190,13 +190,8 @@ typedef enum {
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17),
- /**
- * Do not do a checkout and do not fire callbacks; this is useful
- * for internal functions that will perform the checkout themselves
- * but need to pass checkout options into another function, for
- * example, `git_clone`.
- */
- GIT_CHECKOUT_NONE = (1u << 30)
+ /** Reserved for backward compatibility */
+ GIT_CHECKOUT_RESERVED = (1u << 30)
} git_checkout_strategy_t;
/**
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index f73d7da61..66b0cff81 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -260,6 +260,21 @@ GIT_EXTERN(void) git_buf_free(git_buf *buffer);
/**@}*/
+/** @name Deprecated Checkout Definitions */
+/**@{*/
+
+/**
+ * Do not do a checkout and do not fire callbacks; this is useful
+ * for internal functions that will perform the checkout themselves
+ * but need to pass checkout options into another function, for
+ * example, `git_clone`.
+ *
+ * @deprecated Users should use `GIT_CHECKOUT_DRY_RUN`
+ */
+#define GIT_CHECKOUT_NONE (1u << 30)
+
+/**@}*/
+
/** @name Deprecated Commit Definitions
*/
/**@{*/
diff --git a/src/libgit2/clone.c b/src/libgit2/clone.c
index c872000d0..08cae6d6a 100644
--- a/src/libgit2/clone.c
+++ b/src/libgit2/clone.c
@@ -583,8 +583,10 @@ static int clone_repo(
options.fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
/* Backward compatibility: support the deprecated GIT_CHECKOUT_NONE */
+#ifndef GIT_DEPRECATE_HARD
if (options.checkout_opts.checkout_strategy == GIT_CHECKOUT_NONE)
options.no_checkout = 1;
+#endif
/* Only clone to a new directory or an empty directory */
if (git_fs_path_exists(local_path) && !use_existing && !git_fs_path_is_empty_dir(local_path)) {