From: Junio C Hamano Date: Fri, 26 Jun 2015 06:03:26 +0000 (-0700) Subject: Merge branch 'jk/stash-require-clean-index' into maint X-Git-Tag: v2.5.0-rc1~5^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/351d06df519ee405a1926e0c6ee34d6a1dba6b46?ds=inline;hp=-c Merge branch 'jk/stash-require-clean-index' into maint A hotfix for the topic already in 'master'. * jk/stash-require-clean-index: Revert "stash: require a clean index to apply" --- 351d06df519ee405a1926e0c6ee34d6a1dba6b46 diff --combined git-stash.sh index 0fddd5424b,d4cf818be9..23bd1d3db2 --- a/git-stash.sh +++ b/git-stash.sh @@@ -219,9 -219,6 +219,9 @@@ save_stash () -a|--all) untracked=all ;; + --help) + show_help + ;; --) shift break @@@ -304,17 -301,11 +304,17 @@@ list_stash () } show_stash () { + ALLOW_UNKNOWN_FLAGS=t assert_stash_like "$@" git diff ${FLAGS:---stat} $b_commit $w_commit } +show_help () { + exec git help stash + exit 1 +} + # # Parses the remaining options looking for flags and # at most one revision defaulting to ${ref_stash}@{0} @@@ -341,14 -332,13 +341,14 @@@ # # GIT_QUIET is set to t if -q is specified # INDEX_OPTION is set to --index if --index is specified. -# FLAGS is set to the remaining flags +# FLAGS is set to the remaining flags (if allowed) # # dies if: # * too many revisions specified # * no revision is specified and there is no stash stack # * a revision is specified which cannot be resolve to a SHA1 # * a non-existent stash reference is specified +# * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t" # parse_flags_and_rev() @@@ -381,12 -371,7 +381,12 @@@ --index) INDEX_OPTION=--index ;; + --help) + show_help + ;; -*) + test "$ALLOW_UNKNOWN_FLAGS" = t || + die "$(eval_gettext "unknown option: \$opt")" FLAGS="${FLAGS}${FLAGS:+ }$opt" ;; esac @@@ -457,8 -442,6 +457,6 @@@ apply_stash () assert_stash_like "$@" git update-index -q --refresh || die "$(gettext "unable to refresh index")" - git diff-index --cached --quiet --ignore-submodules HEAD -- || - die "$(gettext "Cannot apply stash: Your index contains uncommitted changes.")" # current index state c_tree=$(git write-tree) || diff --combined t/t3903-stash.sh index 7396ca9911,f179c93ddf..f5f18b7d21 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@@ -45,13 -45,6 +45,6 @@@ test_expect_success 'applying bogus sta test_cmp expect file ' - test_expect_success 'apply requires a clean index' ' - test_when_finished "git reset --hard" && - echo changed >other-file && - git add other-file && - test_must_fail git stash apply - ' - test_expect_success 'apply does not need clean working directory' ' echo 4 >other-file && git stash apply && @@@ -100,10 -93,6 +93,10 @@@ test_expect_success 'unstashing in a su ) ' +test_expect_success 'stash drop complains of extra options' ' + test_must_fail git stash drop --foo +' + test_expect_success 'drop top stash' ' git reset --hard && git stash list > stashlist1 &&