Skip to content

Commit 708bf14

Browse files
committed
Merge branch 'ps/history' into seen
"git history" history rewriting UI. * ps/history: builtin/history: implement "reword" subcommand builtin: add new "history" command wt-status: provide function to expose status for trees replay: yield the object ID of the final rewritten commit replay: small set of cleanups builtin/replay: move core logic into "libgit.a" builtin/replay: extract core logic to replay revisions
2 parents 7f57b06 + e125df7 commit 708bf14

File tree

17 files changed

+1352
-345
lines changed

17 files changed

+1352
-345
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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
git-history(1)
2+
==============
3+
4+
NAME
5+
----
6+
git-history - EXPERIMENTAL: Rewrite history
7+
8+
SYNOPSIS
9+
--------
10+
[synopsis]
11+
git history reword <commit> [--ref-action=(branches|head|print)]
12+
13+
DESCRIPTION
14+
-----------
15+
16+
Rewrite history by rearranging or modifying specific commits in the
17+
history.
18+
19+
THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
20+
21+
This command is related to linkgit:git-rebase[1] in that both commands can be
22+
used to rewrite history. There are a couple of major differences though:
23+
24+
* linkgit:git-history[1] can work in a bare repository as it does not need to
25+
touch either the index or the worktree.
26+
* linkgit:git-history[1] does not execute any linkgit:githooks[5] at the
27+
current point in time. This may change in the future.
28+
* linkgit:git-history[1] by default updates all branches that are descendants
29+
of the original commit to point to the rewritten commit.
30+
31+
Overall, linkgit:git-history[1] aims to provide a more opinionated way to modify
32+
your commit history that is simpler to use compared to linkgit:git-rebase[1] in
33+
general.
34+
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.
38+
39+
LIMITATIONS
40+
-----------
41+
42+
This command does not (yet) work with histories that contain merges. You
43+
should use linkgit:git-rebase[1] with the `--rebase-merges` flag instead.
44+
45+
Furthermore, the command does not support operations that can result in merge
46+
conflicts. This limitation is by design as history rewrites are not intended to
47+
be stateful operations. The limitation can be lifted once (if) Git learns about
48+
first-class conflicts.
49+
50+
COMMANDS
51+
--------
52+
53+
Several commands are available to rewrite history in different ways:
54+
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+
71+
GIT
72+
---
73+
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
@@ -1286,6 +1286,7 @@ LIB_OBJS += repack-geometry.o
12861286
LIB_OBJS += repack-midx.o
12871287
LIB_OBJS += repack-promisor.o
12881288
LIB_OBJS += replace-object.o
1289+
LIB_OBJS += replay.o
12891290
LIB_OBJS += repo-settings.o
12901291
LIB_OBJS += repository.o
12911292
LIB_OBJS += rerere.o
@@ -1418,6 +1419,7 @@ BUILTIN_OBJS += builtin/get-tar-commit-id.o
14181419
BUILTIN_OBJS += builtin/grep.o
14191420
BUILTIN_OBJS += builtin/hash-object.o
14201421
BUILTIN_OBJS += builtin/help.o
1422+
BUILTIN_OBJS += builtin/history.o
14211423
BUILTIN_OBJS += builtin/hook.o
14221424
BUILTIN_OBJS += builtin/index-pack.o
14231425
BUILTIN_OBJS += builtin/init-db.o

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix, struc
196196
int cmd_grep(int argc, const char **argv, const char *prefix, struct repository *repo);
197197
int cmd_hash_object(int argc, const char **argv, const char *prefix, struct repository *repo);
198198
int cmd_help(int argc, const char **argv, const char *prefix, struct repository *repo);
199+
int cmd_history(int argc, const char **argv, const char *prefix, struct repository *repo);
199200
int cmd_hook(int argc, const char **argv, const char *prefix, struct repository *repo);
200201
int cmd_index_pack(int argc, const char **argv, const char *prefix, struct repository *repo);
201202
int cmd_init_db(int argc, const char **argv, const char *prefix, struct repository *repo);

0 commit comments

Comments
 (0)