Thread (114 messages) 114 messages, 6 authors, 1d ago
WARM1d
Revisions (8)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
  6. v6 [diff vs current]
  7. v7 current
  8. v8 [diff vs current]

[PATCH v7 00/11] builtin/history: introduce "drop" subcommand

From: Patrick Steinhardt <hidden>
Date: 2026-06-29 07:34:35

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 v7:
  - Expose `replay_result_queue_update()` so that we don't have to
    duplicate its functionality.
  - Add missing SOB.
  - Link to v6: https://patch.msgid.link/20260615-b4-pks-history-drop-v6-0-2e329e536d78@pks.im

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 (11):
      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
      replay: expose `replay_result_queue_update()`
      builtin/history: split handling of ref updates into two phases
      builtin/history: implement "drop" subcommand

 Documentation/git-history.adoc |  38 ++-
 builtin/history.c              | 286 +++++++++++++++++++---
 builtin/rebase.c               |  41 ++--
 read-cache-ll.h                |   1 +
 read-cache.c                   |  12 +-
 replay.c                       |   8 +-
 replay.h                       |   5 +
 reset.c                        | 102 +++++---
 reset.h                        |  51 ++--
 sequencer.c                    |  17 +-
 t/meson.build                  |   1 +
 t/t3454-history-drop.sh        | 537 +++++++++++++++++++++++++++++++++++++++++
 12 files changed, 978 insertions(+), 121 deletions(-)

Range-diff versus v6:

 1:  61c6eb1bdc =  1:  640b51b963 read-cache: split out function to drop unmerged entries to stage 0
 2:  50a61da426 =  2:  485dee2858 reset: drop `USE_THE_REPOSITORY_VARIABLE`
 3:  96ffa9d2a6 !  3:  fd82a0b592 reset: rename `reset_head()`
    @@ Commit message
         subsequent commit.
     
         Suggested-by: Phillip Wood [off-list ref]
    +    Signed-off-by: Patrick Steinhardt [off-list ref]
     
      ## builtin/rebase.c ##
     @@ builtin/rebase.c: static int finish_rebase(struct rebase_options *opts)
 4:  874c3ecd59 =  4:  7fe6db0459 reset: modernize flags passed to `reset_working_tree()`
 5:  bba2845f2d =  5:  b0fba42b75 reset: introduce dry-run mode
 6:  ada93af1da =  6:  db635dbea4 reset: introduce ability to skip updating HEAD
 7:  3cf1dcf549 =  7:  5422a99683 reset: allow the caller to specify the current HEAD object
 8:  ff28ad814c =  8:  a264b72376 reset: stop assuming that the caller passes in a clean index
 -:  ---------- >  9:  8060e462d1 replay: expose `replay_result_queue_update()`
 9:  7b048d5a16 ! 10:  7233b48732 builtin/history: split handling of ref updates into two phases
    @@ builtin/history.c: static int handle_reference_updates(struct rev_info *revs,
      		    !detached_head)
      			continue;
      
    -+		ALLOC_GROW(result->updates, result->updates_nr + 1, result->updates_alloc);
    -+		result->updates[result->updates_nr].refname = xstrdup(decoration->name);
    -+		result->updates[result->updates_nr].old_oid = original->object.oid;
    -+		result->updates[result->updates_nr].new_oid = rewritten->object.oid;
    -+		result->updates_nr++;
    ++		replay_result_queue_update(result, decoration->name,
    ++					   &original->object.oid,
    ++					   &rewritten->object.oid);
     +	}
     +
     +	return 0;
10:  7389e0432a = 11:  61668ea59a builtin/history: implement "drop" subcommand

---
base-commit: 1666c1265231b0bc5f613fbbf3f0a9896cdef76e
change-id: 20260601-b4-pks-history-drop-28f6c6399e7b
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help