Commit Briefs
gotwebd: avoid full history traversal in briefs/commits
This purposefully breaks the 'previous' button in the commits and briefs page. It's hard to find the parent of a commit since they can only be iterated forward. The way the previous button was generated was to walk the history from the HEAD down to the specified commit. This is costly but more importantly leads to issue when dealing with paths that were deleted from the repository. Discussed with stsp and tracey, ok jamsek.
gotwebd: don't got_ref_list per-commit in got_get_repo_commits
It's wasteful since `refs' is already populated before the loop, and released after. It also leaks the content of `refs' the first time the loop is entered. ok jamsek
refactor got log -d and tog diffstat to compute diff once
This eliminates the previous performance cost by making 'got log -d' and tog diff view compute the diffstat while building the diff in a temp file like we do with 'got diff -d'. Also, keep the current 'got log -d' UI as per stsp's suggestion. ok stsp@
gotwebd: templateify gotweb_render_blame
ok and tweak from jamsek
gotwebd: templateify gotweb_render_diff
ok tracey@; rebased after recent changes.
got: expand diffstat -d option to 'got diff'
Like got log -d, add the switch to 'got diff' to display a diffstat of changes; as per stsp's suggestion, we always include diff output with the diffstat. Disabled in gotwebd (for now :) Includes tweaks from op@ ok stsp@
backout 169b163113a6db9878c9166aa05fbd30d05eb832
pushed by mistake, wasn't reviewed.
gotwebd: templateify gotweb_render_diff
To avoid calling functions from got_operations.c directly from a template (which would hide the error), change got_output_repo_diff into got_open_diff_for_output that returns a file with the diff in it, to be then rendered by the template. got_gotweb_flushfile needs to be exposed then. It also bundles a smaller change: the `label' argument of got_repo_match_object_id is optional and not used, so just pass NULL there.
gotwebd: templateify gotweb_render_tree
ok tracey@
gotwebd: render BLOB inline, add BLOBRAW for serving raw blobs
binary blobs are automatically redirected to the BLOBRAW page (which is the old BLOB.) ok jamske
gotwebd: rework got_output_file_blob, no functional change
can now use got_object_blob_is_binary to simplify the logic. ok stsp@
gotwebd: use Content-Disposition for RSS; sets the filename
Since gotwebd serves the RSS from a path without a file name component, browsers just make up a random string to give the file a name which can be confusing. Furthermore, since it's served as application/rss+xml they try to render the XML (failing.) Use gotweb_render_content_type_file (which sets the Content-Disposition HTTP header) to fix both: the feed is now called <repo-name>.rss and set as attachment (thus saved and not rendered.) Change the function to take an optional filename suffix for the occasion. ok jamsek
gotwebd: add an RSS feed for the tags
ok tracey@
make got_commit_graph_iter_next use caller-provided storage for the id
and adjust the callers. discussed with and ok stsp@
gotwebd: fix briefs navigation broken in 4a9629420
got_get_repo_commits iterates over the commits and build a queue for later display. My previous memleak fix moved the TAILQ_INSERT_TAIL *before* the logic to exit the loop and so it broke the pagination. This fixes it by delaying the insertion into the queue, but also by moving the check for the "previous" button after we've opened the commit. ok tracey
gotwebd: percent-encode generated URLs
This adds a new helper function `gotweb_link' that outputs an HTML link with the parameter correctly escaped. ok stsp@
gotwebd: fix usage of the commit graph iter
got_get_repo_commits mixes ids allocated on the heap and the one returned by the iter_next in the same variable, and then even attemp to free it. This is both a leak (we loose the pointer to the previously allocated id) and a possible invalid free since the object id pointer returned by the graph iterator is not to be passed to free(3). part of a bigger diff that's ok stsp@
gotwebd: drop superfluous check
commit_id is not NULL if got_repo_match_object_id returned successfully. ok stsp@