navid/veins / commit

feb2a61eb3ae

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

parents: 89b55a7b5b5f

Browse files at this commit · Download source

all: cap the log output to 20 by default
--- a/xveins/src/cli.cpp+++ b/xveins/src/cli.cpp@@ -710,6 +710,14 @@             rev = arg;         }     }+    if (!limit) {+        std::size_t amount = 20;+        if (auto configured = user_config_value("log.default_amount")) {+            if (!parse_count(*configured, amount))+                amount = 20;+        }+        limit = amount;+    }     const auto root = open_repo();     if (!root)         return 1;@@ -2185,7 +2193,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";+    std::cout << "  -no-col-titles            omit column titles\n\n";+    std::cout << "without -l or -f, the last log.default_amount commits are shown\n";+    std::cout << "(global config, default 20)\n"; }  void show_show() {--- a/xveins/tests/integration_tests.cpp+++ b/xveins/tests/integration_tests.cpp@@ -677,7 +677,39 @@         stream >> previous;         f.vn({"op", "restore", previous});         t.expect_contains(f.vn({"log"}).out, "renamed");+    }+}++void history_log_default_amount(test::Context& t) {+    VnFixture f;+    f.init();+    linear_history(f, 22);+    t.expect_eq(f.log_rows().size(), 20u);+    const std::vector<LogRow> default_rows = f.log_rows();+    bool has_newest = false;+    bool has_oldest = false;+    for (const LogRow& row : default_rows) {+        if (row.message == "commit 21")+            has_newest = true;+        if (row.message == "commit 2")+            has_oldest = true;+    }+    t.expect(has_newest);+    t.expect(!has_oldest);++    f.vn({"cfg", "-global", "log.default_amount", "3"});+    t.expect_eq(f.log_rows().size(), 3u);+    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);+    const auto oldest = split_lines(f.vn({"log", "-f2", "-no-col-titles"}).out);+    t.expect_eq(oldest.size(), 2u);+    if (oldest.size() == 2) {+        t.expect_contains(oldest[0], "commit 0");+        t.expect_contains(oldest[1], "commit 1");     }+    f.vn({"cfg", "-global", "log.default_amount", "not-a-number"});+    t.expect_eq(f.log_rows().size(), 20u); }  void history_diff_path_filter(test::Context& t) {@@ -1183,6 +1215,7 @@         {"history",          {              {"log_is_topological", history_log_is_topological},+             {"log_default_amount", history_log_default_amount},              {"amend_rewrites_descendants", history_amend_rewrites_descendants},              {"undo_and_operation_restore", history_undo_and_operation_restore},              {"diff_path_filter", history_diff_path_filter},