Skip to content

Commit cd4093b

Browse files
committed
Merge branch 'rr/revert-cherry-pick-continue'
* rr/revert-cherry-pick-continue: builtin/revert.c: make commit_list_append() static revert: Propagate errors upwards from do_pick_commit revert: Introduce --continue to continue the operation revert: Don't implicitly stomp pending sequencer operation revert: Remove sequencer state when no commits are pending reset: Make reset remove the sequencer state revert: Introduce --reset to remove sequencer state revert: Make pick_commits functionally act on a commit list revert: Save command-line options for continuing operation revert: Save data for continuing after conflict resolution revert: Don't create invalid replay_opts in parse_args revert: Separate cmdline parsing from functional code revert: Introduce struct to keep command-line options revert: Eliminate global "commit" variable revert: Rename no_replay to record_origin revert: Don't check lone argument in get_encoding revert: Simplify and inline add_message_to_msg config: Introduce functions to write non-standard file advice: Introduce error_resolve_conflict
2 parents 821b315 + fb3198c commit cd4093b

14 files changed

+960
-171
lines changed

Documentation/git-cherry-pick.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
12+
'git cherry-pick' --reset
13+
'git cherry-pick' --continue
1214

1315
DESCRIPTION
1416
-----------
@@ -110,6 +112,10 @@ effect to your index in a row.
110112
Pass the merge strategy-specific option through to the
111113
merge strategy. See linkgit:git-merge[1] for details.
112114

115+
SEQUENCER SUBCOMMANDS
116+
---------------------
117+
include::sequencer.txt[]
118+
113119
EXAMPLES
114120
--------
115121
`git cherry-pick master`::

Documentation/git-revert.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
12+
'git revert' --reset
13+
'git revert' --continue
1214

1315
DESCRIPTION
1416
-----------
@@ -91,6 +93,10 @@ effect to your index in a row.
9193
Pass the merge strategy-specific option through to the
9294
merge strategy. See linkgit:git-merge[1] for details.
9395

96+
SEQUENCER SUBCOMMANDS
97+
---------------------
98+
include::sequencer.txt[]
99+
94100
EXAMPLES
95101
--------
96102
`git revert HEAD~3`::

Documentation/sequencer.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--reset::
2+
Forget about the current operation in progress. Can be used
3+
to clear the sequencer state after a failed cherry-pick or
4+
revert.
5+
6+
--continue::
7+
Continue the operation in progress using the information in
8+
'.git/sequencer'. Can be used to continue after resolving
9+
conflicts in a failed cherry-pick or revert.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ LIB_H += rerere.h
557557
LIB_H += resolve-undo.h
558558
LIB_H += revision.h
559559
LIB_H += run-command.h
560+
LIB_H += sequencer.h
560561
LIB_H += sha1-array.h
561562
LIB_H += sha1-lookup.h
562563
LIB_H += sideband.h
@@ -664,6 +665,7 @@ LIB_OBJS += revision.o
664665
LIB_OBJS += run-command.o
665666
LIB_OBJS += server-info.o
666667
LIB_OBJS += setup.o
668+
LIB_OBJS += sequencer.o
667669
LIB_OBJS += sha1-array.o
668670
LIB_OBJS += sha1-lookup.o
669671
LIB_OBJS += sha1_file.o

advice.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ static struct {
1919
{ "detachedhead", &advice_detached_head },
2020
};
2121

22+
void advise(const char *advice, ...)
23+
{
24+
va_list params;
25+
26+
va_start(params, advice);
27+
vreportf("hint: ", advice, params);
28+
va_end(params);
29+
}
30+
2231
int git_default_advice_config(const char *var, const char *value)
2332
{
2433
const char *k = skip_prefix(var, "advice.");
@@ -34,16 +43,24 @@ int git_default_advice_config(const char *var, const char *value)
3443
return 0;
3544
}
3645

37-
void NORETURN die_resolve_conflict(const char *me)
46+
int error_resolve_conflict(const char *me)
3847
{
39-
if (advice_resolve_conflict)
48+
error("'%s' is not possible because you have unmerged files.", me);
49+
if (advice_resolve_conflict) {
4050
/*
4151
* Message used both when 'git commit' fails and when
4252
* other commands doing a merge do.
4353
*/
44-
die("'%s' is not possible because you have unmerged files.\n"
45-
"Please, fix them up in the work tree, and then use 'git add/rm <file>' as\n"
46-
"appropriate to mark resolution and make a commit, or use 'git commit -a'.", me);
47-
else
48-
die("'%s' is not possible because you have unmerged files.", me);
54+
advise("Fix them up in the work tree,");
55+
advise("and then use 'git add/rm <file>' as");
56+
advise("appropriate to mark resolution and make a commit,");
57+
advise("or use 'git commit -a'.");
58+
}
59+
return -1;
60+
}
61+
62+
void NORETURN die_resolve_conflict(const char *me)
63+
{
64+
error_resolve_conflict(me);
65+
die("Exiting because of an unresolved conflict.");
4966
}

advice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ extern int advice_implicit_identity;
1111
extern int advice_detached_head;
1212

1313
int git_default_advice_config(const char *var, const char *value);
14-
14+
void advise(const char *advice, ...);
15+
int error_resolve_conflict(const char *me);
1516
extern void NORETURN die_resolve_conflict(const char *me);
1617

1718
#endif /* ADVICE_H */

branch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "refs.h"
44
#include "remote.h"
55
#include "commit.h"
6+
#include "sequencer.h"
67

78
struct tracking {
89
struct refspec spec;
@@ -245,4 +246,5 @@ void remove_branch_state(void)
245246
unlink(git_path("MERGE_MSG"));
246247
unlink(git_path("MERGE_MODE"));
247248
unlink(git_path("SQUASH_MSG"));
249+
remove_sequencer_state(0);
248250
}

0 commit comments

Comments
 (0)