File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,10 +201,7 @@ test true = "$rebase" && {
201201 die " updating an unborn branch with changes added to the index"
202202 fi
203203 else
204- git update-index --ignore-submodules --refresh &&
205- git diff-files --ignore-submodules --quiet &&
206- git diff-index --ignore-submodules --cached --quiet HEAD -- ||
207- die " refusing to pull with rebase: your working tree is not up-to-date"
204+ require_clean_work_tree " pull with rebase" " Please commit or stash them."
208205 fi
209206 oldremoteref= &&
210207 . git-parse-remote &&
Original file line number Diff line number Diff line change @@ -153,14 +153,6 @@ run_pre_rebase_hook () {
153153 fi
154154}
155155
156- require_clean_work_tree () {
157- # test if working tree is dirty
158- git rev-parse --verify HEAD > /dev/null &&
159- git update-index --ignore-submodules --refresh &&
160- git diff-files --quiet --ignore-submodules &&
161- git diff-index --cached --quiet HEAD --ignore-submodules -- ||
162- die " Working tree is dirty"
163- }
164156
165157ORIG_REFLOG_ACTION=" $GIT_REFLOG_ACTION "
166158
@@ -557,7 +549,7 @@ do_next () {
557549 exit " $status "
558550 fi
559551 # Run in subshell because require_clean_work_tree can die.
560- if ! (require_clean_work_tree)
552+ if ! (require_clean_work_tree " rebase " )
561553 then
562554 warn " Commit or stash your changes, and then run"
563555 warn
@@ -768,7 +760,7 @@ first and then run 'git rebase --continue' again."
768760
769761 record_in_rewritten " $( cat " $DOTEST " /stopped-sha) "
770762
771- require_clean_work_tree
763+ require_clean_work_tree " rebase "
772764 do_rest
773765 ;;
774766 --abort)
@@ -866,7 +858,7 @@ first and then run 'git rebase --continue' again."
866858
867859 comment_for_reflog start
868860
869- require_clean_work_tree
861+ require_clean_work_tree " rebase " " Please commit or stash them. "
870862
871863 if test ! -z " $1 "
872864 then
Original file line number Diff line number Diff line change @@ -416,19 +416,7 @@ else
416416 fi
417417fi
418418
419- # The tree must be really really clean.
420- if ! git update-index --ignore-submodules --refresh > /dev/null; then
421- echo >&2 " cannot rebase: you have unstaged changes"
422- git diff-files --name-status -r --ignore-submodules -- >&2
423- exit 1
424- fi
425- diff=$( git diff-index --cached --name-status -r --ignore-submodules HEAD --)
426- case " $diff " in
427- ?* ) echo >&2 " cannot rebase: your index contains uncommitted changes"
428- echo >&2 " $diff "
429- exit 1
430- ;;
431- esac
419+ require_clean_work_tree " rebase" " Please commit or stash them."
432420
433421if test -z " $rebase_root "
434422then
Original file line number Diff line number Diff line change @@ -145,6 +145,35 @@ require_work_tree () {
145145 die " fatal: $0 cannot be used without a working tree."
146146}
147147
148+ require_clean_work_tree () {
149+ git rev-parse --verify HEAD > /dev/null || exit 1
150+ git update-index -q --ignore-submodules --refresh
151+ err=0
152+
153+ if ! git diff-files --quiet --ignore-submodules
154+ then
155+ echo >&2 " Cannot $1 : You have unstaged changes."
156+ err=1
157+ fi
158+
159+ if ! git diff-index --cached --quiet --ignore-submodules HEAD --
160+ then
161+ if [ $err = 0 ]
162+ then
163+ echo >&2 " Cannot $1 : Your index contains uncommitted changes."
164+ else
165+ echo >&2 " Additionally, your index contains uncommitted changes."
166+ fi
167+ err=1
168+ fi
169+
170+ if [ $err = 1 ]
171+ then
172+ test -n " $2 " && echo >&2 " $2 "
173+ exit 1
174+ fi
175+ }
176+
148177get_author_ident_from_commit () {
149178 pick_author_script='
150179 /^author /{
You can’t perform that action at this time.
0 commit comments