navid/veins / commit

24dfbf3b9185

Navid M <navidmomtahen@gmail.com> · 2026-11-28

parents: 1cc615afac9c

Browse files at this commit · Download source

all: implement no diff case
--- a/xveins/src/cli.cpp+++ b/xveins/src/cli.cpp@@ -439,8 +439,8 @@     return false; } -void render_diff(Store& store, std::optional<Id> old_tree, std::optional<Id> new_tree,-                 bool announce_no_diff, std::string_view path_filter = {}) {+std::size_t render_diff(Store& store, std::optional<Id> old_tree, std::optional<Id> new_tree,+                        bool announce_no_diff, std::string_view path_filter = {}) {     auto changes = compare_trees(store, old_tree, new_tree);     if (!path_filter.empty()) {         changes.erase(std::remove_if(changes.begin(), changes.end(),@@ -497,6 +497,7 @@         info_prefix();         std::cout << "no diff to show\n";     }+    return changes.size(); }  // ---------------------------------------------------------------------------@@ -1236,9 +1237,9 @@         path_filter ? std::string_view(*path_filter) : std::string_view{};     std::ostringstream rendered;     auto* old_out = std::cout.rdbuf(rendered.rdbuf());-    render_diff(store, old_tree, new_tree, true, filter);+    const std::size_t diff_count = render_diff(store, old_tree, new_tree, true, filter);     std::cout.rdbuf(old_out);-    if (!all && stdout_is_terminal())+    if (diff_count > 0 && !all && stdout_is_terminal())         (void)run_pager(*root, rendered.str());     else         std::cout << rendered.str();--- a/xveins/tests/integration_tests.cpp+++ b/xveins/tests/integration_tests.cpp@@ -707,6 +707,7 @@     const std::string revision_diff = f.vn({"diff", "-rev", second, "one.txt"}).out;     t.expect_contains(revision_diff, "+one changed");     t.expect_not_contains(revision_diff, "+two changed");+    t.expect_contains(f.vn({"diff"}).out, "no diff to show");     t.expect_contains(f.vn({"help", "diff"}).out, "-a, -all"); }