Commit c01b7841 by yuangli

improve error handling

parent cfc2ae68
...@@ -6,4 +6,3 @@ ...@@ -6,4 +6,3 @@
CMakeSettings.json CMakeSettings.json
.vs .vs
.idea .idea
.cache
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "types.h" #include "types.h"
#include "oid.h" #include "oid.h"
#include "buffer.h" #include "buffer.h"
#include "oidarray.h"
/** /**
* @file git2/repository.h * @file git2/repository.h
......
...@@ -93,13 +93,17 @@ int git_grafts_refresh(git_grafts *grafts) ...@@ -93,13 +93,17 @@ int git_grafts_refresh(git_grafts *grafts)
if (!grafts->path) if (!grafts->path)
return 0; return 0;
error = git_futils_readbuffer_updated(&contents, grafts->path, if ((error = git_futils_readbuffer_updated(&contents, grafts->path,
(grafts->path_checksum).id, &updated); (grafts->path_checksum).id, &updated)) < 0) {
if (error < 0 || error == GIT_ENOTFOUND || !updated) {
if (error == GIT_ENOTFOUND) { if (error == GIT_ENOTFOUND) {
git_grafts_clear(grafts); git_grafts_clear(grafts);
error = 0; error = 0;
} }
goto cleanup;
}
if (!updated) {
goto cleanup; goto cleanup;
} }
......
...@@ -735,13 +735,6 @@ static int load_grafts(git_repository *repo) ...@@ -735,13 +735,6 @@ static int load_grafts(git_repository *repo)
git_str path = GIT_STR_INIT; git_str path = GIT_STR_INIT;
int error; 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 || if ((error = git_str_joinpath(&path, repo->gitdir, "shallow")) < 0 ||
(error = git_grafts_from_file(&repo->shallow_grafts, path.ptr)) < 0) (error = git_grafts_from_file(&repo->shallow_grafts, path.ptr)) < 0)
goto error; goto error;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "submodule.h" #include "submodule.h"
#include "diff_driver.h" #include "diff_driver.h"
#include "grafts.h" #include "grafts.h"
#include "oidarray.h"
#define DOT_GIT ".git" #define DOT_GIT ".git"
#define GIT_DIR DOT_GIT "/" #define GIT_DIR DOT_GIT "/"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment