All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] pull: respect rebase.autostash
Date: Fri, 14 Jun 2013 14:26:17 +0530	[thread overview]
Message-ID: <1371200178-9927-2-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1371200178-9927-1-git-send-email-artagnon@gmail.com>

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@gmail.com>
---
 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

  reply	other threads:[~2013-06-14  8:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14  8:56 [PATCH 0/2] Rebasing pull with autostash Ramkumar Ramachandra
2013-06-14  8:56 ` Ramkumar Ramachandra [this message]
2013-06-14  9:13   ` [PATCH 1/2] pull: respect rebase.autostash Matthieu Moy
2013-06-14 10:41     ` Ramkumar Ramachandra
2013-06-14 11:59       ` Phil Hord
2013-06-14 18:26     ` Junio C Hamano
2013-06-14 12:12   ` Phil Hord
2013-06-14 12:21     ` Phil Hord
2013-06-14 12:29     ` John Keeping
2013-06-14 12:41       ` Phil Hord
2013-06-14 12:46       ` Ramkumar Ramachandra
2013-06-14  8:56 ` [PATCH 2/2] pull: clarify the large && { ... } form Ramkumar Ramachandra
2013-06-14  9:09   ` Matthieu Moy
2013-06-14 10:47     ` Ramkumar Ramachandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371200178-9927-2-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.