mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
am: support --quit
Among the "in progress" commands, only git-am and git-merge do not support --quit. Support --quit in git-am too. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b2e45c695d
commit
65ed8ff376
@ -16,7 +16,7 @@ SYNOPSIS
|
||||
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
|
||||
[--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
|
||||
[(<mbox> | <Maildir>)...]
|
||||
'git am' (--continue | --skip | --abort)
|
||||
'git am' (--continue | --skip | --abort | --quit)
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
@ -167,6 +167,10 @@ default. You can use `--no-utf8` to override this.
|
||||
--abort::
|
||||
Restore the original branch and abort the patching operation.
|
||||
|
||||
--quit::
|
||||
Abort the patching operation but keep HEAD and the index
|
||||
untouched.
|
||||
|
||||
DISCUSSION
|
||||
----------
|
||||
|
||||
|
12
builtin/am.c
12
builtin/am.c
@ -2149,7 +2149,8 @@ enum resume_mode {
|
||||
RESUME_APPLY,
|
||||
RESUME_RESOLVED,
|
||||
RESUME_SKIP,
|
||||
RESUME_ABORT
|
||||
RESUME_ABORT,
|
||||
RESUME_QUIT
|
||||
};
|
||||
|
||||
static int git_am_config(const char *k, const char *v, void *cb)
|
||||
@ -2249,6 +2250,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
|
||||
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_BOOL(0, "committer-date-is-author-date",
|
||||
&state.committer_date_is_author_date,
|
||||
N_("lie about committer date")),
|
||||
@ -2317,7 +2321,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
|
||||
* stray directories.
|
||||
*/
|
||||
if (file_exists(state.dir) && !state.rebasing) {
|
||||
if (resume == RESUME_ABORT) {
|
||||
if (resume == RESUME_ABORT || resume == RESUME_QUIT) {
|
||||
am_destroy(&state);
|
||||
am_state_release(&state);
|
||||
return 0;
|
||||
@ -2359,6 +2363,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
|
||||
case RESUME_ABORT:
|
||||
am_abort(&state);
|
||||
break;
|
||||
case RESUME_QUIT:
|
||||
am_rerere_clear();
|
||||
am_destroy(&state);
|
||||
break;
|
||||
default:
|
||||
die("BUG: invalid resume value");
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ _git_am ()
|
||||
{
|
||||
__git_find_repo_path
|
||||
if [ -d "$__git_repo_path"/rebase-apply ]; then
|
||||
__gitcomp "--skip --continue --resolved --abort"
|
||||
__gitcomp "--skip --continue --resolved --abort --quit"
|
||||
return
|
||||
fi
|
||||
case "$cur" in
|
||||
|
@ -1045,4 +1045,16 @@ test_expect_success 'am works with multi-line in-body headers' '
|
||||
git cat-file commit HEAD | grep "^$LONG$"
|
||||
'
|
||||
|
||||
test_expect_success 'am --quit keeps HEAD where it is' '
|
||||
mkdir .git/rebase-apply &&
|
||||
>.git/rebase-apply/last &&
|
||||
>.git/rebase-apply/next &&
|
||||
git rev-parse HEAD^ >.git/ORIG_HEAD &&
|
||||
git rev-parse HEAD >expected &&
|
||||
git am --quit &&
|
||||
test_path_is_missing .git/rebase-apply &&
|
||||
git rev-parse HEAD >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user