Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Label the age column of a followed log
Diffstat (limited to '')
| -rw-r--r-- | source/ui-log.c | 40 | |
| -rwxr-xr-x | tests/t0103-log.sh | 12 |
2 files changed, 32 insertions, 20 deletions
diff --git a/source/ui-log.c b/source/ui-log.c index 870ff06..2c1d802 100644 --- a/source/ui-log.c +++ b/source/ui-log.c @@ -220,20 +220,16 @@ static void print_filler(int columns) html("<td></td>"); } -static void print_commit(struct commit *commit, struct rev_info *revs, int filler) +/* + * columns counts the filler too, because the rows that span the table reach + * across it as well. + */ +static void print_commit(struct commit *commit, struct rev_info *revs, int columns, int filler) { struct commitinfo *info; - int columns = revs->graph ? 4 : 3; struct strbuf graphbuf = STRBUF_INIT; struct strbuf msgbuf = STRBUF_INIT; - if (ctx.repo->enable_log_filecount) - columns++; - if (ctx.repo->enable_log_linecount) - columns++; - // The rows that span the table reach across the filler as well. - columns += filler; - if (revs->graph) print_graph_above(revs, &graphbuf, columns); @@ -472,7 +468,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern struct rev_info rev; struct commit *commit; struct strvec rev_argv = STRVEC_INIT; - int i, columns = commit_graph ? 4 : 3, filler = 0; + int i, columns, filler = 0; int must_free_tip = 0; // setup_revisions skips the first entry the way a command skips its @@ -565,6 +561,16 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern load_ref_decorations(NULL, DECORATE_FULL_REFS); rev.show_decorations = 1; + // A followed log is walked without the graph even when commit_graph + // asks for one, so the walk decides the columns. + columns = rev.graph ? 4 : 3; + if (ctx.repo->enable_log_filecount) + columns++; + if (ctx.repo->enable_log_linecount) + columns++; + if (table_columns > columns) + filler = table_columns - columns; + rev.diffopt.detect_rename = 1; rev.diffopt.rename_limit = ctx.cfg.renamelimit; if (ctx.qry.ignorews) @@ -584,7 +590,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern } html("<tbody class='log'>\n<tr class='nohover'>"); - if (commit_graph) + if (rev.graph) html("<th scope='col' aria-label='Graph'></th>"); else html("<th class='left' scope='col'>Age</th>"); @@ -601,16 +607,10 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern html("</th><th class='left col-author' scope='col'>Author</th>"); if (rev.graph) html("<th class='left' scope='col'>Age</th>"); - if (ctx.repo->enable_log_filecount) { + if (ctx.repo->enable_log_filecount) html("<th class='left col-count' scope='col'>Files</th>"); - columns++; - } - if (ctx.repo->enable_log_linecount) { + if (ctx.repo->enable_log_linecount) html("<th class='left col-count' scope='col'>Lines</th>"); - columns++; - } - if (table_columns > columns) - filler = table_columns - columns; print_filler(filler); html("</tr>\n"); @@ -630,7 +630,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern counts_ready = 0; if (should_show(commit, &rev)) { i++; - print_commit(commit, &rev, filler); + print_commit(commit, &rev, columns + filler, filler); } release_commit_memory(the_repository->parsed_objects, commit); commit->parents = NULL; diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index d7e745d..4306d8c 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -111,6 +111,18 @@ test_expect_success 'the log draws the commit graph when enabled' ' grep "<th scope=.col. aria-label=.Graph.></th>" tmp ' +# A followed log is walked without the graph, so its first column holds the +# age whatever enable-commit-graph says. +test_expect_success 'a followed log heads its age column with the graph on' ' + { + echo "enable-commit-graph=1" && + cat folrc + } >folgraphrc && + CGIT_CONFIG="$PWD/folgraphrc" QUERY_STRING="url=fol/log/b.txt&follow=1" cgit >tmp && + grep "<th class=.left. scope=.col.>Age</th><th class=.left. scope=.col.>Commit message" tmp && + ! grep "aria-label=.Graph." tmp +' + # The search is literal, so text that is no valid regular expression still # finds the commit holding it. test_expect_success 'a search for brackets matches them literally' ' |
