Skip to content

Commit e125df7

Browse files
pks-tgitster
authored andcommitted
builtin/history: implement "reword" subcommand
Implement a new "reword" subcommand for git-history(1). This subcommand is similar to the user performing an interactive rebase with a single commit changed to use the "reword" instruction. The "reword" subcommand is built on top of the replay subsystem instead of the sequencer. This leads to some major differences compared to git-rebase(1): - We do not check out the commit that is to be reworded and instead perform the operation in-memory. This has the obvious benefit of being significantly faster compared to git-rebase(1), but even more importantly it allows the user to rewrite history even if there are local changes in the working tree or in the index. - We do not execute any hooks, even though we leave some room for changing this in the future. - By default, all local branches that contain the commit will be rewritten. This especially helps with workflows that use stacked branches. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent baf46a8 commit e125df7

File tree

6 files changed

+758
-13
lines changed

6 files changed

+758
-13
lines changed

Documentation/git-history.adoc

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-history - EXPERIMENTAL: Rewrite history
88
SYNOPSIS
99
--------
1010
[synopsis]
11-
git history [<options>]
11+
git history reword <commit> [--ref-action=(branches|head|print)]
1212

1313
DESCRIPTION
1414
-----------
@@ -32,8 +32,9 @@ Overall, linkgit:git-history[1] aims to provide a more opinionated way to modify
3232
your commit history that is simpler to use compared to linkgit:git-rebase[1] in
3333
general.
3434

35-
If you want to reapply a range of commits onto a different base, or interactive
36-
rebases if you want to edit a range of commits.
35+
Use linkgit:git-rebase[1] if you want to reapply a range of commits onto a
36+
different base, or interactive rebases if you want to edit a range of commits
37+
at once.
3738

3839
LIMITATIONS
3940
-----------
@@ -51,6 +52,22 @@ COMMANDS
5152

5253
Several commands are available to rewrite history in different ways:
5354

55+
`reword <commit>`::
56+
Rewrite the commit message of the specified commit. All the other
57+
details of this commit remain unchanged. This command will spawn an
58+
editor with the current message of that commit.
59+
60+
OPTIONS
61+
-------
62+
63+
`--ref-action=(branches|head|print)`::
64+
Control which references will be updated by the command, if any. With
65+
`branches`, all local branches that point to commits which are
66+
decendants of the original commit will be rewritten. With `head`, only
67+
the current `HEAD` reference will be rewritten. With `print`, all
68+
updates as they would be performed with `branches` are printed in a
69+
format that can be consumed by linkgit:git-update-ref[1].
70+
5471
GIT
5572
---
5673
Part of the linkgit:git[1] suite

0 commit comments

Comments
 (0)