Skip to content

Commit 54c8a7c

Browse files
avargitster
authored andcommitted
revisions API: add a TODO for diff_free(&revs->diffopt)
Add a TODO comment indicating that we should release "diffopt" in release_revisions(). In a preceding commit we started releasing the "pruning" member of the same type, but handling "diffopt" will require us to untangle the "no_free" conditions I added in e900d49 (diff: add an API for deferred freeing, 2021-02-11). Let's leave a TODO comment to that effect, and so that we don't forget refactor code that was changed to use release_revisions() in earlier commits to stop using the "diffopt" member after a call to release_revisions(). This works currently, but would become a logic error as soon as we started freeing "diffopt". Doing that change now doesn't harm anything, and future-proofs us against a later change to release_revisions(). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae1b383 commit 54c8a7c

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

diff-lib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ int index_differs_from(struct repository *r,
651651
{
652652
struct rev_info rev;
653653
struct setup_revision_opt opt;
654+
unsigned has_changes;
654655

655656
repo_init_revisions(r, &rev, NULL);
656657
memset(&opt, 0, sizeof(opt));
@@ -662,8 +663,9 @@ int index_differs_from(struct repository *r,
662663
diff_flags_or(&rev.diffopt.flags, flags);
663664
rev.diffopt.ita_invisible_in_index = ita_invisible_in_index;
664665
run_diff_index(&rev, 1);
666+
has_changes = rev.diffopt.flags.has_changes;
665667
release_revisions(&rev);
666-
return (rev.diffopt.flags.has_changes != 0);
668+
return (has_changes != 0);
667669
}
668670

669671
static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)

revision.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,6 +2956,7 @@ void release_revisions(struct rev_info *revs)
29562956
date_mode_release(&revs->date_mode);
29572957
release_revisions_mailmap(revs->mailmap);
29582958
free_grep_patterns(&revs->grep_filter);
2959+
/* TODO (need to handle "no_free"): diff_free(&revs->diffopt) */
29592960
diff_free(&revs->pruning);
29602961
reflog_walk_info_release(revs->reflog_info);
29612962
release_revisions_topo_walk_info(revs->topo_walk_info);

wt-status.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,8 +2545,9 @@ int has_unstaged_changes(struct repository *r, int ignore_submodules)
25452545
rev_info.diffopt.flags.quick = 1;
25462546
diff_setup_done(&rev_info.diffopt);
25472547
result = run_diff_files(&rev_info, 0);
2548+
result = diff_result_code(&rev_info.diffopt, result);
25482549
release_revisions(&rev_info);
2549-
return diff_result_code(&rev_info.diffopt, result);
2550+
return result;
25502551
}
25512552

25522553
/**
@@ -2578,8 +2579,9 @@ int has_uncommitted_changes(struct repository *r,
25782579

25792580
diff_setup_done(&rev_info.diffopt);
25802581
result = run_diff_index(&rev_info, 1);
2582+
result = diff_result_code(&rev_info.diffopt, result);
25812583
release_revisions(&rev_info);
2582-
return diff_result_code(&rev_info.diffopt, result);
2584+
return result;
25832585
}
25842586

25852587
/**

0 commit comments

Comments
 (0)