prepare deprecation of git-revert
Subsystems (2)
PATCH 1/1 prepare deprecation of git-revert
* Rename builtin-revert.c into builtin-cherry-pick.c
* Add option -R/--revert to git-cherry-pick.
Document it by taking the current content of git-revert manpage for the option.
* get rid of the no_replay initialization, just ignore it when we're in the revert case, it makes really no sense to error out.
* put the warning of deprecation in cmd_revert, #if 0-ed out for now.
---
I've not kept the auto-edit feature of git-revert for the git-cherry-pick -R case as I don't believe it makes a lot of sense. But if people are unhappy with that, I can easily "fix" it.
Documentation/git-cherry-pick.txt | 15 +++++++++++++++ Makefile | 6 +++--- builtin-revert.c => builtin-cherry-pick.c | 10 ++++------ 3 files changed, 22 insertions(+), 9 deletions(-) rename builtin-revert.c => builtin-cherry-pick.c (98%)
Documentation/git-cherry-pick.txt +15 -0
@@ -40,6 +40,21 @@ OPTIONS development branch), adding this information can be useful. +-R:: +--revert:: + Given one existing commit, revert the change the patch introduces, and + record a new commit that records it. This requires your working tree + to be clean (no modifications from the HEAD commit). ++ +Note: 'git revert' is used to record a new commit to reverse the +effect of an earlier commit (often a faulty one). If you want to +throw away all uncommitted changes in your working directory, you +should see linkgit:git-reset[1], particularly the '--hard' option. If +you want to extract specific files as they were in another commit, you +should see linkgit:git-checkout[1], specifically the 'git checkout +<commit> -- <filename>' syntax. Take care with these alternatives as +both will discard uncommitted changes in your working directory. + -r:: It used to be that the command defaulted to do `-x` described above, and `-r` was to disable it. Now the
Makefile +3 -3
@@ -306,7 +306,7 @@ PROGRAMS += git-var$X # builtin-$C.o but is linked in as part of some other command. BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS)) -BUILT_INS += git-cherry-pick$X +BUILT_INS += git-revert$X BUILT_INS += git-cherry$X BUILT_INS += git-format-patch$X BUILT_INS += git-fsck-objects$X
@@ -508,6 +508,7 @@ BUILTIN_OBJS += builtin-check-attr.o BUILTIN_OBJS += builtin-check-ref-format.o BUILTIN_OBJS += builtin-checkout-index.o BUILTIN_OBJS += builtin-checkout.o +BUILTIN_OBJS += builtin-cherry-pick.o BUILTIN_OBJS += builtin-clean.o BUILTIN_OBJS += builtin-clone.o BUILTIN_OBJS += builtin-commit-tree.o
@@ -556,7 +557,6 @@ BUILTIN_OBJS += builtin-rerere.o BUILTIN_OBJS += builtin-reset.o BUILTIN_OBJS += builtin-rev-list.o BUILTIN_OBJS += builtin-rev-parse.o -BUILTIN_OBJS += builtin-revert.o BUILTIN_OBJS += builtin-rm.o BUILTIN_OBJS += builtin-send-pack.o BUILTIN_OBJS += builtin-shortlog.o
@@ -1261,7 +1261,7 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS) $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) -builtin-revert.o wt-status.o: wt-status.h +builtin-cherry-pick.o wt-status.o: wt-status.h $(LIB_FILE): $(LIB_OBJS) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
builtin-cherry-pick.c renamed from builtin-revert.c +4 -6
@@ -57,6 +57,7 @@ static void parse_args(int argc, const char **argv)OPT_BOOLEAN ('r' ,NULL , &noop,"no-op (backward compatibility)" ),OPT_BOOLEAN ('s' ,"signoff" , &signoff,"add Signed-off-by:" ),OPT_INTEGER ('m' ,"mainline" , &mainline,"parent number" ), +OPT_SET_INT ('R' ,"revert" , &action,"cherry-pick a reverted patch" ,REVERT ), OPT_END(), };
@@ -261,10 +262,6 @@ static int revert_or_cherry_pick(int argc, const char **argv)setenv (GIT_REFLOG_ACTION , me,0 );parse_args (argc, argv); -/* this is copied from the shell script, but it's never triggered... */ -if (action ==REVERT && !no_replay) -die ("revert is incompatible with replay" ); -if (read_cache () <0 )die ("git %s: failed to read the index" , me);if (no_commit) {
@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)int cmd_revert (int argc,const char **argv,const char *prefix) { +#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif if (isatty (0 )) edit =1 ; - no_replay =1 ; action =REVERT ;return revert_or_cherry_pick (argc, argv); }int cmd_cherry_pick (int argc,const char **argv,const char *prefix) { - no_replay =0 ; action =CHERRY_PICK ;return revert_or_cherry_pick (argc, argv); }
Signature · 1 line
1.6.0.3.790.ga4dd7.dirty
Quoted 29 lines · Pierre Habouzit
* Rename
builtin-revert.cintobuiltin-cherry-pick.c* Add option -R/--revert to git-cherry-pick.
Document it by taking the current content of git-revert manpage for the option.* get rid of the
no_replayinitialization, just ignore it when we're in the revert case, it makes really no sense to error out.* put the warning of deprecation in
cmd_revert, #if 0-ed out for now.Signed-off-by Pierre Habouzit <[email protected]>---
I've not kept the auto-edit feature of git-revert for the git-cherry-pick -R case as I don't believe it makes a lot of sense. But if people are unhappy with that, I can easily "fix" it.
Documentation/git-cherry-pick.txt | 15 +++++++++++++++ Makefile | 6 +++--- builtin-revert.c => builtin-cherry-pick.c | 10 ++++------ 3 files changed, 22 insertions(+), 9 deletions(-) rename builtin-revert.c => builtin-cherry-pick.c (98%)Documentation/git-cherry-pick.txt +0
-0
Documentation/git-cherry-pick.txt OPTIONS · line 49
Quoted 10 lines
Documentation/git-cherry-pick.txt +7
-0@@ -40,6 +40,21 @@ OPTIONS development branch), adding this information can be useful. +-R:: +--revert:: + Given one existing commit, revert the change the patch introduces, and + record a new commit that records it. This requires your working tree + to be clean (no modifications from the HEAD commit). ++ +Note: 'git revert' is used to record a new commit to reverse the
^ this was supposed to spell out 'git cherry-pick -R' of course :/
Quoted 7 lines
Documentation/git-cherry-pick.txt +7
-0+effect of an earlier commit (often a faulty one). If you want to +throw away all uncommitted changes in your working directory, you +should see linkgit:git-reset[1], particularly the '--hard' option. If +you want to extract specific files as they were in another commit, you +should see linkgit:git-checkout[1], specifically the 'git checkout +<commit> -- <filename>' syntax. Take care with these alternatives as +both will discard uncommitted changes in your working directory.
Signature · 3 lines
·O· Pierre Habouzit ··O [email protected] OOO http://www.madism.org
Pierre Habouzit, Fri, Oct 31, 2008 16:55:27 +0100:
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 7 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)int cmd_revert (int argc,const char **argv,const char *prefix) { +#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif
"git revert" is much shorter to type than "git cherry-pick -R". How about renaming "cherry-pick" into something short, like "pick"?
Quoted 11 lines · Alex Riesen
Pierre Habouzit, Fri, Oct 31, 2008 16:55:27 +0100:
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 7 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)int cmd_revert (int argc,const char **argv,const char *prefix) { +#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif "git revert" is much shorter to type than "git cherry-pick -R". How about renaming "cherry-pick" into something short, like "pick"?
Do you really use git revert _that_ often ? I don't. And cherry-pick is a really usual name for the tool.
FWIW the basic idea is to deprecate revert in a (not so ?) long time, and leave git revert unimplemented for ever so that people that would like it to be 'git checkout HEAD --' alias it to that, and the ones that want to keep the current behaviour alias it to 'git cherry-pick -R'
Signature · 3 lines
·O· Pierre Habouzit ··O [email protected] OOO http://www.madism.org
Pierre Habouzit, Fri, Oct 31, 2008 17:58:14 +0100:
Quoted 13 lines · Alex Riesen
Quoted 11 lines
Pierre Habouzit, Fri, Oct 31, 2008 16:55:27 +0100:
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 7 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)int cmd_revert (int argc,const char **argv,const char *prefix) { +#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif "git revert" is much shorter to type than "git cherry-pick -R". How about renaming "cherry-pick" into something short, like "pick"?
Quoted 2 lines
Do you really use git revert _that_ often ? I don't. And cherry-pick is a really usual name for the tool.
Have it 5 times in my bash history of 20k lines. 4 recent, one relatively old.
Quoted 4 lines
FWIW the basic idea is to deprecate revert in a (not so ?) long time, and leave git revert unimplemented for ever so that people that would like it to be 'git checkout HEAD --' alias it to that, and the ones that want to keep the current behaviour alias it to 'git cherry-pick -R'
Well, I kind of got used to it. And it makes sense (as does -R by cherry-pick, I have to admit). I have no other argument against the change.
Hi,
Quoted 11 lines · Alex Riesen
Pierre Habouzit, Fri, Oct 31, 2008 16:55:27 +0100:
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 7 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)int cmd_revert (int argc,const char **argv,const char *prefix) { +#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif "git revert" is much shorter to type than "git cherry-pick -R". How about renaming "cherry-pick" into something short, like "pick"?
I thought we agreed that we should _never_ remove support for "git revert"? I mean, we can deprecate it, but I find it pretty strong, and unnecessary, to break existing users' expectations.
Ciao,
Dscho
Quoted 14 lines · Johannes Schindelin
Quoted 11 lines · Alex Riesen
Pierre Habouzit, Fri, Oct 31, 2008 16:55:27 +0100:
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 7 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv)int cmd_revert (int argc,const char **argv,const char *prefix) { +#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif "git revert" is much shorter to type than "git cherry-pick -R". How about renaming "cherry-pick" into something short, like "pick"?
Quoted 3 lines
I thought we agreed that we should _never_ remove support for "git revert"? I mean, we can deprecate it, but I find it pretty strong, and unnecessary, to break existing users' expectations.
Likewise.
The current state of affairs is that there is no remedy if teachers find "git checkout -- path" or "git revert HEAD~24" is confusing to new people. By introducing "git unstage path" or "git cherry-pick -r HEAD~24", teachers can choose to teach what they feel less confusing, and they do not have to teach "git checkout -- path" or "git revert HEAD~24". We should stop there.
Quoted 11 lines · Pierre Habouzit
* Rename
builtin-revert.cintobuiltin-cherry-pick.c* Add option -R/--revert to git-cherry-pick.
Document it by taking the current content of git-revert manpage for the option.* get rid of the
no_replayinitialization, just ignore it when we're in the revert case, it makes really no sense to error out.* put the warning of deprecation in
cmd_revert, #if 0-ed out for now.
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 3 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0+#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif
By the way, Mercurial names this command IIRC 'hg backout'.
But I think that adding '-R' option to git-cherry-pick is a good idea even if we don't go deprecating git-revert.
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Quoted 13 lines · Jakub Narebski
Quoted 10 lines · Pierre Habouzit
* Rename
builtin-revert.cintobuiltin-cherry-pick.c* Add option -R/--revert to git-cherry-pick.
Document it by taking the current content of git-revert manpage for the option.* get rid of the
no_replayinitialization, just ignore it when we're in the revert case, it makes really no sense to error out.* put the warning of deprecation in
cmd_revert, #if 0-ed out for now.
Quoted 8 lines
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 3 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0+#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif By the way, Mercurial names this command IIRC 'hg backout'.
But I think that adding '-R' option to git-cherry-pick is a good idea even if we don't go deprecating git-revert.
Actually part of the "Git UI sucks at time"-talk by pasy, we somehow decided that git-revert would probably be deprecated in the future to avoid the clash between what people coming from other's SCM worlds expect it to be.
I don't remember what the tentative schedule was, that's why I left the warning commented out for now.
Signature · 3 lines
·O· Pierre Habouzit ··O [email protected] OOO http://www.madism.org
Quoted 5 lines · Jakub Narebski
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 3 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0+#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif By the way, Mercurial names this command IIRC 'hg backout'.
By the way, BitKeeper names this command "bk undo" (which is another reason why I would advocate against "git undo" as a syntatic sugar for "git checkout HEAD -- $*") --- not that I think there are too many BK refugees that might want to switch to git, but it shows that "undo" has its own ambiguities; gk uses "undo" the same way we currently use "git revert".
For people who argue that "git cherry-pick --revert" or "git cherry-pick -R" is too long, I'd argue that for most people its not a common command, and for those for which it is common, they can always make in alias for "git pick".
- Ted
Quoted 6 lines · Junio C Hamano
The current state of affairs is that there is no remedy if teachers find "git checkout -- path" or "git revert HEAD~24" is confusing to new people. By introducing "git unstage path" or "git cherry-pick -r HEAD~24", teachers can choose to teach what they feel less confusing, and they do not have to teach "git checkout -- path" or "git revert HEAD~24". We should stop there.
I think you should go half a step further: officially deprecate "revert", but keep it supported forever. The reason is just to help documentation to be homogeneous (I foresee questions of users having read here about "cherry-pick -R" and there about "revert" and asking "should I use one or the other"). At least, the man page for "revert" should state explicitly "this is a convenience alias for ...".
But I agree that removing support for "revert" is probably useless and somehow harmfull.
(my 2 cents ...)
Signature · 1 line
Matthieu
Quoted 11 lines · Alex Riesen
Pierre Habouzit, Fri, Oct 31, 2008 16:55:27 +0100:
Review static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 7 lines
(quoted diff) +3
-0@@ -439,16 +436,17 @@ static int revert_or_cherry_pick(int argc, const char **argv) int cmd_revert(int argc, const char **argv, const char *prefix) { +#if 0 + warning("git revert is deprecated, please use git cherry-pick --revert/-R instead"); +#endif"git revert" is much shorter to type than "git cherry-pick -R". How about renaming "cherry-pick" into something short, like "pick"?
Maybe a patch like this can help? With it you can type "git cp" for cherry-pick. If someday "git cp" is added, you can type "git c-p", much shorter.
--<--
commit dce5cad329390905bb91115a9de0153772be57d8
Author: Nguyễn Thái Ngọc Duy <[email protected]> Date: Sat Nov 1 17:12:04 2008 +0700
Add git command expansion
This allows git commands to be typed shorter (in shells that do not support autocompletion). There are three types of expansion:
- "foo" matches "foo*" commands (bi -> bisect)
- "foo" also matches "f*-oo*" (fim -> fast-import)
- "foo-bar" (with dash) matches "foo*-bar*" (fo-p -> format-patch)
This feature is only enabled if core.commandexpansion is true. It may work better if we can limit the command set (to porcelain only for example) but I have yet to find a way to pull commands-list.txt to help.c.
builtin.h +1 -0
@@ -12,6 +12,7 @@ extern const char git_more_info_string[];extern void list_common_cmds_help (void );extern const char *help_unknown_cmd (const char *cmd); +extern const char *expand_command (const char *cmd);extern void prune_packed_objects (int );extern int read_line_with_nul (char *buf,int size,FILE *file); extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
git.c +17 -0
@@ -14,6 +14,7 @@ struct pager_config {const char *cmd;int val; }; +static int command_expansion;static int pager_command_config (const char *var,const char *value,void *data) {
@@ -415,6 +416,13 @@ static void execv_dashed_external(const char **argv)strbuf_release (&cmd); } +static int git_command_expansion_config (const char *var,const char *value,void *cb) +{ +if (!strcmp (var,"core.commandexpansion" )) + command_expansion =git_config_bool (var, value); + +return git_default_config (var, value, cb); +}int main (int argc,const char **argv) {
@@ -501,6 +509,15 @@ int main(int argc, const char **argv) cmd, argv[0]);exit (1 ); } +git_config (git_command_expansion_config,NULL ); +if (command_expansion) { +const char *expand_cmd =expand_command (cmd); +if (expand_cmd) { + argv[0 ] = expand_cmd; +handle_internal_command (argc, argv); +execv_dashed_external (argv); + } + } argv[0 ] =help_unknown_cmd (cmd);handle_internal_command (argc, argv);execv_dashed_external (argv);
help.c +61 -0
67 lines not on this page · raw message
--<--
Signature · 1 line
Duy
Hi,
Quoted 8 lines · Nguyen Thai Ngoc Duy
Add git command expansion
This allows git commands to be typed shorter (in shells that do not support autocompletion). There are three types of expansion:
- "foo" matches "foo*" commands (bi -> bisect)
- "foo" also matches "f*-oo*" (fim -> fast-import)
- "foo-bar" (with dash) matches "foo*-bar*" (fo-p -> format-patch)
I'd rather have the soft-alias code back to perform this expansion, but only for a limited and explicit set of abbreviations.
Ciao,
Dscho
Quoted 13 lines · Theodore Tso
Quoted 4 lines · Jakub Narebski
builtin-cherry-pick.c static int revert_or_cherry_pick(int argc, const char **argv) · line 441
Quoted 3 lines
builtin-cherry-pick.c renamed from builtin-revert.c +3
-0+#if 0 +warning ("git revert is deprecated, please use git cherry-pick --revert/-R instead" ); +#endif By the way, Mercurial names this command IIRC 'hg backout'.
By the way, BitKeeper names this command "bk undo" (which is another reason why I would advocate against "git undo" as a syntatic sugar for "git checkout HEAD -- $*") --- not that I think there are too many BK refugees that might want to switch to git, but it shows that "undo" has its own ambiguities; gk uses "undo" the same way we currently use "git revert".
Quoted 5 lines
For people who argue that "git cherry-pick --revert" or "git cherry-pick -R" is too long, I'd argue that for most people its not a common command, and for those for which it is common, they can always make in alias for "git pick".
Probably "git unpick" in that case.
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Quoted 3 lines · Pierre Habouzit
I've not kept the auto-edit feature of git-revert for the git-cherry-pick -R case as I don't believe it makes a lot of sense. But if people are unhappy with that, I can easily "fix" it.
I disagree. I write a new commit message for every revert I do.
When you cherry-pick, you are pulling a good commit from somewhere else. So its commit message should suffice to explain why you are making the change (and infrequently, you might want to give more context or say "and here is where this comes from").
But when you revert, you are saying "this other commit was bad, so let's reverse it." So you can look at the other commit to see what it did, but you still don't know _why_ it was bad. A revert should always give information about what you know _now_ that you didn't know when you made the commit originally.
-Peff
Quoted 13 lines · Jeff King
Quoted 3 lines · Pierre Habouzit
I've not kept the auto-edit feature of git-revert for the git-cherry-pick -R case as I don't believe it makes a lot of sense. But if people are unhappy with that, I can easily "fix" it.
I disagree. I write a new commit message for every revert I do.
When you cherry-pick, you are pulling a good commit from somewhere else. So its commit message should suffice to explain why you are making the change (and infrequently, you might want to give more context or say "and here is where this comes from").
Quoted 5 lines
But when you revert, you are saying "this other commit was bad, so let's reverse it." So you can look at the other commit to see what it did, but you still don't know _why_ it was bad. A revert should always give information about what you know _now_ that you didn't know when you made the commit originally.
Indeed that makes sense, I'll update the patch then, and be lighter on the deprecation side since it seems I misunderstood what people agreed on.
Signature · 3 lines
·O· Pierre Habouzit ··O [email protected] OOO http://www.madism.org