]> git.armaanb.net Git - stagit.git/blobdiff - src/stagit.c
Fix merge
[stagit.git] / src / stagit.c
index ba154d05333c177a711508414be1c288118ca8c2..cac0251bf4666bd0f49156c9b99d9a260354be95 100644 (file)
@@ -56,6 +56,7 @@ struct commitinfo {
 
 static git_repository *repo;
 
+static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */
 static const char *relpath = "";
 static const char *repodir;
 
@@ -285,27 +286,6 @@ void
 xmlencodeline(FILE *fp, const char *s, size_t len)
 {
        size_t i;
-
-       for (i = 0; *s && i < len; s++, i++) {
-               switch(*s) {
-               case '<':  fputs("&lt;",   fp); break;
-               case '>':  fputs("&gt;",   fp); break;
-               case '\'': fputs("&#39;",  fp); break;
-               case '&':  fputs("&amp;",  fp); break;
-               case '"':  fputs("&quot;", fp); break;
-               case '\r': break; /* ignore CR */
-               case '\n': break; /* ignore LF */
-               default:   putc(*s, fp);
-               }
-       }
-}
-
-/* Escape characters below as HTML 2.0 / XML 1.0, ignore printing '\n', '\r' */
-void
-xmlencodeline(FILE *fp, const char *s, size_t len)
-{
-       size_t i;
-
        for (i = 0; *s && i < len; s++, i++) {
                switch(*s) {
                case '<':  fputs("&lt;",   fp); break;
@@ -533,12 +513,12 @@ printcommit(FILE *fp, struct commitinfo *ci)
                xmlencode(fp, ci->author->email, strlen(ci->author->email));
                fputs("</a>&gt;\n<b>Date:</b>   ", fp);
                printtime(fp, &(ci->author->when));
-               fputc('\n', fp);
+               putc('\n', fp);
        }
        if (ci->msg) {
-               fputc('\n', fp);
+               putc('\n', fp);
                xmlencode(fp, ci->msg, strlen(ci->msg));
-               fputc('\n', fp);
+               putc('\n', fp);
        }
 }
 
@@ -784,8 +764,8 @@ printcommitatom(FILE *fp, struct commitinfo *ci)
                xmlencode(fp, ci->summary, strlen(ci->summary));
                fputs("</title>\n", fp);
        }
-       fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"commit/%s.html\" />\n",
-               ci->oid);
+       fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"%scommit/%s.html\" />\n",
+               baseurl, ci->oid);
 
        if (ci->author) {
                fputs("<author>\n<name>", fp);
@@ -806,10 +786,10 @@ printcommitatom(FILE *fp, struct commitinfo *ci)
                xmlencode(fp, ci->author->email, strlen(ci->author->email));
                fputs("&gt;\nDate:   ", fp);
                printtime(fp, &(ci->author->when));
-               fputc('\n', fp);
+               putc('\n', fp);
        }
        if (ci->msg) {
-               fputc('\n', fp);
+               putc('\n', fp);
                xmlencode(fp, ci->msg, strlen(ci->msg));
        }
        fputs("\n</content>\n</entry>\n", fp);
@@ -1174,7 +1154,8 @@ err:
 void
 usage(char *argv0)
 {
-       fprintf(stderr, "%s [-c cachefile | -l commits] repodir\n", argv0);
+       fprintf(stderr, "%s [-c cachefile | -l commits] "
+               "[-u baseurl] repodir\n", argv0);
        exit(1);
 }
 
@@ -1207,6 +1188,10 @@ main(int argc, char *argv[])
                        if (argv[i][0] == '\0' || *p != '\0' ||
                            nlogcommits <= 0 || errno)
                                usage(argv[0]);
+               } else if (argv[i][1] == 'u') {
+                       if (i + 1 >= argc)
+                               usage(argv[0]);
+                       baseurl = argv[++i];
                }
        }
        if (!repodir)