Skip to content

Commit 65fb2f7

Browse files
committed
Merge branch 'ps/history' into seen
"git history" history rewriting UI. * 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: parse commits before dereferencing them replay: stop using `the_repository` replay: extract logic to pick commits wt-status: provide function to expose status for trees
2 parents 72bb00b + 88c9575 commit 65fb2f7

30 files changed

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

0 commit comments

Comments
 (0)