stagit

code cleanup + style, functionally equivalent

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 744293a parent: a7ac283
2 files changed, 12 insertions(+), 20 deletions(-)
Mstagit-index.c+1-1
Mstagit.c+11-19
M · stagit-index.c +1, -1
 1@@ -92,11 +92,11 @@ writefooter(FILE *fp)
 2 int
 3 writelog(FILE *fp)
 4 {
 5-	char *stripped_name = NULL, *p;
 6 	git_commit *commit = NULL;
 7 	const git_signature *author;
 8 	git_revwalk *w = NULL;
 9 	git_oid id;
10+	char *stripped_name = NULL, *p;
11 	int ret = 0;
12 
13 	git_revwalk_new(&w, repo);
M · stagit.c +11, -19
  1@@ -141,7 +141,6 @@ commitinfo_free(struct commitinfo *ci)
  2 
  3 	if (!ci)
  4 		return;
  5-
  6 	if (ci->deltas)
  7 		for (i = 0; i < ci->ndeltas; i++)
  8 			deltainfo_free(ci->deltas[i]);
  9@@ -158,15 +157,13 @@ commitinfo_getbyoid(const git_oid *id)
 10 {
 11 	struct commitinfo *ci;
 12 	git_diff_options opts;
 13-	const git_oid *oid;
 14-	int error;
 15 
 16 	if (!(ci = calloc(1, sizeof(struct commitinfo))))
 17 		err(1, "calloc");
 18 
 19-	ci->id = id;
 20 	if (git_commit_lookup(&(ci->commit), repo, id))
 21 		goto err;
 22+	ci->id = id;
 23 
 24 	git_oid_tostr(ci->oid, sizeof(ci->oid), git_commit_id(ci->commit));
 25 	git_oid_tostr(ci->parentoid, sizeof(ci->parentoid), git_commit_parent_id(ci->commit, 0));
 26@@ -175,12 +172,10 @@ commitinfo_getbyoid(const git_oid *id)
 27 	ci->summary = git_commit_summary(ci->commit);
 28 	ci->msg = git_commit_message(ci->commit);
 29 
 30-	oid = git_commit_tree_id(ci->commit);
 31-	if ((error = git_tree_lookup(&(ci->commit_tree), repo, oid)))
 32+	if (git_tree_lookup(&(ci->commit_tree), repo, git_commit_tree_id(ci->commit)))
 33 		goto err;
 34-	if (!(error = git_commit_parent(&(ci->parent), ci->commit, 0))) {
 35-		oid = git_commit_tree_id(ci->parent);
 36-		if ((error = git_tree_lookup(&(ci->parent_tree), repo, oid))) {
 37+	if (!git_commit_parent(&(ci->parent), ci->commit, 0)) {
 38+		if (git_tree_lookup(&(ci->parent_tree), repo, git_commit_tree_id(ci->parent))) {
 39 			ci->parent = NULL;
 40 			ci->parent_tree = NULL;
 41 		}
 42@@ -188,9 +183,8 @@ commitinfo_getbyoid(const git_oid *id)
 43 
 44 	git_diff_init_options(&opts, GIT_DIFF_OPTIONS_VERSION);
 45 	opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH;
 46-	if ((error = git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts)))
 47+	if (git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts))
 48 		goto err;
 49-
 50 	if (commitinfo_getstats(ci) == -1)
 51 		goto err;
 52 
 53@@ -423,8 +417,7 @@ printshowfile(FILE *fp, struct commitinfo *ci)
 54 	const git_diff_hunk *hunk;
 55 	const git_diff_line *line;
 56 	git_patch *patch;
 57-	size_t nhunks, nhunklines, changed, add, del, total;
 58-	size_t i, j, k;
 59+	size_t nhunks, nhunklines, changed, add, del, total, i, j, k;
 60 	char linestr[80];
 61 
 62 	printcommit(fp, ci);
 63@@ -652,7 +645,7 @@ writeatom(FILE *fp)
 64 	struct commitinfo *ci;
 65 	git_revwalk *w = NULL;
 66 	git_oid id;
 67-	size_t i, m = 100; /* max */
 68+	size_t i, m = 100; /* last 'm' commits */
 69 
 70 	fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
 71 	      "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n<title>", fp);
 72@@ -682,8 +675,7 @@ writeatom(FILE *fp)
 73 int
 74 writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t filesize)
 75 {
 76-	char tmp[PATH_MAX] = "";
 77-	char *d;
 78+	char tmp[PATH_MAX] = "", *d;
 79 	const char *p;
 80 	int lc = 0;
 81 	FILE *fp;
 82@@ -772,10 +764,10 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
 83 {
 84 	const git_tree_entry *entry = NULL;
 85 	git_submodule *module = NULL;
 86-	const char *entryname;
 87-	char filepath[PATH_MAX], entrypath[PATH_MAX];
 88 	git_object *obj = NULL;
 89 	git_off_t filesize;
 90+	const char *entryname;
 91+	char filepath[PATH_MAX], entrypath[PATH_MAX];
 92 	size_t count, i;
 93 	int lc, r, ret;
 94 
 95@@ -889,7 +881,7 @@ writerefs(FILE *fp)
 96 	git_reference *dref = NULL, *r, *ref = NULL;
 97 	git_reference_iterator *it = NULL;
 98 	git_reference **refs = NULL;
 99-	size_t count, i, j, refcount = 0;
100+	size_t count, i, j, refcount;
101 	const char *titles[] = { "Branches", "Tags" };
102 	const char *ids[] = { "branches", "tags" };
103 	const char *name;