aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
authorJohn Keeping2015-08-12 15:55:28 +0100
committerJason A. Donenfeld2015-08-12 16:57:46 +0200
commit30304d8156a72ffc95e45e1aa9407319b81bd253 (patch)
treec3f8220fb2abfa0da7f7f0b479415db42820d838 /cgit.c
parent044e2d26da4f8b4f9ff25e4a729ab4e393073b5e (diff)
downloadcgit-30304d8156a72ffc95e45e1aa9407319b81bd253.tar.gz
cgit-30304d8156a72ffc95e45e1aa9407319b81bd253.tar.bz2
cgit-30304d8156a72ffc95e45e1aa9407319b81bd253.zip
log: allow users to follow a file
Teach the "log" UI to behave in the same way as "git log --follow", when given a suitable instruction by the user. The default behaviour remains to show the log without following renames, but the follow behaviour can be activated by following a link in the page header. Follow is not the default because outputting merges in follow mode is tricky ("git log --follow" will not show merges). We also disable the graph in follow mode because the commit graph is not simplified so we end up with frequent gaps in the graph and many lines that do not connect with any commits we're actually showing. We also teach the "diff" and "commit" UIs to respect the follow flag on URLs, causing the single-file version of these UIs to detect renames. This feature is needed only for commits that rename the path we're interested in. For commits before the file has been renamed (i.e. that appear later in the log list) we change the file path in the links from the log to point to the old name; this means that links to commits always limit by the path known to that commit. If we didn't do this we would need to walk down the log diff'ing every commit whenever we want to show a commit. The drawback is that the "Log" link in the top bar of such a page links to the log limited by the old name, so it will only show pre-rename commits. I consider this a reasonable trade-off since the "Back" button still works and the log matches the path displayed in the top bar. Since following renames requires running diff on every commit we consider, I've added a knob to the configuration file to globally enable/disable this feature. Note that we may consider a large number of commits the revision walking machinery no longer performs any path limitation so we have to examine every commit until we find a page full of commits that affect the target path or something related to it. Suggested-by: René Neumann <necoro@necoro.eu> Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index baad1c8..d84b4be 100644
--- a/cgit.c
+++ b/cgit.c
@@ -152,6 +152,8 @@ static void config_cb(const char *name, const char *value)
152 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); 152 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
153 else if (!strcmp(name, "enable-filter-overrides")) 153 else if (!strcmp(name, "enable-filter-overrides"))
154 ctx.cfg.enable_filter_overrides = atoi(value); 154 ctx.cfg.enable_filter_overrides = atoi(value);
155 else if (!strcmp(name, "enable-follow-links"))
156 ctx.cfg.enable_follow_links = atoi(value);
155 else if (!strcmp(name, "enable-http-clone")) 157 else if (!strcmp(name, "enable-http-clone"))
156 ctx.cfg.enable_http_clone = atoi(value); 158 ctx.cfg.enable_http_clone = atoi(value);
157 else if (!strcmp(name, "enable-index-links")) 159 else if (!strcmp(name, "enable-index-links"))
@@ -333,6 +335,8 @@ static void querystring_cb(const char *name, const char *value)
333 ctx.qry.context = atoi(value); 335 ctx.qry.context = atoi(value);
334 } else if (!strcmp(name, "ignorews")) { 336 } else if (!strcmp(name, "ignorews")) {
335 ctx.qry.ignorews = atoi(value); 337 ctx.qry.ignorews = atoi(value);
338 } else if (!strcmp(name, "follow")) {
339 ctx.qry.follow = atoi(value);
336 } 340 }
337} 341}
338 342