navid/veins / commit
a3273a56ba14
Navid M <navidmomtahen@gmail.com> · 2026-11-29
parents: b2c412f69b54
Browse files at this commit · Download source
--- a/docs/SPECIFICATION_V1.adoc+++ b/docs/SPECIFICATION_V1.adoc@@ -1128,7 +1128,7 @@ | `vn init [path] [-git-import:<gitdir>] [-remote:<url>] [-remote-name:<name>]` | Create a repository, optionally importing an existing git repo and configuring a native remote. | `vn clone <url> [-blobs head\|none\|all]` | Clone via the native protocol. Records the source as remote `o`. | `vn status` | Working-copy changes, conflicts, files needing regeneration.-| `vn log [-rev <revset>] [-lN \| -fN] [-no-col-titles]` | Show history, newest first, flagging conflicted and divergent changes.+| `vn log [-rev <revset>] [-lN \| -fN] [-no-col-titles] [-p]` | Show history, newest first, flagging conflicted and divergent changes. | `vn inf [-inc-gen]` | Show repository, language and author statistics; generated paths are excluded unless `-inc-gen` is passed. | `vn show <rev>`, `vn diff [-rev <rev>]` | Display a commit or a diff. | `vn new [<rev>...]`, `vn describe [-message <message>]`, `vn commit -message <message>` | Create and describe changes. `vn commit` does nothing when the working copy has no changes.@@ -1160,7 +1160,7 @@ `vn fetch` and `vn push` use the active remote when no remote is named: `remote.current`, then `remote.default`, then `o`, then the first configured remote. A native clone records its source as remote `o` and sets `remote.default = o`, so `vn psh o` and bare `vn psh` work immediately after cloning. -`vn log` prints commits newest first in aligned columns with no borders. Column titles are shown by default and can be omitted with `-no-col-titles`. `-lN` limits the output to the last N commits (newest N), while `-fN` shows the first N commits (oldest N) in oldest-first order. The separated forms `-l N` and `-f N`, and the bare forms `lN` and `fN`, are also accepted. Output is colored when standard output is a terminal; setting `NO_COLOR` disables color.+`vn log` prints commits newest first in aligned columns with no borders. Column titles are shown by default and can be omitted with `-no-col-titles`. `-lN` limits the output to the last N commits (newest N), while `-fN` shows the first N commits (oldest N) in oldest-first order. The separated forms `-l N` and `-f N`, and the bare forms `lN` and `fN`, are also accepted. `-p` pages the output through `$PAGER` (or `less -R` when unset) and shows the full history unless `-l` or `-f` is given. Output is colored when standard output is a terminal; setting `NO_COLOR` disables color. `vn status` colors its change markers (`A` bright green, `M` cyan, `D` red, and `C` bright red). `vn diff` prints unified hunks with context; removed lines are red and added lines are green. --- a/xveins/src/cli/cli.cpp+++ b/xveins/src/cli/cli.cpp@@ -754,8 +754,10 @@ bool col_titles = true; bool end_flags = false; bool all = false;+ bool pager = false; std::optional<std::size_t> limit; bool first = false;+ bool explicit_limit = false; auto parse_count = [](std::string_view text, std::size_t& out) -> bool { if (text.empty()) return false;@@ -783,6 +785,8 @@ rev = args[++i]; } else if (!end_flags && arg == "-no-col-titles") { col_titles = false;+ } else if (!end_flags && arg == "-p") {+ pager = true; } else if (!end_flags && (arg == "-a" || arg == "-all")) { all = true; } else if (!end_flags && (arg == "-l" || arg == "-f")) {@@ -799,6 +803,7 @@ } limit = count; first = arg == "-f";+ explicit_limit = true; } else if (!end_flags && arg.size() > 2 && (arg[0] == '-' && (arg[1] == 'l' || arg[1] == 'f'))) { std::size_t count = 0;@@ -809,11 +814,13 @@ } limit = count; first = arg[1] == 'f';+ explicit_limit = true; } else if (!end_flags && arg.size() > 1 && (arg[0] == 'l' || arg[0] == 'f')) { std::size_t count = 0; if (parse_count(std::string_view(arg).substr(1), count)) { limit = count; first = arg[0] == 'f';+ explicit_limit = true; } else { rev = arg; }@@ -825,7 +832,7 @@ rev = arg; } }- if (all) {+ if (all || (pager && !explicit_limit)) { limit.reset(); } else if (!limit) { std::size_t amount = 20;@@ -929,6 +936,10 @@ w_author = std::max(w_author, recs[i].author.size()); ++change_counts[recs[i].change]; }+ std::ostringstream rendered;+ std::streambuf* old_out = nullptr;+ if (pager)+ old_out = std::cout.rdbuf(rendered.rdbuf()); if (col_titles) { print_cell("", 1, Color::Default, false); std::cout << " ";@@ -976,6 +987,10 @@ std::cout << " (divergent)"; std::cout << "\n"; }+ if (pager) {+ std::cout.rdbuf(old_out);+ (void)run_pager(*root, rendered.str());+ } return 0; } @@ -2517,7 +2532,8 @@ } void show_log() {- std::cout << "usage: vn log [-a] [-rev <revset>] [-lN | -fN] [-no-col-titles]\n\n";+ std::cout << "usage: vn log [-a] [-rev <revset>] [-lN | -fN] [-no-col-titles] "+ "[-p]\n\n"; std::cout << "show commit history, newest first\n\n"; std::cout << "options:\n"; std::cout << " -a, -all show the entire history\n";@@ -2524,8 +2540,9 @@ std::cout << " -rev <revset> show only the given revision set\n"; std::cout << " -lN, -l <N> show the last N commits (newest N)\n"; std::cout << " -fN, -f <N> show the first N commits (oldest N)\n";- std::cout << " -no-col-titles omit column titles\n\n";- std::cout << "without -a, -l or -f, the last log.default_amount commits are shown\n";+ std::cout << " -no-col-titles omit column titles\n";+ std::cout << " -p page the full history through the pager\n\n";+ std::cout << "without -a, -l, -f or -p, the last log.default_amount commits are shown\n"; std::cout << "(global config, default 20)\n"; } --- a/xveins/tests/integration/core_tests.cpp+++ b/xveins/tests/integration/core_tests.cpp@@ -26,6 +26,7 @@ t.expect_contains(help_text, "attr"); t.expect_contains(f.vn({"help", "log"}).out, "vn log"); t.expect_contains(f.vn({"help", "log"}).out, "-a, -all");+ t.expect_contains(f.vn({"help", "log"}).out, "-p"); t.expect_contains(f.vn({"help", "go"}).out, "aliases: commit"); t.expect_contains(f.vn({"help", "attr"}).out, "vn attr rm"); }@@ -134,6 +135,8 @@ } t.expect_eq(split_lines(f.vn({"log", "-l", "1", "-no-col-titles"}).out).size(), 1u); t.expect_eq(split_lines(f.vn({"log", "l2", "-no-col-titles"}).out).size(), 2u);+ t.expect_eq(+ split_lines(f.vn({"log", "-p", "-l2", "-no-col-titles"}).out).size(), 2u); const std::string one = f.commit_for_message("commit 1"); const std::string selected = f.vn({"log", "-rev", one, "-no-col-titles"}).out; t.expect_contains(selected, "commit 1");--- a/xveins/tests/integration/history_tests.cpp+++ b/xveins/tests/integration/history_tests.cpp@@ -100,6 +100,8 @@ t.expect_eq(split_lines(f.vn({"log", "-all", "-no-col-titles"}).out).size(), 23u); t.expect_eq(split_lines(f.vn({"log", "-a", "-l5", "-no-col-titles"}).out).size(), 23u); t.expect_eq(split_lines(f.vn({"log", "-l5", "-a", "-no-col-titles"}).out).size(), 23u);+ t.expect_eq(split_lines(f.vn({"log", "-p", "-no-col-titles"}).out).size(), 23u);+ t.expect_eq(split_lines(f.vn({"log", "-p", "-l5", "-no-col-titles"}).out).size(), 5u); f.vn({"cfg", "log.default_amount", "1"}); t.expect_eq(f.log_rows().size(), 3u); t.expect_eq(split_lines(f.vn({"log", "-l5", "-no-col-titles"}).out).size(), 5u);