0b27db8fb840a73902f762614e71f0bee82034ab galt Mon Mar 8 15:20:02 2010 -0800 removed redundancy in html generation, and in mkdir, tidied up tags a bit for consistency diff --git git-reports.c git-reports.c index 81f48c6..1cf10de 100644 --- git-reports.c +++ git-reports.c @@ -192,8 +192,8 @@ { verbose(2, "%c %s\n", f->type, f->path); - // anything other than M? - if (f->type != 'M') + // anything other than M or A? + if (f->type != 'M' && f->type != 'A' ) verbose(2, "special type: %c %s\n", f->type, f->path); } @@ -220,16 +220,23 @@ int lineSize; char *line; char *xline = NULL; +char fmtString[256]; boolean inBody = FALSE; boolean inBlock = TRUE; int blockP = 0, blockN = 0; fprintf(h, "\n\n%s %s\n\n\n
\n", path, commitId);
-while (lineFileNext(lf, &line, &lineSize))
+boolean hasMore = TRUE;
+while (hasMore)
+    {
+    boolean checkEob = FALSE;
+    hasMore = lineFileNext(lf, &line, &lineSize);
+    if (hasMore)
     {
+	char *color = NULL;
     xline = htmlEncode(line);	
     if (line[0] == '-')
 	{
-	fprintf(h, "%s\n", xline);
+	    color = "#FF9999";  /* deleted text light red */
 	if (inBody)
 	    {
 	    inBlock = TRUE;
@@ -238,7 +245,7 @@
 	}
     else if (line[0] == '+')
 	{
-	fprintf(h, "%s\n", xline);
+	    color = "#99FF99";  /* added text light green */
 	if (inBody)
 	    {
 	    inBlock = TRUE;
@@ -248,34 +255,26 @@
     else
 	{
 	if (line[0] == '@')
-	    fprintf(h, "%s\n", xline);
-	else
-	    fprintf(h, "%s\n", xline);
-	if (inBody)
-	    {
-	    if (inBlock)
-		{
-		inBlock = FALSE;
-		if (blockP >= blockN)
-		    linesChanged += blockP;
-		else
-		    linesChanged += blockN;
-		blockP = 0;
-		blockN = 0;
-		}
-	    }
+		color = "#FFFF99";  /* diff control text light yellow (red+green) */
+	    checkEob = TRUE;
 	}
+	if (color)
+	    safef(fmtString, sizeof(fmtString), "%%s\n", color);
+	else
+	    safef(fmtString, sizeof(fmtString), "%%s\n");
+	fprintf(h, fmtString, xline);
 	
     if (line[0] == '@')
 	inBody = TRUE;
 
     freeMem(xline);
-
     }
-// what if there is no last trailing line to end the last block?
-if (inBody)
+    else
     {
-    if (inBlock)
+	checkEob = TRUE;
+	}
+
+    if (checkEob && inBlock)
 	{
 	inBlock = FALSE;
 	if (blockP >= blockN)
@@ -285,6 +284,7 @@
 	blockP = 0;
 	blockN = 0;
 	}
+
     }
 
 lineFileClose(&lf);
@@ -350,7 +350,7 @@
 	{
 	char *end = strchr(line+2, '@');
 	*(end+2) = 0;  // chop the weird unwanted context string from here following e.g. 
-        //@@ -99,7 +99,9 @@ echo
+        //@@ -99,7 +99,9 @@ weird unwanted context string here
         // converts to
         //@@ -99,7 +99,9 @@
 	// saves 17 seconds over the more expensive sed command
@@ -376,10 +376,10 @@
 
 FILE *h = mustOpen(userPath, "w");
 fprintf(h, "\n\nCommits for %s\n\n\n", u);
-fprintf(h, "

Commits for %s

\n", u); +fprintf(h, "

Commits for %s

\n", u); fprintf(h, "switch to files view, user index\n"); -fprintf(h, "

%s to %s (%s to %s) %s

\n", startTag, endTag, startDate, endDate, title); +fprintf(h, "

%s to %s (%s to %s) %s

\n", startTag, endTag, startDate, endDate, title); fprintf(h, "