diff options
context:
space:
mode:
Diffstat (limited to 'source/ui-blame.c')
-rw-r--r--source/ui-blame.c70
1 file changed, 29 insertions, 41 deletions
diff --git a/source/ui-blame.c b/source/ui-blame.c
index 8a7f8f0..7248120 100644
--- a/source/ui-blame.c
+++ b/source/ui-blame.c
@@ -52,7 +52,7 @@ static void free_suspect_details(void)
* keep them alive together.
*/
static void run_blame(struct blame_scoreboard *sb, struct rev_info *revs,
- const char *path, const char *rev)
+ const char *path, const char *rev)
{
struct strvec argv = STRVEC_INIT;
struct blame_origin *origin;
@@ -120,15 +120,13 @@ static char *suspect_detail(struct blame_origin *suspect)
if (ctx.cfg.enable_plain_email)
strbuf_addf(&detail, " %s", info->author_email);
strbuf_addf(&detail, " %s\n",
- show_date(info->author_date, info->author_tz,
- cgit_date_mode(DATE_ISO8601)));
+ show_date(info->author_date, info->author_tz, cgit_date_mode(DATE_ISO8601)));
strbuf_addf(&detail, "committer %s", info->committer);
if (ctx.cfg.enable_plain_email)
strbuf_addf(&detail, " %s", info->committer_email);
strbuf_addf(&detail, " %s\n\n",
- show_date(info->committer_date, info->committer_tz,
- cgit_date_mode(DATE_ISO8601)));
+ show_date(info->committer_date, info->committer_tz, cgit_date_mode(DATE_ISO8601)));
strbuf_addstr(&detail, info->subject);
@@ -145,20 +143,20 @@ static void emit_entry_hash(struct blame_entry *ent)
const char *detail = suspect_detail(suspect);
html("<span class='oid'>");
- cgit_commit_link(repo_find_unique_abbrev(the_repository, oid,
- DEFAULT_ABBREV),
- detail, NULL, ctx.qry.head, oid_to_hex(oid),
- suspect->path);
+ cgit_commit_link(
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
+ detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path
+ );
html("</span>");
- if (!repo_parse_commit(the_repository, suspect->commit) &&
- suspect->commit->parents) {
+ if (!repo_parse_commit(the_repository, suspect->commit) && suspect->commit->parents) {
struct commit *parent = suspect->commit->parents->item;
html(" ");
- cgit_blame_link("^", "Blame the previous revision", NULL,
- ctx.qry.head, oid_to_hex(&parent->object.oid),
- suspect->path);
+ cgit_blame_link(
+ "^", "Blame the previous revision", NULL, ctx.qry.head,
+ oid_to_hex(&parent->object.oid), suspect->path
+ );
}
// The stripes only line up across the columns if each column gives an
@@ -228,8 +226,7 @@ static size_t line_width(struct blame_scoreboard *sb, int line)
* these blocks, so each block has to be padded to the height and width of
* the lines it stands behind.
*/
-static void emit_entry_background(struct blame_scoreboard *sb,
- struct blame_entry *ent)
+static void emit_entry_background(struct blame_scoreboard *sb, struct blame_entry *ent)
{
size_t widest = 2;
int line;
@@ -267,7 +264,7 @@ static void emit_line_backgrounds(struct blame_scoreboard *sb)
}
static void print_blame_page(const struct object_id *oid, const char *path,
- const char *filename, const char *rev)
+ const char *filename, const char *rev)
{
enum object_type type;
char *buf;
@@ -277,21 +274,20 @@ static void print_blame_page(const struct object_id *oid, const char *path,
type = odb_read_object_info(the_repository->objects, oid, &size);
if (type == OBJ_BAD) {
- cgit_print_error_page(404, "Not Found", "Bad object name: %s",
- oid_to_hex(oid));
+ cgit_print_error_page(404, "Not Found", "Bad object name: %s", oid_to_hex(oid));
return;
}
if (ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size) {
- cgit_print_error_page(413, "Content Too Large",
- "blob size (%luKB) exceeds display size limit (%dKB)",
- size / 1024, ctx.cfg.max_blob_size);
+ cgit_print_error_page(
+ 413, "Content Too Large", "blob size (%luKB) exceeds display size limit (%dKB)",
+ size / 1024, ctx.cfg.max_blob_size
+ );
return;
}
buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf) {
- cgit_print_error_page(500, "Internal Server Error",
- "Error reading object %s", oid_to_hex(oid));
+ cgit_print_error_page(500, "Internal Server Error", "Error reading object %s", oid_to_hex(oid));
return;
}
@@ -357,27 +353,24 @@ cleanup:
}
static int walk_tree(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode, void *data)
+ const char *pathname, unsigned mode, void *data)
{
struct walk_tree_context *walk = data;
// match_baselen is -1 when no path was given, which no length equals.
- if (walk->match_baselen >= 0 &&
- base->len == (size_t)walk->match_baselen) {
+ if (walk->match_baselen >= 0 && base->len == (size_t)walk->match_baselen) {
if (S_ISREG(mode)) {
struct strbuf fullpath = STRBUF_INIT;
strbuf_addbuf(&fullpath, base);
strbuf_addstr(&fullpath, pathname);
- print_blame_page(oid, fullpath.buf, pathname,
- walk->rev);
+ print_blame_page(oid, fullpath.buf, pathname, walk->rev);
strbuf_release(&fullpath);
walk->found = TARGET_FILE;
} else if (S_ISDIR(mode)) {
walk->found = TARGET_FOLDER;
}
- } else if (base->len < INT_MAX
- && (int)base->len > walk->match_baselen) {
+ } else if (base->len < INT_MAX && (int)base->len > walk->match_baselen) {
walk->found = TARGET_FOLDER;
} else if (S_ISDIR(mode)) {
return READ_TREE_RECURSIVE;
@@ -419,28 +412,23 @@ void cgit_print_blame(void)
rev = ctx.qry.head;
if (repo_get_oid(the_repository, rev, &oid)) {
- cgit_print_error_page(404, "Not Found",
- "Invalid revision name: %s", rev);
+ cgit_print_error_page(404, "Not Found", "Invalid revision name: %s", rev);
return;
}
commit = lookup_commit_reference(the_repository, &oid);
if (!commit || repo_parse_commit(the_repository, commit)) {
- cgit_print_error_page(404, "Not Found",
- "Invalid commit reference: %s", rev);
+ cgit_print_error_page(404, "Not Found", "Invalid commit reference: %s", rev);
return;
}
walk.rev = xstrdup(rev);
- walk.match_baselen = path_items.match ?
- basedir_len(path_items.match) : -1;
+ walk.match_baselen = path_items.match ? basedir_len(path_items.match) : -1;
- read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
- &paths, walk_tree, &walk);
+ read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
if (walk.found == TARGET_MISSING)
cgit_print_error_page(404, "Not Found", "Not found");
else if (walk.found == TARGET_FOLDER)
- cgit_print_error_page(404, "Not Found",
- "Blame is not available for folders.");
+ cgit_print_error_page(404, "Not Found", "Blame is not available for folders.");
free(walk.rev);
}