@matheusbsbs / matheus-bagliano / commits / f9189cf8f2
Fork 0

pull --rebase: exit early when the working directory is dirty

When rebasing fails during "pull --rebase", you cannot just clean up the working directory and call "pull --rebase" again, since the remote branch was already fetched. Therefore, die early when the working directory is dirty. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed May 21, 2008 at 12:32 UTC f9189cf8f2427b10a40b5b3e530e2c893bc64ae9
2 files changed +23
git-pull.sh
+5
@@ -107,6 +107,11 @@ error_on_no_merge_candidates () {
107 }
108
109 test true = "$rebase" && {
110 + git update-index --refresh &&
111 + git diff-files --quiet &&
112 + git diff-index --cached --quiet HEAD -- ||
113 + die "refusing to pull with rebase: your working tree is not up-to-date"
114 +
115 . git-parse-remote &&
116 origin="$1"
117 test -z "$origin" && origin=$(get_default_remote)
t/t5520-pull.sh
+18
@@ -92,4 +92,22 @@ test_expect_success '--rebase with rebased upstream' '
92
93 '
94
95 +test_expect_success 'pull --rebase dies early with dirty working directory' '
96 +
97 + git update-ref refs/remotes/me/copy copy^ &&
98 + COPY=$(git rev-parse --verify me/copy) &&
99 + git rebase --onto $COPY copy &&
100 + git config branch.to-rebase.remote me &&
101 + git config branch.to-rebase.merge refs/heads/copy &&
102 + git config branch.to-rebase.rebase true &&
103 + echo dirty >> file &&
104 + git add file &&
105 + test_must_fail git pull &&
106 + test $COPY = $(git rev-parse --verify me/copy) &&
107 + git checkout HEAD -- file &&
108 + git pull &&
109 + test $COPY != $(git rev-parse --verify me/copy)
110 +
111 +'
112 +
113 test_done