aboutsummaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-01-13 10:54:37 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-13 05:41:16 -0800
commit475ade1cd6e8ff07495b4b5871a69f7b385259f7 (patch)
tree14b226e9d732aff3b93500836e11d0444447c6c4 /wt-status.c
parent48a72f61f04cb2357544f373677acd5b4149237e (diff)
downloadgit-475ade1cd6e8ff07495b4b5871a69f7b385259f7.tar.xz
wt-status: provide function to expose status for trees
The "wt-status" subsystem is responsible for printing status information around the current state of the working tree. This most importantly includes information around whether the working tree or the index have any changes. We're about to introduce a new command where the changes in neither of them are actually relevant to us. Instead, what we want is to format the changes between two different trees. While it is a little bit of a stretch to add this as functionality to _working tree_ status, it doesn't make any sense to open-code this functionality, either. Implement a new function `wt_status_collect_changes_trees()` that diffs two trees and formats the status accordingly. This function is not yet used, but will be in a subsequent commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c
index e12adb26b9..95942399f8 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -612,6 +612,30 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
}
}
+void wt_status_collect_changes_trees(struct wt_status *s,
+ const struct object_id *old_treeish,
+ const struct object_id *new_treeish)
+{
+ struct diff_options opts = { 0 };
+
+ repo_diff_setup(s->repo, &opts);
+ opts.output_format = DIFF_FORMAT_CALLBACK;
+ opts.format_callback = wt_status_collect_updated_cb;
+ opts.format_callback_data = s;
+ opts.detect_rename = s->detect_rename >= 0 ? s->detect_rename : opts.detect_rename;
+ opts.rename_limit = s->rename_limit >= 0 ? s->rename_limit : opts.rename_limit;
+ opts.rename_score = s->rename_score >= 0 ? s->rename_score : opts.rename_score;
+ opts.flags.recursive = 1;
+ diff_setup_done(&opts);
+
+ diff_tree_oid(old_treeish, new_treeish, "", &opts);
+ diffcore_std(&opts);
+ diff_flush(&opts);
+ wt_status_get_state(s->repo, &s->state, 0);
+
+ diff_free(&opts);
+}
+
static void wt_status_collect_changes_worktree(struct wt_status *s)
{
struct rev_info rev;