From a3576fe1193cf33debd9da69da53e4dd3a1dec78 Mon Sep 17 00:00:00 2001 From: Sunur Efe Vural Date: Mon, 27 Jan 2020 12:46:27 -0500 Subject: [PATCH] use absolute paths in links This is a complimentary patch to rm_file_ext patch[1]. Relative paths are not suitable. [1] --- stagit-index.c | 9 +++++---- stagit.c | 51 +++++++++++++++++++++++++------------------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/stagit-index.c b/stagit-index.c index 757f974..a41ab74 100644 --- a/stagit-index.c +++ b/stagit-index.c @@ -16,6 +16,7 @@ static git_repository *repo; static const char *relpath = ""; +static const char *abspath = "/en/git/"; static char description[255] = "Repositories"; static char *name = ""; @@ -73,11 +74,11 @@ writeheader(FILE *fp) "\n" "", fp); xmlencode(fp, description, strlen(description)); - fprintf(fp, "\n\n", relpath); - fprintf(fp, "\n", relpath); + fprintf(fp, "\n\n", abspath); + fprintf(fp, "\n", abspath); fputs("\n\n", fp); fprintf(fp, "\n\n" - "\n
\"\"", relpath); + "", abspath); xmlencode(fp, description, strlen(description)); fputs("
\n" "
\n
\n
\n" @@ -122,7 +123,7 @@ writelog(FILE *fp) if (!strcmp(p, ".git")) *p = '\0'; - fputs("", fp); xmlencode(fp, stripped_name, strlen(stripped_name)); diff --git a/stagit.c b/stagit.c index 110fe06..6bdeb3f 100644 --- a/stagit.c +++ b/stagit.c @@ -50,6 +50,7 @@ struct commitinfo { static git_repository *repo; static const char *relpath = ""; +static const char *abspath = "/en/git"; static const char *repodir; static char *name = ""; @@ -351,13 +352,13 @@ writeheader(FILE *fp, const char *title) if (description[0]) fputs(" - ", fp); xmlencode(fp, description, strlen(description)); - fprintf(fp, "\n\n", relpath); - fprintf(fp, "\n", - name, relpath); - fprintf(fp, "\n", relpath); + fprintf(fp, "\n\n", abspath); + fprintf(fp, "\n", + name, abspath); + fprintf(fp, "\n", abspath); fputs("\n\n", fp); } fputs("
", fp); - fprintf(fp, "\"\"", - relpath, relpath); + fprintf(fp, "\"\"", + abspath, abspath); fputs("

", fp); xmlencode(fp, strippedname, strlen(strippedname)); fputs("

", fp); @@ -371,18 +372,18 @@ writeheader(FILE *fp, const char *title) fputs("
\n", fp); - fprintf(fp, "Log | ", relpath); - fprintf(fp, "Files | ", relpath); - fprintf(fp, "Refs", relpath); + fprintf(fp, "Log | ", abspath, strippedname); + fprintf(fp, "Files | ", abspath, strippedname); + fprintf(fp, "Refs", abspath, strippedname); if (submodules) - fprintf(fp, " | Submodules", - relpath, submodules); + fprintf(fp, " | Submodules", + abspath, strippedname, submodules); if (readme) - fprintf(fp, " | README", - relpath, readme); + fprintf(fp, " | README", + abspath, strippedname, readme); if (license) - fprintf(fp, " | LICENSE", - relpath, license); + fprintf(fp, " | LICENSE", + abspath, strippedname, license); fputs("
\n
\n
\n", fp); } @@ -427,12 +428,12 @@ writeblobhtml(FILE *fp, const git_blob *blob) void printcommit(FILE *fp, struct commitinfo *ci) { - fprintf(fp, "commit %s\n", - relpath, ci->oid, ci->oid); + fprintf(fp, "commit %s\n", + abspath, strippedname, ci->oid, ci->oid); if (ci->parentoid[0]) - fprintf(fp, "parent %s\n", - relpath, ci->parentoid, ci->parentoid); + fprintf(fp, "parent %s\n", + abspath, strippedname, ci->parentoid, ci->parentoid); if (ci->author) { fputs("Author: ", fp); @@ -532,11 +533,11 @@ printshowfile(FILE *fp, struct commitinfo *ci) for (i = 0; i < ci->ndeltas; i++) { patch = ci->deltas[i]->patch; delta = git_patch_get_delta(patch); - fprintf(fp, "diff --git a/diff --git a/old_file.path, strlen(delta->old_file.path)); fputs("\">", fp); xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path)); - fprintf(fp, " b/ b/new_file.path, strlen(delta->new_file.path)); fprintf(fp, "\">"); xmlencode(fp, delta->new_file.path, strlen(delta->new_file.path)); @@ -584,7 +585,7 @@ writelogline(FILE *fp, struct commitinfo *ci) printtimeshort(fp, &(ci->author->when)); fputs("", fp); if (ci->summary) { - fprintf(fp, "", relpath, ci->oid); + fprintf(fp, "", abspath, strippedname, ci->oid); xmlencode(fp, ci->summary, strlen(ci->summary)); fputs("", fp); } @@ -887,7 +888,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) fputs("", fp); fputs(filemode(git_tree_entry_filemode(entry)), fp); - fprintf(fp, "", fp); xmlencode(fp, entrypath, strlen(entrypath)); @@ -899,8 +900,8 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) fputs("\n", fp); git_object_free(obj); } else if (!git_submodule_lookup(&module, repo, entryname)) { - fprintf(fp, "m---------", - relpath); + fprintf(fp, "m---------", + abspath, strippedname); xmlencode(fp, entrypath, strlen(entrypath)); git_submodule_free(module); fputs("\n", fp); -- 2.25.0