From: Patrick Steinhardt Date: Fri, 13 Feb 2026 09:12:46 GMT Subject: [PATCH v2 0/5] builtin/history: some smaller UI improvements Message-ID: <20260213-b4-pks-history-dry-run-v2-0-756ac376e9e5@pks.im> In-Reply-To: <20260212-b4-pks-history-dry-run-v1-0-1ce03d631c1b@pks.im> Hi, this patch series contains a small set of UI improvements for git-history(1): - The first two commits adapt git-history(1) so that it performs verifications before asking the user for input. - The last two commits rework the "--ref-action=" option to instead be split up into "--dry-run" and "--update-refs=" so that the option is less focussed on technical implementation details. I decided to send this patch series as a small incremental step before sending `git history split`, also because that series conflicts with aa/add-p-no-auto-advance. Changes in v2: - Use `strvec_pushv()` instead of looping around `strvec_push()`. - Document that "--dry-run" writes objects for later use. - Document the default value of "--update-refs=". - Mention the subtlety around false(1) in the commit messages. - Link to v1: https://lore.kernel.org/r/20260212-b4-pks-history-dry-run-v1-0-1ce03d631c1b@pks.im Thanks! Patrick --- Patrick Steinhardt (5): builtin/history: perform revwalk checks before asking for user input builtin/history: check for merges before asking for user input builtin/history: replace "--ref-action=print" with "--dry-run" builtin/history: rename "--ref-action=" to "--update-refs=" Documentation/git-history: document default for "--update-refs=" Documentation/git-history.adoc | 14 ++- builtin/history.c | 254 ++++++++++++++++++++++++++--------------- t/t3451-history-reword.sh | 20 +++- 3 files changed, 182 insertions(+), 106 deletions(-) Range-diff versus v1: 1: a4b0654c49 ! 1: 495a8e7a1a builtin/history: perform revwalk checks before asking for user input @@ Commit message Extract the function to set up the revision walk and call it before we ask for user input to fix this. + Adapt one of the tests that is expected to fail because of this check + to use false(1) as editor. If the editor had been executed by Git, it + would fail with the error message "Aborting commit as launching the + editor failed." + Signed-off-by: Patrick Steinhardt ## builtin/history.c ## 2: 3ea8f7740a ! 2: 13c5edbe7b builtin/history: check for merges before asking for user input @@ Commit message Fix this by checking whether the revwalk contains merge commits before we ask for user input. + Adapt one of the tests that is expected to fail because of this check + to use false(1) as editor. If the editor had been executed by Git, it + would fail with the error message "Aborting commit as launching the + editor failed." + Signed-off-by: Patrick Steinhardt ## builtin/history.c ## @@ builtin/history.c: static int parse_ref_action(const struct option *opt, const c + struct rev_info revs; + int ret; + -+ for (size_t i = 0; i < revwalk_args->nr; i++) -+ strvec_push(&args, revwalk_args->v[i]); ++ strvec_pushv(&args, revwalk_args->v); + strvec_push(&args, "--min-parents=2"); + + repo_init_revisions(repo, &revs, NULL); 3: 4e605e65e0 ! 3: 7226c4d1af builtin/history: replace "--ref-action=print" with "--dry-run" @@ Commit message Add a test to verify that both "--ref-action=" values behave as expected. + This patch is best viewed with "--ignore-space-change". + Signed-off-by: Patrick Steinhardt ## Documentation/git-history.adoc ## @@ Documentation/git-history.adoc: The following commands are available to rewrite -`--ref-action=(branches|head|print)`:: +`--dry-run`:: + Do not update any references, but instead print any ref updates in a -+ format that can be consumed by linkgit:git-update-ref[1]. ++ format that can be consumed by linkgit:git-update-ref[1]. Necessary new ++ objects will be written into the repository, so applying these printed ++ ref updates is generally safe. + +`--ref-action=(branches|head)`:: Control which references will be updated by the command, if any. With 4: 1da7284902 ! 4: 7f41026981 builtin/history: rename "--ref-action=" to "--update-refs=" @@ Documentation/git-history.adoc: git-history - EXPERIMENTAL: Rewrite history DESCRIPTION ----------- @@ Documentation/git-history.adoc: OPTIONS - Do not update any references, but instead print any ref updates in a - format that can be consumed by linkgit:git-update-ref[1]. + objects will be written into the repository, so applying these printed + ref updates is generally safe. -`--ref-action=(branches|head)`:: +`--update-refs=(branches|head)`:: -: ---------- > 5: 0bc831fcab Documentation/git-history: document default for "--update-refs=" --- base-commit: 6fcee4785280a08e7f271bd015a4dc33753e2886 change-id: 20260212-b4-pks-history-dry-run-2b840e530ae6