stagit

performance tweak: check if commit file exists, if so skip

Hiltjo Posthuma contact@arjunchoudhary.com

commit: e2857a3 parent: e86975e
1 files changed, 5 insertions(+), 1 deletions(-)
Murmoms.c+5-1
M · urmoms.c +5, -1
 1@@ -7,6 +7,7 @@
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 #include <string.h>
 5+#include <unistd.h>
 6 
 7 #include "git2.h"
 8 
 9@@ -218,10 +219,13 @@ printshowfile(git_commit *commit)
10 
11 	git_oid_tostr(buf, sizeof(buf), git_commit_id(commit));
12 	snprintf(path, sizeof(path), "commit/%s.html", buf);
13-	fp = efopen(path, "w+b");
14+	/* check if file exists if so skip it */
15+	if (!access(path, F_OK))
16+		return;
17 
18 	memset(&diffstatsbuf, 0, sizeof(diffstatsbuf));
19 
20+	fp = efopen(path, "w+b");
21 	writeheader(fp);
22 	printcommit(fp, commit);
23