From: Mehul Jain <mehul.jain2029@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Matthieu.Moy@grenoble-inp.fr,
pyokagan@gmail.com, sunshine@sunshineco.com,
Mehul Jain <mehul.jain2029@gmail.com>
Subject: [PATCH v10 0/2] introduce --[no-]autostash command line flag
Date: Mon, 21 Mar 2016 23:48:01 +0530 [thread overview]
Message-ID: <1458584283-23816-1-git-send-email-mehul.jain2029@gmail.com> (raw)
Following series of patches introduce --[no-]autostash command line flag
for "git pull --rebase".
[PATCH v10 1/2] git-pull.c: introduce git_pull_config()
It's a clean-up patch for changes introduced in [PATCH v10 2/2].
[PATCH v10 2/2] pull --rebase: add --[no-]autostash flag
Changes introduced w.r.t. previous patch:
* Unnecessary tight coupling between git-rebase and git-pull introduced
in previous patch has been removed by passing "--[no-]autostash" option
to git-rebase only when user explicitly tell via command line.
* Patch looks more clearer than before as "autostash" variable is used for
implementation of logic (thanks to Eric).
* Test titles are modified for better understanding of tests.
* Two new tests are added to cover all the combinations of
"--[no-]autostash" and rebase.autoStash.
* Two more tests are added to checkout for error when "git pull
--[no-]autostash" is called. Here I'm forced to use "test_i18ncmp"
instead of "test_i18ngrep" to compare the expected error message with
the actual because grep was, unfortunately, reading "--[no-]autostash"
as an option and thus leading to test failure.
Previous patch: http://thread.gmane.org/gmane.comp.version-control.git/289127
Here's the interdiff between previous patch and current patch.
diff --git a/builtin/pull.c b/builtin/pull.c
index 671179b..d98f481 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -308,6 +308,7 @@ static enum rebase_type config_get_rebase(void)
return REBASE_FALSE;
}
+
/**
* Read config variables.
*/
@@ -804,7 +805,10 @@ static int run_rebase(const unsigned char *curr_head,
argv_array_pushv(&args, opt_strategy_opts.argv);
if (opt_gpg_sign)
argv_array_push(&args, opt_gpg_sign);
- argv_array_push(&args, opt_autostash ? "--autostash" : "--no-autostash");
+ if (opt_autostash == 0)
+ argv_array_push(&args, "--no-autostash");
+ else if (opt_autostash == 1)
+ argv_array_push(&args, "--autostash");
argv_array_push(&args, "--onto");
argv_array_push(&args, sha1_to_hex(merge_head));
@@ -854,13 +858,14 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
die(_("--[no-]autostash option is only valid with --rebase."));
if (opt_rebase) {
+ int autostash = config_autostash;
+ if (opt_autostash != -1)
+ autostash = opt_autostash;
+
if (is_null_sha1(orig_head) && !is_cache_unborn())
die(_("Updating an unborn branch with changes added to the index."));
- if (opt_autostash == -1)
- opt_autostash = config_autostash;
-
- if (!opt_autostash)
+ if (!autostash)
die_on_unclean_work_tree(prefix);
if (get_rebase_fork_point(rebase_fork_point, repo, *refspecs))
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 85d9bea..745e59e 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -255,7 +255,19 @@ test_expect_success 'pull --rebase succeeds with dirty working directory and reb
test "$(cat new_file)" = dirty &&
test "$(cat file)" = "modified again"
'
-test_expect_success 'pull --rebase: --autostash overrides rebase.autostash' '
+
+test_expect_success 'pull --rebase --autostash & rebase.autostash=true' '
+ test_config rebase.autostash true &&
+ git reset --hard before-rebase &&
+ echo dirty >new_file &&
+ git add new_file &&
+ git pull --rebase --autostash . copy &&
+ test_cmp_rev HEAD^ copy &&
+ test "$(cat new_file)" = dirty &&
+ test "$(cat file)" = "modified again"
+'
+
+test_expect_success 'pull --rebase --autostash & rebase.autoStash=false' '
test_config rebase.autostash false &&
git reset --hard before-rebase &&
echo dirty >new_file &&
@@ -266,8 +278,7 @@ test_expect_success 'pull --rebase: --autostash overrides rebase.autostash' '
test "$(cat file)" = "modified again"
'
-test_expect_success 'pull --rebase --autostash works with rebase.autostash set true' '
- test_config rebase.autostash true &&
+test_expect_success 'pull --rebase: --autostash & rebase.autoStash unset' '
git reset --hard before-rebase &&
echo dirty >new_file &&
git add new_file &&
@@ -277,7 +288,7 @@ test_expect_success 'pull --rebase --autostash works with rebase.autostash set t
test "$(cat file)" = "modified again"
'
-test_expect_success 'pull --rebase: --no-autostash overrides rebase.autostash' '
+test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '
test_config rebase.autostash true &&
git reset --hard before-rebase &&
echo dirty >new_file &&
@@ -286,7 +297,7 @@ test_expect_success 'pull --rebase: --no-autostash overrides rebase.autostash' '
test_i18ngrep "Cannot pull with rebase: Your index contains uncommitted changes." err
'
-test_expect_success 'pull --rebase --no-autostash works with rebase.autostash set false' '
+test_expect_success 'pull --rebase --no-autostash & rebase.autostash=false' '
test_config rebase.autostash false &&
git reset --hard before-rebase &&
echo dirty >new_file &&
@@ -295,6 +306,26 @@ test_expect_success 'pull --rebase --no-autostash works with rebase.autostash se
test_i18ngrep "Cannot pull with rebase: Your index contains uncommitted changes." err
'
+test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' '
+ git reset --hard before-rebase &&
+ echo dirty >new_file &&
+ git add new_file &&
+ test_must_fail git pull --rebase --no-autostash . copy 2>err &&
+ test_i18ngrep "Cannot pull with rebase: Your index contains uncommitted changes." err
+'
+
+test_expect_success 'pull --autostash (without --rebase) should error out' '
+ test_must_fail git pull --autostash . copy 2>actual &&
+ echo "fatal: --[no-]autostash option is only valid with --rebase." >expect &&
+ test_i18ncmp actual expect
+'
+
+test_expect_success 'pull --no-autostash (without --rebase) should error out' '
+ test_must_fail git pull --no-autostash . copy 2>actual &&
+ echo "fatal: --[no-]autostash option is only valid with --rebase." >expect &&
+ test_i18ncmp actual expect
+'
+
test_expect_success 'pull.rebase' '
git reset --hard before-rebase &&
test_config pull.rebase true &&
Mehul Jain (2):
git-pull.c: introduce git_pull_config()
pull --rebase: add --[no-]autostash flag
Documentation/git-pull.txt | 9 ++++++
builtin/pull.c | 30 ++++++++++++++++++--
t/t5520-pull.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 3 deletions(-)
--
2.7.1.340.g69eb491.dirty
next reply other threads:[~2016-03-21 18:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 18:18 Mehul Jain [this message]
2016-03-21 18:18 ` [PATCH v10 1/2] git-pull.c: introduce git_pull_config() Mehul Jain
2016-03-21 18:18 ` [PATCH v10 2/2] pull --rebase: add --[no-]autostash flag Mehul Jain
2016-03-21 18:39 ` Matthieu Moy
2016-03-21 20:12 ` Mehul Jain
2016-03-25 8:31 ` Eric Sunshine
2016-03-25 8:44 ` Eric Sunshine
2016-03-25 16:37 ` Eric Sunshine
2016-03-25 18:07 ` Mehul Jain
2016-03-25 22:29 ` Eric Sunshine
2016-03-25 9:05 ` Matthieu Moy
2016-03-25 18:10 ` Mehul Jain
2016-03-25 18:37 ` Matthieu Moy
2016-03-25 19:07 ` Mehul Jain
2016-03-25 7:23 ` [PATCH v10 0/2] introduce --[no-]autostash command line flag Eric Sunshine
2016-03-25 18:01 ` Mehul Jain
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458584283-23816-1-git-send-email-mehul.jain2029@gmail.com \
--to=mehul.jain2029@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pyokagan@gmail.com \
--cc=sunshine@sunshineco.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).