Skip to content

Wip/fix  continue/ skip in synopsis #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Documentation/git-am.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ default. You can use `--no-utf8` to override this.
user to lie about the author date by using the same
value as the committer date.

--skip::
Skip the current patch. This is only meaningful when
restarting an aborted patch.

-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits. The `keyid` argument is optional and
Expand All @@ -162,6 +158,10 @@ default. You can use `--no-utf8` to override this.
extracted from the e-mail message and the current index
file, and continue.

--skip::
Skip the current patch. This is only meaningful when
restarting an aborted patch.

--resolvemsg=<msg>::
When a patch failure occurs, <msg> will be printed
to the screen before exiting. This overrides the
Expand Down
4 changes: 1 addition & 3 deletions Documentation/git-cherry-pick.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ SYNOPSIS
[verse]
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
[-S[<keyid>]] <commit>...
'git cherry-pick' --continue
'git cherry-pick' --quit
'git cherry-pick' --abort
'git cherry-pick' (--continue | --skip | --abort | --quit)

DESCRIPTION
-----------
Expand Down
15 changes: 9 additions & 6 deletions Documentation/git-merge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ SYNOPSIS
[-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
[--[no-]allow-unrelated-histories]
[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>...]
'git merge' --abort
'git merge' --continue
'git merge' (--continue | --skip | --abort | --quit)

DESCRIPTION
-----------
Expand Down Expand Up @@ -88,6 +87,11 @@ will be appended to the specified message.
Allow the rerere mechanism to update the index with the
result of auto-conflict resolution if possible.

--continue::
After a 'git merge' stops due to conflicts you can conclude the
merge by running 'git merge --continue' (see "HOW TO RESOLVE
CONFLICTS" section below).

--abort::
Abort the current conflict resolution process, and
try to reconstruct the pre-merge state.
Expand All @@ -100,10 +104,9 @@ commit or stash your changes before running 'git merge'.
'git merge --abort' is equivalent to 'git reset --merge' when
`MERGE_HEAD` is present.

--continue::
After a 'git merge' stops due to conflicts you can conclude the
merge by running 'git merge --continue' (see "HOW TO RESOLVE
CONFLICTS" section below).
--quit::
Forget about the current merge in progress. Leave the index
and the working tree as-is.

<commit>...::
Commits, usually other branch heads, to merge into our branch.
Expand Down
24 changes: 12 additions & 12 deletions Documentation/git-rebase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS
[<upstream> [<branch>]]
'git rebase' [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>]
--root [<branch>]
'git rebase' --continue | --skip | --abort | --quit | --edit-todo | --show-current-patch
'git rebase' (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch)

DESCRIPTION
-----------
Expand Down Expand Up @@ -228,6 +228,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
--continue::
Restart the rebasing process after having resolved a merge conflict.

--skip::
Restart the rebasing process by skipping the current patch.

--abort::
Abort the rebase operation and reset HEAD to the original
branch. If <branch> was provided when the rebase operation was
Expand All @@ -240,6 +243,14 @@ leave out at most one of A and B, in which case it defaults to HEAD.
original branch. The index and working tree are also left
unchanged as a result.

--edit-todo::
Edit the todo list during an interactive rebase.

--show-current-patch::
Show the current patch in an interactive rebase or when rebase
is stopped because of conflicts. This is the equivalent of
`git show REBASE_HEAD`.

--keep-empty::
Keep the commits that do not change anything from its
parents in the result.
Expand All @@ -253,17 +264,6 @@ See also INCOMPATIBLE OPTIONS below.
+
See also INCOMPATIBLE OPTIONS below.

--skip::
Restart the rebasing process by skipping the current patch.

--edit-todo::
Edit the todo list during an interactive rebase.

--show-current-patch::
Show the current patch in an interactive rebase or when rebase
is stopped because of conflicts. This is the equivalent of
`git show REBASE_HEAD`.

-m::
--merge::
Use merging strategies to rebase. When the recursive (default) merge
Expand Down
4 changes: 1 addition & 3 deletions Documentation/git-revert.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ SYNOPSIS
--------
[verse]
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
'git revert' --continue
'git revert' --quit
'git revert' --abort
'git revert' (--continue | --skip | --abort | --quit)

DESCRIPTION
-----------
Expand Down
10 changes: 7 additions & 3 deletions Documentation/sequencer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
`.git/sequencer`. Can be used to continue after resolving
conflicts in a failed cherry-pick or revert.

--skip::
Skip the current commit and continue with the rest of the
sequence.

--abort::
Cancel the operation and return to the pre-sequence state.

--quit::
Forget about the current operation in progress. Can be used
to clear the sequencer state after a failed cherry-pick or
revert.

--abort::
Cancel the operation and return to the pre-sequence state.
10 changes: 8 additions & 2 deletions branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,20 @@ void create_branch(struct repository *r,
free(real_ref);
}

void remove_branch_state(struct repository *r)
void remove_merge_branch_state(struct repository *r)
{
sequencer_post_commit_cleanup(r);
unlink(git_path_merge_head(r));
unlink(git_path_merge_rr(r));
unlink(git_path_merge_msg(r));
unlink(git_path_merge_mode(r));
}

void remove_branch_state(struct repository *r)
{
unlink(git_path_cherry_pick_head(r));
unlink(git_path_revert_head(r));
unlink(git_path_squash_msg(r));
remove_merge_branch_state(r);
}

void die_if_checked_out(const char *branch, int ignore_current_worktree)
Expand Down
6 changes: 6 additions & 0 deletions branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ int validate_branchname(const char *name, struct strbuf *ref);
*/
int validate_new_branchname(const char *name, struct strbuf *ref, int force);

/*
* Remove information about the merge state on the current
* branch. (E.g., MERGE_HEAD)
*/
void remove_merge_branch_state(struct repository *r);

/*
* Remove information about the state of working on the current
* branch. (E.g., MERGE_HEAD)
Expand Down
39 changes: 20 additions & 19 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,11 +2164,30 @@ int cmd_am(int argc, const char **argv, const char *prefix)

const char * const usage[] = {
N_("git am [<options>] [(<mbox> | <Maildir>)...]"),
N_("git am [<options>] (--continue | --skip | --abort)"),
N_("git am [<options>] (--continue | --skip | --abort | --quit"
" | --show-current-patch)"),
NULL
};

struct option options[] = {
OPT_CMDMODE(0, "continue", &resume,
N_("continue applying patches after resolving a conflict"),
RESUME_RESOLVED),
OPT_CMDMODE(0, "skip", &resume,
N_("skip the current patch"),
RESUME_SKIP),
OPT_CMDMODE(0, "abort", &resume,
N_("restore the original branch and abort the patching operation."),
RESUME_ABORT),
OPT_CMDMODE(0, "quit", &resume,
N_("abort the patching operation but keep HEAD where it is."),
RESUME_QUIT),
OPT_CMDMODE(0, "show-current-patch", &resume,
N_("show the patch being applied."),
RESUME_SHOW_PATCH),
OPT_CMDMODE('r', "resolved", &resume,
N_("synonym for --continue"),
RESUME_RESOLVED),
OPT_BOOL('i', "interactive", &state.interactive,
N_("run interactively")),
OPT_HIDDEN_BOOL('b', "binary", &binary,
Expand Down Expand Up @@ -2227,24 +2246,6 @@ int cmd_am(int argc, const char **argv, const char *prefix)
PARSE_OPT_NOARG),
OPT_STRING(0, "resolvemsg", &state.resolvemsg, NULL,
N_("override error message when patch failure occurs")),
OPT_CMDMODE(0, "continue", &resume,
N_("continue applying patches after resolving a conflict"),
RESUME_RESOLVED),
OPT_CMDMODE('r', "resolved", &resume,
N_("synonyms for --continue"),
RESUME_RESOLVED),
OPT_CMDMODE(0, "skip", &resume,
N_("skip the current patch"),
RESUME_SKIP),
OPT_CMDMODE(0, "abort", &resume,
N_("restore the original branch and abort the patching operation."),
RESUME_ABORT),
OPT_CMDMODE(0, "quit", &resume,
N_("abort the patching operation but keep HEAD where it is."),
RESUME_QUIT),
OPT_CMDMODE(0, "show-current-patch", &resume,
N_("show the patch being applied."),
RESUME_SHOW_PATCH),
OPT_BOOL(0, "committer-date-is-author-date",
&state.committer_date_is_author_date,
N_("lie about committer date")),
Expand Down
13 changes: 8 additions & 5 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\
"\n");

static const char empty_cherry_pick_advice_single[] =
N_("Otherwise, please use 'git reset'\n");
N_("Otherwise, please use 'git cherry-pick --skip'\n");

static const char empty_cherry_pick_advice_multi[] =
N_("If you wish to skip this commit, use:\n"
N_("and then use:\n"
"\n"
" git reset\n"
" git cherry-pick --continue\n"
"\n"
"Then \"git cherry-pick --continue\" will resume cherry-picking\n"
"the remaining commits.\n");
"to resume cherry-picking the remaining commits.\n"
"If you wish to skip this commit, use:\n"
"\n"
" git cherry-pick --skip\n"
"\n");

static const char *color_status_slots[] = {
[WT_STATUS_HEADER] = "header",
Expand Down
41 changes: 23 additions & 18 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "packfile.h"
#include "tag.h"
#include "alias.h"
#include "branch.h"
#include "commit-reach.h"
#include "wt-status.h"

Expand All @@ -52,8 +53,7 @@ struct strategy {

static const char * const builtin_merge_usage[] = {
N_("git merge [<options>] [<commit>...]"),
N_("git merge --abort"),
N_("git merge --continue"),
N_("git merge (--continue | --skip | --abort | --quit)"),
NULL
};

Expand All @@ -73,6 +73,7 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
static int quit_current_merge;
static int continue_current_merge;
static int allow_unrelated_histories;
static int show_progress = -1;
Expand Down Expand Up @@ -238,6 +239,12 @@ static int option_parse_n(const struct option *opt,
}

static struct option builtin_merge_options[] = {
OPT_BOOL(0, "continue", &continue_current_merge,
N_("continue the current in-progress merge")),
OPT_BOOL(0, "abort", &abort_current_merge,
N_("abort the current in-progress merge")),
OPT_BOOL(0, "quit", &quit_current_merge,
N_("--abort but leave index and working tree alone")),
{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,
N_("do not show a diffstat at the end of the merge"),
PARSE_OPT_NOARG, option_parse_n },
Expand Down Expand Up @@ -272,10 +279,6 @@ static struct option builtin_merge_options[] = {
N_("read message from file"), PARSE_OPT_NONEG,
NULL, 0, option_read_message },
OPT__VERBOSITY(&verbosity),
OPT_BOOL(0, "abort", &abort_current_merge,
N_("abort the current in-progress merge")),
OPT_BOOL(0, "continue", &continue_current_merge,
N_("continue the current in-progress merge")),
OPT_BOOL(0, "allow-unrelated-histories", &allow_unrelated_histories,
N_("allow merging unrelated histories")),
OPT_SET_INT(0, "progress", &show_progress, N_("force progress reporting"), 1),
Expand All @@ -287,14 +290,6 @@ static struct option builtin_merge_options[] = {
OPT_END()
};

/* Cleans up metadata that is uninteresting after a succeeded merge. */
static void drop_save(void)
{
unlink(git_path_merge_head(the_repository));
unlink(git_path_merge_msg(the_repository));
unlink(git_path_merge_mode(the_repository));
}

static int save_state(struct object_id *stash)
{
int len;
Expand Down Expand Up @@ -388,7 +383,7 @@ static void finish_up_to_date(const char *msg)
{
if (verbosity >= 0)
printf("%s%s\n", squash ? _(" (nothing to squash)") : "", msg);
drop_save();
remove_merge_branch_state(the_repository);
}

static void squash_message(struct commit *commit, struct commit_list *remoteheads)
Expand Down Expand Up @@ -881,7 +876,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
&result_commit, NULL, sign_commit))
die(_("failed to write commit object"));
finish(head, remoteheads, &result_commit, "In-index merge");
drop_save();
remove_merge_branch_state(the_repository);
return 0;
}

Expand All @@ -907,7 +902,7 @@ static int finish_automerge(struct commit *head,
strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy);
finish(head, remoteheads, &result_commit, buf.buf);
strbuf_release(&buf);
drop_save();
remove_merge_branch_state(the_repository);
return 0;
}

Expand Down Expand Up @@ -1289,6 +1284,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}

if (quit_current_merge) {
if (orig_argc != 2)
usage_msg_opt(_("--quit expects no arguments"),
builtin_merge_usage,
builtin_merge_options);

remove_merge_branch_state(the_repository);
goto done;
}

if (continue_current_merge) {
int nargc = 1;
const char *nargv[] = {"commit", NULL};
Expand Down Expand Up @@ -1495,7 +1500,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}

finish(head_commit, remoteheads, &commit->object.oid, msg.buf);
drop_save();
remove_merge_branch_state(the_repository);
goto done;
} else if (!remoteheads->next && common->next)
;
Expand Down
Loading