Skip to content

Commit 92aa838

Browse files
committed
Merge branch 'ps/history' into seen
"git history" history rewriting UI. Comments? * ps/history: builtin/history: implement "split" subcommand cache-tree: allow writing in-memory index as tree add-patch: add support for in-memory index patching add-patch: remove dependency on "add-interactive" subsystem add-patch: split out `struct interactive_options` add-patch: split out header from "add-interactive.h" builtin/history: implement "reword" subcommand builtin: add new "history" command replay: stop using `the_repository` replay: extract logic to pick commits wt-status: provide function to expose status for trees
2 parents 401bbf4 + 4ac8283 commit 92aa838

30 files changed

+1972
-377
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
/git-grep
8080
/git-hash-object
8181
/git-help
82+
/git-history
8283
/git-hook
8384
/git-http-backend
8485
/git-http-fetch

Documentation/git-history.adoc

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
git-history(1)
2+
==============
3+
4+
NAME
5+
----
6+
git-history - EXPERIMENTAL: Rewrite history of the current branch
7+
8+
SYNOPSIS
9+
--------
10+
[synopsis]
11+
git history reword <commit>
12+
git history split <commit> [--] [<pathspec>...]
13+
14+
DESCRIPTION
15+
-----------
16+
17+
Rewrite history by rearranging or modifying specific commits in the
18+
history.
19+
20+
THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
21+
22+
This command is similar to linkgit:git-rebase[1] and uses the same
23+
underlying machinery. You should use rebases if you want to reapply a range of
24+
commits onto a different base, or interactive rebases if you want to edit a
25+
range of commits.
26+
27+
Note that this command does not (yet) work with histories that contain
28+
merges. You should use linkgit:git-rebase[1] with the `--rebase-merges`
29+
flag instead.
30+
31+
COMMANDS
32+
--------
33+
34+
Several commands are available to rewrite history in different ways:
35+
36+
`reword <commit>`::
37+
Rewrite the commit message of the specified commit. All the other
38+
details of this commit remain unchanged. This command will spawn an
39+
editor with the current message of that commit.
40+
41+
`split <commit> [--] [<pathspec>...]`::
42+
Interactively split up <commit> into two commits by choosing
43+
hunks introduced by it that will be moved into the new split-out
44+
commit. These hunks will then be written into a new commit that
45+
becomes the parent of the previous commit. The original commit
46+
stays intact, except that its parent will be the newly split-out
47+
commit.
48+
+
49+
The commit message of the new commit will be asked for by launching the
50+
configured editor. Authorship of the commit will be the same as for the
51+
original commit.
52+
+
53+
If passed, _<pathspec>_ can be used to limit which changes shall be split out
54+
of the original commit. Files not matching any of the pathspecs will remain
55+
part of the original commit. For more details, see the 'pathspec' entry in
56+
linkgit:gitglossary[7].
57+
+
58+
It is invalid to select either all or no hunks, as that would lead to
59+
one of the commits becoming empty.
60+
61+
CONFIGURATION
62+
-------------
63+
64+
include::includes/cmd-config-section-all.adoc[]
65+
66+
include::config/sequencer.adoc[]
67+
68+
EXAMPLES
69+
--------
70+
71+
Split a commit
72+
~~~~~~~~~~~~~~
73+
74+
----------
75+
$ git log --stat --oneline
76+
3f81232 (HEAD -> main) original
77+
bar | 1 +
78+
foo | 1 +
79+
2 files changed, 2 insertions(+)
80+
81+
$ git history split HEAD
82+
diff --git a/bar b/bar
83+
new file mode 100644
84+
index 0000000..5716ca5
85+
--- /dev/null
86+
+++ b/bar
87+
@@ -0,0 +1 @@
88+
+bar
89+
(1/1) Stage addition [y,n,q,a,d,e,p,?]? y
90+
91+
diff --git a/foo b/foo
92+
new file mode 100644
93+
index 0000000..257cc56
94+
--- /dev/null
95+
+++ b/foo
96+
@@ -0,0 +1 @@
97+
+foo
98+
(1/1) Stage addition [y,n,q,a,d,e,p,?]? n
99+
100+
$ git log --stat --oneline
101+
7cebe64 (HEAD -> main) original
102+
foo | 1 +
103+
1 file changed, 1 insertion(+)
104+
d1582f3 split-out commit
105+
bar | 1 +
106+
1 file changed, 1 insertion(+)
107+
----------
108+
109+
GIT
110+
---
111+
Part of the linkgit:git[1] suite

Documentation/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ manpages = {
6464
'git-gui.adoc' : 1,
6565
'git-hash-object.adoc' : 1,
6666
'git-help.adoc' : 1,
67+
'git-history.adoc' : 1,
6768
'git-hook.adoc' : 1,
6869
'git-http-backend.adoc' : 1,
6970
'git-http-fetch.adoc' : 1,

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ LIB_OBJS += repack-geometry.o
12741274
LIB_OBJS += repack-midx.o
12751275
LIB_OBJS += repack-promisor.o
12761276
LIB_OBJS += replace-object.o
1277+
LIB_OBJS += replay.o
12771278
LIB_OBJS += repo-settings.o
12781279
LIB_OBJS += repository.o
12791280
LIB_OBJS += rerere.o
@@ -1407,6 +1408,7 @@ BUILTIN_OBJS += builtin/get-tar-commit-id.o
14071408
BUILTIN_OBJS += builtin/grep.o
14081409
BUILTIN_OBJS += builtin/hash-object.o
14091410
BUILTIN_OBJS += builtin/help.o
1411+
BUILTIN_OBJS += builtin/history.o
14101412
BUILTIN_OBJS += builtin/hook.o
14111413
BUILTIN_OBJS += builtin/index-pack.o
14121414
BUILTIN_OBJS += builtin/init-db.o

0 commit comments

Comments
 (0)