From: Patrick Steinhardt Date: Mon, 15 Jun 2026 13:54:50 GMT Subject: [PATCH v6 00/10] builtin/history: introduce "drop" subcommand Message-ID: <20260615-b4-pks-history-drop-v6-0-2e329e536d78@pks.im> In-Reply-To: <20260601-b4-pks-history-drop-v1-0-643e32340d55@pks.im> Hi, this small patch series introduces the new "drop" subcommand for git-history(1). As a reader might guess, the command does exactly that: given a commit, it will drop that commit from the commit history and replay descendant branches on top of it. Changes in v6: - Fix bad interactions of DRY_RUN with UPDATE_HEAD - Link to v5: https://patch.msgid.link/20260611-b4-pks-history-drop-v5-0-34d35725559c@pks.im Changes in v5: - Reject UPDATE_ORIG_HEAD without UPDATE_HEAD. - Link to v4: https://patch.msgid.link/20260610-b4-pks-history-drop-v4-0-70d5f0ae8c25@pks.im Changes in v4: - Remove the `SKIP_REF_UPDATES` flag in favor of a new `UPDATE_HEAD` flag, as suggested by Phillip. - Rename `reset_head()` to `reset_working_tree()`. This better matches the new scope of the function, and it helps us to catch any in-flight patches that would now have to set the `UPDATE_HEAD` flag. - Link to v3: https://patch.msgid.link/20260608-b4-pks-history-drop-v3-0-84ca8e43e937@pks.im Changes in v3: - Fix commit message typos. - Make `update_orig_head` and `skip_ref_updates` mutually exclusive. - Use fancy revisions to specify the commit to drop in the example section. - Detect conflicting changes in the index/working tree in dry-run mode. - Consistently use a subshell. - Rename `RESET_HEAD_ORIG_HEAD` to `RESET_HEAD_UPDATE_ORIG_HEAD`. - - Link to v2: https://patch.msgid.link/20260603-b4-pks-history-drop-v2-0-742cb5b5176d@pks.im Changes in v2: - Reworked `update_worktree()` to use `reset_head()`, which required a bunch of changes to `reset_head()`. - Consistently mention the commit that cannot be dropped as part of error messages. - Adapt error message to not use backticks anymore. - Drop redundant "--graph" flag in a test helper. - Link to v1: https://patch.msgid.link/20260601-b4-pks-history-drop-v1-0-643e32340d55@pks.im Thanks! Patrick --- Patrick Steinhardt (10): read-cache: split out function to drop unmerged entries to stage 0 reset: drop `USE_THE_REPOSITORY_VARIABLE` reset: rename `reset_head()` reset: modernize flags passed to `reset_working_tree()` reset: introduce dry-run mode reset: introduce ability to skip updating HEAD reset: allow the caller to specify the current HEAD object reset: stop assuming that the caller passes in a clean index builtin/history: split handling of ref updates into two phases builtin/history: implement "drop" subcommand Documentation/git-history.adoc | 38 ++- builtin/history.c | 288 +++++++++++++++++++--- builtin/rebase.c | 41 ++-- read-cache-ll.h | 1 + read-cache.c | 12 +- reset.c | 102 +++++--- reset.h | 51 ++-- sequencer.c | 17 +- t/meson.build | 1 + t/t3454-history-drop.sh | 537 +++++++++++++++++++++++++++++++++++++++++ 10 files changed, 971 insertions(+), 117 deletions(-) Range-diff versus v5: 1: e21a324987 = 1: 07dee893d7 read-cache: split out function to drop unmerged entries to stage 0 2: d16b3df944 = 2: 96f33165b8 reset: drop `USE_THE_REPOSITORY_VARIABLE` 3: b73224c4b0 = 3: 35f31792f3 reset: rename `reset_head()` 4: 1b5fbaa9c2 = 4: 1837483676 reset: modernize flags passed to `reset_working_tree()` 5: a73fb4b3e8 = 5: 206b73f71e reset: introduce dry-run mode 6: 3be3208155 ! 6: 48c7b1571f reset: introduce ability to skip updating HEAD @@ reset.c: int reset_working_tree(struct repository *r, if (refs_only) { - if (!dry_run) -+ if (update_head) ++ if (!dry_run && update_head) return update_refs(r, opts, oid, head); return 0; } 7: fb3a357d93 = 7: d6a9a3e524 reset: allow the caller to specify the current HEAD object 8: 9b883dbbad = 8: d4bc3acd87 reset: stop assuming that the caller passes in a clean index 9: 88a929e1a5 = 9: 493a3f4422 builtin/history: split handling of ref updates into two phases 10: 8f19defcb0 = 10: 184849df09 builtin/history: implement "drop" subcommand --- base-commit: 1666c1265231b0bc5f613fbbf3f0a9896cdef76e change-id: 20260601-b4-pks-history-drop-28f6c6399e7b