git.y1.nz

sgw

Static git web (fork of stagit)
download: https://git.y1.nz/archives/sgw.tar.gz
README | Files | Log | Refs | LICENSE

commit 6cf782cc14ea5bf98242e80dba6737e28cc9e6a1
parent c9de381e978e64e4d40e93948a1b784ce12aa364
Author: Emma Weaver <emma@waeaves.com>
Date:   Thu, 18 Jun 2026 00:25:59 -0400

Added warning prints for empty data fields

Diffstat:
Mmain.c2--
Mrepo.c29++++++++++++++++++++---------
2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/main.c b/main.c @@ -127,8 +127,6 @@ get_index_page_path(char *buf, size_t buf_size, const char *dir, char *name) if (chars < 0 || (size_t) (index += chars) >= buf_size) goto page_path_err; - printf("Index page path: %s" "\n", buf); - return; page_path_err: diff --git a/repo.c b/repo.c @@ -70,6 +70,14 @@ find_description(RepoData *data) check_file_error(fp, path, 'r'); fclose(fp); + + if ( + data->description[0] == 'U' && data->description[1] == 'n' && + data->description[2] == 'n' && data->description[3] == 'a' && + data->description[4] == 'm' && data->description[5] == 'e' && + data->description[6] == 'd' && data->description[7] == ' ' && + data->description[8] == 'r' + ) fprintf(stderr, "Warning: empty description: %s" "\n", data->repo_name); } void @@ -81,17 +89,18 @@ find_url(RepoData *data) data->url = malloc(URL_SIZE * sizeof(char)); data->url[0] = '\0'; - if (!(fp = git_fopen(data, path, sizeof(path), ".git/url"))) - return; + if ((fp = git_fopen(data, path, sizeof(path), ".git/url"))) { + if (!fgets(data->url, URL_SIZE, fp)) + data->url[0] = '\0'; - if (!fgets(data->url, URL_SIZE, fp)) - data->url[0] = '\0'; + check_file_error(fp, path, 'r'); + fclose(fp); - check_file_error(fp, path, 'r'); - fclose(fp); + data->url[strcspn(data->url, "\n")] = '\0'; + } - // TODO ??? - data->url[strcspn(data->url, "\n")] = '\0'; + if (!data->url[0]) + fprintf(stderr, "Warning: empty url: %s" "\n", data->repo_name); } void @@ -114,8 +123,10 @@ find_repo_name(RepoData *data) if (!strcmp(p, ".git")) *p = '\0'; - if (data->repo_name[0] == '\0') + if (data->repo_name[0] == '\0') { data->repo_name = "untitled"; + fprintf(stderr, "Warning: untitled repostory: %s" "\n", abs_dir); + } } void

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.