| @@ -291,9 +291,10 @@ trim(char *buf, size_t bufsiz, const char *src)
for (i = 0; i < 8; i++)
buf[d++] = ' ';
break;
- case '|':
+ case '\r': /* ignore CR */
+ case '|': /* ignore separators here */
+ break;
case '\n':
- case '\r':
buf[d++] = ' ';
break;
default:
@@ -305,9 +306,9 @@ end:
buf[d] = '\0';
}
-/* Escape characters in text in geomyidae .gph format */
+/* Escape characters in text in geomyidae .gph format, with newlines */
void
-gphtext(FILE *fp, const char *s, size_t len)
+gphtextnl(FILE *fp, const char *s, size_t len)
{
size_t i, n = 0;
@@ -330,6 +331,23 @@ gphtext(FILE *fp, const char *s, size_t len)
}
}
+/* Escape characters in text in geomyidae .gph format,
+ newlines are ignored */
+void
+gphtext(FILE *fp, const char *s, size_t len)
+{
+ size_t i;
+
+ for (i = 0; *s && i < len; i++) {
+ switch (s[i]) {
+ case '\r':
+ case '\n': break;
+ case '\t': fputs(" ", fp); break;
+ default: fputc(s[i], fp);
+ }
+ }
+}
+
/* Escape characters in links in geomyidae .gph format */
void
gphlink(FILE *fp, const char *s, size_t len)
@@ -425,6 +443,7 @@ printtimeshort(FILE *fp, const git_time *intime)
void
writeheader(FILE *fp, const char *title)
{
+ fputc('t', fp);
gphtext(fp, title, strlen(title));
if (title[0] && strippedname[0])
fputs(" - ", fp);
@@ -521,7 +540,7 @@ printcommit(FILE *fp, struct commitinfo *ci)
}
if (ci->msg) {
fputc('\n', fp);
- gphtext(fp, ci->msg, strlen(ci->msg));
+ gphtextnl(fp, ci->msg, strlen(ci->msg));
fputc('\n', fp);
}
}
@@ -608,7 +627,9 @@ printshowfile(FILE *fp, struct commitinfo *ci)
if (git_patch_get_hunk(&hunk, &nhunklines, patch, j))
break;
+ fputc('t', fp);
gphtext(fp, hunk->header, hunk->header_len);
+ fputc('\n', fp);
for (k = 0; ; k++) {
if (git_patch_get_line_in_hunk(&line, patch, j, k))
@@ -620,6 +641,7 @@ printshowfile(FILE *fp, struct commitinfo *ci)
else
fputs(" ", fp);
gphtext(fp, line->content, line->content_len);
+ fputc('\n', fp);
}
}
}
@@ -797,6 +819,7 @@ writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t fi
fp = efopen(fpath, "w");
writeheader(fp, filename);
+ fputc('t', fp);
gphtext(fp, filename, strlen(filename));
fprintf(fp, " (%juB)\n", (uintmax_t)filesize);
fputs("---\n", fp); |