summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuangli <yuangli@mathworks.com>2022-07-28 14:24:18 +0100
committeryuangli <yuangli@mathworks.com>2022-07-28 14:24:18 +0100
commitc01b7841b77c08189eae916d21d591027962a831 (patch)
tree939cac6050006cebc82d1e4b334b8c6c07f599e2
parentcfc2ae68b4792f0c64152888869ef69d868079d7 (diff)
downloadlibgit2-c01b7841b77c08189eae916d21d591027962a831.tar.gz
improve error handling
-rw-r--r--.gitignore1
-rw-r--r--include/git2/repository.h1
-rw-r--r--src/libgit2/grafts.c10
-rw-r--r--src/libgit2/repository.c7
-rw-r--r--src/libgit2/repository.h1
5 files changed, 7 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index d43bd9c78..1b482f038 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,3 @@
CMakeSettings.json
.vs
.idea
-.cache
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 258b9ac00..c87f3c962 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -11,7 +11,6 @@
#include "types.h"
#include "oid.h"
#include "buffer.h"
-#include "oidarray.h"
/**
* @file git2/repository.h
diff --git a/src/libgit2/grafts.c b/src/libgit2/grafts.c
index 8bcefbab9..82be2a680 100644
--- a/src/libgit2/grafts.c
+++ b/src/libgit2/grafts.c
@@ -93,13 +93,17 @@ int git_grafts_refresh(git_grafts *grafts)
if (!grafts->path)
return 0;
- error = git_futils_readbuffer_updated(&contents, grafts->path,
- (grafts->path_checksum).id, &updated);
- if (error < 0 || error == GIT_ENOTFOUND || !updated) {
+ if ((error = git_futils_readbuffer_updated(&contents, grafts->path,
+ (grafts->path_checksum).id, &updated)) < 0) {
if (error == GIT_ENOTFOUND) {
git_grafts_clear(grafts);
error = 0;
}
+
+ goto cleanup;
+ }
+
+ if (!updated) {
goto cleanup;
}
diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c
index 809617276..c36666c43 100644
--- a/src/libgit2/repository.c
+++ b/src/libgit2/repository.c
@@ -735,13 +735,6 @@ static int load_grafts(git_repository *repo)
git_str path = GIT_STR_INIT;
int error;
- if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
- (error = git_str_joinpath(&path, path.ptr, "grafts")) < 0 ||
- (error = git_grafts_from_file(&repo->grafts, path.ptr)) < 0)
- goto error;
-
- git_str_clear(&path);
-
if ((error = git_str_joinpath(&path, repo->gitdir, "shallow")) < 0 ||
(error = git_grafts_from_file(&repo->shallow_grafts, path.ptr)) < 0)
goto error;
diff --git a/src/libgit2/repository.h b/src/libgit2/repository.h
index 6d39bb92a..3cca53b3e 100644
--- a/src/libgit2/repository.h
+++ b/src/libgit2/repository.h
@@ -25,7 +25,6 @@
#include "submodule.h"
#include "diff_driver.h"
#include "grafts.h"
-#include "oidarray.h"
#define DOT_GIT ".git"
#define GIT_DIR DOT_GIT "/"