* [PATCH/GSoC] pull: implement --[no-]autostash for usage when rebasing
@ 2016-03-19 13:57 Chirayu Desai
2016-03-19 14:08 ` Chirayu Desai
0 siblings, 1 reply; 4+ messages in thread
From: Chirayu Desai @ 2016-03-19 13:57 UTC (permalink / raw)
To: git; +Cc: Chirayu Desai
Since 53c76dc0 pull understands the "rebase.autoStash" configuration
option, which was added to rebase in 58794775
This allows usage of the same option when running 'git pull --rebase',
passing it on to 'git rebase'
Signed-off-by: Chirayu Desai <chirayudesai1@gmail.com>
---
Documentation/git-pull.txt | 7 +++++++
builtin/pull.c | 10 ++++++++++
t/t5544-pull-autostash.sh | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+)
create mode 100755 t/t5544-pull-autostash.sh
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index a62a2a615d..24db186c50 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -128,6 +128,13 @@ unless you have read linkgit:git-rebase[1] carefully.
--no-rebase::
Override earlier --rebase.
+--[no-]autostash::
+ Automatically create a temporary stash before the operation
+ begins, and apply it after the operation ends. This means
+ that you can run pull & rebase on a dirty worktree. However,
+ use with care: the final stash application after a successful
+ rebase might result in non-trivial conflicts.
+
Options related to fetching
~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/builtin/pull.c b/builtin/pull.c
index 10eff03967..c22ce737ce 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -89,6 +89,7 @@ static char *opt_verify_signatures;
static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
static char *opt_gpg_sign;
+static char *opt_autostash;
/* Options passed to git-fetch */
static char *opt_all;
@@ -159,6 +160,8 @@ static struct option pull_options[] = {
OPT_PASSTHRU('S', "gpg-sign", &opt_gpg_sign, N_("key-id"),
N_("GPG sign commit"),
PARSE_OPT_OPTARG),
+ OPT_PASSTHRU(0, "autostash", &opt_autostash, NULL,
+ N_("automatically stash before pull, and apply it after rebase"), PARSE_OPT_NOARG),
/* Options passed to git-fetch */
OPT_GROUP(N_("Options related to fetching")),
@@ -798,6 +801,9 @@ static int run_rebase(const unsigned char *curr_head,
else
argv_array_push(&args, sha1_to_hex(merge_head));
+ if (opt_autostash)
+ argv_array_push(&args, opt_autostash);
+
ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
argv_array_clear(&args);
return ret;
@@ -841,6 +847,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
die(_("Updating an unborn branch with changes added to the index."));
git_config_get_bool("rebase.autostash", &autostash);
+ if (!strcmp(opt_autostash, "--autostash"))
+ autostash = 1;
+ if (!strcmp(opt_autostash, "--no-autostash"))
+ autostash = 0;
if (!autostash)
die_on_unclean_work_tree(prefix);
diff --git a/t/t5544-pull-autostash.sh b/t/t5544-pull-autostash.sh
new file mode 100755
index 0000000000..7f8309ef43
--- /dev/null
+++ b/t/t5544-pull-autostash.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+test_description='git pull --[no-]autostash tests'
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo file >file &&
+ git add file &&
+ git commit -a -m original &&
+ git checkout -b test master &&
+ echo modified file >file &&
+ git commit -m file file
+'
+
+test_expect_success 'pull --rebase --autostash succeeds with dirty working directory' '
+ git checkout -b test1 master &&
+ git reset --hard master &&
+ git log -1 &&
+ echo dirty >new_file &&
+ git add new_file &&
+ git pull --rebase --autostash . test &&
+ test "$(cat new_file)" = dirty &&
+ test "$(cat file)" = "modified file"
+'
+
+test_expect_success 'pull --rebase --no-autostash fails with dirty working directory' '
+ git checkout -b test2 master &&
+ git reset --hard master &&
+ git log -1 &&
+ echo dirty >new_file &&
+ git add new_file &&
+ test_must_fail git pull --rebase --no-autostash . test &&
+ test "$(cat new_file)" = dirty &&
+ test "$(cat file)" = "file"
+'
+
+test_done
\ No newline at end of file
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH/GSoC] pull: implement --[no-]autostash for usage when rebasing
2016-03-19 13:57 [PATCH/GSoC] pull: implement --[no-]autostash for usage when rebasing Chirayu Desai
@ 2016-03-19 14:08 ` Chirayu Desai
2016-03-19 14:23 ` Sidhant Sharma
0 siblings, 1 reply; 4+ messages in thread
From: Chirayu Desai @ 2016-03-19 14:08 UTC (permalink / raw)
To: git
Hello everyone,
I want to participate in GSoC, and this is my microproject to get familiar
with git development.
I am a first year student, enrolled in the Computer Engineering program at
Silver Oak College of Engineering and Technology, Ahmedabad, India.
I have worked on open source software in the past, and have used git quite
a bit during that time. I'll include more details in my proposal, which
I'll send here when done.
I understand that this might be a bit late to get started, and I'll try my
best to get this patch in a good state and get the proposal ready ASAP.
As for the change, I spent a lot more time trying to get the test right
than doing the actual change, most of it trying to get familiar with the
test framework and figuring out what to use. It didn't take much time
though, overall.
I'm adding a few inline comments as I have a few questions.
On Sat, Mar 19, 2016 at 7:28 PM Chirayu Desai <chirayudesai1@gmail.com>
wrote:
Since 53c76dc0 pull understands the "rebase.autoStash" configuration
option, which was added to rebase in 58794775
This allows usage of the same option when running 'git pull --rebase',
passing it on to 'git rebase'
Signed-off-by: Chirayu Desai <chirayudesai1@gmail.com>
---
Documentation/git-pull.txt | 7 +++++++
builtin/pull.c | 10 ++++++++++
t/t5544-pull-autostash.sh | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+)
create mode 100755 t/t5544-pull-autostash.sh
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index a62a2a615d..24db186c50 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -128,6 +128,13 @@ unless you have read linkgit:git-rebase[1] carefully.
--no-rebase::
Override earlier --rebase.
+--[no-]autostash::
+ Automatically create a temporary stash before the operation
+ begins, and apply it after the operation ends. This means
+ that you can run pull & rebase on a dirty worktree. However,
+ use with care: the final stash application after a successful
+ rebase might result in non-trivial conflicts.
+
Options related to fetching
~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/builtin/pull.cb/builtin/pull.c
index 10eff03967..c22ce737ce 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -89,6 +89,7 @@ static char *opt_verify_signatures;
static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
static char *opt_gpg_sign;
+static char *opt_autostash;
/* Options passed to git-fetch */
static char *opt_all;
@@ -159,6 +160,8 @@ static struct option pull_options[] = {
OPT_PASSTHRU('S', "gpg-sign", &opt_gpg_sign, N_("key-id"),
N_("GPG sign commit"),
PARSE_OPT_OPTARG),
+ OPT_PASSTHRU(0, "autostash", &opt_autostash, NULL,
+ N_("automatically stash before pull, and apply it after rebase"),
PARSE_OPT_NOARG),
This shows only "--autostash" when you run 'git pull -help'
Any suggestions?
/* Options passed to git-fetch */
OPT_GROUP(N_("Options related to fetching")),
@@ -798,6 +801,9 @@ static int run_rebase(const unsigned char *curr_head,
else
argv_array_push(&args, sha1_to_hex(merge_head));
+ if (opt_autostash)
+ argv_array_push(&args, opt_autostash);
+
ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
argv_array_clear(&args);
return ret;
@@ -841,6 +847,10 @@ int cmd_pull(int argc, const char **argv, const char
*prefix)
die(_("Updating an unborn branch with changes added to the index."));
git_config_get_bool("rebase.autostash", &autostash);
+ if (!strcmp(opt_autostash, "--autostash"))
+ autostash = 1;
+ if (!strcmp(opt_autostash, "--no-autostash"))
+ autostash = 0;
if (!autostash)
die_on_unclean_work_tree(prefix);
diff --git a/t/t5544-pull-autostash.sh b/t/t5544-pull-autostash.sh
new file mode 100755
index 0000000000..7f8309ef43
--- /dev/null
+++ b/t/t5544-pull-autostash.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+test_description='git pull --[no-]autostash tests'
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo file >file &&
+ git add file &&
+ git commit -a -m original &&
+ git checkout -b test master &&
+ echo modified file >file &&
+ git commit -m file file
+'
+
+test_expect_success 'pull --rebase --autostash succeeds with dirty working
directory' '
+ git checkout -b test1 master &&
+ git reset --hard master &&
+ git log -1 &&
+ echo dirty >new_file &&
+ git add new_file &&
+ git pull --rebase --autostash . test &&
Would a test_comp_rev be needed / good here?
+ test "$(cat new_file)" = dirty &&
+ test "$(cat file)" = "modified file"
+'
+
+test_expect_success 'pull --rebase --no-autostash fails with dirty working
directory' '
+ git checkout -b test2 master &&
+ git reset --hard master &&
+ git log -1 &&
+ echo dirty >new_file &&
+ git add new_file &&
+ test_must_fail git pull --rebase --no-autostash . test &&
Same as above, test_comp_rev
+ test "$(cat new_file)" = dirty &&
+ test "$(cat file)" = "file"
+'
+
+test_done
\ No newline at end of file
--
2.7.4
Regards,
Chirayu Desai
On Sat, Mar 19, 2016 at 7:27 PM, Chirayu Desai <chirayudesai1@gmail.com> wrote:
> Since 53c76dc0 pull understands the "rebase.autoStash" configuration
> option, which was added to rebase in 58794775
>
> This allows usage of the same option when running 'git pull --rebase',
> passing it on to 'git rebase'
>
> Signed-off-by: Chirayu Desai <chirayudesai1@gmail.com>
> ---
> Documentation/git-pull.txt | 7 +++++++
> builtin/pull.c | 10 ++++++++++
> t/t5544-pull-autostash.sh | 37 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 54 insertions(+)
> create mode 100755 t/t5544-pull-autostash.sh
>
> diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
> index a62a2a615d..24db186c50 100644
> --- a/Documentation/git-pull.txt
> +++ b/Documentation/git-pull.txt
> @@ -128,6 +128,13 @@ unless you have read linkgit:git-rebase[1] carefully.
> --no-rebase::
> Override earlier --rebase.
>
> +--[no-]autostash::
> + Automatically create a temporary stash before the operation
> + begins, and apply it after the operation ends. This means
> + that you can run pull & rebase on a dirty worktree. However,
> + use with care: the final stash application after a successful
> + rebase might result in non-trivial conflicts.
> +
> Options related to fetching
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> diff --git a/builtin/pull.c b/builtin/pull.c
> index 10eff03967..c22ce737ce 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -89,6 +89,7 @@ static char *opt_verify_signatures;
> static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
> static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
> static char *opt_gpg_sign;
> +static char *opt_autostash;
>
> /* Options passed to git-fetch */
> static char *opt_all;
> @@ -159,6 +160,8 @@ static struct option pull_options[] = {
> OPT_PASSTHRU('S', "gpg-sign", &opt_gpg_sign, N_("key-id"),
> N_("GPG sign commit"),
> PARSE_OPT_OPTARG),
> + OPT_PASSTHRU(0, "autostash", &opt_autostash, NULL,
> + N_("automatically stash before pull, and apply it after rebase"), PARSE_OPT_NOARG),
>
> /* Options passed to git-fetch */
> OPT_GROUP(N_("Options related to fetching")),
> @@ -798,6 +801,9 @@ static int run_rebase(const unsigned char *curr_head,
> else
> argv_array_push(&args, sha1_to_hex(merge_head));
>
> + if (opt_autostash)
> + argv_array_push(&args, opt_autostash);
> +
> ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
> argv_array_clear(&args);
> return ret;
> @@ -841,6 +847,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
> die(_("Updating an unborn branch with changes added to the index."));
>
> git_config_get_bool("rebase.autostash", &autostash);
> + if (!strcmp(opt_autostash, "--autostash"))
> + autostash = 1;
> + if (!strcmp(opt_autostash, "--no-autostash"))
> + autostash = 0;
> if (!autostash)
> die_on_unclean_work_tree(prefix);
>
> diff --git a/t/t5544-pull-autostash.sh b/t/t5544-pull-autostash.sh
> new file mode 100755
> index 0000000000..7f8309ef43
> --- /dev/null
> +++ b/t/t5544-pull-autostash.sh
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +
> +test_description='git pull --[no-]autostash tests'
> +. ./test-lib.sh
> +
> +test_expect_success setup '
> + echo file >file &&
> + git add file &&
> + git commit -a -m original &&
> + git checkout -b test master &&
> + echo modified file >file &&
> + git commit -m file file
> +'
> +
> +test_expect_success 'pull --rebase --autostash succeeds with dirty working directory' '
> + git checkout -b test1 master &&
> + git reset --hard master &&
> + git log -1 &&
> + echo dirty >new_file &&
> + git add new_file &&
> + git pull --rebase --autostash . test &&
> + test "$(cat new_file)" = dirty &&
> + test "$(cat file)" = "modified file"
> +'
> +
> +test_expect_success 'pull --rebase --no-autostash fails with dirty working directory' '
> + git checkout -b test2 master &&
> + git reset --hard master &&
> + git log -1 &&
> + echo dirty >new_file &&
> + git add new_file &&
> + test_must_fail git pull --rebase --no-autostash . test &&
> + test "$(cat new_file)" = dirty &&
> + test "$(cat file)" = "file"
> +'
> +
> +test_done
> \ No newline at end of file
> --
> 2.7.4
>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH/GSoC] pull: implement --[no-]autostash for usage when rebasing
2016-03-19 14:08 ` Chirayu Desai
@ 2016-03-19 14:23 ` Sidhant Sharma
2016-03-19 14:31 ` Chirayu Desai
0 siblings, 1 reply; 4+ messages in thread
From: Sidhant Sharma @ 2016-03-19 14:23 UTC (permalink / raw)
To: Chirayu Desai, git
On Saturday 19 March 2016 07:38 PM, Chirayu Desai wrote:
> Hello everyone,
>
> I want to participate in GSoC, and this is my microproject to get familiar
> with git development.
>
> I am a first year student, enrolled in the Computer Engineering program at
> Silver Oak College of Engineering and Technology, Ahmedabad, India.
> I have worked on open source software in the past, and have used git quite
> a bit during that time. I'll include more details in my proposal, which
> I'll send here when done.
> I understand that this might be a bit late to get started, and I'll try my
> best to get this patch in a good state and get the proposal ready ASAP.
>
> As for the change, I spent a lot more time trying to get the test right
> than doing the actual change, most of it trying to get familiar with the
> test framework and figuring out what to use. It didn't take much time
> though, overall.
>
> I'm adding a few inline comments as I have a few questions.
Hi,
Thanks for the patch. I believe there already is work in progress on this (See
[1] and [2]). You may want to try another microproject. It may also be a good
idea to mention which GSoC project idea you would like to work on, as there
already may be other proposals on their way.
Thanks and regards,
Sidhant Sharma
[1] http://thread.gmane.org/gmane.comp.version-control.git/287568/focus=287569
[2] http://thread.gmane.org/gmane.comp.version-control.git/289127/focus=289222
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH/GSoC] pull: implement --[no-]autostash for usage when rebasing
2016-03-19 14:23 ` Sidhant Sharma
@ 2016-03-19 14:31 ` Chirayu Desai
0 siblings, 0 replies; 4+ messages in thread
From: Chirayu Desai @ 2016-03-19 14:31 UTC (permalink / raw)
To: Sidhant Sharma; +Cc: git
Apologies, I did not see the patch, I looked for threads with GSoC in
their titles but missed looking for "rebase" / this microproject. I'll
go through the list and make sure it hasn't been picked yet.
As for the GSoC project idea, I was thinking of "Git remote
whitelist/blacklist", and writing another e-mail to this list for
discussion, however I felt that it might be a little less to do as a
whole for GSoC, so I was trying to pick something else to do alongwith
this.
I'll make sure I check the existing applications and threads.
Thanks,
Chirayu Desai
On Sat, Mar 19, 2016 at 7:53 PM, Sidhant Sharma <tigerkid001@gmail.com> wrote:
>
> On Saturday 19 March 2016 07:38 PM, Chirayu Desai wrote:
>> Hello everyone,
>>
>> I want to participate in GSoC, and this is my microproject to get familiar
>> with git development.
>>
>> I am a first year student, enrolled in the Computer Engineering program at
>> Silver Oak College of Engineering and Technology, Ahmedabad, India.
>> I have worked on open source software in the past, and have used git quite
>> a bit during that time. I'll include more details in my proposal, which
>> I'll send here when done.
>> I understand that this might be a bit late to get started, and I'll try my
>> best to get this patch in a good state and get the proposal ready ASAP.
>>
>> As for the change, I spent a lot more time trying to get the test right
>> than doing the actual change, most of it trying to get familiar with the
>> test framework and figuring out what to use. It didn't take much time
>> though, overall.
>>
>> I'm adding a few inline comments as I have a few questions.
> Hi,
>
> Thanks for the patch. I believe there already is work in progress on this (See
> [1] and [2]). You may want to try another microproject. It may also be a good
> idea to mention which GSoC project idea you would like to work on, as there
> already may be other proposals on their way.
>
>
> Thanks and regards,
> Sidhant Sharma
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/287568/focus=287569
> [2] http://thread.gmane.org/gmane.comp.version-control.git/289127/focus=289222
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-19 14:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-19 13:57 [PATCH/GSoC] pull: implement --[no-]autostash for usage when rebasing Chirayu Desai
2016-03-19 14:08 ` Chirayu Desai
2016-03-19 14:23 ` Sidhant Sharma
2016-03-19 14:31 ` Chirayu Desai
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 NNTP newsgroup(s).