navid/veins / commit
c161f7014d53
Navid M <navidmomtahen@gmail.com> · 2026-11-28
parents: 4179151a4b9c
Browse files at this commit · Download source
--- a/xveins/src/cli.cpp+++ b/xveins/src/cli.cpp@@ -865,6 +865,7 @@ int run_show(const std::vector<std::string>& args) { std::string rev; bool col_titles = true;+ bool all = false; bool end_flags = false; for (std::size_t i = 2; i < args.size(); ++i) { const std::string& arg = args[i];@@ -877,6 +878,8 @@ return 1; } rev = args[++i];+ } else if (!end_flags && (arg == "-a" || arg == "-all" || arg == "--all")) {+ all = true; } else if (!end_flags && arg == "-no-col-titles") { col_titles = false; } else if (!end_flags && is_flag(arg)) {@@ -915,6 +918,8 @@ std::cout << "cannot read commit\n"; return 1; }+ std::ostringstream rendered;+ auto* old_out = std::cout.rdbuf(rendered.rdbuf()); if (col_titles) { std::cout << "commit " << hex_encode(*target) << "\n"; std::cout << "change " << base32_encode(loaded->commit.change_id) << "\n";@@ -952,7 +957,13 @@ if (parent) old_tree = parent->commit.root_tree; }- render_diff(store, old_tree, loaded->commit.root_tree, false);+ const std::size_t diff_count =+ render_diff(store, old_tree, loaded->commit.root_tree, false);+ std::cout.rdbuf(old_out);+ if (diff_count > 0 && !all && stdout_is_terminal())+ (void)run_pager(*root, rendered.str());+ else+ std::cout << rendered.str(); return 0; } @@ -2199,11 +2210,13 @@ } void show_show() {- std::cout << "usage: vn show [rev] [-no-col-titles]\n\n";- std::cout << "show a commit's metadata and its diff against its first parent\n\n";+ std::cout << "usage: vn show [-a] [rev] [-no-col-titles]\n\n";+ std::cout << "show a commit's metadata and its diff against its first parent,\n";+ std::cout << "paged when stdout is a terminal\n\n"; std::cout << "arguments:\n"; std::cout << " [rev] revision to show (default: @)\n\n"; std::cout << "options:\n";+ std::cout << " -a, -all print the whole output at once\n"; std::cout << " -no-col-titles omit the metadata labels\n"; } --- a/xveins/tests/integration_tests.cpp+++ b/xveins/tests/integration_tests.cpp@@ -754,7 +754,10 @@ const std::string diff = f.vn({"diff", one, "@"}).out; t.expect_contains(diff, "-one"); t.expect_contains(diff, "+two");- t.expect_contains(f.vn({"show", one}).out, "one");+ const std::string shown = f.vn({"show", one}).out;+ t.expect_contains(shown, "one");+ t.expect_contains(f.vn({"show", "-a", one}).out, "--- /dev/null");+ t.expect_contains(f.vn({"help", "show"}).out, "-a, -all"); } void refs_bookmarks(test::Context& t) {