Introduction
Introduction Statistics Contact Development Disclaimer Help
tfix when commit has no parent - stagit - static git page generator
git clone git://src.adamsgaard.dk/stagit
Log
Files
Refs
README
LICENSE
---
commit 55b823b226194cd25864f1b61bc5b4f343e4e822
parent a523491d6cea4d7fff9b3bdeeb79842412dc31cd
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 7 Dec 2015 21:16:28 +0100
fix when commit has no parent
also dont show parent when there is no id for it.
Diffstat:
M urmoms.c | 41 ++++++++++++++++++++---------…
1 file changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/urmoms.c b/urmoms.c
t@@ -168,7 +168,7 @@ printcommit(FILE *fp, git_commit *commit)
fprintf(fp, "<b>commit</b> <a href=\"%scommit/%s.html\">%s</a>\n",
relpath, buf, buf);
- if (git_oid_tostr(buf, sizeof(buf), git_commit_parent_id(commit, 0)))
+ if (git_oid_tostr(buf, sizeof(buf), git_commit_parent_id(commit, 0)) &…
fprintf(fp, "<b>parent</b> <a href=\"%scommit/%s.html\">%s</a>…
relpath, buf, buf);
t@@ -225,12 +225,15 @@ printshowfile(git_commit *commit)
writeheader(fp);
printcommit(fp, commit);
- if ((error = git_commit_parent(&parent, commit, 0)))
- return;
if ((error = git_commit_tree(&commit_tree, commit)))
goto err;
- if ((error = git_commit_tree(&parent_tree, parent)))
- goto err;
+ if (!(error = git_commit_parent(&parent, commit, 0))) {
+ if ((error = git_commit_tree(&parent_tree, parent)))
+ goto err; /* TODO: handle error */
+ } else {
+ parent = NULL;
+ parent_tree = NULL;
+ }
if ((error = git_diff_tree_to_tree(&diff, repo, parent_tree, commit_tr…
goto err;
t@@ -334,7 +337,7 @@ writelog(FILE *fp)
size_t i, nfiles, ndel, nadd;
const char *summary;
char buf[GIT_OID_HEXSZ + 1];
- int error;
+ int error, ret = 0;
mkdir("commit", 0755);
t@@ -352,14 +355,20 @@ writelog(FILE *fp)
relpath = "";
- if (git_commit_lookup(&commit, repo, &id))
- return 1; /* TODO: error */
- if ((error = git_commit_parent(&parent, commit, 0)))
- continue; /* TODO: handle error */
+ if (git_commit_lookup(&commit, repo, &id)) {
+ ret = 1;
+ goto err;
+ }
if ((error = git_commit_tree(&commit_tree, commit)))
- continue; /* TODO: handle error */
- if ((error = git_commit_tree(&parent_tree, parent)))
- continue; /* TODO: handle error */
+ goto errdiff; /* TODO: handle error */
+ if (!(error = git_commit_parent(&parent, commit, 0))) {
+ if ((error = git_commit_tree(&parent_tree, parent)))
+ goto errdiff; /* TODO: handle error */
+ } else {
+ parent = NULL;
+ parent_tree = NULL;
+ }
+
if ((error = git_diff_tree_to_tree(&diff, repo, parent_tree, c…
continue; /* TODO: handle error */
if (git_diff_get_stats(&stats, diff))
t@@ -399,14 +408,16 @@ writelog(FILE *fp)
relpath = "../";
printshowfile(commit);
+errdiff:
git_diff_free(diff);
git_commit_free(commit);
}
fprintf(fp, "</tbody></table>");
+err:
git_revwalk_free(w);
relpath = "";
- return 0;
+ return ret;
}
void
t@@ -439,7 +450,7 @@ printcommitatom(FILE *fp, git_commit *commit)
fputs("<content type=\"text\">", fp);
fprintf(fp, "commit %s\n", buf);
- if (git_oid_tostr(buf, sizeof(buf), git_commit_parent_id(commit, 0)))
+ if (git_oid_tostr(buf, sizeof(buf), git_commit_parent_id(commit, 0)) &…
fprintf(fp, "parent %s\n", buf);
if ((count = (int)git_commit_parentcount(commit)) > 1) {
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.