summaryrefslogtreecommitdiff
path: root/file
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-27 03:41:09 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-08-27 03:41:09 (GMT)
commitbfc763f768a4d9c1e0998669d796ee9cae057264 (patch)
tree7a643512efeea116e986ed22315fc03fe267e4a7 /file
parent19b6ddff92b79530add41b2b6205035bea362cb2 (diff)
downloadeeshow-bfc763f768a4d9c1e0998669d796ee9cae057264.zip
eeshow-bfc763f768a4d9c1e0998669d796ee9cae057264.tar.gz
eeshow-bfc763f768a4d9c1e0998669d796ee9cae057264.tar.bz2
file/git-file.c, git-hist.c: use pfatal_git, perror_git
Diffstat (limited to 'file')
-rw-r--r--file/git-file.c34
-rw-r--r--file/git-hist.c41
2 files changed, 22 insertions, 53 deletions
diff --git a/file/git-file.c b/file/git-file.c
index 6c828ef..3d67f8f 100644
--- a/file/git-file.c
+++ b/file/git-file.c
@@ -96,21 +96,15 @@ static git_tree *pick_revision(git_repository *repo, const char *revision)
git_object *obj;
git_tree *tree;
- if (git_revparse_single(&obj, repo, revision)) {
- const git_error *e = giterr_last();
-
- fatal("%s: %s\n", git_repository_path(repo), e->message);
- }
+ if (git_revparse_single(&obj, repo, revision))
+ pfatal_git(git_repository_path(repo));
if (git_object_type(obj) != GIT_OBJ_COMMIT)
- fatal("%s: not a commit\n", revision);
+ fatal("%s: not a commit", revision);
commit = (git_commit *) obj;
- if (git_commit_tree(&tree, commit)) {
- const git_error *e = giterr_last();
-
- fatal("%s: %s\n", revision, e->message);
- }
+ if (git_commit_tree(&tree, commit))
+ pfatal_git(revision);
return tree;
}
@@ -284,9 +278,7 @@ static git_tree_entry *find_file(git_repository *repo, git_tree *tree,
free(repo_path);
if (git_tree_entry_bypath(&entry, tree, canon_path)) {
- const git_error *e = giterr_last();
-
- error("%s: %s", path, e->message);
+ perror_git(path);
free(canon_path);
return NULL;
}
@@ -305,21 +297,15 @@ static const void *get_data(struct vcs_git *vcs_git, git_tree_entry *entry,
if (git_tree_entry_type(entry) != GIT_OBJ_BLOB)
fatal("entry is not a blob\n");
- if (git_tree_entry_to_object(&obj, repo, entry)) {
- const git_error *e = giterr_last();
-
- fatal("%s\n", e->message);
- }
+ if (git_tree_entry_to_object(&obj, repo, entry))
+ pfatal_git("git_tree_entry_to_object");
vcs_git->obj = obj;
if (verbose > 2) {
git_buf buf = { 0 };
- if (git_object_short_id(&buf, obj)) {
- const git_error *e = giterr_last();
-
- fatal("%s\n", e->message);
- }
+ if (git_object_short_id(&buf, obj))
+ pfatal_git("git_object_short_id");
progress(3, "object %s", buf.ptr);
git_buf_free(&buf);
}
diff --git a/file/git-hist.c b/file/git-hist.c
index d308799..a4c1776 100644
--- a/file/git-hist.c
+++ b/file/git-hist.c
@@ -81,7 +81,6 @@ static void recurse(struct hist *h,
{
unsigned n, i, j;
struct hist **b;
- const git_error *e;
n = git_commit_parentcount(h->commit);
if (verbose > 2)
@@ -98,10 +97,8 @@ static void recurse(struct hist *h,
git_commit *commit;
struct hist *found = NULL;
- if (git_commit_parent(&commit, h->commit, i)) {
- e = giterr_last();
- fatal("git_commit_parent: %s\n", e->message);
- }
+ if (git_commit_parent(&commit, h->commit, i))
+ pfatal_git("git_commit_parent");
for (j = 0; j != n_branches; j++) {
found = find_commit(b[j], commit);
if (found)
@@ -142,27 +139,20 @@ struct hist *vcs_git_hist(const char *path)
struct hist *head, *dirty;
git_repository *repo;
git_oid oid;
- const git_error *e;
head = new_commit(0);
git_init_once();
if (git_repository_open_ext(&repo, path,
- GIT_REPOSITORY_OPEN_CROSS_FS, NULL)) {
- e = giterr_last();
- fatal("%s: %s\n", path, e->message);
- }
+ GIT_REPOSITORY_OPEN_CROSS_FS, NULL))
+ pfatal_git(path);
- if (git_reference_name_to_id(&oid, repo, "HEAD")) {
- e = giterr_last();
- fatal("%s: %s\n", git_repository_path(repo), e->message);
- }
+ if (git_reference_name_to_id(&oid, repo, "HEAD"))
+ pfatal_git(git_repository_path(repo));
- if (git_commit_lookup(&head->commit, repo, &oid)) {
- e = giterr_last();
- fatal("%s: %s\n", git_repository_path(repo), e->message);
- }
+ if (git_commit_lookup(&head->commit, repo, &oid))
+ pfatal_git(git_repository_path(repo));
recurse(head, 1, &head);
@@ -191,7 +181,6 @@ char *vcs_git_get_rev(struct hist *h)
const char *vcs_git_summary(struct hist *h)
{
const char *summary;
- const git_error *e;
if (!h->commit)
return "Uncommitted changes";
@@ -199,8 +188,7 @@ const char *vcs_git_summary(struct hist *h)
if (summary)
return summary;
- e = giterr_last();
- fatal("git_commit_summary: %s\n", e->message);
+ pfatal_git("git_commit_summary");
}
@@ -213,7 +201,6 @@ const char *vcs_git_summary(struct hist *h)
char *vcs_git_long_for_pango(struct hist *h,
char *(*formatter)(const char *fmt, ...))
{
- const git_error *e;
git_buf buf = { 0 };
time_t commit_time;
const git_signature *sig;
@@ -232,8 +219,7 @@ char *vcs_git_long_for_pango(struct hist *h,
return s;
fail:
- e = giterr_last();
- fatal("vcs_git_long_for_pango: %s\n", e->message);
+ pfatal_git("vcs_git_long_for_pango");
}
@@ -252,14 +238,11 @@ void hist_iterate(struct hist *h,
void dump_hist(struct hist *h)
{
git_buf buf = { 0 };
- const git_error *e;
unsigned i;
if (h->commit) {
- if (git_object_short_id(&buf, (git_object *) h->commit)) {
- e = giterr_last();
- fatal("git_object_short_id: %s\n", e->message);
- }
+ if (git_object_short_id(&buf, (git_object *) h->commit))
+ pfatal_git("git_object_short_id");
printf("%*s%s %s\n",
2 * h->branch, "", buf.ptr, vcs_git_summary(h));
git_buf_free(&buf);