Commit 49f9941df594136c606bbb9b110869967e0f8e30

Dmitry Lobanov 2021-05-16T23:54:25

submodule: git submodule dup has been added.

diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index bedd76d..139a0cb 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -224,6 +224,13 @@ GIT_EXTERN(int) git_submodule_lookup(
 	const char *name);
 
 /**
+ * Dup (retain) a submodule
+ *
+ * @param submodule Submodule object
+ */
+GIT_EXTERN(git_submodule *) git_submodule_dup(git_submodule *submodule);
+
+/**
  * Release a submodule
  *
  * @param submodule Submodule object
diff --git a/src/submodule.c b/src/submodule.c
index 1486945..0460f47 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -1854,6 +1854,14 @@ static void submodule_release(git_submodule *sm)
 	git__free(sm);
 }
 
+git_submodule* git_submodule_dup(git_submodule *sm)
+{
+	if (!sm)
+		return;
+	GIT_REFCOUNT_INC(sm);
+	return sm;
+}
+
 void git_submodule_free(git_submodule *sm)
 {
 	if (!sm)