Skip to content

Commit 2108fe4

Browse files
avargitster
authored andcommitted
revisions API users: add straightforward release_revisions()
Add a release_revisions() to various users of "struct rev_list" in those straightforward cases where we only need to add the release_revisions() call to the end of a block, and don't need to e.g. refactor anything to use a "goto cleanup" pattern. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1878b5e commit 2108fe4

28 files changed

+39
-0
lines changed

add-interactive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ static int get_modified_files(struct repository *r,
570570

571571
if (ps)
572572
clear_pathspec(&rev.prune_data);
573+
release_revisions(&rev);
573574
}
574575
hashmap_clear_and_free(&s.file_map, struct pathname_entry, ent);
575576
if (unmerged_count)

bisect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ static int check_ancestors(struct repository *r, int rev_nr,
884884
/* Clean up objects used, as they will be reused. */
885885
clear_commit_marks_many(rev_nr, rev, ALL_REV_FLAGS);
886886

887+
release_revisions(&revs);
887888
return res;
888889
}
889890

@@ -964,6 +965,7 @@ static void show_diff_tree(struct repository *r,
964965

965966
setup_revisions(ARRAY_SIZE(argv) - 1, argv, &opt, NULL);
966967
log_tree_commit(&opt, commit);
968+
release_revisions(&opt);
967969
}
968970

969971
/*

builtin/add.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
340340

341341
unlink(file);
342342
free(file);
343+
release_revisions(&rev);
343344
return 0;
344345
}
345346

builtin/am.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm
13971397
add_pending_object(&rev_info, &commit->object, "");
13981398
diff_setup_done(&rev_info.diffopt);
13991399
log_tree_commit(&rev_info, commit);
1400+
release_revisions(&rev_info);
14001401
}
14011402

14021403
/**
@@ -1429,6 +1430,7 @@ static void write_index_patch(const struct am_state *state)
14291430
add_pending_object(&rev_info, &tree->object, "");
14301431
diff_setup_done(&rev_info.diffopt);
14311432
run_diff_index(&rev_info, 1);
1433+
release_revisions(&rev_info);
14321434
}
14331435

14341436
/**
@@ -1582,6 +1584,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15821584
add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
15831585
diff_setup_done(&rev_info.diffopt);
15841586
run_diff_index(&rev_info, 1);
1587+
release_revisions(&rev_info);
15851588
}
15861589

15871590
if (run_apply(state, index_path))

builtin/bisect--helper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
555555
reset_revision_walk();
556556

557557
strbuf_release(&commit_name);
558+
release_revisions(&revs);
558559
fclose(fp);
559560
return 0;
560561
}
@@ -1041,6 +1042,7 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
10411042
oid_to_hex(&commit->object.oid));
10421043

10431044
reset_revision_walk();
1045+
release_revisions(&revs);
10441046
} else {
10451047
strvec_push(&argv_state, argv[i]);
10461048
}

builtin/blame.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,5 +1203,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
12031203

12041204
cleanup:
12051205
cleanup_scoreboard(&sb);
1206+
release_revisions(&revs);
12061207
return 0;
12071208
}

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
10821082

10831083
/* Clean up objects used, as they will be reused. */
10841084
repo_clear_commit_marks(the_repository, ALL_REV_FLAGS);
1085+
release_revisions(&revs);
10851086
}
10861087

10871088
static int switch_branches(const struct checkout_opts *opts,

builtin/commit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ static const char *find_author_by_nickname(const char *name)
11231123
strbuf_release(&buf);
11241124
format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
11251125
clear_mailmap(&mailmap);
1126+
release_revisions(&revs);
11261127
return strbuf_detach(&buf, NULL);
11271128
}
11281129
die(_("--author '%s' is not 'Name <email>' and matches no existing author"), name);

builtin/describe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
517517

518518
traverse_commit_list(&revs, process_commit, process_object, &pcd);
519519
reset_revision_walk();
520+
release_revisions(&revs);
520521
}
521522

522523
static void describe(const char *arg, int last_one)
@@ -667,6 +668,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
667668
suffix = NULL;
668669
else
669670
suffix = dirty;
671+
release_revisions(&revs);
670672
}
671673
describe("HEAD", 1);
672674
} else if (dirty) {

builtin/fast-export.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
12751275
printf("done\n");
12761276

12771277
refspec_clear(&refspecs);
1278+
release_revisions(&revs);
12781279

12791280
return 0;
12801281
}

0 commit comments

Comments
 (0)