On Fri, 11 Feb 2011, Martin von Zweigbergk wrote: > On Thu, 10 Feb 2011, Junio C Hamano wrote: > > > I am not sure if forbidding "-v --continue" adds any value; would it be > > too much effort to allow "--continue -v" instead to achieve the same > > degree of consistency between the two? > > I'll have a look at it when > I get some time. This would apply on top of mz/rebase after dropping 95135b0 (rebase: stricter check of standalone sub command, 2011-02-06). If you agree with it, I will include it in a future re-roll. -- 8< -- Subject: [PATCH/RFC] rebase: allow options to be overridden when resuming The sub commands '--continue', '--skip' or '--abort' may only be used standalone according to the documentation. Other options following the sub command are currently not accepted, but options preceeding them are. For example, 'git rebase --continue -v' is not accepted, while 'git rebase -v --continue' is. In the latter case, the verbose option will only be used until the rebase is interrupted (e.g. for editing, or due to conflict). From that point on, the intial settings will be used again. Improve the situation by allowing options to be combined with sub commands both before and after the sub command itself. Persist the new value to make sure it is remembered across interruptions. Fail if options that can not be used together with sub commands, such as '-i', are used. For simplicity, allow the same set of options for all three sub commands, even though e.g. '-s' makes no sense when combined with '--abort'. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@xxxxxxxxx> --- Documentation/git-rebase.txt | 2 +- git-rebase.sh | 51 ++++++++++++++++++++++++++++++++---------- t/t3418-rebase-continue.sh | 12 ++++++++++ 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 96680c8..095a67f 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -13,7 +13,7 @@ SYNOPSIS 'git rebase' [-i | --interactive] [options] --onto <newbase> --root [<branch>] -'git rebase' --continue | --skip | --abort +'git rebase' --continue | --skip | --abort [options] DESCRIPTION ----------- diff --git a/git-rebase.sh b/git-rebase.sh index 34a2a0a..5abfeac 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -67,6 +67,16 @@ preserve_merges= autosquash= test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t +write_options() { + echo "$GIT_QUIET" > "$state_dir"/quiet && + test t = "$verbose" && : > "$state_dir"/verbose + test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy + test -n "$strategy_opts" && echo "$strategy_opts" > \ + "$state_dir"/strategy_opts + test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \ + "$state_dir"/allow_rerere_autoupdate +} + read_basic_state () { head_name=$(cat "$state_dir"/head-name) && onto=$(cat "$state_dir"/onto) && @@ -78,9 +88,21 @@ read_basic_state () { orig_head=$(cat "$state_dir"/orig-head) else orig_head=$(cat "$state_dir"/head) - fi && - GIT_QUIET=$(cat "$state_dir"/quiet) && - test -f "$state_dir"/verbose && verbose=t + fi + # First write any overriding options from the command line + write_options + if test -n "$GIT_QUIET" + then + rm "$state_dir"/verbose + else + GIT_QUIET=$(cat "$state_dir"/quiet) + fi + if test t = "$verbose" + then + rm "$state_dir"/quiet + else + test -f "$state_dir"/verbose && verbose=t + fi test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)" test -f "$state_dir"/strategy_opts && strategy_opts="$(cat "$state_dir"/strategy_opts)" @@ -92,13 +114,7 @@ write_basic_state () { echo "$head_name" > "$state_dir"/head-name && echo "$onto" > "$state_dir"/onto && echo "$orig_head" > "$state_dir"/orig-head && - echo "$GIT_QUIET" > "$state_dir"/quiet && - test t = "$verbose" && : > "$state_dir"/verbose - test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy - test -n "$strategy_opts" && echo "$strategy_opts" > \ - "$state_dir"/strategy_opts - test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \ - "$state_dir"/allow_rerere_autoupdate + write_options } output () { @@ -164,6 +180,7 @@ then fi test -n "$type" && in_progress=t +resume_incompatible= while test $# != 0 do case "$1" in @@ -174,11 +191,11 @@ do ok_to_skip_pre_rebase= ;; --continue|--skip|--abort) + test -n "$action" && usage action=${1##--} - shift - break ;; --onto) + resume_incompatible=t test 2 -le "$#" || usage onto="$2" shift @@ -197,6 +214,7 @@ do autosquash= ;; -M|-m|--m|--me|--mer|--merg|--merge) + resume_incompatible=t do_merge=t ;; -X*|--strategy-option*) @@ -232,9 +250,11 @@ do do_merge=t ;; -n|--no-stat) + resume_incompatible=t diffstat= ;; --stat) + resume_incompatible=t diffstat=t ;; -v|--verbose) @@ -249,6 +269,7 @@ do diffstat= ;; --whitespace=*) + resume_incompatible=t git_am_opt="$git_am_opt $1" case "$1" in --whitespace=fix|--whitespace=strip) @@ -257,19 +278,24 @@ do esac ;; --ignore-whitespace) + resume_incompatible=t git_am_opt="$git_am_opt $1" ;; --committer-date-is-author-date|--ignore-date) + resume_incompatible=t git_am_opt="$git_am_opt $1" force_rebase=t ;; -C*) + resume_incompatible=t git_am_opt="$git_am_opt $1" ;; --root) + resume_incompatible=t rebase_root=t ;; -f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff) + resume_incompatible=t force_rebase=t ;; --rerere-autoupdate|--no-rerere-autoupdate) @@ -288,6 +314,7 @@ test $# -gt 2 && usage if test -n "$action" then + test -n "$resume_incompatible" && "--$action used with incompatible option" test -z "$in_progress" && die "No rebase in progress?" # Only interactive rebase uses detailed reflog messages if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 15cef3c..1581f00 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -90,4 +90,16 @@ test_expect_success 'rebase --continue remembers --rerere-autoupdate' ' git rebase --continue ' +test_expect_success 'rebase --continue --no-rerere-autoupdate overrides' ' + rm -fr .git/rebase-* && + git reset --hard topic@{1} && + test_must_fail git rebase -m --rerere-autoupdate master && + test "$(cat F2)" = "Resolved" && + git rebase --continue --no-rerere-autoupdate && + test "$(cat F3)" = "Resolved" && + test_must_fail git rebase --continue && + git add F3 && + git rebase --continue +' + test_done -- 1.7.4.rc2.33.g8a14f -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html