revisions API: have release_revisions() release "prune_data"
Extend the the release_revisions() function so that it frees the "prune_data" in the "struct rev_info". This means that any code that calls "release_revisions()" already can get rid of adjacent calls to clear_pathspec(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Apr 13, 2022 at 22:01 UTC
689a8e80dd4f7b3a20be88146bdea833c7759603
6 files changed
+1
-8
add-interactive.c
-2
@@ -568,8 +568,6 @@ static int get_modified_files(struct repository *r,
568
run_diff_files(&rev, 0);
569
}
570
571
- if (ps)
572
- clear_pathspec(&rev.prune_data);
571
release_revisions(&rev);
572
}
573
hashmap_clear_and_free(&s.file_map, struct pathname_entry, ent);
builtin/add.c
-1
@@ -142,7 +142,6 @@ int add_files_to_cache(const char *prefix,
142
rev.diffopt.flags.override_submodule_config = 1;
143
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
144
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
145
- clear_pathspec(&rev.prune_data);
145
release_revisions(&rev);
146
return !!data.add_errors;
147
}
builtin/stash.c
-2
@@ -1064,7 +1064,6 @@ static int check_changes_tracked_files(const struct pathspec *ps)
1064
}
1065
1066
done:
1067
- clear_pathspec(&rev.prune_data);
1067
release_revisions(&rev);
1068
return ret;
1069
}
@@ -1276,7 +1275,6 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
1275
1276
done:
1277
discard_index(&istate);
1279
- clear_pathspec(&rev.prune_data);
1278
release_revisions(&rev);
1279
strbuf_release(&diff_output);
1280
remove_path(stash_index_path.buf);
diff-lib.c
-1
@@ -641,7 +641,6 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
641
642
if (diff_cache(&revs, tree_oid, NULL, 1))
643
exit(128);
644
- clear_pathspec(&revs.prune_data);
644
release_revisions(&revs);
645
return 0;
646
}
revision.c
+1
@@ -2949,6 +2949,7 @@ void release_revisions(struct rev_info *revs)
2949
object_array_clear(&revs->pending);
2950
release_revisions_cmdline(&revs->cmdline);
2951
list_objects_filter_release(&revs->filter);
2952
+ clear_pathspec(&revs->prune_data);
2953
release_revisions_mailmap(revs->mailmap);
2954
free_grep_patterns(&revs->grep_filter);
2955
}
wt-status.c
-2
@@ -616,7 +616,6 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
616
rev.diffopt.rename_score = s->rename_score >= 0 ? s->rename_score : rev.diffopt.rename_score;
617
copy_pathspec(&rev.prune_data, &s->pathspec);
618
run_diff_files(&rev, 0);
619
- clear_pathspec(&rev.prune_data);
619
release_revisions(&rev);
620
}
621
@@ -664,7 +663,6 @@ static void wt_status_collect_changes_index(struct wt_status *s)
663
copy_pathspec(&rev.prune_data, &s->pathspec);
664
run_diff_index(&rev, 1);
665
release_revisions(&rev);
667
- clear_pathspec(&rev.prune_data);
666
}
667
668
static int add_file_to_list(const struct object_id *oid,