summaryrefslogtreecommitdiff
path: root/src/diff_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diff_file.c')
-rw-r--r--src/diff_file.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/diff_file.c b/src/diff_file.c
index 7dabf8d6f..2f3f797c5 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -177,11 +177,17 @@ static int diff_file_content_commit_to_str(
unsigned int sm_status = 0;
const git_oid *sm_head;
- if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0 ||
- (error = git_submodule_status(&sm_status, sm)) < 0) {
+ if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) {
/* GIT_EEXISTS means a "submodule" that has not been git added */
- if (error == GIT_EEXISTS)
+ if (error == GIT_EEXISTS) {
+ giterr_clear();
error = 0;
+ }
+ return error;
+ }
+
+ if ((error = git_submodule_status(&sm_status, sm)) < 0) {
+ git_submodule_free(sm);
return error;
}
@@ -196,6 +202,8 @@ static int diff_file_content_commit_to_str(
if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
status = "-dirty";
+
+ git_submodule_free(sm);
}
git_oid_tostr(oid, sizeof(oid), &fc->file->id);