[PATCH 1/2] pull: respect rebase.autostash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a rebasing pull is requested, pull unconditionally runs
require_clean_worktree() resulting in:

  # dirty worktree or index
  $ git pull
  Cannot pull with rebase: Your index contains uncommitted changes.
  Please commit or stash them.

It does this to inform the user early on that a rebase cannot be run on
a dirty worktree, and that a stash is required.  However,
rr/rebase-autostash lifts this limitation on rebase by providing a way
to automatically stash using the rebase.autostash configuration
variable.  Read this variable in pull, and take advantage of this
feature.

Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
 git-pull.sh     |  2 ++
 t/t5520-pull.sh | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/git-pull.sh b/git-pull.sh
index 638aabb..fb01763 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -44,6 +44,7 @@ merge_args= edit=
 curr_branch=$(git symbolic-ref -q HEAD)
 curr_branch_short="${curr_branch#refs/heads/}"
 rebase=$(git config --bool branch.$curr_branch_short.rebase)
+autostash=$(git config --bool rebase.autostash)
 if test -z "$rebase"
 then
 	rebase=$(git config --bool pull.rebase)
@@ -203,6 +204,7 @@ test true = "$rebase" && {
 			die "$(gettext "updating an unborn branch with changes added to the index")"
 		fi
 	else
+		test true = "$autostash" ||
 		require_clean_work_tree "pull with rebase" "Please commit or stash them."
 	fi
 	oldremoteref= &&
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 6af6c63..08afd25 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -102,6 +102,17 @@ test_expect_success 'pull.rebase' '
 	test new = $(git show HEAD:file2)
 '
 
+test_expect_success 'pull --rebase respects rebase.autostash' '
+	git reset --hard before-rebase &&
+	test_config pull.rebase true &&
+	test_config rebase.autostash true &&
+	echo dirty >>file2
+	git pull . copy &&
+	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
+	test new = $(git show HEAD:file2) &&
+	grep dirty file2
+'
+
 test_expect_success 'branch.to-rebase.rebase' '
 	git reset --hard before-rebase &&
 	test_config branch.to-rebase.rebase true &&
-- 
1.8.3.1.379.gb74074e.dirty

--
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]