commit 9d84e7dd9e16bfa028f8607ebeae226c7ea4c0ed from: Tracey Emery date: Wed Jan 15 22:10:30 2020 UTC start shortlog page and fix for actual single line commit - cdb914e5a0f172fb2b47056756c143dace8f1977 commit + 9d84e7dd9e16bfa028f8607ebeae226c7ea4c0ed blob - 8f9b2cf6f568f007f0e1d1cce187828cc667f290 blob + 106ff970598595629b38dd4456b7d32c91379c50 --- Makefile.inc +++ Makefile.inc @@ -1,5 +1,5 @@ CPPFLAGS += -DGOT_LIBEXECDIR=${LIBEXECDIR} -DGOT_VERSION=${GOT_VERSION} -CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable +#CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable #CFLAGS += -DGOT_PACK_NO_MMAP #CFLAGS += -DGOT_NO_OBJ_CACHE #CFLAGS += -DGOT_OBJ_CACHE_DEBUG blob - 0ba9cc13b26a4335693a021bb34188e6a2cb7e32 blob + 69b21bc7c6576a212fa584990ba15f078a2e2883 --- gotweb/gotweb.c +++ gotweb/gotweb.c @@ -142,7 +142,7 @@ static char *gw_get_time_str(time_t, int); static char *gw_get_repo_age(struct trans *, char *, char *, int); static char *gw_get_repo_shortlog(struct trans *, - const char *); + const char *, int); static char *gw_get_repo_tags(struct trans *); static char *gw_get_repo_heads(struct trans *); static char *gw_get_clone_url(struct trans *, char *); @@ -409,7 +409,20 @@ static const struct got_error * gw_shortlog(struct trans *gw_trans) { const struct got_error *error = NULL; + char *shortlog, *shortlog_html; + shortlog = gw_get_repo_shortlog(gw_trans, NULL, + gw_trans->gw_conf->got_max_commits_display); + + if (shortlog != NULL && strcmp(shortlog, "") != 0) { + if ((asprintf(&shortlog_html, summary_shortlog, + shortlog)) == -1) + return got_error_from_errno("asprintf"); + khttp_puts(gw_trans->gw_req, shortlog_html); + free(shortlog_html); + free(shortlog); + } + return error; } @@ -484,7 +497,7 @@ gw_summary(struct trans *gw_trans) } khttp_puts(gw_trans->gw_req, div_end); - shortlog = gw_get_repo_shortlog(gw_trans, NULL); + shortlog = gw_get_repo_shortlog(gw_trans, NULL, D_MAXSLCOMMDISP); tags = gw_get_repo_tags(gw_trans); heads = gw_get_repo_heads(gw_trans); @@ -1098,7 +1111,8 @@ gw_get_clone_url(struct trans *gw_trans, char *dir) } static char * -gw_get_repo_shortlog(struct trans *gw_trans, const char *search_pattern) +gw_get_repo_shortlog(struct trans *gw_trans, const char *search_pattern, + int limit) { const struct got_error *error; struct got_repository *repo = NULL; @@ -1110,9 +1124,9 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha char *start_commit = NULL, *shortlog = NULL, *id_str = NULL, *path = NULL, *in_repo_path = NULL, *commit_row = NULL, *commit_age = NULL, *commit_author = NULL, *commit_log = NULL, - *shortlog_navs_html = NULL; + *commit_log0, *newline, *shortlog_navs_html = NULL; regex_t regex; - int have_match, limit = D_MAXSLCOMMDISP; + int have_match; size_t newsize; struct buf *diffbuf; time_t committer_time; @@ -1303,9 +1317,17 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha TM_DIFF)); asprintf(&commit_author, "%s", got_object_commit_get_author(commit_disp)); - error = got_object_commit_get_logmsg(&commit_log, commit_disp); + error = got_object_commit_get_logmsg(&commit_log0, commit_disp); if (error) commit_log = strdup(""); + else { + commit_log = commit_log0; + while (*commit_log == '\n') + commit_log++; + newline = strchr(commit_log, '\n'); + if (newline) + *newline = '\0'; + } asprintf(&shortlog_navs_html, shortlog_navs, gw_trans->repo_name, id_str, gw_trans->repo_name, id_str, gw_trans->repo_name, id_str, gw_trans->repo_name, id_str); @@ -1316,7 +1338,7 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha free(commit_age); free(commit_author); - free(commit_log); + free(commit_log0); free(shortlog_navs_html); free(commit_row); free(id_str);