From: Junio C Hamano Date: Mon, 19 Dec 2016 22:45:35 +0000 (-0800) Subject: Merge branch 'nd/rebase-forget' X-Git-Tag: v2.12.0-rc0~130 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/06cd5a1e01328724b7709ac232e36263e59f5f26?hp=-c Merge branch 'nd/rebase-forget' "git rebase" learned "--quit" option, which allows a user to remove the metadata left by an earlier "git rebase" that was manually aborted without using "git rebase --abort". * nd/rebase-forget: rebase: add --quit to cleanup rebase, leave everything else untouched --- 06cd5a1e01328724b7709ac232e36263e59f5f26 diff --combined Documentation/git-rebase.txt index de222c81af,f89245818f..67d48e6883 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@@ -12,7 -12,7 +12,7 @@@ SYNOPSI [ []] 'git rebase' [-i | --interactive] [options] [--exec ] [--onto ] --root [] - 'git rebase' --continue | --skip | --abort | --edit-todo + 'git rebase' --continue | --skip | --abort | --quit | --edit-todo DESCRIPTION ----------- @@@ -208,10 -208,10 +208,10 @@@ rebase.stat: rebase. False by default. rebase.autoSquash:: - If set to true enable '--autosquash' option by default. + If set to true enable `--autosquash` option by default. rebase.autoStash:: - If set to true enable '--autostash' option by default. + If set to true enable `--autostash` option by default. rebase.missingCommitsCheck:: If set to "warn", print warnings about removed commits in @@@ -220,7 -220,7 +220,7 @@@ done. "ignore" by default. rebase.instructionFormat:: - Custom commit list format to use during an '--interactive' rebase. + Custom commit list format to use during an `--interactive` rebase. OPTIONS ------- @@@ -252,6 -252,11 +252,11 @@@ leave out at most one of A and B, in wh will be reset to where it was when the rebase operation was started. + --quit:: + Abort the rebase operation but HEAD is not reset back to the + original branch. The index and working tree are also left + unchanged as a result. + --keep-empty:: Keep the commits that do not change anything from its parents in the result. @@@ -391,6 -396,9 +396,6 @@@ idea unless you know what you are doin final history. will be interpreted as one or more shell commands. + -This option can only be used with the `--interactive` option -(see INTERACTIVE MODE below). -+ You may execute several commands by either using one instance of `--exec` with several commands: + @@@ -403,9 -411,6 +408,9 @@@ or by giving more than one `--exec` If `--autosquash` is used, "exec" lines will not be appended for the intermediate commits, and will only appear at the end of each squash/fixup series. ++ +This uses the `--interactive` machinery internally, but it can be run +without an explicit `--interactive`. --root:: Rebase all commits reachable from , instead of @@@ -428,9 -433,9 +433,9 @@@ "fixup! " or "squash! " after the first, in case you referred to an earlier fixup/squash with `git commit --fixup/--squash`. + -This option is only valid when the '--interactive' option is used. +This option is only valid when the `--interactive` option is used. + -If the '--autosquash' option is enabled by default using the +If the `--autosquash` option is enabled by default using the configuration variable `rebase.autoSquash`, this option can be used to override and disable this setting. diff --combined contrib/completion/git-completion.bash index 21016bf8df,2c134f8d90..78fe5b7f5c --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -338,7 -338,7 +338,7 @@@ __git_tags ( __git_refs () { local i hash dir="$(__gitdir "${1-}")" track="${2-}" - local format refs + local format refs pfx if [ -d "$dir" ]; then case "$cur" in refs|refs/*) @@@ -347,15 -347,14 +347,15 @@@ track="" ;; *) + [[ "$cur" == ^* ]] && pfx="^" for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do - if [ -e "$dir/$i" ]; then echo $i; fi + if [ -e "$dir/$i" ]; then echo $pfx$i; fi done format="refname:short" refs="refs/tags refs/heads refs/remotes" ;; esac - git --git-dir="$dir" for-each-ref --format="%($format)" \ + git --git-dir="$dir" for-each-ref --format="$pfx%($format)" \ $refs if [ -n "$track" ]; then # employ the heuristic used by git checkout @@@ -804,50 -803,6 +804,50 @@@ __git_find_on_cmdline ( done } +# Echo the value of an option set on the command line or config +# +# $1: short option name +# $2: long option name including = +# $3: list of possible values +# $4: config string (optional) +# +# example: +# result="$(__git_get_option_value "-d" "--do-something=" \ +# "yes no" "core.doSomething")" +# +# result is then either empty (no option set) or "yes" or "no" +# +# __git_get_option_value requires 3 arguments +__git_get_option_value () +{ + local c short_opt long_opt val + local result= values config_key word + + short_opt="$1" + long_opt="$2" + values="$3" + config_key="$4" + + ((c = $cword - 1)) + while [ $c -ge 0 ]; do + word="${words[c]}" + for val in $values; do + if [ "$short_opt$val" = "$word" ] || + [ "$long_opt$val" = "$word" ]; then + result="$val" + break 2 + fi + done + ((c--)) + done + + if [ -n "$config_key" ] && [ -z "$result" ]; then + result="$(git --git-dir="$(__gitdir)" config "$config_key")" + fi + + echo "$result" +} + __git_has_doubledash () { local c=1 @@@ -1009,8 -964,8 +1009,8 @@@ _git_branch ( while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in - -d|-m) only_local_ref="y" ;; - -r) has_r="y" ;; + -d|--delete|-m|--move) only_local_ref="y" ;; + -r|--remotes) has_r="y" ;; esac ((c++)) done @@@ -1024,7 -979,7 +1024,7 @@@ --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --merged --no-merged --set-upstream-to= --edit-description --list - --unset-upstream + --unset-upstream --delete --move --remotes " ;; *) @@@ -1137,15 -1092,12 +1137,15 @@@ _git_clone ( --depth --single-branch --branch + --recurse-submodules " return ;; esac } +__git_untracked_file_modes="all no normal" + _git_commit () { case "$prev" in @@@ -1167,7 -1119,7 +1167,7 @@@ return ;; --untracked-files=*) - __gitcomp "all no normal" "" "${cur##--untracked-files=}" + __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}" return ;; --*) @@@ -1206,8 -1158,6 +1206,8 @@@ _git_describe ( __git_diff_algorithms="myers minimal patience histogram" +__git_diff_submodule_formats="log short" + __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check @@@ -1223,7 -1173,6 +1223,7 @@@ --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= + --submodule --submodule= " _git_diff () @@@ -1235,10 -1184,6 +1235,10 @@@ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" return ;; + --submodule=*) + __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" + return + ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-index @@@ -1394,15 -1339,15 +1394,15 @@@ _git_help ( { case "$cur" in --*) - __gitcomp "--all --info --man --web" + __gitcomp "--all --guides --info --man --web" return ;; esac __git_compute_all_commands __gitcomp "$__git_all_commands $(__git_aliases) attributes cli core-tutorial cvs-migration - diffcore gitk glossary hooks ignore modules - namespaces repository-layout tutorial tutorial-2 + diffcore everyday gitk glossary hooks ignore modules + namespaces repository-layout revisions tutorial tutorial-2 workflows " } @@@ -1502,14 -1447,6 +1502,14 @@@ _git_log ( __gitcomp "full short no" "" "${cur##--decorate=}" return ;; + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --submodule=*) + __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" + return + ;; --*) __gitcomp " $__git_log_common_options @@@ -1521,7 -1458,6 +1521,7 @@@ --relative-date --date= --pretty= --format= --oneline --show-signature + --cherry-mark --cherry-pick --graph --decorate --decorate= @@@ -1734,10 -1670,10 +1734,10 @@@ _git_rebase ( { local dir="$(__gitdir)" if [ -f "$dir"/rebase-merge/interactive ]; then - __gitcomp "--continue --skip --abort --edit-todo" + __gitcomp "--continue --skip --abort --quit --edit-todo" return elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then - __gitcomp "--continue --skip --abort" + __gitcomp "--continue --skip --abort --quit" return fi __git_complete_strategy && return @@@ -1843,56 -1779,6 +1843,56 @@@ _git_stage ( _git_add } +_git_status () +{ + local complete_opt + local untracked_state + + case "$cur" in + --ignore-submodules=*) + __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}" + return + ;; + --untracked-files=*) + __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}" + return + ;; + --column=*) + __gitcomp " + always never auto column row plain dense nodense + " "" "${cur##--column=}" + return + ;; + --*) + __gitcomp " + --short --branch --porcelain --long --verbose + --untracked-files= --ignore-submodules= --ignored + --column= --no-column + " + return + ;; + esac + + untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \ + "$__git_untracked_file_modes" "status.showUntrackedFiles")" + + case "$untracked_state" in + no) + # --ignored option does not matter + complete_opt= + ;; + all|normal|*) + complete_opt="--cached --directory --no-empty-directory --others" + + if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then + complete_opt="$complete_opt --ignored --exclude=*" + fi + ;; + esac + + __git_complete_index_file "$complete_opt" +} + __git_config_get_set_variables () { local prevword word config_file= c=$cword @@@ -2198,7 -2084,6 +2198,7 @@@ _git_config ( format.attach format.cc format.coverLetter + format.from format.headers format.numbered format.pretty @@@ -2473,10 -2358,6 +2473,10 @@@ _git_show ( __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" return ;; + --submodule=*) + __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" + return + ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --oneline --show-signature @@@ -2713,32 -2594,6 +2713,32 @@@ _git_whatchanged ( _git_log } +_git_worktree () +{ + local subcommands="add list lock prune unlock" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then + __gitcomp "$subcommands" + else + case "$subcommand,$cur" in + add,--*) + __gitcomp "--detach" + ;; + list,--*) + __gitcomp "--porcelain" + ;; + lock,--*) + __gitcomp "--reason" + ;; + prune,--*) + __gitcomp "--dry-run --expire --verbose" + ;; + *) + ;; + esac + fi +} + __git_main () { local i c=1 command __git_dir diff --combined git-rebase.sh index 04f6e44bc8,c62b17863e..48d7c5ded4 --- a/git-rebase.sh +++ b/git-rebase.sh @@@ -43,8 -43,10 +43,9 @@@ continue! continu abort! abort and check out the original branch skip! skip current patch and continue edit-todo! edit the todo list during an interactive rebase + quit! abort but keep HEAD where it is " . git-sh-setup -. git-sh-i18n set_reflog_action rebase require_work_tree_exists cd_to_toplevel @@@ -86,10 -88,7 +87,10 @@@ preserve_merges autosquash= keep_empty= test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t -gpg_sign_opt= +case "$(git config --bool commit.gpgsign)" in +true) gpg_sign_opt=-S ;; +*) gpg_sign_opt= ;; +esac read_basic_state () { test -f "$state_dir/head-name" && @@@ -153,7 -152,7 +154,7 @@@ move_to_original_branch () git symbolic-ref \ -m "rebase finished: returning to $head_name" \ HEAD $head_name || - die "$(gettext "Could not move back to $head_name")" + die "$(eval_gettext "Could not move back to \$head_name")" ;; esac } @@@ -241,7 -240,7 +242,7 @@@ d --verify) ok_to_skip_pre_rebase= ;; - --continue|--skip|--abort|--edit-todo) + --continue|--skip|--abort|--quit|--edit-todo) test $total_argc -eq 2 || usage action=${1##--} ;; @@@ -250,7 -249,6 +251,7 @@@ ;; --exec=*) cmd="${cmd}exec ${1#--exec=}${LF}" + test -z "$interactive_rebase" && interactive_rebase=implied ;; --interactive) interactive_rebase=explicit @@@ -351,6 -349,12 +352,6 @@@ done test $# -gt 2 && usage -if test -n "$cmd" && - test "$interactive_rebase" != explicit -then - die "$(gettext "The --exec option must be used with the --interactive option")" -fi - if test -n "$action" then test -z "$in_progress" && die "$(gettext "No rebase in progress?")" @@@ -399,6 -403,9 +400,9 @@@ abort finish_rebase exit ;; + quit) + exec rm -rf "$state_dir" + ;; edit-todo) run_specific_rebase ;; @@@ -448,7 -455,7 +452,7 @@@ the then . git-parse-remote error_on_missing_default_upstream "rebase" "rebase" \ - "against" "git rebase " + "against" "git rebase $(gettext '')" fi test "$fork_point" = auto && fork_point=t