Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,7 @@ void setup_blame_bloom_data(struct blame_scoreboard *sb)

void cleanup_scoreboard(struct blame_scoreboard *sb)
{
clear_blame_suspects(&blame_suspects);
free(sb->lineno);
free(sb->final_buf);
clear_prio_queue(&sb->commits);
Expand Down
1 change: 1 addition & 0 deletions blame.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ void init_scoreboard(struct blame_scoreboard *sb);
void setup_scoreboard(struct blame_scoreboard *sb,
struct blame_origin **orig);
void setup_blame_bloom_data(struct blame_scoreboard *sb);
/* Release all entry and caller references to origins before clearing the slab. */
void cleanup_scoreboard(struct blame_scoreboard *sb);

struct blame_entry *blame_entry_prepend(struct blame_entry *head,
Expand Down
1 change: 1 addition & 0 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ int cmd_blame(int argc,
cleanup:
for (ent = sb.ent; ent; ) {
struct blame_entry *e = ent->next;
blame_origin_decref(ent->suspect);
free(ent);
ent = e;
}
Expand Down
34 changes: 33 additions & 1 deletion t/helper/test-repository.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "test-tool.h"
#include "blame.h"
#include "commit-graph.h"
#include "commit.h"
#include "environment.h"
#include "hex.h"
#include "object.h"
#include "repository.h"
#include "revision.h"
#include "setup.h"
#include "tree.h"

Expand Down Expand Up @@ -65,11 +67,41 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
repo_clear(&r);
}

static void test_blame_scoreboard(const char *path)
{
struct repository *repo = the_repository;

setup_git_directory(repo);
/* A second setup exposes leaks left by the first scoreboard. */
for (int i = 0; i < 2; i++) {
const char *args[] = { "blame", "HEAD", NULL };
struct blame_scoreboard sb;
struct blame_origin *origin;
struct rev_info revs;

repo_init_revisions(repo, &revs, NULL);
setup_revisions(ARRAY_SIZE(args) - 1, args, &revs, NULL);
init_scoreboard(&sb);
sb.repo = repo;
sb.revs = &revs;
sb.path = path;
setup_scoreboard(&sb, &origin);
blame_origin_decref(origin);
cleanup_scoreboard(&sb);
release_revisions(&revs);
}
repo_clear(repo);
}

int cmd__repository(int argc, const char **argv)
{
if (argc < 2)
die("must have at least 2 arguments");
if (!strcmp(argv[1], "parse_commit_in_graph")) {
if (!strcmp(argv[1], "blame-scoreboard")) {
if (argc != 3)
die("usage: test-tool repository blame-scoreboard <path>");
test_blame_scoreboard(argv[2]);
} else if (!strcmp(argv[1], "parse_commit_in_graph")) {
struct object_id oid;
if (argc < 5)
die("not enough arguments");
Expand Down
1 change: 1 addition & 0 deletions t/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ integration_tests = [
't8013-blame-ignore-revs.sh',
't8014-blame-ignore-fuzzy.sh',
't8015-blame-diff-algorithm.sh',
't8016-blame-scoreboard.sh',
't8020-last-modified.sh',
't9001-send-email.sh',
't9002-column.sh',
Expand Down
12 changes: 12 additions & 0 deletions t/t8016-blame-scoreboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

test_description='blame scoreboard teardown'

. ./test-lib.sh

test_expect_success 'set up and tear down two scoreboards in one process' '
test_commit one file &&
test-tool repository blame-scoreboard file
'

test_done
Loading