summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuang Li <yuangli@uk-yuangli-l.dhcp.mathworks.com>2022-06-28 09:35:51 +0100
committerYuang Li <yuangli@uk-yuangli-l.dhcp.mathworks.com>2022-06-28 09:35:51 +0100
commit9d1507d1d36d640669d82f80d2b0151e11dbab2f (patch)
tree1059f08bb5ad12f9bd260316172d84619e98c72e
parent397753f01701ed7e5148f147e3a126a0abbd33e4 (diff)
downloadlibgit2-9d1507d1d36d640669d82f80d2b0151e11dbab2f.tar.gz
correct use of feature flag
-rw-r--r--src/commit.c36
-rw-r--r--src/repository.c3
2 files changed, 19 insertions, 20 deletions
diff --git a/src/commit.c b/src/commit.c
index ab6863481..a4899ed57 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -502,31 +502,29 @@ int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned
{
int error;
-
if ((error = commit_parse(commit, git_odb_object_data(odb_obj),
git_odb_object_size(odb_obj), flags)) < 0)
return error;
- if (GIT_OPT_ENABLE_SHALLOW) {
-
- git_repository *repo = git_object_owner((git_object *)commit);
- git_commit_graft *graft;
-
- /* Perform necessary grafts */
- if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) == 0 ||
- git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) == 0) {
- size_t idx;
- git_oid *oid;
- git_array_clear(commit->parent_ids);
- git_array_init_to_size(commit->parent_ids, git_array_size(graft->parents));
- git_array_foreach(graft->parents, idx, oid) {
- git_oid *id = git_array_alloc(commit->parent_ids);
- GIT_ERROR_CHECK_ALLOC(id);
+ if (!git_shallow__enabled)
+ return 0;
- git_oid_cpy(id, oid);
- }
+ git_repository *repo = git_object_owner((git_object *)commit);
+ git_commit_graft *graft;
+
+ /* Perform necessary grafts */
+ if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) == 0 ||
+ git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) == 0) {
+ size_t idx;
+ git_oid *oid;
+ git_array_clear(commit->parent_ids);
+ git_array_init_to_size(commit->parent_ids, git_array_size(graft->parents));
+ git_array_foreach(graft->parents, idx, oid) {
+ git_oid *id = git_array_alloc(commit->parent_ids);
+ GIT_ERROR_CHECK_ALLOC(id);
+
+ git_oid_cpy(id, oid);
}
-
}
return 0;
diff --git a/src/repository.c b/src/repository.c
index f9b34445c..87874fece 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -14,6 +14,7 @@
#include "common.h"
#include "commit.h"
+#include "grafts.h"
#include "tag.h"
#include "blob.h"
#include "futils.h"
@@ -926,7 +927,7 @@ int git_repository_open_ext(
if ((error = check_extensions(config, version)) < 0)
goto cleanup;
- if (GIT_OPT_ENABLE_SHALLOW && (error = load_grafts(repo)) < 0)
+ if (git_shallow__enabled && (error = load_grafts(repo)) < 0)
goto cleanup;
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)