summaryrefslogtreecommitdiff
path: root/src/diff_output.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-03-07 00:02:55 +0100
committerVicent Martí <tanoku@gmail.com>2012-03-07 00:11:43 +0100
commitcb8a79617b15e347f26d21cedde0f2b8670c1876 (patch)
tree459706192f41bbf15496f0c9bfe2e21b16a7e70b /src/diff_output.c
parent9d160ba85539bbc593369f597a07d42c2770dff4 (diff)
downloadlibgit2-cb8a79617b15e347f26d21cedde0f2b8670c1876.tar.gz
error-handling: Repository
This also includes droping `git_buf_lasterror` because it makes no sense in the new system. Note that in most of the places were it has been dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so instead it should return a generic `-1` and obviously not throw anything.
Diffstat (limited to 'src/diff_output.c')
-rw-r--r--src/diff_output.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/diff_output.c b/src/diff_output.c
index 5e7486ab8..9c34dcf71 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -482,8 +482,8 @@ static int print_compact(void *data, git_diff_delta *delta, float progress)
else
git_buf_printf(pi->buf, "%c\t%s\n", code, delta->old.path);
- if (git_buf_lasterror(pi->buf) != GIT_SUCCESS)
- return git_buf_lasterror(pi->buf);
+ if (git_buf_oom(pi->buf) == true)
+ return GIT_ENOMEM;
return pi->print_cb(pi->cb_data, GIT_DIFF_LINE_FILE_HDR, pi->buf->ptr);
}
@@ -534,7 +534,10 @@ static int print_oid_range(diff_print_info *pi, git_diff_delta *delta)
git_buf_printf(pi->buf, "index %s..%s\n", start_oid, end_oid);
}
- return git_buf_lasterror(pi->buf);
+ if (git_buf_oom(pi->buf))
+ return GIT_ENOMEM;
+
+ return 0;
}
static int print_patch_file(void *data, git_diff_delta *delta, float progress)
@@ -567,8 +570,8 @@ static int print_patch_file(void *data, git_diff_delta *delta, float progress)
git_buf_printf(pi->buf, "+++ %s%s\n", newpfx, newpath);
}
- if (git_buf_lasterror(pi->buf) != GIT_SUCCESS)
- return git_buf_lasterror(pi->buf);
+ if (git_buf_oom(pi->buf))
+ return GIT_ENOMEM;
error = pi->print_cb(pi->cb_data, GIT_DIFF_LINE_FILE_HDR, pi->buf->ptr);
if (error != GIT_SUCCESS || delta->binary != 1)
@@ -578,8 +581,8 @@ static int print_patch_file(void *data, git_diff_delta *delta, float progress)
git_buf_printf(
pi->buf, "Binary files %s%s and %s%s differ\n",
oldpfx, oldpath, newpfx, newpath);
- if (git_buf_lasterror(pi->buf) != GIT_SUCCESS)
- return git_buf_lasterror(pi->buf);
+ if (git_buf_oom(pi->buf))
+ return GIT_ENOMEM;
return pi->print_cb(pi->cb_data, GIT_DIFF_LINE_BINARY, pi->buf->ptr);
}
@@ -601,7 +604,7 @@ static int print_patch_hunk(
if (git_buf_printf(pi->buf, "%.*s", (int)header_len, header) == GIT_SUCCESS)
return pi->print_cb(pi->cb_data, GIT_DIFF_LINE_HUNK_HDR, pi->buf->ptr);
else
- return git_buf_lasterror(pi->buf);
+ return GIT_ENOMEM;
}
static int print_patch_line(
@@ -624,8 +627,8 @@ static int print_patch_line(
else if (content_len > 0)
git_buf_printf(pi->buf, "%.*s", (int)content_len, content);
- if (git_buf_lasterror(pi->buf) != GIT_SUCCESS)
- return git_buf_lasterror(pi->buf);
+ if (git_buf_oom(pi->buf))
+ return GIT_ENOMEM;
return pi->print_cb(pi->cb_data, line_origin, pi->buf->ptr);
}